[Xfce4-commits] <garcon:master> Add changed signal to GarconMenuItem.

Nick Schermer nick at xfce.org
Sat Aug 29 19:02:14 CEST 2009


Updating branch refs/heads/master
         to 587ad35c6dd88779bac6f76ab0e6b34859e2de3b (commit)
       from ee9b6537576b6403d9e9ca49315399c94af30085 (commit)

commit 587ad35c6dd88779bac6f76ab0e6b34859e2de3b
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Aug 29 19:01:14 2009 +0200

    Add changed signal to GarconMenuItem.

 garcon/garcon-menu-item.c |   41 +++++++++++++++++++++++++++++------------
 garcon/garcon-menu-item.h |   24 +++++++++++++++++++++---
 2 files changed, 50 insertions(+), 15 deletions(-)

diff --git a/garcon/garcon-menu-item.c b/garcon/garcon-menu-item.c
index 04914d3..85436c8 100644
--- a/garcon/garcon-menu-item.c
+++ b/garcon/garcon-menu-item.c
@@ -60,6 +60,13 @@ enum
   PROP_PATH,
 };
 
+/* Signal identifiers */
+enum
+{
+  CHANGED,
+  LAST_SIGNAL,
+};
+
 
 
 static void         garcon_menu_item_element_init                    (GarconMenuElementIface *iface);
@@ -80,10 +87,10 @@ static gboolean     garcon_menu_item_get_element_show_in_environment (GarconMenu
 static gboolean     garcon_menu_item_get_element_no_display          (GarconMenuElement      *element);
 
 
-struct _GarconMenuItemClass
-{
-  GObjectClass __parent__;
-};
+
+static guint item_signals[LAST_SIGNAL];
+
+
 
 struct _GarconMenuItemPrivate
 {
@@ -141,14 +148,6 @@ struct _GarconMenuItemPrivate
   guint     num_allocated;
 };
 
-struct _GarconMenuItem
-{
-  GObject                  __parent__;
-
-  /* < private > */
-  GarconMenuItemPrivate *priv;
-};
-
 
 
 G_DEFINE_TYPE_WITH_CODE (GarconMenuItem, garcon_menu_item, G_TYPE_OBJECT,
@@ -357,6 +356,21 @@ garcon_menu_item_class_init (GarconMenuItemClass *klass)
                                                         NULL,
                                                         G_PARAM_READWRITE |
                                                         G_PARAM_STATIC_STRINGS));
+
+  /**
+   * GarconMenuItem::changed:
+   * @item : a #GarconMenuItem.
+   *
+   * Emitted when #GarconMenuItem has been reloaded.
+   **/
+  item_signals[CHANGED] =
+    g_signal_new (g_intern_static_string ("changed"),
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (GarconMenuItemClass, changed),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
 }
 
 
@@ -902,6 +916,9 @@ garcon_menu_item_reload_from_file (GarconMenuItem  *item,
   /* Flush property notifications */
   g_object_thaw_notify (G_OBJECT (item));
 
+  /* Emit signal to everybody knows we reloaded the file */
+  g_signal_emit (G_OBJECT (item), item_signals[CHANGED], 0);
+
   g_key_file_free (rc);
 
   return TRUE;
diff --git a/garcon/garcon-menu-item.h b/garcon/garcon-menu-item.h
index 48b975d..8a59774 100644
--- a/garcon/garcon-menu-item.h
+++ b/garcon/garcon-menu-item.h
@@ -32,6 +32,10 @@
 
 G_BEGIN_DECLS
 
+typedef struct _GarconMenuItemPrivate GarconMenuItemPrivate;
+typedef struct _GarconMenuItemClass   GarconMenuItemClass;
+typedef struct _GarconMenuItem        GarconMenuItem;
+
 #define GARCON_TYPE_MENU_ITEM            (garcon_menu_item_get_type())
 #define GARCON_MENU_ITEM(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GARCON_TYPE_MENU_ITEM, GarconMenuItem))
 #define GARCON_MENU_ITEM_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GARCON_TYPE_MENU_ITEM, GarconMenuItemClass))
@@ -39,9 +43,23 @@ G_BEGIN_DECLS
 #define GARCON_IS_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GARCON_TYPE_MENU_ITEM))
 #define GARCON_MENU_ITEM_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GARCON_TYPE_MENU_ITEM, GarconMenuItemClass))
 
-typedef struct _GarconMenuItemPrivate GarconMenuItemPrivate;
-typedef struct _GarconMenuItemClass   GarconMenuItemClass;
-typedef struct _GarconMenuItem        GarconMenuItem;
+struct _GarconMenuItemClass
+{
+  GObjectClass __parent__;
+
+  /* signals */
+  void (*changed) (GarconMenuItem *item);
+};
+
+struct _GarconMenuItem
+{
+  GObject                  __parent__;
+
+  /* < private > */
+  GarconMenuItemPrivate *priv;
+};
+
+
 
 GType           garcon_menu_item_get_type                          (void) G_GNUC_CONST;
 



More information about the Xfce4-commits mailing list