]> cgit.babelmonkeys.de Git - jubjub.git/commitdiff
Build roster window in JubGtkRosterUI
authorFlorian Zeitz <florob@babelmonkeys.de>
Tue, 1 Jan 2013 21:55:11 +0000 (22:55 +0100)
committerFlorian Zeitz <florob@babelmonkeys.de>
Tue, 1 Jan 2013 21:55:11 +0000 (22:55 +0100)
src/gui/gtk/JubGtkRosterUI.h
src/gui/gtk/JubGtkRosterUI.m
src/gui/gtk/JubGtkUI.h
src/gui/gtk/JubGtkUI.m

index 1fd03946d4e626a6fd28f43ca2b67d6a23808af5..5aa41b30c461542f2453770c24608b47623719d8 100644 (file)
@@ -6,6 +6,7 @@
 
 @interface JubGtkRosterUI: OFObject <XMPPRosterDelegate, XMPPConnectionDelegate>
 {
+       GtkWidget *roster_window;
        GtkTreeStore *roster_model;
        GtkTreeModelFilter *roster_filter;
        OFMapTable *groupMap;
        OFMutableDictionary *chatMap;
        OFCountedSet *presences;
        XMPPConnection *connection;
-       GtkBuilder *builder;
 }
 
-- initWithBuilder: (GtkBuilder*)builder
-       connection: (XMPPConnection*)connection;
+- initWithConnection: (XMPPConnection*)connection;
 - (JubGtkChatUI*)chatForJID: (XMPPJID*)jid;
 @end
index 66a050ef4002b152a0fc7362542a4999da765e8a..b3899e34a1d750edf1e57d0d6961d4a8f4baf326 100644 (file)
@@ -80,14 +80,14 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model,
 }
 
 @implementation JubGtkRosterUI
-- initWithBuilder: (GtkBuilder*)builder_
-       connection: (XMPPConnection*)connection_
+- initWithConnection: (XMPPConnection*)connection_
 {
        self = [super init];
 
        @try {
                GtkTreeView *roster_view;
                GtkComboBox *presence_combo;
+               GtkBuilder *builder;
 
                groupMap = [[OFMapTable alloc]
                    initWithKeyFunctions: keyFunctions
@@ -97,7 +97,14 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model,
                presences = [[OFCountedSet alloc] init];
                connection = [connection_ retain];
 
-               builder = g_object_ref(builder_);
+               builder = gtk_builder_new();
+               gtk_builder_add_from_file(builder, "data/gtk/roster.ui", NULL);
+               gtk_builder_connect_signals(builder, NULL);
+
+               roster_window =
+                   GTK_WIDGET(gtk_builder_get_object(builder, "RosterWindow"));
+
+               gtk_widget_show(roster_window);
 
                roster_model = GTK_TREE_STORE(gtk_builder_get_object(builder,
                    "RosterTreeStore"));
@@ -119,6 +126,8 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model,
 
                g_signal_connect(presence_combo, "changed",
                    G_CALLBACK(presence_changed), connection);
+
+               g_object_unref(G_OBJECT(builder));
        } @catch (id e) {
                [self release];
                @throw e;
@@ -131,16 +140,11 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model,
 {
        [groupMap release];
        [contactMap release];
+       [chatMap release];
        [presences release];
        [connection release];
 
-       if (roster_model)
-               g_object_unref(roster_model);
-
-       if (roster_filter)
-               g_object_unref(roster_filter);
-
-       g_object_unref(builder);
+       gtk_widget_destroy(roster_window);
 
        [super dealloc];
 }
index add8d76c6fd72e5af0112e039061ff89af8418d3..afec54e2d1545dd7df4ba5f32f29bfd77cf4b83f 100644 (file)
@@ -9,7 +9,6 @@
 @interface JubGtkUI: OFObject <JubUI>
 {
        JubGtkRosterUI *rosterUI;
-       GtkBuilder *builder;
 }
 
 - initWithConnection: (XMPPConnection*)connection;
index 26c2cbb978895d4f557942bb2b08ea4cd516b3b7..b6110f4ea6d0d45912ac23e196b50c4b1db5446a 100644 (file)
@@ -23,11 +23,8 @@ void on_roster_window_destroy(GObject *object, gpointer user_data)
 
                gtk_init(argc, argv);
 
-               builder = gtk_builder_new();
-               gtk_builder_add_from_file(builder, "data/gtk/roster.ui", NULL);
-
-               rosterUI = [[JubGtkRosterUI alloc] initWithBuilder: builder
-                                                       connection: connection];
+               rosterUI = [[JubGtkRosterUI alloc]
+                   initWithConnection: connection];
        } @catch (id e) {
                [self release];
                @throw e;
@@ -39,22 +36,12 @@ void on_roster_window_destroy(GObject *object, gpointer user_data)
 - (void)dealloc
 {
        [rosterUI release];
-       g_object_unref(G_OBJECT(builder));
 
        [super dealloc];
 }
 
 - (void)startUIThread
 {
-       GtkWidget *roster_window;
-
-       roster_window =
-           GTK_WIDGET(gtk_builder_get_object(builder, "RosterWindow"));
-
-       gtk_builder_connect_signals(builder, NULL);
-
-       gtk_widget_show(roster_window);
-
        [[OFThread threadWithBlock: ^(void){
                gtk_main();
                [OFApplication terminate];