[Xfce4-commits] <xfce4-panel:devel> Implement xfce_panel_plugin_get_comment() in libxfce4panel.

Nick Schermer nick at xfce.org
Tue Aug 11 20:30:44 CEST 2009


Updating branch refs/heads/devel
         to 6a0f1e6adaa06dd6fc31404c40e90f3a6497fe82 (commit)
       from a039f28c21ba2f2ac0d9261117c3c01547fc5226 (commit)

commit 6a0f1e6adaa06dd6fc31404c40e90f3a6497fe82
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Mar 21 00:05:16 2009 +0100

    Implement xfce_panel_plugin_get_comment() in libxfce4panel.

 libxfce4panel/libxfce4panel.h              |    5 ++-
 libxfce4panel/xfce-panel-macros.h          |    4 +-
 libxfce4panel/xfce-panel-plugin-provider.h |    1 +
 libxfce4panel/xfce-panel-plugin.c          |   48 ++++++++++++++++++++++++++-
 libxfce4panel/xfce-panel-plugin.h          |    2 +
 panel/panel-module.c                       |   13 +++++--
 panel/panel-plugin-external.c              |   22 ++++++-------
 wrapper/main.c                             |   18 ++++++----
 wrapper/wrapper-module.c                   |   13 +++++--
 wrapper/wrapper-module.h                   |    1 +
 10 files changed, 95 insertions(+), 32 deletions(-)

diff --git a/libxfce4panel/libxfce4panel.h b/libxfce4panel/libxfce4panel.h
index 519fbcc..0b7cd2e 100644
--- a/libxfce4panel/libxfce4panel.h
+++ b/libxfce4panel/libxfce4panel.h
@@ -90,7 +90,7 @@ G_BEGIN_DECLS
   \
   XFCE_PANEL_DEFINE_TYPE (TypeName, type_name, XFCE_TYPE_PANEL_PLUGIN) \
   \
-  PANEL_SYMBOL_EXPORT GType \
+  PANEL_SYMBOL_EXPORT G_MODULE_EXPORT GType \
   __xpp_initialize (GTypeModule *type_module, \
                     gboolean    *make_resident) \
   { \
@@ -130,12 +130,14 @@ G_BEGIN_DECLS
   __xpp_construct (const gchar  *name, \
                    gint          unique_id, \
                    const gchar  *display_name, \
+                   const gchar  *comment, \
                    gchar       **arguments, \
                    GdkScreen    *screen); \
   PANEL_SYMBOL_EXPORT G_MODULE_EXPORT XfcePanelPlugin * \
   __xpp_construct (const gchar  *name, \
                    gint          unique_id, \
                    const gchar  *display_name, \
+                   const gchar  *comment, \
                    gchar       **arguments, \
                    GdkScreen    *screen) \
   { \
@@ -150,6 +152,7 @@ G_BEGIN_DECLS
                                "name", name, \
                                "unique-id", unique_id, \
                                "display-name", display_name, \
+                               "comment", comment, \
                                "arguments", arguments, NULL); \
         \
         g_signal_connect_after (G_OBJECT (plugin), "realize", G_CALLBACK (__xpp_realize), NULL); \
diff --git a/libxfce4panel/xfce-panel-macros.h b/libxfce4panel/xfce-panel-macros.h
index 52328ef..d5c23e4 100644
--- a/libxfce4panel/xfce-panel-macros.h
+++ b/libxfce4panel/xfce-panel-macros.h
@@ -60,9 +60,9 @@ G_BEGIN_DECLS
 
 /* visibility support */
 #ifdef HAVE_GNUC_VISIBILITY
-#define PANEL_SYMBOL_EXPORT G_MODULE_EXPORT __attribute__ ((visibility("default")))
+#define PANEL_SYMBOL_EXPORT __attribute__ ((visibility("default")))
 #else
-#define PANEL_SYMBOL_EXPORT G_MODULE_EXPORT
+#define PANEL_SYMBOL_EXPORT
 #endif
 
 /* make api compatible with 4.4 panel */
diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h
index 1325681..b497705 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.h
+++ b/libxfce4panel/xfce-panel-plugin-provider.h
@@ -38,6 +38,7 @@ typedef enum   _XfcePanelPluginProviderSignal XfcePanelPluginProviderSignal;
 typedef GtkWidget *(*PluginConstructFunc)   (const gchar  *name,
                                              gint          unique_id,
                                              const gchar  *display_name,
+                                             const gchar  *comment,
                                              gchar       **arguments,
                                              GdkScreen    *screen);
 typedef GType      (*PluginInitializeFunc)  (GTypeModule  *module,
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index ae6689e..b5dedcf 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -85,6 +85,7 @@ enum
   PROP_0,
   PROP_NAME,
   PROP_DISPLAY_NAME,
+  PROP_COMMENT,
   PROP_ARGUMENTS,
   PROP_UNIQUE_ID
 };
@@ -115,6 +116,7 @@ struct _XfcePanelPluginPrivate
   /* plugin information */
   gchar               *name;
   gchar               *display_name;
+  gchar               *comment;
   gint                 unique_id;
   gchar               *property_base;
   gchar              **arguments;
@@ -340,6 +342,22 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
                                                         | G_PARAM_CONSTRUCT_ONLY));
 
   /**
+   * XfcePanelPlugin:comment:
+   *
+   *
+   * Since 4.8.0
+   **/
+  g_object_class_install_property (gobject_class,
+                                   PROP_COMMENT,
+                                   g_param_spec_string ("comment",
+                                                        "Comment",
+                                                        "Plugin comment",
+                                                        NULL,
+                                                        G_PARAM_READWRITE
+                                                        | G_PARAM_STATIC_STRINGS
+                                                        | G_PARAM_CONSTRUCT_ONLY));
+
+  /**
    * XfcePanelPlugin:id:
    *
    * The unique id of the #XfcePanelPlugin. Plugin writer can use it to
@@ -387,6 +405,7 @@ xfce_panel_plugin_init (XfcePanelPlugin *plugin)
   /* initialize plugin value */
   plugin->priv->name = NULL;
   plugin->priv->display_name = NULL;
