[gnome-calendar] source-dialog: Remove online accounts



commit 7ee0acdcbf533a34d5524087bee1cb6fe6cd64dc
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon May 27 19:23:56 2019 -0300

    source-dialog: Remove online accounts
    
    Showing these online accounts in the dialog only added
    an additional step. We'll be adding a link to online
    accounts in the next commit, so for now, remove the
    widgets from the source dialog.

 data/ui/source-dialog.ui     | 211 ---------------------------------
 src/gui/gcal-source-dialog.c | 273 -------------------------------------------
 2 files changed, 484 deletions(-)
---
diff --git a/data/ui/source-dialog.ui b/data/ui/source-dialog.ui
index 395fc017..53ceaac9 100644
--- a/data/ui/source-dialog.ui
+++ b/data/ui/source-dialog.ui
@@ -123,217 +123,6 @@
                             <property name="border_width">18</property>
                             <property name="orientation">vertical</property>
                             <property name="spacing">18</property>
-                            <child>
-                              <object class="GtkGrid" id="online_account_main_grid">
-                                <property name="visible">True</property>
-                                <property name="row_spacing">12</property>
-                                <property name="column_spacing">12</property>
-                                <child>
-                                  <object class="GtkLabel" id="online_account_label">
-                                    <property name="visible">True</property>
-                                    <property name="hexpand">True</property>
-                                    <property name="label" translatable="yes">Online Accounts</property>
-                                    <property name="xalign">0</property>
-                                    <attributes>
-                                      <attribute name="weight" value="bold"/>
-                                    </attributes>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">0</property>
-                                    <property name="top_attach">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkButton" id="online_accounts_settings_button">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="tooltip_text" translatable="yes">Open online account 
settings</property>
-                                    <signal name="clicked" handler="online_accounts_settings_button_clicked" 
object="GcalSourceDialog" swapped="no"/>
-                                    <child>
-                                      <object class="GtkImage" id="online_accounts_settings_button_image">
-                                        <property name="visible">True</property>
-                                        <property name="icon_name">emblem-system-symbolic</property>
-                                      </object>
-                                    </child>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">1</property>
-                                    <property name="top_attach">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkFrame" id="online_accounts_main_frame">
-                                    <property name="visible">True</property>
-                                    <child>
-                                      <object class="GtkListBox" id="online_accounts_listbox">
-                                        <property name="visible">True</property>
-                                        <property name="selection_mode">none</property>
-                                        <signal name="row-activated" 
handler="online_accounts_listbox_row_activated" object="GcalSourceDialog" swapped="no"/>
-                                        <child>
-                                          <object class="GtkListBoxRow" id="google_stub_row">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <child>
-                                              <object class="GtkGrid" id="google_stub_grid">
-                                                <property name="visible">True</property>
-                                                <property name="border_width">6</property>
-                                                <property name="margin_end">18</property>
-                                                <property name="column_spacing">12</property>
-                                                <child>
-                                                  <object class="GtkImage" id="google_account_image">
-                                                    <property name="visible">True</property>
-                                                    <property name="pixel_size">32</property>
-                                                    <property name="icon_name">goa-account-google</property>
-                                                  </object>
-                                                  <packing>
-                                                    <property name="left_attach">0</property>
-                                                    <property name="top_attach">0</property>
-                                                    <property name="height">2</property>
-                                                  </packing>
-                                                </child>
-                                                <child>
-                                                  <object class="GtkLabel" id="google_account_label">
-                                                    <property name="visible">True</property>
-                                                    <property name="label" 
translatable="yes">Google</property>
-                                                    <property name="xalign">0</property>
-                                                  </object>
-                                                  <packing>
-                                                    <property name="left_attach">1</property>
-                                                    <property name="top_attach">0</property>
-                                                  </packing>
-                                                </child>
-                                                <child>
-                                                  <object class="GtkLabel" id="google_account_config_label">
-                                                    <property name="visible">True</property>
-                                                    <property name="label" translatable="yes">Click to set 
up</property>
-                                                    <property name="xalign">0</property>
-                                                    <style>
-                                                      <class name="dim-label"/>
-                                                    </style>
-                                                  </object>
-                                                  <packing>
-                                                    <property name="left_attach">1</property>
-                                                    <property name="top_attach">1</property>
-                                                  </packing>
-                                                </child>
-                                              </object>
-                                            </child>
-                                          </object>
-                                        </child>
-                                        <child>
-                                          <object class="GtkListBoxRow" id="nextcloud_stub_row">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <child>
-                                              <object class="GtkGrid" id="nextcloud_stub_grid">
-                                                <property name="visible">True</property>
-                                                <property name="border_width">6</property>
-                                                <property name="margin_end">18</property>
-                                                <property name="column_spacing">12</property>
-                                                <child>
-                                                  <object class="GtkImage" id="nextcloud_account_image">
-                                                    <property name="visible">True</property>
-                                                    <property name="pixel_size">32</property>
-                                                    <property 
name="icon_name">goa-account-owncloud</property>
-                                                  </object>
-                                                  <packing>
-                                                    <property name="left_attach">0</property>
-                                                    <property name="top_attach">0</property>
-                                                    <property name="height">2</property>
-                                                  </packing>
-                                                </child>
-                                                <child>
-                                                  <object class="GtkLabel" id="nextcloud_account_label">
-                                                    <property name="visible">True</property>
-                                                    <property name="label" 
translatable="yes">Nextcloud</property>
-                                                    <property name="xalign">0</property>
-                                                  </object>
-                                                  <packing>
-                                                    <property name="left_attach">1</property>
-                                                    <property name="top_attach">0</property>
-                                                  </packing>
-                                                </child>
-                                                <child>
-                                                  <object class="GtkLabel" 
id="nextcloud_account_config_label">
-                                                    <property name="visible">True</property>
-                                                    <property name="label" translatable="yes">Click to set 
up</property>
-                                                    <property name="xalign">0</property>
-                                                    <style>
-                                                      <class name="dim-label"/>
-                                                    </style>
-                                                  </object>
-                                                  <packing>
-                                                    <property name="left_attach">1</property>
-                                                    <property name="top_attach">1</property>
-                                                  </packing>
-                                                </child>
-                                              </object>
-                                            </child>
-                                          </object>
-                                        </child>
-                                        <child>
-                                          <object class="GtkListBoxRow" id="exchange_stub_row">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <child>
-                                              <object class="GtkGrid" id="exchange_stub_grid">
-                                                <property name="visible">True</property>
-                                                <property name="border_width">6</property>
-                                                <property name="margin_end">18</property>
-                                                <property name="column_spacing">12</property>
-                                                <child>
-                                                  <object class="GtkImage" id="exchange_account_image">
-                                                    <property name="visible">True</property>
-                                                    <property name="pixel_size">32</property>
-                                                    <property name="icon_name">goa-account</property>
-                                                  </object>
-                                                  <packing>
-                                                    <property name="left_attach">0</property>
-                                                    <property name="top_attach">0</property>
-                                                    <property name="height">2</property>
-                                                  </packing>
-                                                </child>
-                                                <child>
-                                                  <object class="GtkLabel" id="exchange_account_label">
-                                                    <property name="visible">True</property>
-                                                    <property name="label" translatable="yes">Microsoft 
Exchange</property>
-                                                    <property name="xalign">0</property>
-                                                  </object>
-                                                  <packing>
-                                                    <property name="left_attach">1</property>
-                                                    <property name="top_attach">0</property>
-                                                  </packing>
-                                                </child>
-                                                <child>
-                                                  <object class="GtkLabel" 
id="exchange_account_config_label">
-                                                    <property name="visible">True</property>
-                                                    <property name="label" translatable="yes">Click to set 
up</property>
-                                                    <property name="xalign">0</property>
-                                                    <style>
-                                                      <class name="dim-label"/>
-                                                    </style>
-                                                  </object>
-                                                  <packing>
-                                                    <property name="left_attach">1</property>
-                                                    <property name="top_attach">1</property>
-                                                  </packing>
-                                                </child>
-                                              </object>
-                                            </child>
-                                          </object>
-                                        </child>
-                                      </object>
-                                    </child>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">0</property>
-                                    <property name="top_attach">1</property>
-                                    <property name="width">2</property>
-                                  </packing>
-                                </child>
-                              </object>
-                            </child>
                             <child>
                               <object class="GtkGrid" id="other_calendars_main_grid">
                                 <property name="visible">True</property>
