[gnome-panel] libgnome-panel: remove GpAppletVTable
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] libgnome-panel: remove GpAppletVTable
- Date: Sat, 6 Jan 2018 18:15:09 +0000 (UTC)
commit 558cb3974abb7d5c34f46d4cce0c1ec428454d97
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sat Jan 6 20:14:13 2018 +0200
libgnome-panel: remove GpAppletVTable
libgnome-panel/gp-module.c | 58 ++++++++++++--------------------
libgnome-panel/gp-module.h | 59 ++++++++++++++-------------------
modules/clock/clock-module.c | 11 +-----
modules/fish/fish-module.c | 11 +-----
modules/notification-area/na-module.c | 11 +-----
modules/separator/separator-module.c | 11 +-----
modules/status-notifier/sn-module.c | 11 +-----
modules/wncklet/wncklet-module.c | 19 +++-------
8 files changed, 63 insertions(+), 128 deletions(-)
---
diff --git a/libgnome-panel/gp-module.c b/libgnome-panel/gp-module.c
index ea1d9ad..6d1f945 100644
--- a/libgnome-panel/gp-module.c
+++ b/libgnome-panel/gp-module.c
@@ -33,11 +33,11 @@
* }
*
* static GpAppletInfo *
- * example_get_applet_info (const gchar *applet)
+ * example_get_applet_info (const gchar *id)
* {
* GpAppletInfo *info;
*
- * if (g_strcmp0 (applet, "example1") == 0)
+ * if (g_strcmp0 (id, "example1") == 0)
* {
* info = gp_applet_info_new (example1_get_type,
* _("Example 1 name"),
@@ -47,7 +47,7 @@
* 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)
+ * else if (g_strcmp0 (id, "example2") == 0)
* {
* info = gp_applet_info_new (example2_get_type,
* _("Example 2 name"),
@@ -93,16 +93,9 @@
*
* gp_module_set_applet_ids (module, "example1", "example2", NULL);
*
+ * gp_module_set_get_applet_info (module, example_get_applet_info);
* gp_module_set_compatibility (module, example_get_applet_id_from_iid);
* }
- *
- * void
- * gp_module_get_applet_vtable (GpAppletVTable *vtable)
- * {
- * *vtable = (GpAppletVTable) {
- * example_get_applet_info
- * };
- * }
* ]|
*/
@@ -122,8 +115,7 @@
#include "gp-applet-info-private.h"
#include "gp-module-private.h"
-typedef void (* LoadFunc) (GpModule *module);
-typedef void (* GetAppletVTableFunc) (GpAppletVTable *vtable);
+typedef void (* LoadFunc) (GpModule *module);
struct _GpModule
{
@@ -141,9 +133,10 @@ struct _GpModule
gchar **applet_ids;
+ GpGetAppletInfoFunc get_applet_info_func;
+
GetAppletIdFromIidFunc compatibility_func;
- GpAppletVTable applet_vtable;
GHashTable *applets;
};
@@ -258,7 +251,7 @@ get_applet_info (GpModule *module,
if (info != NULL)
return info;
- info = module->applet_vtable.get_applet_info (applet);
+ info = module->get_applet_info_func (applet);
if (info == NULL)
{
@@ -338,7 +331,6 @@ gp_module_new_from_path (const gchar *path)
GModuleFlags flags;
const gchar *symbol;
LoadFunc load_func;
- GetAppletVTableFunc applet_vtable_func;
g_return_val_if_fail (path != NULL && *path != '\0', NULL);
@@ -397,26 +389,6 @@ gp_module_new_from_path (const gchar *path)
return NULL;
}
- symbol = "gp_module_get_applet_vtable";
- if (!g_module_symbol (module->library, symbol, (gpointer) &applet_vtable_func))
- {
- g_warning ("Failed to get '%s' for module '%s': %s",
- symbol, path, g_module_error ());
-
- g_object_unref (module);
- return NULL;
- }
-
- if (applet_vtable_func == NULL)
- {
- g_warning ("Invalid '%s' in module '%s'", symbol, path);
-
- g_object_unref (module);
- return NULL;
- }
-
- applet_vtable_func (&module->applet_vtable);
-
return module;
}
@@ -519,6 +491,20 @@ gp_module_get_applets (GpModule *module)
}
/**
+ * gp_module_set_get_applet_info:
+ * @module: a #GpModule
+ * @func: the function to call to get #GpAppletInfo
+ *
+ * Specifies a function to be used to get #GpAppletInfo.
+ */
+void
+gp_module_set_get_applet_info (GpModule *module,
+ GpGetAppletInfoFunc func)
+{
+ module->get_applet_info_func = func;
+}
+
+/**
* gp_module_applet_new:
* @module: a #GpModule
* @applet: the applet id
diff --git a/libgnome-panel/gp-module.h b/libgnome-panel/gp-module.h
index 3ece866..91054ac 100644
--- a/libgnome-panel/gp-module.h
+++ b/libgnome-panel/gp-module.h
@@ -31,6 +31,14 @@ G_BEGIN_DECLS
#define GP_MODULE_ABI_VERSION 0x0001
/**
+ * GpGetAppletInfoFunc:
+ * @id: the applet id
+ *
+ * Returns: (transfer full): returns a #GpAppletInfo.
+ */
+typedef GpAppletInfo * (* GpGetAppletInfoFunc) (const gchar *id);
+
+/**
* GetAppletIdFromIidFunc:
* @iid: the applet iid
*
@@ -39,40 +47,31 @@ G_BEGIN_DECLS
*
* Returns: (transfer none): the applet id, or %NULL.
*/
-typedef const gchar * (* GetAppletIdFromIidFunc) (const gchar *iid);
-
-/**
- * GpAppletVTable:
- * @get_applet_info: (transfer full): returns a #GpAppletInfo.
- *
- * The #GpAppletVTable provides the functions required by the #GpModule.
- */
-typedef struct _GpAppletVTable GpAppletVTable;
-struct _GpAppletVTable
-{
- GpAppletInfo * (* get_applet_info) (const gchar *applet);
-};
+typedef const gchar * (* GetAppletIdFromIidFunc) (const gchar *iid);
#define GP_TYPE_MODULE (gp_module_get_type ())
G_DECLARE_FINAL_TYPE (GpModule, gp_module, GP, MODULE, GObject)
-void gp_module_set_abi_version (GpModule *module,
- guint32 abi_version);
+void gp_module_set_abi_version (GpModule *module,
+ guint32 abi_version);
+
+void gp_module_set_gettext_domain (GpModule *module,
+ const gchar *gettext_domain);
-void gp_module_set_gettext_domain (GpModule *module,
- const gchar *gettext_domain);
+void gp_module_set_id (GpModule *module,
+ const gchar *id);
-void gp_module_set_id (GpModule *module,
- const gchar *id);
+void gp_module_set_version (GpModule *module,
+ const gchar *version);
-void gp_module_set_version (GpModule *module,
- const gchar *version);
+void gp_module_set_applet_ids (GpModule *module,
+ ...);
-void gp_module_set_applet_ids (GpModule *module,
- ...);
+void gp_module_set_get_applet_info (GpModule *module,
+ GpGetAppletInfoFunc func);
-void gp_module_set_compatibility (GpModule *module,
- GetAppletIdFromIidFunc func);
+void gp_module_set_compatibility (GpModule *module,
+ GetAppletIdFromIidFunc func);
/**
* gp_module_load:
@@ -84,15 +83,7 @@ void gp_module_set_compatibility (GpModule *module,
* used to setup all required module info. As minimum gp_module_set_id() and
* gp_module_set_abi_version() should be called.
*/
-void gp_module_load (GpModule *module);
-
-/**
- * gp_module_get_applet_vtable:
- * @vtable: (out caller-allocates): return location for the #GpAppletVTable
- *
- * Required API for GNOME Panel modules to implement.
- */
-void gp_module_get_applet_vtable (GpAppletVTable *vtable);
+void gp_module_load (GpModule *module);
G_END_DECLS
diff --git a/modules/clock/clock-module.c b/modules/clock/clock-module.c
index e25c386..e5f81f5 100644
--- a/modules/clock/clock-module.c
+++ b/modules/clock/clock-module.c
@@ -23,7 +23,7 @@
#include "clock-applet.h"
static GpAppletInfo *
-clock_get_applet_info (const gchar *applet)
+clock_get_applet_info (const gchar *id)
{
const gchar *name;
const gchar *description;
@@ -66,13 +66,6 @@ gp_module_load (GpModule *module)
gp_module_set_applet_ids (module, "clock", NULL);
+ gp_module_set_get_applet_info (module, clock_get_applet_info);
gp_module_set_compatibility (module, clock_get_applet_id_from_iid);
}
-
-void
-gp_module_get_applet_vtable (GpAppletVTable *vtable)
-{
- *vtable = (GpAppletVTable) {
- clock_get_applet_info
- };
-}
diff --git a/modules/fish/fish-module.c b/modules/fish/fish-module.c
index 6d02700..253576e 100644
--- a/modules/fish/fish-module.c
+++ b/modules/fish/fish-module.c
@@ -23,7 +23,7 @@
#include "fish-applet.h"
static GpAppletInfo *
-fish_get_applet_info (const gchar *applet)
+fish_get_applet_info (const gchar *id)
{
const gchar *name;
const gchar *description;
@@ -66,13 +66,6 @@ gp_module_load (GpModule *module)
gp_module_set_applet_ids (module, "fish", NULL);
+ gp_module_set_get_applet_info (module, fish_get_applet_info);
gp_module_set_compatibility (module, fish_get_applet_id_from_iid);
}
-
-void
-gp_module_get_applet_vtable (GpAppletVTable *vtable)
-{
- *vtable = (GpAppletVTable) {
- fish_get_applet_info
- };
-}
diff --git a/modules/notification-area/na-module.c b/modules/notification-area/na-module.c
index 5622bcf..b15974f 100644
--- a/modules/notification-area/na-module.c
+++ b/modules/notification-area/na-module.c
@@ -23,7 +23,7 @@
#include "na-applet.h"
static GpAppletInfo *
-na_get_applet_info (const gchar *applet)
+na_get_applet_info (const gchar *id)
{
const gchar *name;
const gchar *description;
@@ -65,13 +65,6 @@ gp_module_load (GpModule *module)
gp_module_set_applet_ids (module, "notification-area", NULL);
+ gp_module_set_get_applet_info (module, na_get_applet_info);
gp_module_set_compatibility (module, na_get_applet_id_from_iid);
}
-
-void
-gp_module_get_applet_vtable (GpAppletVTable *vtable)
-{
- *vtable = (GpAppletVTable) {
- na_get_applet_info
- };
-}
diff --git a/modules/separator/separator-module.c b/modules/separator/separator-module.c
index dfc6360..9c6275e 100644
--- a/modules/separator/separator-module.c
+++ b/modules/separator/separator-module.c
@@ -23,7 +23,7 @@
#include "separator-applet.h"
static GpAppletInfo *
-separator_get_applet_info (const gchar *applet)
+separator_get_applet_info (const gchar *id)
{
const gchar *name;
const gchar *description;
@@ -63,13 +63,6 @@ gp_module_load (GpModule *module)
gp_module_set_applet_ids (module, "separator", NULL);
+ gp_module_set_get_applet_info (module, separator_get_applet_info);
gp_module_set_compatibility (module, separator_get_applet_id_from_iid);
}
-
-void
-gp_module_get_applet_vtable (GpAppletVTable *vtable)
-{
- *vtable = (GpAppletVTable) {
- separator_get_applet_info
- };
-}
diff --git a/modules/status-notifier/sn-module.c b/modules/status-notifier/sn-module.c
index 673db22..5d1789b 100644
--- a/modules/status-notifier/sn-module.c
+++ b/modules/status-notifier/sn-module.c
@@ -23,7 +23,7 @@
#include "sn-applet.h"
static GpAppletInfo *
-sn_get_applet_info (const gchar *applet)
+sn_get_applet_info (const gchar *id)
{
const gchar *name;
const gchar *description;
@@ -62,13 +62,6 @@ gp_module_load (GpModule *module)
gp_module_set_applet_ids (module, "status-notifier", NULL);
+ gp_module_set_get_applet_info (module, sn_get_applet_info);
gp_module_set_compatibility (module, sn_get_applet_id_from_iid);
}
-
-void
-gp_module_get_applet_vtable (GpAppletVTable *vtable)
-{
- *vtable = (GpAppletVTable) {
- sn_get_applet_info
- };
-}
diff --git a/modules/wncklet/wncklet-module.c b/modules/wncklet/wncklet-module.c
index 880c52b..559069b 100644
--- a/modules/wncklet/wncklet-module.c
+++ b/modules/wncklet/wncklet-module.c
@@ -27,7 +27,7 @@
#include "workspace-switcher.h"
static GpAppletInfo *
-wncklet_get_applet_info (const gchar *applet)
+wncklet_get_applet_info (const gchar *id)
{
GpGetAppletTypeFunc type_func;
const gchar *name;
@@ -35,28 +35,28 @@ wncklet_get_applet_info (const gchar *applet)
const gchar *icon;
GpAppletInfo *info;
- if (g_strcmp0 (applet, "show-desktop") == 0)
+ if (g_strcmp0 (id, "show-desktop") == 0)
{
type_func = show_desktop_applet_get_type;
name = _("Show Desktop");
description = _("Hide application windows and show the desktop");
icon = "user-desktop";
}
- else if (g_strcmp0 (applet, "window-list") == 0)
+ else if (g_strcmp0 (id, "window-list") == 0)
{
type_func = window_list_applet_get_type;
name = _("Window List");
description = _("Switch between open windows using buttons");
icon = "gnome-panel-window-list";
}
- else if (g_strcmp0 (applet, "window-menu") == 0)
+ else if (g_strcmp0 (id, "window-menu") == 0)
{
type_func = window_menu_applet_get_type;
name = _("Window Selector");
description = _("Switch between open windows using a menu");
icon = "gnome-panel-window-menu";
}
- else if (g_strcmp0 (applet, "workspace-switcher") == 0)
+ else if (g_strcmp0 (id, "workspace-switcher") == 0)
{
type_func = workspace_switcher_applet_get_type;
name = _("Workspace Switcher");
@@ -113,13 +113,6 @@ gp_module_load (GpModule *module)
"window-menu", "workspace-switcher",
NULL);
+ gp_module_set_get_applet_info (module, wncklet_get_applet_info);
gp_module_set_compatibility (module, wncklet_get_applet_id_from_iid);
}
-
-void
-gp_module_get_applet_vtable (GpAppletVTable *vtable)
-{
- *vtable = (GpAppletVTable) {
- wncklet_get_applet_info
- };
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]