[gnome-system-tools] Fix time-admin crash due to broken callbacks



commit ee73854305e6d3c01cd973eb8965a380b5d28005
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Thu Feb 11 13:56:27 2010 +0100

    Fix time-admin crash due to broken callbacks
    
    When we moved to GtkBuilder signals, we stopped passing the GstDialog as user_data, leading to invalid pointers. So pass this in gtk_builder_connect_signals().
    
    Also remove manually-connected signals form main.c, and put them in the UI file, where some were already present. Make those callbacks non-static.

 interfaces/time.ui      |    1 +
 src/common/gst-dialog.c |    2 +-
 src/time/main.c         |   16 +++++-----------
 3 files changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/interfaces/time.ui b/interfaces/time.ui
index f006adf..2c4a322 100644
--- a/interfaces/time.ui
+++ b/interfaces/time.ui
@@ -322,6 +322,7 @@
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
+            <signal name="clicked" handler="timezone_button_clicked"/>
             <child>
               <object class="GtkHBox" id="hbox52">
                 <property name="visible">True</property>
diff --git a/src/common/gst-dialog.c b/src/common/gst-dialog.c
index e74a315..d7435d7 100644
--- a/src/common/gst-dialog.c
+++ b/src/common/gst-dialog.c
@@ -213,7 +213,7 @@ gst_dialog_constructor (GType                  type,
 			/* no point in continuing */
 			exit (-1);
 		}
-		gtk_builder_connect_signals (priv->builder, NULL);
+		gtk_builder_connect_signals (priv->builder, dialog);
 		priv->child = gst_dialog_get_widget (dialog, priv->widget_name);
 		toplevel = gtk_widget_get_toplevel (priv->child);
 
diff --git a/src/time/main.c b/src/time/main.c
index b20adb4..52906e1 100644
--- a/src/time/main.c
+++ b/src/time/main.c
@@ -55,16 +55,10 @@ static const gchar *policy_widgets [] = {
 
 ETzMap *tzmap;
 
-static void timezone_button_clicked (GtkWidget *w, gpointer data);
 static void update_tz (GstTimeTool *time_tool);
-static void server_button_clicked (GtkWidget *w, gpointer data);
 
-static GstDialogSignal signals[] = {
-	{ "timezone_button",     "clicked",  G_CALLBACK (timezone_button_clicked) },
-	{ "timeserver_button",   "clicked",  G_CALLBACK (server_button_clicked) },
-	{ "ntp_add_server",      "clicked",  G_CALLBACK (on_ntp_addserver) },
-	{ NULL, NULL }
-};
+void timezone_button_clicked (GtkWidget *w, gpointer data);
+void server_button_clicked   (GtkWidget *w, gpointer data);
 
 #define is_leap_year(yyy) ((((yyy % 4) == 0) && ((yyy % 100) != 0)) || ((yyy % 400) == 0));
 
@@ -120,7 +114,7 @@ gst_time_update_date (GstTimeTool *tool, gint add)
 }
 #undef is_leap_year
 
-static void
+void
 timezone_button_clicked (GtkWidget *w, gpointer data)
 {
 	GstTimeTool *time_tool;
@@ -131,7 +125,7 @@ timezone_button_clicked (GtkWidget *w, gpointer data)
 	gst_time_tool_run_timezone_dialog (time_tool);
 }
 
-static void
+void
 server_button_clicked (GtkWidget *w, gpointer data)
 {
 	GtkWidget *d;
@@ -161,7 +155,7 @@ main (int argc, char *argv[])
 	tool = GST_TOOL (gst_time_tool_new ());
 
 	gst_dialog_require_authentication_for_widgets (tool->main_dialog, policy_widgets);
-	gst_dialog_connect_signals (tool->main_dialog, signals);
+
 	gtk_widget_show (GTK_WIDGET (tool->main_dialog));
 	gtk_main ();
 



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