+  plugin->priv->comment = NULL;
   plugin->priv->unique_id = -1;
   plugin->priv->property_base = NULL;
   plugin->priv->arguments = NULL;
@@ -440,6 +459,10 @@ xfce_panel_plugin_get_property (GObject    *object,
         g_value_set_static_string (value, private->display_name);
         break;
 
+      case PROP_COMMENT:
+        g_value_set_static_string (value, private->comment);
+        break;
+
       case PROP_UNIQUE_ID:
         g_value_set_int (value, private->unique_id);
         break;
@@ -474,6 +497,10 @@ xfce_panel_plugin_set_property (GObject      *object,
         private->display_name = g_value_dup_string (value);
         break;
 
+      case PROP_COMMENT:
+        private->comment = g_value_dup_string (value);
+        break;
+
       case PROP_UNIQUE_ID:
         private->unique_id = g_value_get_int (value);
         break;
@@ -521,6 +548,7 @@ xfce_panel_plugin_finalize (GObject *object)
   /* cleanup */
   g_free (plugin->priv->name);
   g_free (plugin->priv->display_name);
+  g_free (plugin->priv->comment);
   g_free (plugin->priv->property_base);
   g_strfreev (plugin->priv->arguments);
 
@@ -1051,8 +1079,6 @@ xfce_panel_plugin_get_name (XfcePanelPlugin *plugin)
 PANEL_SYMBOL_EXPORT const gchar *
 xfce_panel_plugin_get_display_name (XfcePanelPlugin *plugin)
 {
-
-
   g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), NULL);
 
   if (G_LIKELY (plugin->priv->display_name))
@@ -1063,6 +1089,24 @@ xfce_panel_plugin_get_display_name (XfcePanelPlugin *plugin)
 
 
 
+PANEL_SYMBOL_EXPORT const gchar *
+xfce_panel_plugin_get_comment (XfcePanelPlugin *plugin)
+{
+  g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), NULL);
+
+  return plugin->priv->comment;
+}
+
+
+
+/**
+ * xfce_panel_plugin_get_unique_id:
+ * @plugin : an #XfcePanelPlugin.
+ *
+ * Return value: the unique id of the plugin.
+ *
+ * Since 4.8
+ **/
 gint
 xfce_panel_plugin_get_unique_id (XfcePanelPlugin *plugin)
 {
diff --git a/libxfce4panel/xfce-panel-plugin.h b/libxfce4panel/xfce-panel-plugin.h
index 8da2e5a..1550dbd 100644
--- a/libxfce4panel/xfce-panel-plugin.h
+++ b/libxfce4panel/xfce-panel-plugin.h
@@ -92,6 +92,8 @@ const gchar         *xfce_panel_plugin_get_name            (XfcePanelPlugin   *p
 
 const gchar         *xfce_panel_plugin_get_display_name    (XfcePanelPlugin   *plugin);
 
+const gchar         *xfce_panel_plugin_get_comment         (XfcePanelPlugin   *plugin);
+
 gint                 xfce_panel_plugin_get_unique_id       (XfcePanelPlugin   *plugin);
 
 const gchar         *xfce_panel_plugin_get_property_base   (XfcePanelPlugin   *plugin);
diff --git a/panel/panel-module.c b/panel/panel-module.c
index e599a99..939bafd 100644
--- a/panel/panel-module.c
+++ b/panel/panel-module.c
@@ -356,7 +356,7 @@ panel_module_new_plugin (PanelModule  *module,
   /* return null if the module is not usable (unique and already used) */
   if (G_UNLIKELY (panel_module_is_usable (module) == FALSE))
     return NULL;
-  
+
   /* get the internal plugin name */
   name = panel_module_get_name (module);
 
@@ -376,14 +376,19 @@ panel_module_new_plugin (PanelModule  *module,
                                      "name", name,
                                      "unique-id", unique_id,
                                      "display-name", module->display_name,
-                                     "arguments", arguments, NULL);
+                                     "comment", module->comment,
+                                     "arguments", arguments,
+                                     NULL);
             }
           else if (module->construct_func != NULL)
             {
               /* create a new panel plugin */
-              plugin = (*module->construct_func) (name, unique_id, 
+              plugin = (*module->construct_func) (name,
+                                                  unique_id,
                                                   module->display_name,
-                                                  arguments, screen);
+                                                  module->comment,
+                                                  arguments,
+                                                  screen);
             }
         }
     }
diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c
index a8d4a89..3502387 100644
--- a/panel/panel-plugin-external.c
+++ b/panel/panel-plugin-external.c
@@ -214,7 +214,7 @@ panel_plugin_external_realize (GtkWidget *widget)
   GError               *error = NULL;
   gboolean              succeed;
   gchar                *socket_id, *unique_id;
-  gint                  i, argc = 12;
+  gint                  i, argc = 14;
   GdkScreen            *screen;
 
   /* realize the socket first */
@@ -229,7 +229,7 @@ panel_plugin_external_realize (GtkWidget *widget)
     argc += g_strv_length (external->arguments);
 
   /* allocate argv */
-  argv = g_new (gchar *, argc);
+  argv = g_new0 (gchar *, argc);
 
   /* setup the basic argv */
   argv[0]  = (gchar *) LIBEXECDIR "/xfce4-panel-wrapper";
@@ -239,18 +239,17 @@ panel_plugin_external_realize (GtkWidget *widget)
   argv[4]  = (gchar *) unique_id;
   argv[5]  = (gchar *) "-d";
   argv[6]  = (gchar *) panel_module_get_display_name (external->module);
-  argv[7]  = (gchar *) "-f";
-  argv[8]  = (gchar *) panel_module_get_filename (external->module);
-  argv[9]  = (gchar *) "-s";
-  argv[10] = (gchar *) socket_id;
+  argv[7]  = (gchar *) "-c";
+  argv[8]  = (gchar *) panel_module_get_comment (external->module);
+  argv[9]  = (gchar *) "-f";
+  argv[10] = (gchar *) panel_module_get_filename (external->module);
+  argv[11] = (gchar *) "-s";
+  argv[12] = (gchar *) socket_id;
 
   /* append the arguments */
   if (G_UNLIKELY (external->arguments != NULL))
     for (i = 0; external->arguments[i] != NULL; i++)
-      argv[i + 11] = external->arguments[i];
-
-  /* close the argv */
-  argv[argc - 1] = NULL;
+      argv[i + 13] = external->arguments[i];
 
   /* get the widget screen */
   screen = gtk_widget_get_screen (widget);
@@ -261,13 +260,12 @@ panel_plugin_external_realize (GtkWidget *widget)
   /* cleanup */
   g_free (socket_id);
   g_free (unique_id);
