From 36a2bde0d1145a1d2184e17a79d6906810b647fd Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 31 Dec 2005 07:06:31 +0000 Subject: [PATCH] Connect to notify instead of multiple detailed signals. 2005-12-31 Matthias Clasen * gtk/gtkaction.c: * gtk/gtkentry.c: Connect to notify instead of multiple detailed signals. --- ChangeLog | 6 ++++ ChangeLog.pre-2-10 | 6 ++++ gtk/gtkaction.c | 86 ++++++++++++++++++++++++++-------------------- gtk/gtkentry.c | 26 ++++++++------ 4 files changed, 76 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a7fd7040a..813653cfdf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-12-31 Matthias Clasen + + * gtk/gtkaction.c: + * gtk/gtkentry.c: Connect to notify instead of multiple + detailed signals. + 2005-12-30 Matthias Clasen * gdk/gdk.symbols: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 5a7fd7040a..813653cfdf 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2005-12-31 Matthias Clasen + + * gtk/gtkaction.c: + * gtk/gtkentry.c: Connect to notify instead of multiple + detailed signals. + 2005-12-30 Matthias Clasen * gdk/gdk.symbols: diff --git a/gtk/gtkaction.c b/gtk/gtkaction.c index 076d8b4c6e..ab2c22bac5 100644 --- a/gtk/gtkaction.c +++ b/gtk/gtkaction.c @@ -768,7 +768,6 @@ gtk_action_sync_tooltip (GtkAction *action, } } - static gboolean gtk_action_create_menu_proxy (GtkToolItem *tool_item, GtkAction *action) @@ -792,6 +791,52 @@ gtk_action_create_menu_proxy (GtkToolItem *tool_item, return TRUE; } +static void +gtk_action_handle_notify (GtkAction *action, + GParamSpec *pspec, + GtkWidget *proxy) +{ + if (pspec->name == I_("sensitive")) + gtk_action_sync_sensitivity (action, pspec, proxy); + else if (pspec->name == I_("visible")) + gtk_action_sync_visible (action, pspec, proxy); + else if (GTK_IS_MENU_ITEM (proxy) && pspec->name == I_("label")) + gtk_action_sync_label (action, pspec, proxy); + else if (GTK_IS_IMAGE_MENU_ITEM (proxy) && pspec->name == I_("stock-id")) + gtk_action_sync_stock_id (action, pspec, proxy); + else if (GTK_IS_TOOL_ITEM (proxy)) + { + if (pspec->name == I_("visible-horizontal") || + pspec->name == I_("visible-vertical") || + pspec->name == I_("is-important")) + gtk_action_sync_property (action, pspec, proxy); + else if (pspec->name == I_("tooltip")) + gtk_action_sync_tooltip (action, pspec, proxy); + + if (GTK_IS_TOOL_BUTTON (proxy)) + { + if (pspec->name == I_("short-label")) + gtk_action_sync_short_label (action, pspec, proxy); + if (pspec->name == I_("stock-id")) + gtk_action_sync_property (action, pspec, proxy); + } + } + else if (GTK_IS_BUTTON (proxy)) + { + if (gtk_button_get_use_stock (GTK_BUTTON (proxy))) + { + if (pspec->name == I_("stock-id")) + gtk_action_sync_button_stock_id (action, pspec, proxy); + } + else if (GTK_BIN (proxy)->child == NULL || + GTK_IS_LABEL (GTK_BIN (proxy)->child)) + { + if (pspec->name == I_("short-label")) + gtk_action_sync_short_label (action, pspec, proxy); + } + } +} + static void connect_proxy (GtkAction *action, GtkWidget *proxy) @@ -805,12 +850,10 @@ connect_proxy (GtkAction *action, g_signal_connect (proxy, "destroy", G_CALLBACK (remove_proxy), action); - g_signal_connect_object (action, "notify::sensitive", - G_CALLBACK (gtk_action_sync_sensitivity), proxy, 0); - gtk_widget_set_sensitive (proxy, gtk_action_is_sensitive (action)); + g_signal_connect_object (action, "notify", + G_CALLBACK (gtk_action_handle_notify), proxy, 0); - g_signal_connect_object (action, "notify::visible", - G_CALLBACK (gtk_action_sync_visible), proxy, 0); + gtk_widget_set_sensitive (proxy, gtk_action_is_sensitive (action)); if (gtk_action_is_visible (action)) gtk_widget_show (proxy); else @@ -852,8 +895,6 @@ connect_proxy (GtkAction *action, NULL); gtk_label_set_label (GTK_LABEL (label), action->private_data->label); - g_signal_connect_object (action, "notify::label", - G_CALLBACK (gtk_action_sync_label), proxy, 0); if (GTK_IS_IMAGE_MENU_ITEM (proxy)) { @@ -875,9 +916,6 @@ connect_proxy (GtkAction *action, } gtk_image_set_from_stock (GTK_IMAGE (image), action->private_data->stock_id, GTK_ICON_SIZE_MENU); - g_signal_connect_object (action, "notify::stock-id", - G_CALLBACK (gtk_action_sync_stock_id), - proxy, 0); } if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)) == NULL) @@ -902,19 +940,6 @@ connect_proxy (GtkAction *action, "tooltip"); gtk_action_sync_tooltip (action, pspec, proxy); - g_signal_connect_object (action, "notify::visible-horizontal", - G_CALLBACK (gtk_action_sync_property), - proxy, 0); - g_signal_connect_object (action, "notify::visible-vertical", - G_CALLBACK (gtk_action_sync_property), - proxy, 0); - g_signal_connect_object (action, "notify::is-important", - G_CALLBACK (gtk_action_sync_property), - proxy, 0); - g_signal_connect_object (action, "notify::tooltip", - G_CALLBACK (gtk_action_sync_tooltip), - proxy, 0); - g_signal_connect_object (proxy, "create_menu_proxy", G_CALLBACK (gtk_action_create_menu_proxy), action, 0); @@ -930,12 +955,6 @@ connect_proxy (GtkAction *action, "stock_id", action->private_data->stock_id, NULL); - g_signal_connect_object (action, "notify::short-label", - G_CALLBACK (gtk_action_sync_short_label), - proxy, 0); - g_signal_connect_object (action, "notify::stock-id", - G_CALLBACK (gtk_action_sync_property), - proxy, 0); g_signal_connect_object (proxy, "clicked", G_CALLBACK (gtk_action_activate), action, G_CONNECT_SWAPPED); @@ -950,9 +969,6 @@ connect_proxy (GtkAction *action, g_object_set (proxy, "label", action->private_data->stock_id, NULL); - g_signal_connect_object (action, "notify::stock-id", - G_CALLBACK (gtk_action_sync_button_stock_id), - proxy, 0); } else if (GTK_BIN (proxy)->child == NULL || GTK_IS_LABEL (GTK_BIN (proxy)->child)) @@ -962,10 +978,6 @@ connect_proxy (GtkAction *action, "label", action->private_data->short_label, "use_underline", TRUE, NULL); - g_signal_connect_object (action, "notify::short-label", - G_CALLBACK (gtk_action_sync_short_label), - proxy, 0); - } /* we leave the button alone if there is a custom child */ diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index aa91bd4a2a..a8fa84dd97 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -5390,9 +5390,13 @@ static void clear_completion_callback (GtkEntry *entry, GParamSpec *pspec) { - GtkEntryCompletion *completion = gtk_entry_get_completion (entry); - - completion->priv->has_completion = FALSE; + if (pspec->name == I_("cursor-position") || + pspec->name == I_("selection-bound")) + { + GtkEntryCompletion *completion = gtk_entry_get_completion (entry); + + completion->priv->has_completion = FALSE; + } } static gboolean @@ -5433,8 +5437,12 @@ completion_changed (GtkEntryCompletion *completion, { GtkEntry *entry = GTK_ENTRY (data); - disconnect_completion_signals (entry, completion); - connect_completion_signals (entry, completion); + if (pspec->name == I_("popup-completion") || + pspec->name == I_("inline-completion")) + { + disconnect_completion_signals (entry, completion); + connect_completion_signals (entry, completion); + } } static void @@ -5477,18 +5485,14 @@ connect_completion_signals (GtkEntry *entry, completion->priv->insert_text_id = g_signal_connect (entry, "insert_text", G_CALLBACK (completion_insert_text_callback), completion); - g_signal_connect (entry, "notify::cursor-position", - G_CALLBACK (clear_completion_callback), completion); - g_signal_connect (entry, "notify::selection-bound", + g_signal_connect (entry, "notify", G_CALLBACK (clear_completion_callback), completion); g_signal_connect (entry, "activate", G_CALLBACK (accept_completion_callback), completion); g_signal_connect (entry, "focus_out_event", G_CALLBACK (accept_completion_callback), completion); } - g_signal_connect (completion, "notify::popup-completion", - G_CALLBACK (completion_changed), entry); - g_signal_connect (completion, "notify::inline-completion", + g_signal_connect (completion, "notify", G_CALLBACK (completion_changed), entry); }