From: Florian Zeitz Date: Sun, 6 Jan 2013 22:01:38 +0000 (+0100) Subject: Make the PresenceComboBox's changed handler only fire when the user changed it X-Git-Url: https://cgit.babelmonkeys.de/?a=commitdiff_plain;h=83cc2e59c768a9ec9be5a9e021acb02714c37e8e;p=jubjub.git Make the PresenceComboBox's changed handler only fire when the user changed it --- diff --git a/src/gui/gtk/JubGtkRosterUI.h b/src/gui/gtk/JubGtkRosterUI.h index be03945..ec94383 100644 --- a/src/gui/gtk/JubGtkRosterUI.h +++ b/src/gui/gtk/JubGtkRosterUI.h @@ -12,6 +12,7 @@ GtkTreeStore *roster_model; GtkTreeModelFilter *roster_filter; GtkComboBox *presence_combo; + gulong presence_combo_changed_handler_id; OFMapTable *groupMap; OFMutableDictionary *contactMap; OFMutableDictionary *chatMap; diff --git a/src/gui/gtk/JubGtkRosterUI.m b/src/gui/gtk/JubGtkRosterUI.m index 90bad6f..ae0d54d 100644 --- a/src/gui/gtk/JubGtkRosterUI.m +++ b/src/gui/gtk/JubGtkRosterUI.m @@ -127,8 +127,9 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model, presence_combo = GTK_COMBO_BOX(gtk_builder_get_object(builder, "PresenceComboBox")); - g_signal_connect(presence_combo, "changed", - G_CALLBACK(presence_changed), connection); + presence_combo_changed_handler_id = + g_signal_connect(presence_combo, "changed", + G_CALLBACK(presence_changed), connection); g_object_unref(G_OBJECT(builder)); } @catch (id e) { @@ -376,8 +377,12 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model, if (status != nil) tooltip = [@"Status: " stringByAppendingString: status]; - // FIXME: Changing the active id will send another presence g_idle_add_block(^{ + // Block the PresenceComboBox's changed handler, so it doesn't + // fire and resend presence + g_signal_handler_block(presence_combo, + presence_combo_changed_handler_id); + if ([presence.type isEqual: @"unavailable"]) gtk_combo_box_set_active_id(presence_combo, "unavailable"); @@ -388,6 +393,9 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model, gtk_combo_box_set_active_id(presence_combo, [show UTF8String]); + // Unblock the changed handler + g_signal_handler_unblock(presence_combo, + presence_combo_changed_handler_id); gtk_widget_set_tooltip_markup(GTK_WIDGET(presence_combo), [tooltip UTF8String]);