[gtk+/open-with-dialog: 4/52] open-with: don't override the class signal handler, as it's RUN_LAST



commit 1d67b4ac26960cd65e81fad60c5673b7e9ad7051
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Nov 16 15:12:17 2010 +0100

    open-with: don't override the class signal handler, as it's RUN_LAST
    
    And explain why in a comment; basically we want our handler to always
    run before client code.

 gtk/gtkopenwithdialog.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkopenwithdialog.c b/gtk/gtkopenwithdialog.c
index d53bbe1..bd3929a 100644
--- a/gtk/gtkopenwithdialog.c
+++ b/gtk/gtkopenwithdialog.c
@@ -293,7 +293,8 @@ emit_application_selected (GtkOpenWithDialog *self,
 
 static void
 gtk_open_with_dialog_response (GtkDialog *dialog,
-			       gint response_id)
+			       gint response_id,
+			       gpointer user_data)
 {
   GAppInfo *application;
   GtkOpenWithDialog *self = GTK_OPEN_WITH_DIALOG (dialog);
@@ -346,6 +347,9 @@ gtk_open_with_dialog_response (GtkDialog *dialog,
 	    }
 	}
 
+      /* don't forward this signal to other clients in this case */
+      g_signal_stop_emission_by_name (self, "response");
+
       break;
     default :
       break;
@@ -1058,7 +1062,6 @@ static void
 gtk_open_with_dialog_class_init (GtkOpenWithDialogClass *klass)
 {
   GObjectClass *gobject_class;
-  GtkDialogClass *dialog_class;
 
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = gtk_open_with_dialog_finalize;
@@ -1066,9 +1069,6 @@ gtk_open_with_dialog_class_init (GtkOpenWithDialogClass *klass)
   gobject_class->get_property = gtk_open_with_dialog_get_property;
   gobject_class->constructed = gtk_open_with_dialog_constructed;
 
-  dialog_class = GTK_DIALOG_CLASS (klass);
-  dialog_class->response = gtk_open_with_dialog_response;
-
   properties[PROP_GFILE] =
     g_param_spec_object ("gfile",
 			 P_("A GFile object"),
@@ -1249,6 +1249,12 @@ gtk_open_with_dialog_init (GtkOpenWithDialog *self)
 
   gtk_dialog_set_default_response (GTK_DIALOG (self),
 				   GTK_RESPONSE_OK);
+
+  /* we can't override the class signal handler here, as it's a RUN_LAST;
+   * we want our signal handler instead to be executed before any user code.
+   */
+  g_signal_connect (self, "response",
+		    G_CALLBACK (gtk_open_with_dialog_response), NULL);
 }
 
 static void



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