[gnome-panel] libgnome-panel: add gp_applet_info_set_about_dialog



commit 7901234a198f4123ce6445e8a444e5839d0672ba
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Jan 5 21:36:31 2018 +0200

    libgnome-panel: add gp_applet_info_set_about_dialog

 libgnome-panel/gp-applet-info-private.h |   14 +++++++-------
 libgnome-panel/gp-applet-info.c         |   16 ++++++++--------
 libgnome-panel/gp-applet-info.h         |   29 +++++++++++++++++++----------
 libgnome-panel/gp-module.c              |   28 +++++++++++-----------------
 libgnome-panel/gp-module.h              |    8 ++------
 modules/clock/clock-module.c            |    3 +--
 modules/fish/fish-module.c              |    3 +--
 modules/notification-area/na-module.c   |    3 +--
 modules/separator/separator-module.c    |    3 +--
 modules/status-notifier/sn-module.c     |    3 +--
 modules/wncklet/wncklet-module.c        |    3 +--
 11 files changed, 53 insertions(+), 60 deletions(-)
---
diff --git a/libgnome-panel/gp-applet-info-private.h b/libgnome-panel/gp-applet-info-private.h
index 082de12..b188b1f 100644
--- a/libgnome-panel/gp-applet-info-private.h
+++ b/libgnome-panel/gp-applet-info-private.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Alberts Muktupāvels
+ * Copyright (C) 2016-2018 Alberts Muktupāvels
  *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
@@ -24,14 +24,14 @@ G_BEGIN_DECLS
 
 struct _GpAppletInfo
 {
-  gchar    *name;
-  gchar    *description;
-  gchar    *icon_name;
+  gchar                  *name;
+  gchar                  *description;
+  gchar                  *icon_name;
 
-  gchar    *help_uri;
-  gboolean  has_about_dialog;
+  gchar                  *help_uri;
+  GpSetupAboutDialogFunc  about_dialog_func;
 
-  gchar    *backends;
+  gchar                  *backends;
 };
 
 void gp_applet_info_free (GpAppletInfo *info);
diff --git a/libgnome-panel/gp-applet-info.c b/libgnome-panel/gp-applet-info.c
index 41e48a2..f8a24d6 100644
--- a/libgnome-panel/gp-applet-info.c
+++ b/libgnome-panel/gp-applet-info.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Alberts Muktupāvels
+ * Copyright (C) 2016-2018 Alberts Muktupāvels
  *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
