[gnome-calendar/calendar-management] source-manager: enable/disable sources when the relative action is fired



commit 6b6b0f32bc23ad6cca4933b8b05958cf591e810c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Feb 4 00:39:51 2015 -0200

    source-manager: enable/disable sources when the relative action is fired

 src/gcal-source-manager-dialog.c |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/src/gcal-source-manager-dialog.c b/src/gcal-source-manager-dialog.c
index be60250..8ecfc87 100644
--- a/src/gcal-source-manager-dialog.c
+++ b/src/gcal-source-manager-dialog.c
@@ -80,6 +80,10 @@ static void     row_activated_cb                           (GtkListBox
                                                             GtkListBoxRow       *row,
                                                             gpointer             user_data);
 
+static void     show_action_state_changed                  (GSimpleAction       *menu_item,
+                                                            GVariant            *value,
+                                                            gpointer             user_data);
+
 static void     source_added_cb                            (GcalManager         *manager,
                                                             ESource             *source,
                                                             gboolean             enabled,
@@ -128,7 +132,7 @@ static GActionEntry action_entries[] =
   { "file", file_action_activated, NULL, NULL, NULL },
   { "local", local_action_activated, NULL, NULL, NULL },
   { "url", url_action_activated, NULL, NULL, NULL },
-  { "show", NULL, NULL, "false", NULL },
+  { "show", NULL, NULL, "false", show_action_state_changed },
   { "default", NULL, NULL, "false", NULL },
   { "rename", NULL, NULL, NULL, NULL },
   { "color", color_action_activated, NULL, NULL, NULL },
@@ -333,6 +337,37 @@ row_activated_cb (GtkListBox    *listbox,
 }
 
 /**
+ * show_action_state_changed:
+ *
+ * Update the source's enable/disable
+ * state.
+ *
+ * Returns:
+ */
+static void
+show_action_state_changed (GSimpleAction *menu_item,
+                           GVariant      *value,
+                           gpointer       user_data)
+{
+  GcalSourceManagerDialogPrivate *priv;
+  gboolean should_show;
+
+  priv = gcal_source_manager_dialog_get_instance_private (GCAL_SOURCE_MANAGER_DIALOG (user_data));
+  should_show = g_variant_get_boolean (value);
+
+  g_assert_nonnull (priv->selected_source);
+
+  /* Show/hide the source from the views */
+  if (should_show)
+    gcal_manager_enable_source (priv->manager, priv->selected_source);
+  else
+    gcal_manager_disable_source (priv->manager, priv->selected_source);
+
+  g_simple_action_set_state (menu_item, value);
+}
+
+
+/**
  * source_added_cb:
  *
  * Callback for when an #ESource is added


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