[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Re: Re: Help on development of a gtk frontend for the debian-installer



Hi joey

I'm new to debian developement, so please excuse my for my errors; at the
end of this mail is appended the svn diff you asked me ( the original gtk.c
i'm working on is the one i found on svn ,if this can help ).
Athought there are many new parts of code most of them were just made for
debugging purposes, the only real important ones are those in the gtk_go()
function.
Last night i did more testing with debian installer rc2 and the gtk over
dfb fe and, again, i couldn't make it crash.
Now i woluld like to know why the modifications at the source code made it
work: as i explained before i could not find any usable information about
how to manipulate the question-list and so im' not sure i'm solving a bug
or doing somethigh bad whithout noticing.

More news to come

ciao

Attilio

Joey Hess ha scritto:
> attilio wrote:
>
>>today i managed to resolve the bugs that previously would not alow the

>>gtk fe nor the back/forward mechanism to work correctly (actually only

>>select, boolean and string questions work correctly).
>>I've slightly modified the gtk_go() function with ("//atti" is where
>>i've added/changed something)
>
>
> Could you please re-send your changes as a unified diff? If you are
> working from a subversion checkout of the installer, the easiest way is
> to just run the "svn diff" command. This will make it easier for us to
> see what changes you are making.
>





Index: gtk.c
===================================================================
--- gtk.c	(revision 26214)
+++ gtk.c	(working copy)
@@ -65,6 +65,8 @@

 #include <gtk/gtk.h>

+#include <syslog.h>
+
 #define q_get_extended_description(q)   question_get_field((q), "", "extended_description")
 #define q_get_description(q)  		question_get_field((q), "", "description")
 #define q_get_choices(q)		question_get_field((q), "", "choices")
@@ -83,6 +85,27 @@

 typedef int (custom_func_t)(struct frontend*, struct question*, GtkWidget*);

+
+static gboolean delete_event( GtkWidget *widget,
+                              GdkEvent  *event,
+                              gpointer   data )
+{
+    /* If you return FALSE in the "delete_event" signal handler,
+     * GTK will emit the "destroy" signal. Returning TRUE means
+     * you don't want the window to be destroyed.
+     * This is useful for popping up 'are you sure you want to quit?'
+     * type dialogs. */
+	syslog(LOG_DEBUG,"atti - delete event occurred\n");
+
+
+    /* Change TRUE to FALSE and the main window will be destroyed with
+     * a "delete_event". */
+
+    return FALSE;
+}
+
+
+
 void register_setter(void (*func)(void*, struct question*),
 		     void *data, struct question *q, struct frontend *obj)
 {
@@ -259,6 +282,9 @@
     struct setter_struct *s, *p;

     s = ((struct frontend_data*)obj->data)->setters;
+
+  	//syslog(LOG_DEBUG,"atti - call_setters() called\n");
+
     while (s != NULL)
     {
         (*s->func)(s->data, s->q);
@@ -277,23 +303,25 @@
     int *tindex = NULL;
     const gchar *indices = q_get_indices(q);

+
     count = strgetargc(q_get_choices_vals(q));
     if (count <= 0)
         return /* DC_NOTOK */;
     choices = malloc(sizeof(char *) * count);
     choices_translated = malloc(sizeof(char *) * count);
     tindex = malloc(sizeof(int) * count);
-    if (strchoicesplitsort(q_get_choices_vals(q), q_get_choices(q), indices,
choices, choices_translated, tindex, count) != count)
-        return /* DC_NOTOK */;
+
+  	syslog(LOG_DEBUG,"atti - button_single_callback() called \n", gtk_button_get_label(GTK_BUTTON(button))
);// +atti
+
+    if (strchoicesplitsort(q_get_choices_vals(q), q_get_choices(q), indices,
choices, choices_translated, tindex, count) != count) return /* DC_NOTOK
*/;
     for (i = 0; i < count; i++)
-    {
-	if (strcmp(gtk_button_get_label(GTK_BUTTON(button)), choices_translated[i])
== 0)
-	    question_setvalue(q, choices[tindex[i]]);
+    	{
+		if (strcmp(gtk_button_get_label(GTK_BUTTON(button)), choices_translated[i])
== 0) question_setvalue(q, choices[tindex[i]]);

-	free(choices[tindex[i]]);
-	free(choices_translated[i]);
-
-    }
+		free(choices[tindex[i]]);
+		free(choices_translated[i]);
+    	}
+
     free(choices);
     free(choices_translated);
     free(tindex);
@@ -305,11 +333,12 @@

 void check_toggled_callback (GtkWidget *toggle, gpointer data)
 {
-  struct question *q = (struct question*)data;
-  gboolean value;
+	struct question *q = (struct question*)data;
+	gboolean value;

-  value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(toggle));
-  bool_setter (toggle, q);
+	syslog(LOG_DEBUG,"atti - check_toggled_callback() called - \n");// +atti
+	value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(toggle));
+	bool_setter (toggle, q);
 }

 void boolean_single_callback(GtkWidget *button, struct frontend_question_data*
data )
@@ -318,6 +347,7 @@
     struct question *q = data->q;
     char *ret;

+   	syslog(LOG_DEBUG,"atti - boolean_single_callback() called\n");// +atti
     ret = (char*) gtk_object_get_user_data(GTK_OBJECT(button));
     question_setvalue(q, ret);
     free(ret);
@@ -331,10 +361,12 @@
 {
     int value;
     void *ret;
-
+
     ret = gtk_object_get_user_data(GTK_OBJECT(button));
     value = *(int*) ret;

+   	syslog(LOG_DEBUG,"atti - exit_button_callback() called, value: %d \n",value);//
+atti
+
     ((struct frontend_data*)obj->data)->button_val = value;

     gtk_main_quit();
@@ -379,6 +411,8 @@
   struct frontend_question_data *data;
   const char *defval = question_getvalue(q, "");

+  syslog(LOG_DEBUG,"atti - gtkhandler_boolean_single() called\n");
+
   data = NEW(struct frontend_question_data);
   data->obj = obj;
   data->q = q;
@@ -414,6 +448,8 @@
     struct frontend_question_data *data;
     const char *defval = question_getvalue(q, "");

+	 syslog(LOG_DEBUG,"atti - gtkhandler_boolean_multiple() called\n");
+
     data = NEW(struct frontend_question_data);
     data->obj = obj;
     data->q = q;
@@ -442,6 +478,7 @@

 static int gtkhandler_boolean(struct frontend *obj, struct question *q,
GtkWidget *qbox)
 {
+	 syslog(LOG_DEBUG,"atti - gtkhandler_boolean() called\n");
     if (q->next == NULL && q->prev == NULL)
         return gtkhandler_boolean_single(obj, q, qbox);
     else
@@ -457,6 +494,8 @@
     int *tindex = NULL;
     const gchar *indices = q_get_indices(q);

+	 syslog(LOG_DEBUG,"atti - gtkhandler_multiselect() called\n");
+
     data = NEW(struct frontend_question_data);
     data->obj = obj;
     data->q = q;
@@ -519,6 +558,8 @@
 {
     GtkWidget *frame, *label;

+		 syslog(LOG_DEBUG,"atti - gtkhandler_note() called\n");
+
     label = gtk_label_new (q_get_extended_description(q));
     gtk_misc_set_alignment(GTK_MISC (label), 0.0, 0.0);
     gtk_label_set_line_wrap(GTK_LABEL (label), TRUE);
@@ -541,6 +582,7 @@
 {
     GtkWidget *frame, *entry;
     struct frontend_question_data *data;
+	 syslog(LOG_DEBUG,"atti - gtkhandler_password() called\n");

     entry = gtk_entry_new ();
     gtk_entry_set_max_length (GTK_ENTRY (entry), 50);
@@ -579,6 +621,8 @@
     int *tindex = NULL;
     const gchar *indices = q_get_indices(q);

+	syslog(LOG_DEBUG,"atti - gtkhandler_select_single() called\n");
+
     data = NEW(struct frontend_question_data);
     data->obj = obj;
     data->q = q;
@@ -630,7 +674,9 @@
     const char *defval = question_getvalue(q, "");
     int *tindex = NULL;
     const gchar *indices = q_get_indices(q);
-
+
+	syslog(LOG_DEBUG,"atti - gtkhandler_select_multiple() called\n");
+
     count = strgetargc(q_get_choices_vals(q));
     if (count <= 0)
         return DC_NOTOK;
@@ -680,6 +726,9 @@

 static int gtkhandler_select(struct frontend *obj, struct question *q, GtkWidget
*qbox)
 {
+
+	//syslog(LOG_DEBUG," - question: tag=%s, variable=%s, value=%s\n",q->tag,q->variables->variable,q->variables->value);
+
     if (q->next == NULL && q->prev == NULL)
         return gtkhandler_select_single(obj, q, qbox);
     else
@@ -692,6 +741,8 @@
     struct frontend_question_data *data;
     const char *defval = question_getvalue(q, "");

+	syslog(LOG_DEBUG,"atti - gtkhandler_string() called\n");
+
     entry = gtk_entry_new ();
     if (defval)
 	gtk_entry_set_text (GTK_ENTRY(entry), defval);
@@ -761,7 +812,7 @@

 void set_window_properties(GtkWidget *window)
 {
-    gtk_widget_set_size_request (window, 600, 400);
+    gtk_widget_set_size_request (window, 800, 600);
     gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
     gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
     gtk_window_set_decorated (GTK_WINDOW (window), TRUE);
@@ -795,6 +846,8 @@
     gtk_object_set_user_data (GTK_OBJECT(button_prev), ret_val);
     g_signal_connect (G_OBJECT(button_prev), "clicked",
                       G_CALLBACK(exit_button_callback), obj);
+
+
     gtk_box_pack_start (GTK_BOX(actionbox), button_prev, TRUE, TRUE, 2);

     button_next = gtk_button_new_from_stock (GTK_STOCK_GO_FORWARD);
@@ -812,8 +865,31 @@

     gtk_box_pack_start(GTK_BOX (mainbox), targetbox_scroll, TRUE, TRUE,
5);
     gtk_container_add(GTK_CONTAINER(window), mainbox);
+
+
 }

+
+static int gtk_shutdown(struct frontend *obj) //atti +
+{
+	struct question *q = obj->questions;
+	syslog(LOG_DEBUG,"atti - gtk_shutdown() called\n");
+	return DC_OK;
+}
+
+
+static int gtk_clear(struct frontend *obj) //atti +
+{
+	syslog(LOG_DEBUG,"atti - gtk_clear() called\n");
+	return DC_OK;
+}
+
+static int gtk_add(struct frontend *obj, struct question *q) //atti +
+{
+    syslog(LOG_DEBUG,"atti - gtk_add() called\n");
+	return DC_OK;
+}
+
 static int gtk_initialize(struct frontend *obj, struct configuration *conf)
 {
     GtkWidget *window;
@@ -829,6 +905,8 @@
     obj->data = NEW(struct frontend_data);
     obj->interactive = 1;

+	syslog(LOG_DEBUG,"atti - gtk_initialize() chiamata\n");
+
     gtk_init (&args, &name);

     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -844,7 +922,8 @@
 {
     struct frontend_data *data = (struct frontend_data *) obj->data;
     struct question *q = obj->questions;
-    int i;
+    struct question *qaux; // atti+
+    int i,j, num_domande=0;
     int ret;
     GtkWidget *questionbox;

@@ -860,42 +939,80 @@
        gtk_label_set_text(GTK_LABEL(data->description_label),
        q_get_extended_description(q));
     */
+
+
+    qaux=q;//+atti num_domande will take count of the question list's lenght,
while qaux is a ptr to the last question in the list
+    num_domande=1;
+    while(qaux->next!=NULL)
+    	{
+    	num_domande++;
+    	qaux=qaux->next;
+    	}
+    syslog(LOG_DEBUG,"atti - gtk_go() called, question list's lenght: %d
",num_domande);
+    //syslog(LOG_DEBUG,"atti - addr prima e ultima domanda: %d , %d", obj->questions,
qaux);
+
+	//if(num_domande>1) q=q->next; //atti + maybe the first question, which
is always debian-installer/mainmenu should not be shown?
+
+	j=0;
     while (q != 0)
-    {
+    	{
+    	j++;
+    	syslog(LOG_DEBUG,"  atti - question %d: %s",j,q->tag);
         for (i = 0; i < DIM(question_handlers); i++)
             if (strcmp(q->template->type, question_handlers[i].type) ==
0)
             {
                 ret = question_handlers[i].handler(obj, q, questionbox);
                 if (ret != DC_OK)
-                {
+                	{
                     return ret;
-                }
+                	}
             }
-        q = q->next;
-    }
+        q->prev=NULL;	//atti+ without this the ASSERT() in frontend.c, line
15, fails!
+        q = q->next;
+    	}
+
     q = obj->questions;
+
+
     gtk_window_set_title(GTK_WINDOW(data->window), obj->title);
     gtk_widget_set_sensitive (data->button_prev, obj->methods.can_go_back(obj,
q));
     gtk_widget_grab_default(data->button_next);
     gtk_widget_show_all(data->window);
     gtk_main();
+
     if (data->button_val == DC_OK)
-    {
-	call_setters(obj);
-	q = obj->questions;
-	while (q != NULL)
-	{
-	    obj->qdb->methods.set(obj->qdb, q);
-	    q = q->next;
-	}
-    }
-    gtk_widget_destroy(questionbox);
+	    {
+		call_setters(obj);

+		q = obj->questions;
+
+		while (q != NULL)
+			{
+		    obj->qdb->methods.set(obj->qdb, q);
+		    q = q->next;
+			}
+		q = obj->questions;
+   		}
+
+	else if (data->button_val == DC_GOBACK && q->prev != NULL )
+	    {
+	    q = qaux;
+		q = qaux->prev;
+	    }
+	q->next=NULL;
+   	//q->prev=NULL;
+
+
+
+    gtk_widget_destroy(questionbox); // cancello i widget ma non la question
box in cui ne metterò di nuovi.
+
     /* FIXME
       gtk_label_set_text(GTK_LABEL(data->description_label), "");
     */

-    return data->button_val;
+
+    return DC_OK;
+
 }

 static bool gtk_can_go_back(struct frontend *obj, struct question *q)
@@ -964,6 +1081,9 @@
 {
     initialize: gtk_initialize,
     go: gtk_go,
+//    shutdown: gtk_shutdown,	//atti +
+//    clear: gtk_clear,	//atti +
+//    add: gtk_add,		//atti +
     can_go_back: gtk_can_go_back,
     progress_start: gtk_progress_start,
     progress_info: gtk_progress_info,


__________________________________________________________________
Tiscali Adsl 3 Mega Flat con 3 MESI GRATIS!
Con Tiscali Adsl 3 Mega Flat navighi con la Supervelocita'
a soli 29.95 euro al mese, senza limiti di tempo. E se attivi
entro il 31 Marzo, 3 MESI sono GRATIS!
Scopri come su http://abbonati.tiscali.it/adsl/sa/2flat_tc/





Reply to: