[gnome-panel/wip/muktupavels/remove-panel-applet-private: 3/5] panel-applets-manager: remove abstract PanelAppletsManager class
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/muktupavels/remove-panel-applet-private: 3/5] panel-applets-manager: remove abstract PanelAppletsManager class
- Date: Mon, 13 Apr 2020 20:28:43 +0000 (UTC)
commit d5dc7b0e8740937d7f4566fd8209ab7b3ec42c59
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Apr 13 22:50:50 2020 +0300
panel-applets-manager: remove abstract PanelAppletsManager class
gnome-panel/gp-applet-manager.c | 147 ++++++++++++++----------------------
gnome-panel/gp-applet-manager.h | 35 ++++++++-
gnome-panel/panel-applets-manager.c | 44 ++++-------
gnome-panel/panel-applets-manager.h | 48 ------------
4 files changed, 102 insertions(+), 172 deletions(-)
---
diff --git a/gnome-panel/gp-applet-manager.c b/gnome-panel/gp-applet-manager.c
index 6bb2879e4..d37eb4a07 100644
--- a/gnome-panel/gp-applet-manager.c
+++ b/gnome-panel/gp-applet-manager.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Alberts Muktupāvels
+ * Copyright (C) 2016-2020 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,13 +28,13 @@
struct _GpAppletManager
{
- PanelAppletsManager parent;
+ GObject parent;
- GHashTable *modules;
- GHashTable *infos;
+ GHashTable *modules;
+ GHashTable *infos;
};
-G_DEFINE_TYPE (GpAppletManager, gp_applet_manager, PANEL_TYPE_APPLETS_MANAGER)
+G_DEFINE_TYPE (GpAppletManager, gp_applet_manager, G_TYPE_OBJECT)
static GVariant *
get_initial_settings (PanelAppletFrameActivating *frame_act)
@@ -163,61 +163,68 @@ gp_applet_manager_finalize (GObject *object)
G_OBJECT_CLASS (gp_applet_manager_parent_class)->finalize (object);
}
-static GList *
-gp_applet_manager_get_applets (PanelAppletsManager *manager)
+static void
+gp_applet_manager_class_init (GpAppletManagerClass *manager_class)
{
- GpAppletManager *applet_manager;
+ GObjectClass *object_class;
- applet_manager = GP_APPLET_MANAGER (manager);
+ object_class = G_OBJECT_CLASS (manager_class);
- return g_hash_table_get_values (applet_manager->infos);
+ object_class->finalize = gp_applet_manager_finalize;
}
-static gboolean
-gp_applet_manager_factory_activate (PanelAppletsManager *manager,
- const gchar *iid)
+static void
+gp_applet_manager_init (GpAppletManager *manager)
{
- GpAppletManager *applet_manager;
-
- applet_manager = GP_APPLET_MANAGER (manager);
+ manager->modules = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, g_object_unref);
- if (!g_hash_table_lookup (applet_manager->infos, iid))
- return FALSE;
+ manager->infos = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, applet_info_free);
- return TRUE;
+ load_external_modules (manager);
}
-static gboolean
-gp_applet_manager_factory_deactivate (PanelAppletsManager *manager,
- const gchar *iid)
+GpAppletManager *
+gp_applet_manager_new (void)
{
- GpAppletManager *applet_manager;
+ return g_object_new (GP_TYPE_APPLET_MANAGER, NULL);
+}
- applet_manager = GP_APPLET_MANAGER (manager);
+GList *
+gp_applet_manager_get_applets (GpAppletManager *self)
+{
+ return g_hash_table_get_values (self->infos);
+}
- if (!g_hash_table_lookup (applet_manager->infos, iid))
+gboolean
+gp_applet_manager_factory_activate (GpAppletManager *self,
+ const char *iid)
+{
+ if (!g_hash_table_lookup (self->infos, iid))
return FALSE;
return TRUE;
}
-static PanelAppletInfo *
-gp_applet_manager_get_applet_info (PanelAppletsManager *manager,
- const gchar *iid)
+void
+gp_applet_manager_factory_deactivate (GpAppletManager *self,
+ const char *iid)
{
- GpAppletManager *applet_manager;
-
- applet_manager = GP_APPLET_MANAGER (manager);
+}
- return g_hash_table_lookup (applet_manager->infos, iid);
+PanelAppletInfo *
+gp_applet_manager_get_applet_info (GpAppletManager *self,
+ const char *iid)
+{
+ return g_hash_table_lookup (self->infos, iid);
}
-static gboolean
-gp_applet_manager_load_applet (PanelAppletsManager *manager,
- const gchar *iid,
+gboolean
+gp_applet_manager_load_applet (GpAppletManager *self,
+ const char *iid,
PanelAppletFrameActivating *frame_act)
{
- GpAppletManager *applet_manager;
const gchar *applet_id;
gchar *module_id;
GpModule *module;
@@ -236,14 +243,12 @@ gp_applet_manager_load_applet (PanelAppletsManager *manager,
g_return_val_if_fail (iid != NULL, FALSE);
g_return_val_if_fail (frame_act != NULL, FALSE);
- applet_manager = GP_APPLET_MANAGER (manager);
-
applet_id = g_strrstr (iid, "::");
if (!applet_id)
return FALSE;
module_id = g_strndup (iid, strlen (iid) - strlen (applet_id));
- module = g_hash_table_lookup (applet_manager->modules, module_id);
+ module = g_hash_table_lookup (self->modules, module_id);
g_free (module_id);
if (!module)
@@ -314,18 +319,15 @@ gp_applet_manager_load_applet (PanelAppletsManager *manager,
return TRUE;
}
-static gchar *
-gp_applet_manager_get_new_iid (PanelAppletsManager *manager,
- const gchar *old_iid)
+char *
+gp_applet_manager_get_new_iid (GpAppletManager *self,
+ const char *old_iid)
{
- GpAppletManager *applet_manager;
GList *modules;
GList *l;
gchar *new_iid;
- applet_manager = GP_APPLET_MANAGER (manager);
-
- modules = g_hash_table_get_values (applet_manager->modules);
+ modules = g_hash_table_get_values (self->modules);
new_iid = NULL;
for (l = modules; l != NULL; l = l->next)
@@ -348,15 +350,14 @@ gp_applet_manager_get_new_iid (PanelAppletsManager *manager,
return new_iid;
}
-static gboolean
-gp_applet_manager_open_initial_setup_dialog (PanelAppletsManager *manager,
- const gchar *iid,
+gboolean
+gp_applet_manager_open_initial_setup_dialog (GpAppletManager *self,
+ const char *iid,
GtkWindow *parent,
GpInitialSetupCallback callback,
gpointer user_data,
GDestroyNotify free_func)
{
- GpAppletManager *applet_manager;
const gchar *applet_id;
gchar *module_id;
GpModule *module;
@@ -365,14 +366,12 @@ gp_applet_manager_open_initial_setup_dialog (PanelAppletsManager *manager,
g_return_val_if_fail (iid != NULL, FALSE);
- applet_manager = GP_APPLET_MANAGER (manager);
-
applet_id = g_strrstr (iid, "::");
if (!applet_id)
return FALSE;
module_id = g_strndup (iid, strlen (iid) - strlen (applet_id));
- module = g_hash_table_lookup (applet_manager->modules, module_id);
+ module = g_hash_table_lookup (self->modules, module_id);
g_free (module_id);
if (!module)
@@ -405,10 +404,9 @@ gp_applet_manager_open_initial_setup_dialog (PanelAppletsManager *manager,
return TRUE;
}
-static GtkWidget *
-gp_applet_manager_get_standalone_menu (PanelAppletsManager *manager)
+GtkWidget *
+gp_applet_manager_get_standalone_menu (GpAppletManager *self)
{
- GpAppletManager *applet_manager;
GSettings *general_settings;
gboolean enable_tooltips;
gboolean locked_down;
@@ -417,8 +415,6 @@ gp_applet_manager_get_standalone_menu (PanelAppletsManager *manager)
GList *l;
GtkWidget *menu;
- applet_manager = GP_APPLET_MANAGER (manager);
-
general_settings = g_settings_new ("org.gnome.gnome-panel.general");
enable_tooltips = g_settings_get_boolean (general_settings, "enable-tooltips");
@@ -427,7 +423,7 @@ gp_applet_manager_get_standalone_menu (PanelAppletsManager *manager)
g_object_unref (general_settings);
- modules = g_hash_table_get_values (applet_manager->modules);
+ modules = g_hash_table_get_values (self->modules);
menu = NULL;
for (l = modules; l != NULL; l = l->next)
@@ -447,36 +443,3 @@ gp_applet_manager_get_standalone_menu (PanelAppletsManager *manager)
return menu;
}
-
-static void
-gp_applet_manager_class_init (GpAppletManagerClass *manager_class)
-{
- GObjectClass *object_class;
- PanelAppletsManagerClass *applets_manager_class;
-
- object_class = G_OBJECT_CLASS (manager_class);
- applets_manager_class = PANEL_APPLETS_MANAGER_CLASS (manager_class);
-
- object_class->finalize = gp_applet_manager_finalize;
-
- applets_manager_class->get_applets = gp_applet_manager_get_applets;
- applets_manager_class->factory_activate = gp_applet_manager_factory_activate;
- applets_manager_class->factory_deactivate = gp_applet_manager_factory_deactivate;
- applets_manager_class->get_applet_info = gp_applet_manager_get_applet_info;
- applets_manager_class->load_applet = gp_applet_manager_load_applet;
- applets_manager_class->get_new_iid = gp_applet_manager_get_new_iid;
- applets_manager_class->open_initial_setup_dialog = gp_applet_manager_open_initial_setup_dialog;
- applets_manager_class->get_standalone_menu = gp_applet_manager_get_standalone_menu;
-}
-
-static void
-gp_applet_manager_init (GpAppletManager *manager)
-{
- manager->modules = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, g_object_unref);
-
- manager->infos = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, applet_info_free);
-
- load_external_modules (manager);
-}
diff --git a/gnome-panel/gp-applet-manager.h b/gnome-panel/gp-applet-manager.h
index 5b16d0fff..e57f0ca03 100644
--- a/gnome-panel/gp-applet-manager.h
+++ b/gnome-panel/gp-applet-manager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Alberts Muktupāvels
+ * Copyright (C) 2016-2020 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,13 +18,42 @@
#ifndef GP_APPLET_MANAGER_H
#define GP_APPLET_MANAGER_H
-#include <panel-applets-manager.h>
+#include "panel-applets-manager.h"
G_BEGIN_DECLS
#define GP_TYPE_APPLET_MANAGER gp_applet_manager_get_type ()
G_DECLARE_FINAL_TYPE (GpAppletManager, gp_applet_manager,
- GP, APPLET_MANAGER, PanelAppletsManager)
+ GP, APPLET_MANAGER, GObject)
+
+GpAppletManager *gp_applet_manager_new (void);
+
+GList *gp_applet_manager_get_applets (GpAppletManager *self);
+
+gboolean gp_applet_manager_factory_activate (GpAppletManager *self,
+ const char *iid);
+
+void gp_applet_manager_factory_deactivate (GpAppletManager *self,
+ const char *iid);
+
+PanelAppletInfo *gp_applet_manager_get_applet_info (GpAppletManager *self,
+ const char *iid);
+
+gboolean gp_applet_manager_load_applet (GpAppletManager *self,
+ const char *iid,
+ PanelAppletFrameActivating *frame_act);
+
+char *gp_applet_manager_get_new_iid (GpAppletManager *self,
+ const char *old_iid);
+
+gboolean gp_applet_manager_open_initial_setup_dialog (GpAppletManager *self,
+ const char *iid,
+ GtkWindow *parent,
+ GpInitialSetupCallback callback,
+ gpointer user_data,
+ GDestroyNotify free_func);
+
+GtkWidget *gp_applet_manager_get_standalone_menu (GpAppletManager *self);
G_END_DECLS
diff --git a/gnome-panel/panel-applets-manager.c b/gnome-panel/panel-applets-manager.c
index 3d98ed3bb..99c2610a4 100644
--- a/gnome-panel/panel-applets-manager.c
+++ b/gnome-panel/panel-applets-manager.c
@@ -27,21 +27,7 @@
#include "gp-applet-manager.h"
#include "panel-applets-manager.h"
-G_DEFINE_ABSTRACT_TYPE (PanelAppletsManager, panel_applets_manager, G_TYPE_OBJECT)
-
-static void
-panel_applets_manager_init (PanelAppletsManager *manager)
-{
-}
-
-static void
-panel_applets_manager_class_init (PanelAppletsManagerClass *class)
-{
-}
-
-/* Generic methods */
-
-static PanelAppletsManager *manager = NULL;
+static GpAppletManager *manager = NULL;
static void
_panel_applets_manager_cleanup (gpointer data)
@@ -57,7 +43,7 @@ _panel_applets_managers_ensure_loaded (void)
panel_cleanup_register (PANEL_CLEAN_FUNC (_panel_applets_manager_cleanup), NULL);
- manager = g_object_new (GP_TYPE_APPLET_MANAGER, NULL);
+ manager = gp_applet_manager_new ();
}
GList *
@@ -65,7 +51,7 @@ panel_applets_manager_get_applets (void)
{
_panel_applets_managers_ensure_loaded ();
- return PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_applets (manager);
+ return gp_applet_manager_get_applets (manager);
}
gboolean
@@ -73,7 +59,7 @@ panel_applets_manager_factory_activate (const gchar *iid)
{
_panel_applets_managers_ensure_loaded ();
- return PANEL_APPLETS_MANAGER_GET_CLASS (manager)->factory_activate (manager, iid);
+ return gp_applet_manager_factory_activate (manager, iid);
}
void
@@ -81,7 +67,7 @@ panel_applets_manager_factory_deactivate (const gchar *iid)
{
_panel_applets_managers_ensure_loaded ();
- PANEL_APPLETS_MANAGER_GET_CLASS (manager)->factory_deactivate (manager, iid);
+ gp_applet_manager_factory_deactivate (manager, iid);
}
PanelAppletInfo *
@@ -89,7 +75,7 @@ panel_applets_manager_get_applet_info (const gchar *iid)
{
_panel_applets_managers_ensure_loaded ();
- return PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_applet_info (manager, iid);
+ return gp_applet_manager_get_applet_info (manager, iid);
}
gboolean
@@ -98,7 +84,7 @@ panel_applets_manager_load_applet (const gchar *iid,
{
_panel_applets_managers_ensure_loaded ();
- return PANEL_APPLETS_MANAGER_GET_CLASS (manager)->load_applet (manager, iid, frame_act);
+ return gp_applet_manager_load_applet (manager, iid, frame_act);
}
gchar *
@@ -106,7 +92,7 @@ panel_applets_manager_get_new_iid (const gchar *old_iid)
{
_panel_applets_managers_ensure_loaded ();
- return PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_new_iid (manager, old_iid);
+ return gp_applet_manager_get_new_iid (manager, old_iid);
}
gboolean
@@ -120,12 +106,12 @@ panel_applets_manager_open_initial_setup_dialog (const gchar *iid,
_panel_applets_managers_ensure_loaded ();
- ret = PANEL_APPLETS_MANAGER_GET_CLASS (manager)->open_initial_setup_dialog (manager,
- iid,
- parent,
- callback,
- user_data,
- free_func);
+ ret = gp_applet_manager_open_initial_setup_dialog (manager,
+ iid,
+ parent,
+ callback,
+ user_data,
+ free_func);
if (!ret && user_data != NULL && free_func != NULL)
free_func (user_data);
@@ -138,5 +124,5 @@ panel_applets_manager_get_standalone_menu (void)
{
_panel_applets_managers_ensure_loaded ();
- return PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_standalone_menu (manager);
+ return gp_applet_manager_get_standalone_menu (manager);
}
diff --git a/gnome-panel/panel-applets-manager.h b/gnome-panel/panel-applets-manager.h
index c1cfa037d..a1839d874 100644
--- a/gnome-panel/panel-applets-manager.h
+++ b/gnome-panel/panel-applets-manager.h
@@ -29,54 +29,6 @@
G_BEGIN_DECLS
-#define PANEL_TYPE_APPLETS_MANAGER (panel_applets_manager_get_type ())
-#define PANEL_APPLETS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
PANEL_TYPE_APPLETS_MANAGER, PanelAppletsManager))
-#define PANEL_APPLETS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
PANEL_TYPE_APPLETS_MANAGER, PanelAppletsManagerClass))
-#define PANEL_IS_APPLETS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
PANEL_TYPE_APPLETS_MANAGER))
-#define PANEL_IS_APPLETS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
PANEL_TYPE_APPLETS_MANAGER))
-#define PANEL_APPLETS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PANEL_TYPE_APPLETS_MANAGER,
PanelAppletsManagerClass))
-
-typedef struct _PanelAppletsManager PanelAppletsManager;
-typedef struct _PanelAppletsManagerClass PanelAppletsManagerClass;
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (PanelAppletsManager, g_object_unref)
-
-struct _PanelAppletsManagerClass {
- GObjectClass parent_class;
-
- GList * (*get_applets) (PanelAppletsManager *manager);
-
- gboolean (*factory_activate) (PanelAppletsManager *manager,
- const gchar *iid);
- gboolean (*factory_deactivate) (PanelAppletsManager *manager,
- const gchar *iid);
-
- PanelAppletInfo * (*get_applet_info) (PanelAppletsManager *manager,
- const gchar *iid);
-
- gboolean (*load_applet) (PanelAppletsManager *manager,
- const gchar *iid,
- PanelAppletFrameActivating *frame_act);
-
- gchar * (*get_new_iid) (PanelAppletsManager *manager,
- const gchar *old_iid);
-
- gboolean (*open_initial_setup_dialog) (PanelAppletsManager *manager,
- const gchar *iid,
- GtkWindow *parent,
- GpInitialSetupCallback callback,
- gpointer user_data,
- GDestroyNotify free_func);
-
- GtkWidget * (*get_standalone_menu) (PanelAppletsManager *manager);
-};
-
-struct _PanelAppletsManager {
- GObject parent;
-};
-
-GType panel_applets_manager_get_type (void);
-
GList *panel_applets_manager_get_applets (void);
gboolean panel_applets_manager_factory_activate (const gchar *iid);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]