[gnome-panel] panel-applets-manager: add open_initial_setup_dialog
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] panel-applets-manager: add open_initial_setup_dialog
- Date: Sat, 15 Sep 2018 20:43:12 +0000 (UTC)
commit 30968bbae8c559f8a99d7913ce7c4bd270697268
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sat Sep 15 22:16:08 2018 +0300
panel-applets-manager: add open_initial_setup_dialog
.../libpanel-applet-private/gp-applet-manager.c | 59 ++++++++++++++++++++++
.../panel-applets-manager-dbus.c | 12 +++++
gnome-panel/panel-applets-manager.c | 36 +++++++++++++
gnome-panel/panel-applets-manager.h | 14 +++++
4 files changed, 121 insertions(+)
---
diff --git a/gnome-panel/libpanel-applet-private/gp-applet-manager.c
b/gnome-panel/libpanel-applet-private/gp-applet-manager.c
index 6e12c0b93..ab7578086 100644
--- a/gnome-panel/libpanel-applet-private/gp-applet-manager.c
+++ b/gnome-panel/libpanel-applet-private/gp-applet-manager.c
@@ -22,6 +22,7 @@
#include "gp-applet-frame.h"
#include "gp-applet-manager.h"
#include "libgnome-panel/gp-applet-info-private.h"
+#include "libgnome-panel/gp-initial-setup-dialog-private.h"
#include "libgnome-panel/gp-module-private.h"
struct _GpAppletManager
@@ -351,6 +352,63 @@ 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,
+ GtkWindow *parent,
+ GpInitialSetupCallback callback,
+ gpointer user_data,
+ GDestroyNotify free_func)
+{
+ GpAppletManager *applet_manager;
+ const gchar *applet_id;
+ gchar *module_id;
+ GpModule *module;
+ GpAppletInfo *info;
+ GpInitialSetupDialog *dialog;
+
+ 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);
+ g_free (module_id);
+
+ if (!module)
+ return FALSE;
+
+ applet_id += 2;
+ info = gp_module_get_applet_info (module, applet_id, NULL);
+
+ if (!info || !info->initial_setup_dialog_func)
+ return FALSE;
+
+ dialog = gp_initital_setup_dialog_new ();
+ gp_initital_setup_dialog_add_callback (dialog, callback, user_data, free_func);
+
+ info->initial_setup_dialog_func (dialog);
+
+ if (parent)
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
+ }
+ else
+ {
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
+ }
+
+
+ gtk_widget_show (GTK_WIDGET (dialog));
+
+ return TRUE;
+}
+
static void
gp_applet_manager_class_init (GpAppletManagerClass *manager_class)
{
@@ -369,6 +427,7 @@ gp_applet_manager_class_init (GpAppletManagerClass *manager_class)
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;
+ applets_manager_class->open_initial_setup_dialog = gp_applet_manager_open_initial_setup_dialog;
}
static void
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 81cbb5616..55c8b12c6 100644
--- a/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c
+++ b/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c
@@ -543,6 +543,17 @@ panel_applets_manager_dbus_get_new_iid (PanelAppletsManager *manager,
return NULL;
}
+static gboolean
+panel_applets_manager_dbus_open_initial_setup_dialog (PanelAppletsManager *manager,
+ const gchar *iid,
+ GtkWindow *parent,
+ GpInitialSetupCallback callback,
+ gpointer user_data,
+ GDestroyNotify free_func)
+{
+ return FALSE;
+}
+
static void
panel_applets_manager_dbus_finalize (GObject *object)
{
@@ -589,4 +600,5 @@ panel_applets_manager_dbus_class_init (PanelAppletsManagerDBusClass *class)
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;
+ manager_class->open_initial_setup_dialog = panel_applets_manager_dbus_open_initial_setup_dialog;
}
diff --git a/gnome-panel/panel-applets-manager.c b/gnome-panel/panel-applets-manager.c
index 9b00f2766..1ce6da96a 100644
--- a/gnome-panel/panel-applets-manager.c
+++ b/gnome-panel/panel-applets-manager.c
@@ -201,3 +201,39 @@ panel_applets_manager_get_new_iid (const gchar *old_iid)
return NULL;
}
+
+gboolean
+panel_applets_manager_open_initial_setup_dialog (const gchar *iid,
+ GtkWindow *parent,
+ GpInitialSetupCallback callback,
+ gpointer user_data,
+ GDestroyNotify free_func)
+{
+ GSList *l;
+ gboolean ret;
+
+ _panel_applets_managers_ensure_loaded ();
+
+ ret = FALSE;
+ for (l = panel_applets_managers; l != NULL; l = l->next) {
+ PanelAppletsManager *manager = PANEL_APPLETS_MANAGER (l->data);
+
+ if (!PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_applet_info (manager, iid))
+ continue;
+
+ ret = PANEL_APPLETS_MANAGER_GET_CLASS (manager)->open_initial_setup_dialog (manager,
+ iid,
+ parent,
+ callback,
+ user_data,
+ free_func);
+
+ if (ret)
+ break;
+ }
+
+ if (!ret && user_data != NULL && free_func != NULL)
+ free_func (user_data);
+
+ return ret;
+}
diff --git a/gnome-panel/panel-applets-manager.h b/gnome-panel/panel-applets-manager.h
index fb69d4768..bfebcc023 100644
--- a/gnome-panel/panel-applets-manager.h
+++ b/gnome-panel/panel-applets-manager.h
@@ -23,6 +23,7 @@
#include <glib-object.h>
+#include "libgnome-panel/gp-initial-setup-dialog-private.h"
#include "panel-applet-frame.h"
#include "panel-applet-info.h"
@@ -63,6 +64,13 @@ struct _PanelAppletsManagerClass {
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);
};
struct _PanelAppletsManager {
@@ -86,6 +94,12 @@ GtkWidget *panel_applets_manager_get_applet_widget (const gchar
gchar *panel_applets_manager_get_new_iid (const gchar *old_iid);
+gboolean panel_applets_manager_open_initial_setup_dialog (const gchar *iid,
+ GtkWindow *parent,
+ GpInitialSetupCallback callback,
+ gpointer user_data,
+ GDestroyNotify free_func);
+
G_END_DECLS
#endif /* __PANEL_APPLETS_MANAGER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]