[gnome-panel] status-notifier: pass SnApplet object to SnItemV0



commit 1fd7efbd3d110307278b8ca92f99ba2db306e573
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Jan 30 22:46:28 2018 +0200

    status-notifier: pass SnApplet object to SnItemV0

 modules/status-notifier/sn-host-v0.c |    2 +-
 modules/status-notifier/sn-item-v0.c |    4 +++-
 modules/status-notifier/sn-item-v0.h |    3 ++-
 modules/status-notifier/sn-item.c    |   31 +++++++++++++++++++++++++++++++
 modules/status-notifier/sn-item.h    |    3 +++
 5 files changed, 40 insertions(+), 3 deletions(-)
---
diff --git a/modules/status-notifier/sn-host-v0.c b/modules/status-notifier/sn-host-v0.c
index ef84417..db830d4 100644
--- a/modules/status-notifier/sn-host-v0.c
+++ b/modules/status-notifier/sn-host-v0.c
@@ -120,7 +120,7 @@ add_registered_item (SnHostV0    *v0,
 
   get_bus_name_and_object_path (service, &bus_name, &object_path);
 
-  item = sn_item_v0_new (bus_name, object_path);
+  item = sn_item_v0_new (v0->applet, bus_name, object_path);
   g_object_ref_sink (item);
 
   v0->items = g_slist_prepend (v0->items, item);
diff --git a/modules/status-notifier/sn-item-v0.c b/modules/status-notifier/sn-item-v0.c
index 07e33de..e021158 100644
--- a/modules/status-notifier/sn-item-v0.c
+++ b/modules/status-notifier/sn-item-v0.c
@@ -1286,10 +1286,12 @@ sn_item_v0_init (SnItemV0 *v0)
 }
 
 SnItem *
-sn_item_v0_new (const gchar *bus_name,
+sn_item_v0_new (SnApplet    *applet,
+                const gchar *bus_name,
                 const gchar *object_path)
 {
   return g_object_new (SN_TYPE_ITEM_V0,
+                       "applet", applet,
                        "bus-name", bus_name,
                        "object-path", object_path,
                        NULL);
diff --git a/modules/status-notifier/sn-item-v0.h b/modules/status-notifier/sn-item-v0.h
index 87672ad..4a58409 100644
--- a/modules/status-notifier/sn-item-v0.h
+++ b/modules/status-notifier/sn-item-v0.h
@@ -25,7 +25,8 @@ G_BEGIN_DECLS
 #define SN_TYPE_ITEM_V0 sn_item_v0_get_type ()
 G_DECLARE_FINAL_TYPE (SnItemV0, sn_item_v0, SN, ITEM_V0, SnItem)
 
-SnItem *sn_item_v0_new (const gchar *bus_name,
+SnItem *sn_item_v0_new (SnApplet    *applet,
+                        const gchar *bus_name,
                         const gchar *object_path);
 
 G_END_DECLS
diff --git a/modules/status-notifier/sn-item.c b/modules/status-notifier/sn-item.c
index 86f4291..fa4281a 100644
--- a/modules/status-notifier/sn-item.c
+++ b/modules/status-notifier/sn-item.c
@@ -22,6 +22,8 @@
 
 typedef struct
 {
+  SnApplet       *applet;
+
   gchar          *bus_name;
   gchar          *object_path;
 
@@ -36,6 +38,8 @@ enum
 {
   PROP_0,
 
+  PROP_APPLET,
+
   PROP_BUS_NAME,
   PROP_OBJECT_PATH,
 
@@ -68,6 +72,8 @@ sn_item_dispose (GObject *object)
   item = SN_ITEM (object);
   priv = sn_item_get_instance_private (item);
 
+  priv->applet = NULL;
+
   g_clear_object (&priv->menu);
 
   G_OBJECT_CLASS (sn_item_parent_class)->dispose (object);
@@ -102,6 +108,10 @@ sn_item_get_property (GObject    *object,
 
   switch (property_id)
     {
+      case PROP_APPLET:
+        g_assert_not_reached ();
+        break;
+
       case PROP_BUS_NAME:
         g_value_set_string (value, priv->bus_name);
         break;
@@ -138,6 +148,11 @@ sn_item_set_property (GObject      *object,
 
   switch (property_id)
     {
+      case PROP_APPLET:
+        g_assert (priv->applet == NULL);
+        priv->applet = g_value_get_object (value);
+        break;
+
       case PROP_BUS_NAME:
         priv->bus_name = g_value_dup_string (value);
         break;
@@ -252,6 +267,12 @@ sn_item_ready (SnItem *item)
 static void
 install_properties (GObjectClass *object_class)
 {
+  properties[PROP_APPLET] =
+    g_param_spec_object ("applet", "Applet", "Applet",
+                         SN_TYPE_APPLET,
+                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE |
+                         G_PARAM_STATIC_STRINGS);
+
   properties[PROP_BUS_NAME] =
     g_param_spec_string ("bus-name", "bus-name", "bus-name", NULL,
                          G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
@@ -349,6 +370,16 @@ sn_item_get_menu (SnItem *item)
   return priv->menu;
 }
 
+SnApplet *
+sn_item_get_applet (SnItem *item)
+{
+  SnItemPrivate *priv;
+
+  priv = sn_item_get_instance_private (item);
+
+  return priv->applet;
+}
+
 const gchar *
 sn_item_get_bus_name (SnItem *item)
 {
diff --git a/modules/status-notifier/sn-item.h b/modules/status-notifier/sn-item.h
index a01223e..61a4068 100644
--- a/modules/status-notifier/sn-item.h
+++ b/modules/status-notifier/sn-item.h
@@ -19,6 +19,7 @@
 #define SN_ITEM_H
 
 #include <gtk/gtk.h>
+#include "sn-applet.h"
 
 G_BEGIN_DECLS
 
@@ -74,6 +75,8 @@ SnItemCategory  sn_item_get_category    (SnItem *item);
 
 GtkMenu        *sn_item_get_menu        (SnItem *item);
 
+SnApplet       *sn_item_get_applet      (SnItem *item);
+
 const gchar    *sn_item_get_bus_name    (SnItem *item);
 const gchar    *sn_item_get_object_path (SnItem *item);
 


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