[gnome-calendar/calendar-management] source-manager: update internal action states



commit 4ee1c67cf5cc519c49d15a5b96153594b62d102d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Feb 3 23:02:56 2015 -0200

    source-manager: update internal action states

 src/gcal-source-manager-dialog.c |   40 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/src/gcal-source-manager-dialog.c b/src/gcal-source-manager-dialog.c
index 42244d5..15c7829 100644
--- a/src/gcal-source-manager-dialog.c
+++ b/src/gcal-source-manager-dialog.c
@@ -39,7 +39,10 @@ struct _GcalSourceManagerDialogPrivate
   GHashTable              *source_origin;
 
   /* actions */
-  GSimpleActionGroup *action_group;
+  GSimpleActionGroup      *action_group;
+
+  /* selected source */
+  ESource                 *selected_source;
 
   /* properties */
   GcalManager             *manager; /* weak ref */
@@ -98,6 +101,9 @@ static GtkWidget* make_header_for_data                     (GcalSourceOrigin
 static GtkWidget* make_row_for_source                      (GcalSourceManagerDialog *dialog,
                                                             ESource                 *source);
 
+static void       update_action_states                     (GcalSourceManagerDialog *dialog,
+                                                            ESource                 *source);
+
 /* prototypes */
 static void     gcal_source_manager_dialog_constructed     (GObject             *object);
 
@@ -525,6 +531,38 @@ make_row_for_source (GcalSourceManagerDialog *dialog,
   return row;
 }
 
+/**
+ * update_action_states:
+ *
+ * Update internal action states.
+ *
+ * Returns:
+ */
+static void
+update_action_states (GcalSourceManagerDialog *dialog,
+                      ESource                 *source)
+{
+  GcalSourceManagerDialogPrivate *priv;
+  gboolean is_enabled, is_default;
+  GAction *action;
+
+  priv = gcal_source_manager_dialog_get_instance_private (dialog);
+
+  priv->selected_source = source;
+
+  if (source == NULL)
+    return;
+
+  is_enabled = gcal_manager_is_source_enabled (priv->manager, source);
+  is_default = (source == gcal_manager_get_default_source (priv->manager));
+
+  action = g_action_map_lookup_action (G_ACTION_MAP (priv->action_group), "show");
+  g_action_change_state (action, g_variant_new_boolean (is_enabled));
+
+  action = g_action_map_lookup_action (G_ACTION_MAP (priv->action_group), "default");
+  g_action_change_state (action, g_variant_new_boolean (is_default));
+}
+
 GtkWidget *
 gcal_source_manager_dialog_new (GcalManager *manager)
 {


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