]> git.0d.be Git - empathy.git/commitdiff
use different labels if view is empty
authorFelix Kaser <f.kaser@gmx.net>
Thu, 5 Aug 2010 10:55:31 +0000 (12:55 +0200)
committerFelix Kaser <f.kaser@gmx.net>
Thu, 5 Aug 2010 12:42:11 +0000 (14:42 +0200)
either show "no match found" or "your contact list is empty".
fixes bug #621642

libempathy-gtk/empathy-individual-view.c
libempathy-gtk/empathy-individual-view.h
src/empathy-main-window.c
src/empathy-main-window.ui

index 7882123f76f810e6f5ad30c99ed51384d577e079..369933e6a5f17b92f5ff533a609d16c309f0d924 100644 (file)
@@ -2220,6 +2220,19 @@ empathy_individual_view_set_live_search (EmpathyIndividualView *view,
     }
 }
 
+gboolean
+empathy_individual_view_is_searching (EmpathyIndividualView *self)
+{
+  EmpathyIndividualViewPriv *priv;
+
+  g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_VIEW (self), FALSE);
+
+  priv = GET_PRIV (self);
+
+  return (priv->search_widget != NULL &&
+          gtk_widget_get_visible (priv->search_widget));
+}
+
 gboolean
 empathy_individual_view_get_show_offline (EmpathyIndividualView *self)
 {
index ce3c95ce33ba9c03e03b9a3df1123fef2facb2d1..9d6cec0fef5deef9879d9006030257c4c9b8d724 100644 (file)
@@ -102,5 +102,8 @@ void empathy_individual_view_set_show_offline (
     EmpathyIndividualView *view,
     gboolean show_offline);
 
+gboolean empathy_individual_view_is_searching (
+    EmpathyIndividualView *view);
+
 G_END_DECLS
 #endif /* __EMPATHY_INDIVIDUAL_VIEW_H__ */
index 3fdccff47b538d97f28f81f3db5d718c2291870d..4aa5e4c9c3128b4f2e3190135679cbec5f9362c8 100644 (file)
 /* Name in the geometry file */
 #define GEOMETRY_NAME "main-window"
 
+/* Labels for empty contact list */
+#define CONTACT_LIST_EMPTY _("Your contact list is empty")
+#define NO_MATCH_FOUND _("No match found")
+
 G_DEFINE_TYPE (EmpathyMainWindow, empathy_main_window, GTK_TYPE_WINDOW);
 
 #define GET_PRIV(self) ((EmpathyMainWindowPriv *)((EmpathyMainWindow *) self)->priv)
@@ -370,12 +374,15 @@ main_window_row_deleted_cb (GtkTreeModel      *model,
        if (!gtk_tree_model_get_iter_first (model, &help_iter)) {
                priv->empty = TRUE;
 
-               /* TODO: check if we are searching or not */
-               gtk_label_set_text (GTK_LABEL (priv->no_entry_label),
-                               _("Your contact list is empty"));
+               if (empathy_individual_view_is_searching (priv->individual_view))
+                       gtk_label_set_text (GTK_LABEL (priv->no_entry_label),
+                                       NO_MATCH_FOUND);
+               else
+                       gtk_label_set_text (GTK_LABEL (priv->no_entry_label),
+                                       CONTACT_LIST_EMPTY);
+
                gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
-                               1);
-               g_debug ("contact list empty");
+                               0);
        }
 }
 
@@ -390,8 +397,8 @@ main_window_row_inserted_cb (GtkTreeModel      *model,
        if (priv->empty) {
                priv->empty = FALSE;
                gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
-                               0);
-               g_debug ("contact list is not empty any more");
+                               1);
+               gtk_widget_grab_focus (GTK_WIDGET (priv->individual_view));
        }
 }
 
@@ -1530,8 +1537,6 @@ empathy_main_window_init (EmpathyMainWindow *window)
        priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
        priv->gsettings_contacts = g_settings_new (EMPATHY_PREFS_CONTACTS_SCHEMA);
 
-       priv->empty = TRUE;
-
        gtk_window_set_title (GTK_WINDOW (window), _("Contact List"));
        gtk_window_set_role (GTK_WINDOW (window), "contact_list");
        gtk_window_set_default_size (GTK_WINDOW (window), 225, 325);
@@ -1689,6 +1694,11 @@ empathy_main_window_init (EmpathyMainWindow *window)
        g_signal_connect_swapped (window, "map",
                G_CALLBACK (gtk_widget_grab_focus), priv->individual_view);
 
+       /* Set up the Notebook for the TreeView */
+       priv->empty = TRUE;
+       gtk_label_set_text (GTK_LABEL (priv->no_entry_label),
+                       CONTACT_LIST_EMPTY);
+
        /* Connect to proper signals to check if contact list is empty or not */
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->individual_view));
        g_signal_connect (model, "row-inserted",
index 97ab02b9ea4adfc0d3549dcda776ba072ec0dd18..fee4ddc140d2676cb4420bb623f4e12d3935973d 100644 (file)
             <property name="can_focus">True</property>
             <property name="show_tabs">False</property>
             <property name="show_border">False</property>
+            <child>
+              <object class="GtkLabel" id="no_entry_label">
+                <property name="visible">True</property>
+                <property name="yalign">0.30000001192092896</property>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
             <child>
               <object class="GtkScrolledWindow" id="roster_scrolledwindow">
                 <property name="visible">True</property>
                   <placeholder/>
                 </child>
               </object>
-              <packing>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="no_entry_label">
-                <property name="visible">True</property>
-                <property name="yalign">0.30000001192092896</property>
-                <property name="label" translatable="yes">label</property>
-              </object>
               <packing>
                 <property name="position">1</property>
               </packing>