]> cgit.babelmonkeys.de Git - jubjub.git/blobdiff - src/gui/gtk/JubGtkRosterUI.m
Track current presence
[jubjub.git] / src / gui / gtk / JubGtkRosterUI.m
index c27142f2f68fa0bf4b697ae8c121fae2cbd3e704..90bad6fa50c53abd97a0c916afa7c816e5405610 100644 (file)
@@ -1,10 +1,11 @@
+#import <ObjXMPP/namespaces.h>
+#include <string.h>
+
 #import "JubGtkRosterUI.h"
 #import "JubGObjectMap.h"
 #import "JubGtkChatUI.h"
 #import "JubGtkHelper.h"
 
-#include <string.h>
-
 static void roster_row_activated(GtkTreeView *tree_view, GtkTreePath *path,
     GtkTreeViewColumn *column, gpointer data)
 {
@@ -86,7 +87,6 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model,
 
        @try {
                GtkTreeView *roster_view;
-               GtkComboBox *presence_combo;
                GtkBuilder *builder;
 
                groupMap = [[OFMapTable alloc]
@@ -362,4 +362,35 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model,
        }
 }
 
+-      (void)client: (JubChatClient*)client
+  didChangePresence: (XMPPPresence*)presence
+{
+       OFString *tooltip = @"";
+       OFString *show =
+           [[presence elementForName: @"show"
+                           namespace: XMPP_NS_CLIENT] stringValue];
+       OFString *status =
+           [[presence elementForName: @"status"
+                           namespace: XMPP_NS_CLIENT] stringValue];
+
+       if (status != nil)
+               tooltip = [@"<b>Status:</b> " stringByAppendingString: status];
+
+       // FIXME: Changing the active id will send another presence
+       g_idle_add_block(^{
+               if ([presence.type isEqual: @"unavailable"])
+                       gtk_combo_box_set_active_id(presence_combo,
+                           "unavailable");
+               else if (show == nil)
+                       gtk_combo_box_set_active_id(presence_combo,
+                           "available");
+               else
+                       gtk_combo_box_set_active_id(presence_combo,
+                           [show UTF8String]);
+
+
+               gtk_widget_set_tooltip_markup(GTK_WIDGET(presence_combo),
+                   [tooltip UTF8String]);
+       });
+}
 @end