[gnome-control-center/wip/gbsneto/new-goa-panel: 5/25] online-accounts: make the main listbox non-selectable



commit 25565fe385021368f92fcf78c679bb6fad3a43ad
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Nov 9 15:55:45 2016 -0200

    online-accounts: make the main listbox non-selectable
    
    Instead of selecting an account, this commit makes the account
    editor dialog only visible through explicit activation of the
    account row.
    
    As a side effect, this commit temporarily makes removing an
    account non-functional.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=774222

 panels/online-accounts/cc-online-accounts-panel.c |   88 +++++----------------
 panels/online-accounts/online-accounts.ui         |    4 +-
 2 files changed, 21 insertions(+), 71 deletions(-)
---
diff --git a/panels/online-accounts/cc-online-accounts-panel.c 
b/panels/online-accounts/cc-online-accounts-panel.c
index 6e584bc..e745a7f 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -53,9 +53,9 @@ struct _CcGoaPanel
   GtkWidget *accounts_vbox;
 };
 
-static void on_listbox_selection_changed (GtkListBox    *listbox,
-                                          GtkListBoxRow *selected_row,
-                                          CcGoaPanel    *self);
+static void on_listbox_row_activated (GtkListBox    *listbox,
+                                      GtkListBoxRow *activated_row,
+                                      CcGoaPanel    *self);
 
 static void on_toolbar_add_button_clicked (GtkToolButton *button,
                                            gpointer       user_data);
@@ -71,10 +71,6 @@ static void on_account_added (GoaClient  *client,
                               GoaObject  *object,
                               gpointer    user_data);
 
-static void on_account_changed (GoaClient  *client,
-                                GoaObject  *object,
-                                gpointer    user_data);
-
 static void on_account_removed (GoaClient  *client,
                                 GoaObject  *object,
                                 gpointer    user_data);
@@ -251,11 +247,6 @@ cc_goa_panel_init (CcGoaPanel *panel)
                     panel);
 
   g_signal_connect (panel->client,
-                    "account-changed",
-                    G_CALLBACK (on_account_changed),
-                    panel);
-
-  g_signal_connect (panel->client,
                     "account-removed",
                     G_CALLBACK (on_account_removed),
                     panel);
@@ -313,7 +304,7 @@ cc_goa_panel_class_init (CcGoaPanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, toolbar_remove_button);
 
   gtk_widget_class_bind_template_callback (widget_class, on_add_button_clicked);
-  gtk_widget_class_bind_template_callback (widget_class, on_listbox_selection_changed);
+  gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated);
   gtk_widget_class_bind_template_callback (widget_class, on_toolbar_add_button_clicked);
   gtk_widget_class_bind_template_callback (widget_class, on_toolbar_remove_button_clicked);
 }
@@ -328,15 +319,6 @@ show_page (CcGoaPanel *panel,
 }
 
 static void
