aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Kaser <f.kaser@gmx.net>2010-08-05 18:12:28 +0800
committerFelix Kaser <f.kaser@gmx.net>2010-08-05 20:41:20 +0800
commitb3ee9d59131212736dc713e7f1687cf8536bb979 (patch)
treed92f3a7ac67c4cc7ecd87dce907eeb7304456426
parentd9db9822240a5aece8ee660bebb2afe7202a7f53 (diff)
downloadgsoc2013-empathy-b3ee9d59131212736dc713e7f1687cf8536bb979.tar
gsoc2013-empathy-b3ee9d59131212736dc713e7f1687cf8536bb979.tar.gz
gsoc2013-empathy-b3ee9d59131212736dc713e7f1687cf8536bb979.tar.bz2
gsoc2013-empathy-b3ee9d59131212736dc713e7f1687cf8536bb979.tar.lz
gsoc2013-empathy-b3ee9d59131212736dc713e7f1687cf8536bb979.tar.xz
gsoc2013-empathy-b3ee9d59131212736dc713e7f1687cf8536bb979.tar.zst
gsoc2013-empathy-b3ee9d59131212736dc713e7f1687cf8536bb979.zip
show label if contact list is empty
at the moment there is only one label, but we should distinguish if the contact list is empty because no contact is online or because the live search matched nothing
-rw-r--r--src/empathy-main-window.c52
1 files changed, 48 insertions, 4 deletions
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index b82c077f8..3fdccff47 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -103,6 +103,7 @@ struct _EmpathyMainWindowPriv {
EmpathyEventManager *event_manager;
guint flash_timeout_id;
gboolean flash_on;
+ gboolean empty;
GSettings *gsettings_ui;
GSettings *gsettings_contacts;
@@ -359,6 +360,42 @@ OUT:
}
static void
+main_window_row_deleted_cb (GtkTreeModel *model,
+ GtkTreePath *path,
+ EmpathyMainWindow *window)
+{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
+ GtkTreeIter help_iter;
+
+ 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"));
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
+ 1);
+ g_debug ("contact list empty");
+ }
+}
+
+static void
+main_window_row_inserted_cb (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ EmpathyMainWindow *window)
+{
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
+
+ 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");
+ }
+}
+
+static void
main_window_remove_error (EmpathyMainWindow *window,
TpAccount *account)
{
@@ -1485,6 +1522,7 @@ empathy_main_window_init (EmpathyMainWindow *window)
gboolean show_offline;
gchar *filename;
GSList *l;
+ GtkTreeModel *model;
priv = window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window,
EMPATHY_TYPE_MAIN_WINDOW, EmpathyMainWindowPriv);
@@ -1492,6 +1530,8 @@ 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);
@@ -1649,10 +1689,14 @@ empathy_main_window_init (EmpathyMainWindow *window)
g_signal_connect_swapped (window, "map",
G_CALLBACK (gtk_widget_grab_focus), priv->individual_view);
- /* TODO: Set up the TreeView Notebook */
- // have to detect when the contact list is empty (gtk_tree_model_get_iter_first)
- //if we are searching display: no match found, otherwise: your contact list is empty
- //hook to row-added and row removed? fire own signals when empty, not 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",
+ G_CALLBACK (main_window_row_inserted_cb),
+ window);
+ g_signal_connect (model, "row-deleted",
+ G_CALLBACK (main_window_row_deleted_cb),
+ window);
/* Load user-defined accelerators. */
main_window_accels_load ();