make code displaying the 'no match found' page more generic
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 23 Aug 2011 09:08:23 +0000 (11:08 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 3 Feb 2012 11:57:51 +0000 (12:57 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=656097

src/empathy-roster-window.c

index 0e9768bf0e9c2139dff2715178e0398bbf5d95c9..8f5bcf2fc9934863addb4342c8ab159f163f0c6b 100644 (file)
@@ -92,7 +92,7 @@
 enum
 {
   PAGE_CONTACT_LIST = 0,
-  PAGE_NO_MATCH
+  PAGE_MESSAGE
 };
 
 enum
@@ -607,6 +607,23 @@ OUT:
   tp_clear_object (&individual);
 }
 
+static void
+display_page_message (EmpathyRosterWindow *self,
+    const gchar *msg)
+{
+  gchar *tmp;
+
+  tmp = g_strdup_printf ("<b><span size='xx-large'>%s</span></b>", msg);
+
+  gtk_label_set_markup (GTK_LABEL (self->priv->no_entry_label), tmp);
+  g_free (tmp);
+
+  gtk_label_set_line_wrap (GTK_LABEL (self->priv->no_entry_label), TRUE);
+
+  gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook),
+      PAGE_MESSAGE);
+}
+
 static void
 roster_window_row_deleted_cb (GtkTreeModel *model,
     GtkTreePath *path,
@@ -620,23 +637,18 @@ roster_window_row_deleted_cb (GtkTreeModel *model,
 
       if (empathy_individual_view_is_searching (self->priv->individual_view))
         {
-          gchar *tmp;
-
-          tmp = g_strdup_printf ("<b><span size='xx-large'>%s</span></b>",
-              _("No match found"));
-
-          gtk_label_set_markup (GTK_LABEL (self->priv->no_entry_label), tmp);
-          g_free (tmp);
-
-          gtk_label_set_line_wrap (GTK_LABEL (self->priv->no_entry_label),
-              TRUE);
-
-          gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook),
-              PAGE_NO_MATCH);
+          display_page_message (self, _("No match found"));
         }
     }
 }
 
+static void
+display_page_contact_list (EmpathyRosterWindow *self)
+{
+  gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook),
+      PAGE_CONTACT_LIST);
+}
+
 static void
 roster_window_row_inserted_cb (GtkTreeModel      *model,
     GtkTreePath *path,
@@ -646,8 +658,8 @@ roster_window_row_inserted_cb (GtkTreeModel      *model,
   if (self->priv->empty)
     {
       self->priv->empty = FALSE;
-      gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook),
-          PAGE_CONTACT_LIST);
+
+      display_page_contact_list (self);
       gtk_widget_grab_focus (GTK_WIDGET (self->priv->individual_view));
 
       /* The store is being filled, it will be done after an idle cb.