[gnome-calendar/calendar-management] source-manager: user GActionEntries to map actions



commit dab21664cbb7fcfbc75e0df9d88f98352ed71056
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Feb 3 23:01:49 2015 -0200

    source-manager: user GActionEntries to map actions

 src/gcal-source-manager-dialog.c |   62 ++++++++++++++++++++++++++++++--------
 1 files changed, 49 insertions(+), 13 deletions(-)
---
diff --git a/src/gcal-source-manager-dialog.c b/src/gcal-source-manager-dialog.c
index dc77e1a..42244d5 100644
--- a/src/gcal-source-manager-dialog.c
+++ b/src/gcal-source-manager-dialog.c
@@ -65,6 +65,10 @@ static void     display_header_func                        (GtkListBoxRow
                                                             GtkListBoxRow       *before,
                                                             gpointer             user_data);
 
+static void     local_action_activated                     (GSimpleAction       *menu_item,
+                                                            GVariant            *value,
+                                                            gpointer             user_data);
+
 static void     row_activated_cb                           (GtkListBox          *listbox,
                                                             GtkListBoxRow       *row,
                                                             gpointer             user_data);
@@ -109,6 +113,18 @@ static void     gcal_source_manager_dialog_set_property    (GObject           *o
 
 G_DEFINE_TYPE_WITH_PRIVATE (GcalSourceManagerDialog, gcal_source_manager_dialog, GTK_TYPE_DIALOG)
 
+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 },
+  { "default", NULL, NULL, "false", NULL },
+  { "rename", NULL, NULL, NULL, NULL },
+  { "color", NULL, NULL, NULL, NULL },
+  { "remove", NULL, NULL, NULL, NULL },
+};
+
 /**
  * file_action_activated:
  *
@@ -221,6 +237,21 @@ display_header_func (GtkListBoxRow *row,
 }
 
 /**
+ * local_action_activated:
+ *
+ * Creates a local source.
+ *
+ * Returns:
+ */
+static void
+local_action_activated (GSimpleAction *menu_item,
+                        GVariant      *value,
+                        gpointer       user_data)
+{
+  /* TODO: implement me */
+}
+
+/**
  * row_activated_cb:
  *
  * Updates the edit stack properties,
@@ -397,6 +428,21 @@ make_header_for_data (GcalSourceOrigin *origin)
   return frame;
 }
 
+/**
+ * url_action_activated:
+ *
+ * Spawns an URL input dialog.
+ *
+ * Returns:
+ */
+static void
+url_action_activated (GSimpleAction *menu_item,
+                      GVariant      *value,
+                      gpointer       user_data)
+{
+  /* TODO: implement me */
+}
+
 static void
 fill_sources_list (GcalSourceManagerDialog *dialog)
 {
@@ -569,7 +615,6 @@ static void
 gcal_source_manager_dialog_constructed (GObject *object)
 {
   GcalSourceManagerDialogPrivate *priv;
-  GSimpleAction *file_action, *local_action, *url_action;
 
   GtkBuilder *builder;
   GMenuModel *sourcesmenu, *editsourcemenu;
@@ -598,18 +643,9 @@ gcal_source_manager_dialog_constructed (GObject *object)
   priv->action_group = g_simple_action_group_new ();
   gtk_widget_insert_action_group (GTK_WIDGET (object), "sources", G_ACTION_GROUP (priv->action_group));
 
-  /* sources.file action */
-  file_action = g_simple_action_new ("file", NULL);
-  g_signal_connect (file_action, "activate", G_CALLBACK (file_action_activated), object);
-  g_action_map_add_action (G_ACTION_MAP (priv->action_group), G_ACTION (file_action));
-
-  /* sources.local action */
-  local_action = g_simple_action_new ("local", NULL);
-  g_action_map_add_action (G_ACTION_MAP (priv->action_group), G_ACTION (local_action));
-
-  /* sources.url action */
-  url_action = g_simple_action_new ("url", NULL);
-  g_action_map_add_action (G_ACTION_MAP (priv->action_group), G_ACTION (url_action));
+  /* add action entries */
+  g_action_map_add_action_entries (G_ACTION_MAP (priv->action_group), action_entries, G_N_ELEMENTS 
(action_entries),
+                                   object);
 
   /* add separators to the listbox */
   gtk_list_box_set_header_func (GTK_LIST_BOX (priv->sources_listbox), display_header_func, object, NULL);


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