+#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)
{
}
@implementation JubGtkRosterUI
-- initWithConnection: (XMPPConnection*)connection_
+- initWithClient: (JubChatClient*)client;
{
self = [super init];
@try {
GtkTreeView *roster_view;
- GtkComboBox *presence_combo;
GtkBuilder *builder;
groupMap = [[OFMapTable alloc]
contactMap = [[OFMutableDictionary alloc] init];
chatMap = [[OFMutableDictionary alloc] init];
presences = [[OFCountedSet alloc] init];
- connection = [connection_ retain];
+ connection = [client.connection retain];
+
+ [connection addDelegate: self];
+ [client.roster addDelegate: self];
builder = gtk_builder_new();
gtk_builder_add_from_file(builder, "data/gtk/roster.ui", NULL);
}
}
+- (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