-show_page_nothing_selected (CcGoaPanel *panel)
-{
-  show_page (panel, 0);
-
-  gtk_widget_set_sensitive (panel->accounts_tree_box, FALSE);
-  gtk_widget_show (panel->accounts_tree_label);
-}
-
-static void
 show_page_account (CcGoaPanel  *panel,
                    GoaObject *object)
 {
@@ -391,23 +373,23 @@ static void
 select_account_by_id (CcGoaPanel  *panel,
                       const gchar *account_id)
 {
-  GtkListBoxRow *account_row;
+  GoaObject *row_object;
   GList *children, *l;
 
-  account_row = NULL;
+  row_object = NULL;
   children = gtk_container_get_children (GTK_CONTAINER (panel->accounts_listbox));
 
   for (l = children; l != NULL; l = l->next)
     {
       GoaAccount *account;
-      GoaObject *row_object;
+      GoaObject *object;
 
-      row_object = g_object_get_data (l->data, "goa-object");
+      object = g_object_get_data (l->data, "goa-object");
       account = goa_object_peek_account (row_object);
 
       if (g_strcmp0 (goa_account_get_id (account), account_id) == 0)
         {
-          account_row = l->data;
+          show_page_account (panel, object);
           break;
         }
     }
@@ -416,35 +398,26 @@ select_account_by_id (CcGoaPanel  *panel,
 }
 
 static void
-on_listbox_selection_changed (GtkListBox    *listbox,
-                              GtkListBoxRow *selected_row,
-                              CcGoaPanel    *self)
+on_listbox_row_activated (GtkListBox    *listbox,
+                          GtkListBoxRow *activated_row,
+                          CcGoaPanel    *self)
 {
-  if (selected_row)
-    {
-      GoaObject *object;
-      gboolean is_locked;
+  GoaObject *object;
+  gboolean is_locked;
 
-      object = g_object_get_data (G_OBJECT (selected_row), "goa-object");
-      is_locked = goa_account_get_is_locked (goa_object_peek_account (object));
+  object = g_object_get_data (G_OBJECT (activated_row), "goa-object");
+  is_locked = goa_account_get_is_locked (goa_object_peek_account (object));
 
-      show_page_account (self, object);
+  show_page_account (self, object);
 
-      gtk_widget_set_sensitive (self->toolbar_remove_button, !is_locked);
-    }
-  else
-    {
-      show_page_nothing_selected (self);
-    }
+  gtk_widget_set_sensitive (self->toolbar_remove_button, !is_locked);
 }
 
 static void
 fill_accounts_listbox (CcGoaPanel *self)
 {
-  GtkListBox *listbox;
   GList *accounts, *l;
 
-  listbox = GTK_LIST_BOX (self->accounts_listbox);
   accounts = goa_client_get_accounts (self->client);
 
   for (l = accounts; l != NULL; l = l->next)
@@ -536,35 +509,14 @@ on_account_added (GoaClient *client,
 }
 
 static void
-on_account_changed (GoaClient  *client,
-                    GoaObject  *object,
-                    gpointer    user_data)
-{
-  CcGoaPanel *panel = CC_GOA_PANEL (user_data);
-  GtkListBoxRow *selected_row;
-  GoaObject *selected_object;
-
-  selected_row = gtk_list_box_get_selected_row (GTK_LIST_BOX (panel->accounts_listbox));
-
-  if (!selected_row)
-    return;
-
-  selected_object = g_object_get_data (G_OBJECT (selected_row), "goa-object");
-
-  if (selected_object == object)
-    show_page_account (panel, selected_object);
-}
-
-static void
 on_account_removed (GoaClient *client,
                     GoaObject *object,
                     gpointer   user_data)
 {
   CcGoaPanel *self = user_data;
-  GList *children, *l, *prev;
+  GList *children, *l;
 
   children = gtk_container_get_children (GTK_CONTAINER (self->accounts_listbox));
-  prev = NULL;
 
   for (l = children; l != NULL; l = l->next)
     {
@@ -577,8 +529,6 @@ on_account_removed (GoaClient *client,
           gtk_widget_destroy (l->data);
           break;
         }
-
-      prev = l;
     }
 
   g_list_free (children);
diff --git a/panels/online-accounts/online-accounts.ui b/panels/online-accounts/online-accounts.ui
index 18ba771..4f06252 100644
--- a/panels/online-accounts/online-accounts.ui
+++ b/panels/online-accounts/online-accounts.ui
@@ -35,8 +35,8 @@
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="width_request">278</property>
-                        <property name="selection_mode">browse</property>
-                        <signal name="row-selected" handler="on_listbox_selection_changed" 
object="CcGoaPanel" swapped="no" />
+                        <property name="selection_mode">none</property>
+                        <signal name="row-activated" handler="on_listbox_row_activated" object="CcGoaPanel" 
swapped="no" />
                       </object>
                     </child>
                   </object>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]