[gnome-panel] panel-applet-frame: add compatibility code
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] panel-applet-frame: add compatibility code
- Date: Thu, 1 Dec 2016 13:17:26 +0000 (UTC)
commit 926a84bf7d14361af6dff20b927b42ea9259c3db
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Dec 1 15:12:31 2016 +0200
panel-applet-frame: add compatibility code
.../libpanel-applet-private/gp-applet-manager.c | 35 ++++++++++++++++++++
.../libpanel-applet-private/gp-module-private.h | 31 +++++++++--------
gnome-panel/libpanel-applet-private/gp-module.c | 10 ++++++
.../panel-applets-manager-dbus.c | 8 ++++
gnome-panel/panel-applet-frame.c | 13 +++++++
gnome-panel/panel-applets-manager.c | 21 ++++++++++++
gnome-panel/panel-applets-manager.h | 5 +++
7 files changed, 109 insertions(+), 14 deletions(-)
---
diff --git a/gnome-panel/libpanel-applet-private/gp-applet-manager.c
b/gnome-panel/libpanel-applet-private/gp-applet-manager.c
index bd49fa9..52e4bdf 100644
--- a/gnome-panel/libpanel-applet-private/gp-applet-manager.c
+++ b/gnome-panel/libpanel-applet-private/gp-applet-manager.c
@@ -276,6 +276,40 @@ gp_applet_manager_get_applet_widget (PanelAppletsManager *manager,
return NULL;
}
+static gchar *
+gp_applet_manager_get_new_iid (PanelAppletsManager *manager,
+ const gchar *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);
+ new_iid = NULL;
+
+ for (l = modules; l != NULL; l = l->next)
+ {
+ GpModule *module;
+ const gchar *applet;
+
+ module = GP_MODULE (l->data);
+ applet = gp_module_get_applet_from_iid (module, old_iid);
+
+ if (applet != NULL)
+ {
+ new_iid = g_strdup_printf ("%s::%s", gp_module_get_id (module), applet);
+ break;
+ }
+ }
+
+ g_list_free (modules);
+
+ return new_iid;
+}
+
static void
gp_applet_manager_class_init (GpAppletManagerClass *manager_class)
{
@@ -293,6 +327,7 @@ gp_applet_manager_class_init (GpAppletManagerClass *manager_class)
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_applet_widget = gp_applet_manager_get_applet_widget;
+ applets_manager_class->get_new_iid = gp_applet_manager_get_new_iid;
}
static void
diff --git a/gnome-panel/libpanel-applet-private/gp-module-private.h
b/gnome-panel/libpanel-applet-private/gp-module-private.h
index c6ede2c..aff2377 100644
--- a/gnome-panel/libpanel-applet-private/gp-module-private.h
+++ b/gnome-panel/libpanel-applet-private/gp-module-private.h
@@ -36,25 +36,28 @@ typedef enum
#define GP_MODULE_ERROR gp_module_error_quark ()
GQuark gp_module_error_quark (void);
-GpModule *gp_module_new_from_path (const gchar *path);
+GpModule *gp_module_new_from_path (const gchar *path);
-GpModule *gp_module_new_from_vtable (const GpModuleVTable *vtable);
+GpModule *gp_module_new_from_vtable (const GpModuleVTable *vtable);
-const gchar *gp_module_get_id (GpModule *module);
+const gchar *gp_module_get_id (GpModule *module);
-const gchar * const *gp_module_get_applets (GpModule *module);
+const gchar * const *gp_module_get_applets (GpModule *module);
-GpAppletInfo *gp_module_get_applet_info (GpModule *module,
- const gchar *applet,
- GError **error);
+GpAppletInfo *gp_module_get_applet_info (GpModule *module,
+ const gchar *applet,
+ GError **error);
-GpApplet *gp_module_applet_new (GpModule *module,
- const gchar *applet,
- const gchar *settings_path,
- gboolean locked_down,
- GtkOrientation orientation,
- GtkPositionType position,
- GError **error);
+const gchar *gp_module_get_applet_from_iid (GpModule *module,
+ const gchar *old_iid);
+
+GpApplet *gp_module_applet_new (GpModule *module,
+ const gchar *applet,
+ const gchar *settings_path,
+ gboolean locked_down,
+ GtkOrientation orientation,
+ GtkPositionType position,
+ GError **error);
G_END_DECLS
diff --git a/gnome-panel/libpanel-applet-private/gp-module.c b/gnome-panel/libpanel-applet-private/gp-module.c
index 619fea5..4268d9b 100644
--- a/gnome-panel/libpanel-applet-private/gp-module.c
+++ b/gnome-panel/libpanel-applet-private/gp-module.c
@@ -380,6 +380,16 @@ gp_module_get_applet_info (GpModule *module,
return get_applet_info (module, applet, error);
}
+const gchar *
+gp_module_get_applet_from_iid (GpModule *module,
+ const gchar *old_iid)
+{
+ if (module->vtable.get_applet_from_iid == NULL)
+ return NULL;
+
+ return module->vtable.get_applet_from_iid (old_iid);
+}
+
/**
* gp_module_applet_new:
* @module: a #GpModule
diff --git a/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c
b/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c
index 3b3f5dc..f18d4ac 100644
--- a/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c
+++ b/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c
@@ -540,6 +540,13 @@ panel_applets_manager_dbus_get_applet_widget (PanelAppletsManager *manager,
return info->get_applet_widget (info->id, uid);
}
+static gchar *
+panel_applets_manager_dbus_get_new_iid (PanelAppletsManager *manager,
+ const gchar *old_iid)
+{
+ return NULL;
+}
+
static void
panel_applets_manager_dbus_finalize (GObject *object)
{
@@ -588,6 +595,7 @@ panel_applets_manager_dbus_class_init (PanelAppletsManagerDBusClass *class)
manager_class->get_applet_info = panel_applets_manager_dbus_get_applet_info;
manager_class->load_applet = panel_applets_manager_dbus_load_applet;
manager_class->get_applet_widget = panel_applets_manager_dbus_get_applet_widget;
+ manager_class->get_new_iid = panel_applets_manager_dbus_get_new_iid;
g_type_class_add_private (class, sizeof (PanelAppletsManagerDBusPrivate));
}
diff --git a/gnome-panel/panel-applet-frame.c b/gnome-panel/panel-applet-frame.c
index edac10e..b25be67 100644
--- a/gnome-panel/panel-applet-frame.c
+++ b/gnome-panel/panel-applet-frame.c
@@ -849,6 +849,19 @@ panel_applet_frame_load (PanelWidget *panel_widget,
applet_iid = g_settings_get_string (settings, PANEL_OBJECT_IID_KEY);
+ if (!panel_applets_manager_get_applet_info (applet_iid)) {
+ gchar *new_iid;
+
+ new_iid = panel_applets_manager_get_new_iid (applet_iid);
+
+ if (new_iid != NULL) {
+ g_settings_set_string (settings, PANEL_OBJECT_IID_KEY, new_iid);
+ g_free (applet_iid);
+
+ applet_iid = new_iid;
+ }
+ }
+
panel_applet_frame_load_helper (applet_iid, panel_widget, id, settings);
g_free (applet_iid);
}
diff --git a/gnome-panel/panel-applets-manager.c b/gnome-panel/panel-applets-manager.c
index 042fdd9..9b00f27 100644
--- a/gnome-panel/panel-applets-manager.c
+++ b/gnome-panel/panel-applets-manager.c
@@ -180,3 +180,24 @@ panel_applets_manager_get_applet_widget (const gchar *iid,
return NULL;
}
+
+gchar *
+panel_applets_manager_get_new_iid (const gchar *old_iid)
+{
+ GSList *l;
+ PanelAppletsManager *manager;
+ gchar *new_iid;
+
+ _panel_applets_managers_ensure_loaded ();
+
+ for (l = panel_applets_managers; l != NULL; l = l->next) {
+ manager = PANEL_APPLETS_MANAGER (l->data);
+
+ new_iid = PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_new_iid (manager, old_iid);
+
+ if (new_iid != NULL)
+ return new_iid;
+ }
+
+ return NULL;
+}
diff --git a/gnome-panel/panel-applets-manager.h b/gnome-panel/panel-applets-manager.h
index 1cb1548..fb69d47 100644
--- a/gnome-panel/panel-applets-manager.h
+++ b/gnome-panel/panel-applets-manager.h
@@ -60,6 +60,9 @@ struct _PanelAppletsManagerClass {
GtkWidget * (*get_applet_widget) (PanelAppletsManager *manager,
const gchar *iid,
guint uid);
+
+ gchar * (*get_new_iid) (PanelAppletsManager *manager,
+ const gchar *old_iid);
};
struct _PanelAppletsManager {
@@ -81,6 +84,8 @@ gboolean panel_applets_manager_load_applet (const gchar
GtkWidget *panel_applets_manager_get_applet_widget (const gchar *iid,
guint uid);
+gchar *panel_applets_manager_get_new_iid (const gchar *old_iid);
+
G_END_DECLS
#endif /* __PANEL_APPLETS_MANAGER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]