diff --git a/src/gui/gcal-source-dialog.c b/src/gui/gcal-source-dialog.c
index 1600f9ad..cc90f5ea 100644
--- a/src/gui/gcal-source-dialog.c
+++ b/src/gui/gcal-source-dialog.c
@@ -91,12 +91,6 @@ struct _GcalSourceDialog
   /* overview widgets */
   GtkWidget          *add_calendar_menu_button;
   GtkWidget          *calendars_listbox;
-  GtkWidget          *online_accounts_listbox;
-
-  /* stub goa rows */
-  GtkWidget          *exchange_stub_row;
-  GtkWidget          *google_stub_row;
-  GtkWidget          *nextcloud_stub_row;
 
   /* flags */
   GcalSourceDialogMode mode;
@@ -174,17 +168,6 @@ static void       name_entry_text_changed               (GObject             *ob
                                                          GParamSpec          *pspec,
                                                          gpointer             user_data);
 
-static void       online_accounts_listbox_row_activated (GtkListBox          *box,
-                                                         GtkListBoxRow       *row,
-                                                         gpointer             user_data);
-
-static gint       online_accounts_listbox_sort_func      (GtkListBoxRow       *row1,
-                                                          GtkListBoxRow       *row2,
-                                                          gpointer             user_data);
-
-static void       online_accounts_settings_button_clicked (GtkWidget         *button,
-                                                          gpointer            user_data);
-
 static void       on_file_activated                     (GSimpleAction       *action,
                                                          GVariant            *param,
                                                          gpointer             user_data);