@@ -52,7 +52,7 @@ gp_applet_info_new (const gchar *name,
   info->icon_name = g_strdup (icon_name);
 
   info->help_uri = NULL;
-  info->has_about_dialog = FALSE;
+  info->about_dialog_func = NULL;
 
   info->backends = NULL;
 
@@ -75,17 +75,17 @@ gp_applet_info_set_help_uri (GpAppletInfo *info,
 }
 
 /**
- * gp_applet_info_set_has_about_dialog:
+ * gp_applet_info_set_about_dialog:
  * @info: a #GpAppletInfo
- * @has_about_dialog: whether applet has an about dialog
+ * @func: the function to call to setup about dialog
  *
- * Sets whether applet has an about dialog.
+ * Specifies a function to be used to setup about dialog.
  */
 void
-gp_applet_info_set_has_about_dialog (GpAppletInfo *info,
-                                     gboolean      has_about_dialog)
+gp_applet_info_set_about_dialog (GpAppletInfo           *info,
+                                 GpSetupAboutDialogFunc  func)
 {
-  info->has_about_dialog = has_about_dialog;
+  info->about_dialog_func = func;
 }
 
 /**
diff --git a/libgnome-panel/gp-applet-info.h b/libgnome-panel/gp-applet-info.h
index 9227258..b303441 100644
--- a/libgnome-panel/gp-applet-info.h
+++ b/libgnome-panel/gp-applet-info.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Alberts Muktupāvels
+ * Copyright (C) 2016-2018 Alberts Muktupāvels
  *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
@@ -19,6 +19,7 @@
 #define GP_APPLET_INFO_H
 
 #include <glib.h>
+#include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
@@ -29,18 +30,26 @@ G_BEGIN_DECLS
  */
 typedef struct _GpAppletInfo GpAppletInfo;
 
-GpAppletInfo *gp_applet_info_new                  (const gchar  *name,
-                                                   const gchar  *description,
-                                                   const gchar  *icon_name);
+/**
+ * GpSetupAboutDialogFunc:
+ * @dialog: a #GtkAboutDialog
+ *
+ * Function for setting up about dialog.
+ */
+typedef void (* GpSetupAboutDialogFunc) (GtkAboutDialog *dialog);
+
+GpAppletInfo *gp_applet_info_new              (const gchar            *name,
+                                               const gchar            *description,
+                                               const gchar            *icon_name);
 
-void          gp_applet_info_set_help_uri         (GpAppletInfo *info,
-                                                   const gchar  *help_uri);
+void          gp_applet_info_set_help_uri     (GpAppletInfo           *info,
+                                               const gchar            *help_uri);
 
-void          gp_applet_info_set_has_about_dialog (GpAppletInfo *info,
-                                                   gboolean      has_about_dialog);
+void          gp_applet_info_set_about_dialog (GpAppletInfo           *info,
+                                               GpSetupAboutDialogFunc  func);
 
-void          gp_applet_info_set_backends         (GpAppletInfo *info,
-                                                   const gchar  *backends);
+void          gp_applet_info_set_backends     (GpAppletInfo           *info,
+                                               const gchar            *backends);
 
 G_END_DECLS
 
diff --git a/libgnome-panel/gp-module.c b/libgnome-panel/gp-module.c
index ba0d615..468a05c 100644
--- a/libgnome-panel/gp-module.c
+++ b/libgnome-panel/gp-module.c
@@ -24,6 +24,14 @@
  * A module with one or more applets.
  *
  * |[<!-- language="C" -->
+ * static gboolean
+ * example1_setup_about (GtkAboutDialog *dialog)
+ * {
+ *   gtk_about_dialog_set_comments (about, "...");
+ *   gtk_about_dialog_set_copyright (about, "...");
+ *   // ...
+ * }
+ *
  * static GpAppletInfo *
  * example_get_applet_info (const gchar *applet)
  * {
@@ -34,6 +42,9 @@
  *       info = gp_applet_info_new (_("Example 1 name"),
  *                                  _("Example 1 description"),
  *                                  "example1-icon");
+ *
+ *       gp_applet_info_set_about_dialog (info, example1_setup_about);
+ *       gp_applet_info_set_help_uri (info, "help:example/example1");
  *     }
  *   else if (g_strcmp0 (applet, "example2") == 0)
  *     {
@@ -81,22 +92,6 @@
  *   return NULL;
  * }
  *
- * static gboolean
- * example_setup_about (GtkAboutDialog *dialog,
- *                      const gchar    *applet)
- * {
- *   if (g_strcmp0 (applet, "example1") == 0)
- *     {
- *       gtk_about_dialog_set_comments (about, "...");
- *       gtk_about_dialog_set_copyright (about, "...");
- *       // ...
- *
- *       return TRUE;
- *     }
- *
- *   return FALSE;
- * }
- *
  * void
  * gp_module_load (GpModule *module)
  * {
@@ -120,7 +115,6 @@
  *   *vtable = (GpAppletVTable) {
  *     example_get_applet_info,
  *     example_get_applet_type,
- *     example_setup_about // or NULL if not needed
  *   };
  * }
  * ]|
diff --git a/libgnome-panel/gp-module.h b/libgnome-panel/gp-module.h
index 15df3e7..4650df5 100644
--- a/libgnome-panel/gp-module.h
+++ b/libgnome-panel/gp-module.h
@@ -45,19 +45,15 @@ typedef const gchar * (* GetAppletIdFromIidFunc) (const gchar *iid);
  * GpAppletVTable:
  * @get_applet_info: (transfer full): returns a #GpAppletInfo.
  * @get_applet_type: returns a #GType.
- * @setup_about: Function for setting up about dialog.
  *
  * The #GpAppletVTable provides the functions required by the #GpModule.
  */
 typedef struct _GpAppletVTable GpAppletVTable;
 struct _GpAppletVTable
 {
-  GpAppletInfo * (* get_applet_info)     (const gchar    *applet);
+  GpAppletInfo * (* get_applet_info) (const gchar *applet);
 
-  GType          (* get_applet_type)     (const gchar    *applet);
-
-  gboolean       (* setup_about)         (GtkAboutDialog *dialog,
-                                          const gchar    *applet);
+  GType          (* get_applet_type) (const gchar *applet);
 };
 
 #define GP_TYPE_MODULE (gp_module_get_type ())
diff --git a/modules/clock/clock-module.c b/modules/clock/clock-module.c
index c0b19e2..d1c72bd 100644
--- a/modules/clock/clock-module.c
+++ b/modules/clock/clock-module.c
@@ -74,7 +74,6 @@ gp_module_get_applet_vtable (GpAppletVTable *vtable)
 {
   *vtable = (GpAppletVTable) {
     clock_get_applet_info,
-    clock_get_applet_type,
-    NULL
+    clock_get_applet_type
   };
 }
diff --git a/modules/fish/fish-module.c b/modules/fish/fish-module.c
index 5626a6b..1c8393c 100644
--- a/modules/fish/fish-module.c
+++ b/modules/fish/fish-module.c
@@ -74,7 +74,6 @@ gp_module_get_applet_vtable (GpAppletVTable *vtable)
 {
   *vtable = (GpAppletVTable) {
     fish_get_applet_info,
-    fish_get_applet_type,
-    NULL
+    fish_get_applet_type
   };
 }
diff --git a/modules/notification-area/na-module.c b/modules/notification-area/na-module.c
index 5a732b7..e9ef412 100644
--- a/modules/notification-area/na-module.c
+++ b/modules/notification-area/na-module.c
@@ -74,7 +74,6 @@ gp_module_get_applet_vtable (GpAppletVTable *vtable)
 {
   *vtable = (GpAppletVTable) {
     na_get_applet_info,
-    na_get_applet_type,
-    NULL
+    na_get_applet_type
   };
 }
diff --git a/modules/separator/separator-module.c b/modules/separator/separator-module.c
index 0ada658..ec62697 100644
--- a/modules/separator/separator-module.c
+++ b/modules/separator/separator-module.c
@@ -68,7 +68,6 @@ gp_module_get_applet_vtable (GpAppletVTable *vtable)
 {
   *vtable = (GpAppletVTable) {
     separator_get_applet_info,
-    separator_get_applet_type,
-    NULL
+    separator_get_applet_type
   };
 }
diff --git a/modules/status-notifier/sn-module.c b/modules/status-notifier/sn-module.c
index f3c0c8a..1d7a109 100644
--- a/modules/status-notifier/sn-module.c
+++ b/modules/status-notifier/sn-module.c
@@ -72,7 +72,6 @@ gp_module_get_applet_vtable (GpAppletVTable *vtable)
 {
   *vtable = (GpAppletVTable) {
     sn_get_applet_info,
-    sn_get_applet_type,
-    NULL
+    sn_get_applet_type
   };
 }
diff --git a/modules/wncklet/wncklet-module.c b/modules/wncklet/wncklet-module.c
index b7def0b..8e860b7 100644
--- a/modules/wncklet/wncklet-module.c
+++ b/modules/wncklet/wncklet-module.c
@@ -140,7 +140,6 @@ gp_module_get_applet_vtable (GpAppletVTable *vtable)
 {
   *vtable = (GpAppletVTable) {
     wncklet_get_applet_info,
-    wncklet_get_applet_type,
-    NULL
+    wncklet_get_applet_type
   };
 }


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