]> git.babelmonkeys.de Git - jubjub.git/commitdiff
Enable changing presence (show only)
authorFlorian Zeitz <florob@babelmonkeys.de>
Tue, 1 Jan 2013 20:48:42 +0000 (21:48 +0100)
committerFlorian Zeitz <florob@babelmonkeys.de>
Tue, 1 Jan 2013 20:48:42 +0000 (21:48 +0100)
data/gtk/roster.ui
src/gui/gtk/JubGtkRosterUI.m

index 3d1cf577aaa6f2d45da39fa371f8e8665f1747cd..302ef0afd726a8628b067c367de8e16ddabd135b 100644 (file)
           </packing>
         </child>
         <child>
-          <object class="GtkComboBox" id="PresenceCombobox">
+          <object class="GtkComboBox" id="PresenceComboBox">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="model">PresenceListStore</property>
             <property name="id_column">0</property>
-            <property name="active_id">unavailable</property>
+            <property name="active_id">available</property>
             <child>
               <object class="GtkCellRendererText" id="cellrenderertext3"/>
               <attributes>
index 7c81f9552f36e0728276ea3727b98e129162ebff..d63608e08be91b81d4b82a72e08ac16732cbaf4e 100644 (file)
@@ -3,6 +3,8 @@
 #import "JubGtkChatUI.h"
 #import "JubGtkHelper.h"
 
+#include <string.h>
+
 static gboolean roster_row_activated(GtkTreeView *tree_view, GtkTreePath *path,
     GtkTreeViewColumn *column, gpointer data)
 {
@@ -31,6 +33,27 @@ static gboolean roster_row_activated(GtkTreeView *tree_view, GtkTreePath *path,
        return TRUE;
 }
 
+static void presence_changed(GtkComboBox *combo_box, gpointer data)
+{
+       XMPPPresence *pres;
+       XMPPConnection *connection = data;
+       OFAutoreleasePool *pool = [OFAutoreleasePool new];
+
+       const char *status = gtk_combo_box_get_active_id(combo_box);
+
+       if (!strcmp(status, "unavailable"))
+               pres = [XMPPPresence presenceWithType: @"unavailable"];
+       else {
+               pres = [XMPPPresence presence];
+               if (strcmp(status, "available"))
+                       [pres addShow: @(status)];
+       }
+
+       [connection sendStanza: pres];
+
+       [pool release];
+}
+
 static gboolean filter_roster_by_presence(GtkTreeModel *model,
     GtkTreeIter *iter, gpointer data)
 {
@@ -66,6 +89,7 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model,
 
        @try {
                GtkTreeView *roster_view;
+               GtkComboBox *presence_combo;
 
                groupMap = [[OFMapTable alloc]
                    initWithKeyFunctions: keyFunctions
@@ -91,6 +115,12 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model,
 
                g_signal_connect(roster_view, "row_activated",
                    G_CALLBACK(roster_row_activated), self);
+
+               presence_combo = GTK_COMBO_BOX(gtk_builder_get_object(builder,
+                       "PresenceComboBox"));
+
+               g_signal_connect(presence_combo, "changed",
+                   G_CALLBACK(presence_changed), connection);
        } @catch (id e) {
                [self release];
                @throw e;