@@ -710,40 +693,6 @@ spawn_goa_with_args (const gchar *action,
   g_clear_object (&proxy);
 }
 
-static void
-online_accounts_listbox_row_activated (GtkListBox    *box,
-                                       GtkListBoxRow *row,
-                                       gpointer       user_data)
-{
-  GcalSourceDialog *self = GCAL_SOURCE_DIALOG (user_data);
-
-  if ((GtkWidget*) row == self->exchange_stub_row)
-    {
-      spawn_goa_with_args ("add", "exchange");
-    }
-  else if ((GtkWidget*) row == self->google_stub_row)
-    {
-      spawn_goa_with_args ("add", "google");
-    }
-  else if ((GtkWidget*) row == self->nextcloud_stub_row)
-    {
-      spawn_goa_with_args ("add", "owncloud");
-    }
-  else
-    {
-      GoaAccount *account;
-      gchar *id;
-
-      account = g_object_get_data (G_OBJECT (row), "goa-account");
-      g_return_if_fail (GOA_IS_ACCOUNT (account));
-
-      id = goa_account_dup_id (account);
-      spawn_goa_with_args (id, NULL);
-
-      g_free (id);
-    }
-}
-
 static void
 response_signal (GtkDialog *dialog,
                  gint       response_id,
@@ -1134,13 +1083,6 @@ url_entry_text_changed (GObject    *object,
     }
 }
 