-  g_free (argv);
 
   /* handle problem */
   if (G_UNLIKELY (succeed == FALSE))
     {
       /* show warnings */
-      g_critical ("Failed to spawn the xfce4-panel-wrapped: %s", error->message);
+      g_critical ("Failed to spawn the xfce4-panel-wrapper: %s", error->message);
 
       /* cleanup */
       g_error_free (error);
diff --git a/wrapper/main.c b/wrapper/main.c
index 3fcef6b..7ffc0a8 100644
--- a/wrapper/main.c
+++ b/wrapper/main.c
@@ -54,6 +54,7 @@
 
 static gchar   *opt_display_name = NULL;
 static gint     opt_unique_id = -1;
+static gchar   *opt_comment = NULL;
 static gchar   *opt_filename = NULL;
 static gint     opt_socket_id = 0;
 static gchar  **opt_arguments = NULL;
@@ -65,6 +66,7 @@ static GOptionEntry option_entries[] =
 {
   { "name", 'n', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &wrapper_name, NULL, NULL },
   { "display-name", 'd', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &opt_display_name, NULL, NULL },
+  { "comment", 'c', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &opt_comment, NULL, NULL },
   { "unique-id", 'i', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_INT, &opt_unique_id, NULL, NULL },
   { "filename", 'f', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &opt_filename, NULL, NULL },
   { "socket-id", 's', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_INT, &opt_socket_id, NULL, NULL },
@@ -226,7 +228,7 @@ main (gint argc, gchar **argv)
     {
       /* set error if not set by gtk */
       if (error == NULL)
-        g_set_error (&error, 0, 0, "Unable to open display \"%s\"", 
+        g_set_error (&error, 0, 0, "Unable to open display \"%s\"",
                      gdk_get_display_arg_name ());
       goto error;
     }
@@ -299,12 +301,14 @@ main (gint argc, gchar **argv)
 
   /* create a new wrapper module */
   module = wrapper_module_new (opt_filename);
-  
+
   /* create the plugin provider */
   provider = wrapper_module_new_provider (module,
                                           gdk_screen_get_default (),
-                                          wrapper_name, opt_unique_id, 
-                                          opt_display_name, opt_arguments);
+                                          wrapper_name, opt_unique_id,
+                                          opt_display_name,
+                                          opt_comment,
+                                          opt_arguments);
   if (G_LIKELY (provider != NULL))
     {
       /* create quark */
@@ -328,7 +332,7 @@ main (gint argc, gchar **argv)
       gtk_container_add (GTK_CONTAINER (plug), GTK_WIDGET (provider));
       gtk_widget_show (GTK_WIDGET (plug));
       gtk_widget_show (GTK_WIDGET (provider));
-      
+
       /* everything went fine */
       succeed = TRUE;
 
@@ -356,12 +360,12 @@ error:
   /* close the module */
   if (G_LIKELY (module != NULL))
     g_object_unref (G_OBJECT (module));
-  
+
   if (G_UNLIKELY (error != NULL))
     {
       /* print the critical error */
       g_critical ("Wrapper %s-%d: %s.", wrapper_name, opt_unique_id, error->message);
-      
+
       /* cleanup */
       g_error_free (error);
     }
diff --git a/wrapper/wrapper-module.c b/wrapper/wrapper-module.c
index b7f3c62..e8b6315 100644
--- a/wrapper/wrapper-module.c
+++ b/wrapper/wrapper-module.c
@@ -187,10 +187,10 @@ WrapperModule *
 wrapper_module_new (const gchar *filename)
 {
   WrapperModule *module;
-  
+
   module = g_object_new (WRAPPER_TYPE_MODULE, NULL);
   module->filename = g_strdup (filename);
-  
+
   return module;
 }
 
@@ -202,6 +202,7 @@ wrapper_module_new_provider (WrapperModule  *module,
                              const gchar    *name,
                              gint            unique_id,
                              const gchar    *display_name,
+                             const gchar    *comment,
                              gchar         **arguments)
 {
   GtkWidget *plugin = NULL;
@@ -216,14 +217,18 @@ wrapper_module_new_provider (WrapperModule  *module,
                                  "name", name,
                                  "unique-id", unique_id,
                                  "display-name", display_name,
+                                 "comment", comment,
                                  "arguments", arguments, NULL);
         }
       else if (module->construct_func != NULL)
         {
           /* create a new panel plugin */
-          plugin = (*module->construct_func) (name, unique_id,
+          plugin = (*module->construct_func) (name,
+                                              unique_id,
                                               display_name,
-                                              arguments, screen);
+                                              comment,
+                                              arguments,
+                                              screen);
         }
 
       if (G_LIKELY (plugin != NULL))
diff --git a/wrapper/wrapper-module.h b/wrapper/wrapper-module.h
index 5d28eb9..2a8ae82 100644
--- a/wrapper/wrapper-module.h
+++ b/wrapper/wrapper-module.h
@@ -44,6 +44,7 @@ GtkWidget     *wrapper_module_new_provider (WrapperModule  *module,
                                             const gchar    *name,
                                             gint            unique_id,
                                             const gchar    *display_name,
+                                            const gchar    *comment,
                                             gchar         **arguments) G_GNUC_MALLOC;
 
 G_END_DECLS



More information about the Xfce4-commits mailing list