[glib/wip/gapplication] application: Add remove_action()



commit 45bba7a89006762eee769838833dde227c5b54b8
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Tue May 18 12:03:54 2010 +0100

    application: Add remove_action()
    
    Since we allow live addition of the actions available for a
    GApplication we should also allow live removal.

 gio/gapplication.c |   33 ++++++++++++++++++++++++++++++---
 gio/gapplication.h |    2 ++
 gio/gio.symbols    |    2 ++
 3 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/gio/gapplication.c b/gio/gapplication.c
index cfd66e5..687f799 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -121,7 +121,7 @@ timeout_handle_actions_changed (gpointer user_data)
   return FALSE;
 }
 
-static void
+static inline void
 queue_actions_change_notification (GApplication *application)
 {
   GApplicationPrivate *priv = application->priv;
@@ -262,21 +262,48 @@ g_application_add_action (GApplication *application,
   GApplicationAction *action;
 
   g_return_if_fail (G_IS_APPLICATION (application));
+  g_return_if_fail (name != NULL && *name != '\0');
 
   priv = application->priv;
 
   g_return_if_fail (g_hash_table_lookup (priv->actions, name) == NULL);
-  
+
   action = g_slice_new (GApplicationAction);
   action->name = g_strdup (name);
   action->description = g_strdup (description);
   action->enabled = TRUE;
-  
+
   g_hash_table_insert (priv->actions, action->name, action);
   queue_actions_change_notification (application);
 }
 
 /**
+ * g_application_remove_action:
+ * @application: a #GApplication
+ * @name: the name of the action to remove
+ *
+ * Removes the action @name from the list of actions of @application
+ *
+ * Since: 2.26
+ */
+void
+g_application_remove_action (GApplication *application,
+                             const gchar  *name)
+{
+  GApplicationPrivate *priv;
+
+  g_return_if_fail (G_IS_APPLICATION (application));
+  g_return_if_fail (name != NULL && *name != '\0');
+
+  priv = application->priv;
+
+  g_return_if_fail (g_hash_table_lookup (priv->actions, name) != NULL);
+
+  g_hash_table_remove (priv->actions, name);
+  queue_actions_change_notification (application);
+}
+
+/**
  * g_application_invoke_action:
  * @application: a #GApplication
  * @name: the name of the action to invoke
diff --git a/gio/gapplication.h b/gio/gapplication.h
index aecaa7f..d02fd2b 100644
--- a/gio/gapplication.h
+++ b/gio/gapplication.h
@@ -140,6 +140,8 @@ G_CONST_RETURN gchar *  g_application_get_id                    (GApplication
 void                    g_application_add_action                (GApplication      *application,
                                                                  const char        *name,
                                                                  const char        *description);
+void                    g_application_remove_action             (GApplication      *application,
+                                                                 const char        *name);
 void                    g_application_set_action_enabled        (GApplication      *application,
                                                                  const char        *name,
                                                                  gboolean           enabled);
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 879739d..a759a41 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -35,6 +35,8 @@ g_application_get_instance
 g_application_get_id
 g_application_set_action_enabled
 g_application_get_action_enabled
+g_application_add_action
+g_application_remove_action
 g_application_invoke_action
 g_application_get_mainloop
 g_application_run



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