]> git.babelmonkeys.de Git - jubjub.git/commitdiff
Allow showing offline contacts in the GTK UI
authorFlorian Zeitz <florob@babelmonkeys.de>
Tue, 11 Jun 2013 20:40:58 +0000 (22:40 +0200)
committerFlorian Zeitz <florob@babelmonkeys.de>
Tue, 11 Jun 2013 20:40:58 +0000 (22:40 +0200)
data/gtk/roster.ui
src/gui/gtk/JubGtkRosterUI.h
src/gui/gtk/JubGtkRosterUI.m

index a2dc3504303555c62ca856b5a0bd903542377ece..4223a851cfdc6cf5b3a1514a30547bd51b8164f4 100644 (file)
                 <property name="can_focus">False</property>
                 <property name="label" translatable="yes">_Ansicht</property>
                 <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkCheckMenuItem" id="showOfflineCheckMenuItem">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Show _Offline Contacts</property>
+                        <property name="use_underline">True</property>
+                        <accelerator key="o" signal="activate" modifiers="GDK_CONTROL_MASK"/>
+                      </object>
+                    </child>
+                  </object>
+                </child>
               </object>
             </child>
             <child>
                 <property name="label" translatable="yes">_Hilfe</property>
                 <property name="use_underline">True</property>
                 <child type="submenu">
-                  <object class="GtkMenu" id="menu3">
+                  <object class="GtkMenu" id="menu4">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <child>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="model">RosterTreeModelFilter</property>
+                <property name="headers_visible">False</property>
                 <property name="search_column">0</property>
                 <property name="tooltip_column">3</property>
                 <child internal-child="selection">
                 <child>
                   <object class="GtkTreeViewColumn" id="RosterTreeViewColumn1">
                     <property name="title" translatable="yes">Status</property>
+                    <property name="expand">True</property>
                     <child>
                       <object class="GtkCellRendererText" id="cellrenderertext1"/>
                       <attributes>
                 <child>
                   <object class="GtkTreeViewColumn" id="RosterTreeViewColumn2">
                     <property name="title" translatable="yes">Name</property>
+                    <property name="expand">True</property>
                     <child>
                       <object class="GtkCellRendererText" id="cellrenderertext2"/>
                       <attributes>
                 </child>
                 <child>
                   <object class="GtkTreeViewColumn" id="RosterTreeViewColumn3">
+                    <property name="sizing">fixed</property>
+                    <property name="fixed_width">32</property>
                     <property name="title" translatable="yes">Avatar</property>
                     <child>
-                      <object class="GtkCellRendererPixbuf" id="cellrendererpixbuf1"/>
+                      <object class="GtkCellRendererPixbuf" id="cellrendererpixbuf1">
+                        <property name="width">32</property>
+                        <property name="height">32</property>
+                      </object>
                       <attributes>
                         <attribute name="pixbuf">4</attribute>
                       </attributes>
index 0fc8e2d43e0a25fe835aed68878b9b7defe06fe2..461a11aca3115133058f2ca38ed3405552c822e6 100644 (file)
@@ -19,7 +19,9 @@
        OFMapTable *_subDialogMap;
        OFMutableDictionary *_contactMap;
        JubChatClient *_client;
+       bool _showOffline;
 }
+@property (assign) bool showOffline;
 
 - initWithClient: (JubChatClient*)client;
 -      (void)client: (JubChatClient*)client
index e7e36f723a86fa53a1ca67ca533e3dbcd12e9abd..5711ee68dfe0a21eeb73f0da2e3fe4305493c238 100644 (file)
@@ -50,6 +50,7 @@ static void presence_changed(GtkComboBox *combo_box, gpointer data)
 static gboolean filter_roster_by_presence(GtkTreeModel *model,
     GtkTreeIter *iter, gpointer data)
 {
+       bool *showOffline = data;
        char *status;
        gtk_tree_model_get(model, iter, 2, &status, -1);
 
@@ -57,12 +58,18 @@ static gboolean filter_roster_by_presence(GtkTreeModel *model,
        if (!status)
                return TRUE;
 
-       if (!strcmp(status, "unavailable"))
+       if (!*showOffline && !strcmp(status, "unavailable"))
                return FALSE;
 
        return TRUE;
 }
 
+static void menu_show_offline(GtkCheckMenuItem *checkmenuitem, gpointer data)
+{
+       JubGtkRosterUI *ui = data;
+       ui.showOffline = gtk_check_menu_item_get_active(checkmenuitem);
+}
+
 static void dialog_response_callback(GtkDialog *dialog, gint response_id,
     gpointer user_data)
 {
@@ -77,6 +84,7 @@ static void dialog_response_callback(GtkDialog *dialog, gint response_id,
        self = [super init];
 
        @try {
+               GtkCheckMenuItem *show_offline_menu_item;
                GtkTreeView *roster_view;
                GtkBuilder *builder;
 
@@ -108,7 +116,7 @@ static void dialog_response_callback(GtkDialog *dialog, gint response_id,
                    gtk_builder_get_object(builder, "RosterTreeModelFilter"));
 
                gtk_tree_model_filter_set_visible_func(_roster_filter,
-                   filter_roster_by_presence, NULL, NULL);
+                   filter_roster_by_presence, &_showOffline, NULL);
 
                roster_view = GTK_TREE_VIEW(gtk_builder_get_object(builder,
                        "RosterTreeView"));
@@ -123,6 +131,13 @@ static void dialog_response_callback(GtkDialog *dialog, gint response_id,
                    g_signal_connect(_presence_combo, "changed",
                        G_CALLBACK(presence_changed), client);
 
+               show_offline_menu_item =
+                   GTK_CHECK_MENU_ITEM(gtk_builder_get_object(builder,
+                       "showOfflineCheckMenuItem"));
+
+               g_signal_connect(show_offline_menu_item, "toggled",
+                   G_CALLBACK(menu_show_offline), self);
+
                g_object_unref(G_OBJECT(builder));
        } @catch (id e) {
                [self release];
@@ -450,7 +465,8 @@ static void dialog_response_callback(GtkDialog *dialog, gint response_id,
                OFArray *groups = contact.rosterItem.groups;;
 
                GdkPixbuf *avatar =
-                   gdk_pixbuf_new_from_file([avatarFile UTF8String], NULL);
+                   gdk_pixbuf_new_from_file_at_size([avatarFile UTF8String],
+                       32, 32, NULL);
 
                if (groups == nil)
                        groups = @[ @"General" ];
@@ -507,4 +523,17 @@ static void dialog_response_callback(GtkDialog *dialog, gint response_id,
                    [tooltip UTF8String]);
        });
 }
+
+- (bool)showOffline
+{
+       OF_GETTER(_showOffline, YES);
+}
+
+- (void)setShowOffline: (bool)showOffline
+{
+       _showOffline = showOffline;
+       g_idle_add_block(^{
+               gtk_tree_model_filter_refilter(_roster_filter);
+       });
+}
 @end