From 630cb7a445daeee274fee51937283be165467170 Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Tue, 1 Jan 2013 21:48:42 +0100 Subject: [PATCH] Enable changing presence (show only) --- data/gtk/roster.ui | 4 ++-- src/gui/gtk/JubGtkRosterUI.m | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/data/gtk/roster.ui b/data/gtk/roster.ui index 3d1cf57..302ef0a 100644 --- a/data/gtk/roster.ui +++ b/data/gtk/roster.ui @@ -260,12 +260,12 @@ - + True False PresenceListStore 0 - unavailable + available diff --git a/src/gui/gtk/JubGtkRosterUI.m b/src/gui/gtk/JubGtkRosterUI.m index 7c81f95..d63608e 100644 --- a/src/gui/gtk/JubGtkRosterUI.m +++ b/src/gui/gtk/JubGtkRosterUI.m @@ -3,6 +3,8 @@ #import "JubGtkChatUI.h" #import "JubGtkHelper.h" +#include + 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; -- 2.39.5