-static void
-online_accounts_settings_button_clicked (GtkWidget *button,
-                                         gpointer   user_data)
-{
-  spawn_goa_with_args (NULL, NULL);
-}
-
 static void
 on_file_activated (GSimpleAction *action,
                    GVariant      *param,
@@ -1811,198 +1753,14 @@ remove_button_clicked (GtkWidget *button,
  * Callbacks
  */
 
-static GcalAccountType
-get_account_type (GoaAccount *account)
-{
-  g_return_val_if_fail (GOA_IS_ACCOUNT (account), GCAL_ACCOUNT_TYPE_NOT_SUPPORTED);
-
-  if (g_strcmp0 (goa_account_get_provider_type (account), "exchange") == 0)
-    return GCAL_ACCOUNT_TYPE_EXCHANGE;
-
-  if (g_strcmp0 (goa_account_get_provider_type (account), "google") == 0)
-    return GCAL_ACCOUNT_TYPE_GOOGLE;
-
-  if (g_strcmp0 (goa_account_get_provider_type (account), "owncloud") == 0)
-    return GCAL_ACCOUNT_TYPE_OWNCLOUD;
-
-  return GCAL_ACCOUNT_TYPE_NOT_SUPPORTED;
-}
-
-static void
-account_calendar_disable_changed (GObject    *object,
-                                  GParamSpec *pspec,
-                                  gpointer    user_data)
-{
-  GoaAccount *account = GOA_ACCOUNT (object);
-
-  g_return_if_fail (GTK_IS_LABEL (user_data));
-
-  gtk_label_set_label (GTK_LABEL (user_data), goa_account_get_calendar_disabled (account) ? _("Off") : 
_("On"));
-}
-
-static void
-add_goa_account (GcalSourceDialog *dialog,
-                 GoaAccount       *account)
-{
-  GcalAccountType type;
-  GtkBuilder *builder;
-  GtkWidget *provider_label;
-  GtkWidget *account_label;
-  GtkWidget *enabled_label;
-  GtkWidget *row;
-  GtkWidget *icon;
-  const gchar *icon_name;
-
-  type = get_account_type (account);
-
-  if (type == GCAL_ACCOUNT_TYPE_NOT_SUPPORTED)
-    return;
-
-  builder = gtk_builder_new_from_resource ("/org/gnome/calendar/online-account-row.ui");
-  row = GTK_WIDGET (gtk_builder_get_object (builder, "row"));
-  icon = GTK_WIDGET (gtk_builder_get_object (builder, "icon"));
-  provider_label = GTK_WIDGET (gtk_builder_get_object (builder, "account_provider_label"));
-  account_label = GTK_WIDGET (gtk_builder_get_object (builder, "account_name_label"));
-  enabled_label = GTK_WIDGET (gtk_builder_get_object (builder, "on_off_label"));
-
-  switch (type)
-    {
-    case GCAL_ACCOUNT_TYPE_EXCHANGE:
-      icon_name = "goa";
-      gtk_widget_hide (dialog->exchange_stub_row);
-      break;
-
-    case GCAL_ACCOUNT_TYPE_GOOGLE:
-      icon_name = "goa-account-google";
-      gtk_widget_hide (dialog->google_stub_row);
-      break;
-
-    case GCAL_ACCOUNT_TYPE_OWNCLOUD:
-      icon_name = "goa-account-owncloud";
-      gtk_widget_hide (dialog->nextcloud_stub_row);
-      break;
-
-    case GCAL_ACCOUNT_TYPE_NOT_SUPPORTED:
-    default:
-      icon_name = "goa";
-      g_assert_not_reached ();
-    }
-
-  /* update fields */
-  gtk_label_set_label (GTK_LABEL (provider_label), goa_account_get_provider_name (account));
-  gtk_label_set_label (GTK_LABEL (account_label), goa_account_get_identity (account));
-  gtk_label_set_label (GTK_LABEL (enabled_label),
-                       goa_account_get_attention_needed (account) ? _("Expired") :
-                       goa_account_get_calendar_disabled (account) ? _("Off") : _("On"));
-  gtk_image_set_from_icon_name (GTK_IMAGE (icon), icon_name, GTK_ICON_SIZE_DIALOG);
-  gtk_image_set_pixel_size (GTK_IMAGE (icon), 32);
-
-  g_object_set_data (G_OBJECT (row), "goa-account", account);
-  g_signal_connect (account, "notify::calendar-disabled",
-                    G_CALLBACK (account_calendar_disable_changed), enabled_label);
-
-  gtk_list_box_insert (GTK_LIST_BOX (dialog->online_accounts_listbox), row, 0);
-
-  g_object_unref (builder);
-}
-
-static void
-goa_account_added_cb (GoaClient *client,
-                      GoaObject *object,
-                      gpointer   user_data)
-{
-  add_goa_account (GCAL_SOURCE_DIALOG (user_data), goa_object_get_account (object));
-}
-
-static void
-goa_account_removed_cb (GoaClient *client,
-                        GoaObject *object,
-                        gpointer   user_data)
-{
-  GcalSourceDialog *self;
-  GoaAccount *account;
-  GcalAccountType type;
-  GList *children, *l;
-  gint counter = 1;
-
-  self = GCAL_SOURCE_DIALOG (user_data);
-  account = goa_object_get_account (object);
-  type = get_account_type (account);
-
-  if (type == GCAL_ACCOUNT_TYPE_NOT_SUPPORTED)
-    return;
-
-  children = gtk_container_get_children (GTK_CONTAINER (self->online_accounts_listbox));
-
-  for (l = children; l != NULL; l = l->next)
-    {
-      GoaAccount *row_account;
-      GcalAccountType row_type;
-
-      row_account = g_object_get_data (l->data, "goa-account");
-      row_type = row_account ? get_account_type (row_account) : GCAL_ACCOUNT_TYPE_NOT_SUPPORTED;
-
-      if (row_account == account)
-        {
-          gtk_widget_destroy (l->data);
-          counter--;
-        }
-      else if (type == row_type)
-        {
-          counter++;
-        }
-    }
-
-  /*
-   * If there's any other account with the same type,
-   * it should show back the stub row of the given type.
-   */
-  if (counter == 0)
-    {
-      switch (type)
-        {
-        case GCAL_ACCOUNT_TYPE_EXCHANGE:
-          gtk_widget_show (self->exchange_stub_row);
-          break;
-
-        case GCAL_ACCOUNT_TYPE_GOOGLE:
-          gtk_widget_show (self->google_stub_row);
-          break;
-
-        case GCAL_ACCOUNT_TYPE_OWNCLOUD:
-          gtk_widget_show (self->nextcloud_stub_row);
-          break;
-
-        case GCAL_ACCOUNT_TYPE_NOT_SUPPORTED:
-        default:
-          g_assert_not_reached ();
-        }
-    }
-
-  g_list_free (children);
-}
-
 static void
 setup_context (GcalSourceDialog *self)
 {
   GList *accounts = NULL;
   GcalManager *manager;
-  GoaClient *client;
-  GList *l;
 
   GCAL_ENTRY;
 
-  /* Add already fetched accounts */
-  client = gcal_context_get_goa_client (self->context);
-  accounts = goa_client_get_accounts (client);
-
-  for (l = accounts; l != NULL; l = l->next)
-    add_goa_account (self, goa_object_get_account (l->data));
-
-  /* Be ready to other accounts */
-  g_signal_connect (client, "account-added", G_CALLBACK (goa_account_added_cb), self);
-  g_signal_connect (client, "account-removed", G_CALLBACK (goa_account_removed_cb), self);
-
   manager = gcal_context_get_manager (self->context);
   g_signal_connect (manager, "calendar-added", G_CALLBACK (add_calendar), self);
   g_signal_connect (manager, "calendar-removed", G_CALLBACK (remove_calendar), self);
@@ -2033,10 +1791,6 @@ gcal_source_dialog_constructed (GObject *object)
   gtk_list_box_set_sort_func (GTK_LIST_BOX (self->calendars_listbox), (GtkListBoxSortFunc) 
calendar_listbox_sort_func,
                               object, NULL);
 
-  gtk_list_box_set_header_func (GTK_LIST_BOX (self->online_accounts_listbox), display_header_func, NULL, 
NULL);
-  gtk_list_box_set_sort_func (GTK_LIST_BOX (self->online_accounts_listbox), (GtkListBoxSortFunc) 
online_accounts_listbox_sort_func,
-                              object, NULL);
-
   /* Action group */
   self->action_group = g_simple_action_group_new ();
   gtk_widget_insert_action_group (GTK_WIDGET (object), "source", G_ACTION_GROUP (self->action_group));
@@ -2144,16 +1898,12 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, credentials_user_entry);
   gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, default_check);
   gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, edit_grid);
