]> git.babelmonkeys.de Git - jubjub.git/commitdiff
Make the PresenceComboBox's changed handler only fire when the user changed it
authorFlorian Zeitz <florob@babelmonkeys.de>
Sun, 6 Jan 2013 22:01:38 +0000 (23:01 +0100)
committerFlorian Zeitz <florob@babelmonkeys.de>
Sun, 6 Jan 2013 22:01:38 +0000 (23:01 +0100)
src/gui/gtk/JubGtkRosterUI.h
src/gui/gtk/JubGtkRosterUI.m

index be0394596d0e719c131a64871cbe4172dfc0a4f3..ec94383e4255e9050ad0aa6d136a3f41af84911e 100644 (file)
@@ -12,6 +12,7 @@
        GtkTreeStore *roster_model;
        GtkTreeModelFilter *roster_filter;
        GtkComboBox *presence_combo;
        GtkTreeStore *roster_model;
        GtkTreeModelFilter *roster_filter;
        GtkComboBox *presence_combo;
+       gulong presence_combo_changed_handler_id;
        OFMapTable *groupMap;
        OFMutableDictionary *contactMap;
        OFMutableDictionary *chatMap;
        OFMapTable *groupMap;
        OFMutableDictionary *contactMap;
        OFMutableDictionary *chatMap;
index 90bad6fa50c53abd97a0c916afa7c816e5405610..ae0d54d778d78ab296d876413f93fe7e5d0f19be 100644 (file)
@@ -127,8 +127,9 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model,
                presence_combo = GTK_COMBO_BOX(gtk_builder_get_object(builder,
                        "PresenceComboBox"));
 
                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) {
 
                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 = [@"<b>Status:</b> " stringByAppendingString: status];
 
        if (status != nil)
                tooltip = [@"<b>Status:</b> " stringByAppendingString: status];
 
-       // FIXME: Changing the active id will send another presence
        g_idle_add_block(^{
        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");
                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]);
 
                        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]);
 
                gtk_widget_set_tooltip_markup(GTK_WIDGET(presence_combo),
                    [tooltip UTF8String]);