-  gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, exchange_stub_row);
-  gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, google_stub_row);
   gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, headerbar);
   gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, location_dim_label);
   gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, main_scrolledwindow);
   gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, name_entry);
   gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, notification);
   gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, notification_label);
-  gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, online_accounts_listbox);
-  gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, nextcloud_stub_row);
   gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, remove_button);
   gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, settings_button);
   gtk_widget_class_bind_template_child (widget_class, GcalSourceDialog, stack);
@@ -2177,8 +1927,6 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, hide_notification);
   gtk_widget_class_bind_template_callback (widget_class, name_entry_text_changed);
   gtk_widget_class_bind_template_callback (widget_class, notification_child_revealed_changed);
-  gtk_widget_class_bind_template_callback (widget_class, online_accounts_listbox_row_activated);
-  gtk_widget_class_bind_template_callback (widget_class, online_accounts_settings_button_clicked);
   gtk_widget_class_bind_template_callback (widget_class, remove_button_clicked);
   gtk_widget_class_bind_template_callback (widget_class, response_signal);
   gtk_widget_class_bind_template_callback (widget_class, settings_button_clicked);
@@ -2193,27 +1941,6 @@ gcal_source_dialog_init (GcalSourceDialog *self)
   gtk_widget_init_template (GTK_WIDGET (self));
 }
 
-static gint
-online_accounts_listbox_sort_func (GtkListBoxRow *row1,
-                                   GtkListBoxRow *row2,
-                                   gpointer       user_data)
-{
-  GcalAccountType t1, t2;
-  GoaAccount *a1 = g_object_get_data (G_OBJECT (row1), "goa-account");
-  GoaAccount *a2 = g_object_get_data (G_OBJECT (row2), "goa-account");
-
-  if (!a1 || !a2)
-    return a1 ? -1 : (a2 ? 1 : 0);
-
-  t1 = get_account_type (a1);
-  t2 = get_account_type (a2);
-
-  if (t1 != t2)
-    return t1 - t2;
-
-  return g_strcmp0 (goa_account_get_identity (a1), goa_account_get_identity (a2));
-}
-
 /**
  * gcal_source_dialog_set_mode:
  * @dialog: a #GcalSourceDialog


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