[gnome-control-center/gnome-3-2] Add a way for panels to receive additional arguments.
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gnome-3-2] Add a way for panels to receive additional arguments.
- Date: Thu, 8 Sep 2011 16:06:39 +0000 (UTC)
commit de84ef8f6a99217ba9354d6e8fe7a96065dfa6e6
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Mon Aug 22 14:22:37 2011 +0200
Add a way for panels to receive additional arguments.
This patch introduces the "argv" property to CcPanel. Panels that
wish to handle extra arguments shall override it and act
appropriately in the constructor.
https://bugzilla.gnome.org/show_bug.cgi?id=657093
libgnome-control-center/cc-panel.c | 15 +++++++++++++++
libgnome-control-center/cc-shell.c | 3 ++-
libgnome-control-center/cc-shell.h | 2 ++
panels/keyboard/keyboard-general.c | 2 +-
panels/universal-access/cc-ua-panel.c | 6 +++---
shell/control-center.c | 7 ++++++-
shell/gnome-control-center.c | 10 ++++++----
7 files changed, 35 insertions(+), 10 deletions(-)
---
diff --git a/libgnome-control-center/cc-panel.c b/libgnome-control-center/cc-panel.c
index f408f2b..1f1d2b8 100644
--- a/libgnome-control-center/cc-panel.c
+++ b/libgnome-control-center/cc-panel.c
@@ -58,6 +58,7 @@ enum
{
PROP_0,
PROP_SHELL,
+ PROP_ARGV
};
G_DEFINE_ABSTRACT_TYPE (CcPanel, cc_panel, GTK_TYPE_BIN)
@@ -79,6 +80,13 @@ cc_panel_set_property (GObject *object,
panel->priv->shell = g_value_get_object (value);
break;
+ case PROP_ARGV:
+ {
+ gchar **argv = g_value_get_boxed (value);
+ if (argv && argv[0])
+ g_warning ("Ignoring additional argument %s", argv[0]);
+ break;
+ }
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -199,6 +207,13 @@ cc_panel_class_init (CcPanelClass *klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
| G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_SHELL, pspec);
+
+ pspec = g_param_spec_boxed ("argv",
+ "Argument vector",
+ "Additional arguments passed on the command line",
+ G_TYPE_STRV,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ g_object_class_install_property (object_class, PROP_ARGV, pspec);
}
static void
diff --git a/libgnome-control-center/cc-shell.c b/libgnome-control-center/cc-shell.c
index 345b0c5..1145b8b 100644
--- a/libgnome-control-center/cc-shell.c
+++ b/libgnome-control-center/cc-shell.c
@@ -184,6 +184,7 @@ cc_shell_set_active_panel (CcShell *shell,
gboolean
cc_shell_set_active_panel_from_id (CcShell *shell,
const gchar *id,
+ const gchar **argv,
GError **error)
{
CcShellClass *class;
@@ -202,7 +203,7 @@ cc_shell_set_active_panel_from_id (CcShell *shell,
}
else
{
- return class->set_active_panel_from_id (shell, id, error);
+ return class->set_active_panel_from_id (shell, id, argv, error);
}
}
diff --git a/libgnome-control-center/cc-shell.h b/libgnome-control-center/cc-shell.h
index 1778afc..3ab8062 100644
--- a/libgnome-control-center/cc-shell.h
+++ b/libgnome-control-center/cc-shell.h
@@ -86,6 +86,7 @@ struct _CcShellClass
/* vfuncs */
gboolean (*set_active_panel_from_id) (CcShell *shell,
const gchar *id,
+ const gchar **argv,
GError **error);
GtkWidget * (*get_toplevel) (CcShell *shell);
};
@@ -97,6 +98,7 @@ void cc_shell_set_active_panel (CcShell *shell,
CcPanel *panel);
gboolean cc_shell_set_active_panel_from_id (CcShell *shell,
const gchar *id,
+ const gchar **argv,
GError **error);
GtkWidget * cc_shell_get_toplevel (CcShell *shell);
diff --git a/panels/keyboard/keyboard-general.c b/panels/keyboard/keyboard-general.c
index 7f1a00e..26c1db0 100644
--- a/panels/keyboard/keyboard-general.c
+++ b/panels/keyboard/keyboard-general.c
@@ -63,7 +63,7 @@ layout_link_clicked (GtkLinkButton *button,
GError *error = NULL;
shell = cc_panel_get_shell (panel);
- if (cc_shell_set_active_panel_from_id (shell, "region", &error) == FALSE)
+ if (cc_shell_set_active_panel_from_id (shell, "region", NULL, &error) == FALSE)
{
g_warning ("Failed to activate Region panel: %s", error->message);
g_error_free (error);
diff --git a/panels/universal-access/cc-ua-panel.c b/panels/universal-access/cc-ua-panel.c
index c125ba4..16e8eed 100644
--- a/panels/universal-access/cc-ua-panel.c
+++ b/panels/universal-access/cc-ua-panel.c
@@ -587,7 +587,7 @@ hearing_sound_preferences_clicked (GtkButton *button,
CcShell *shell;
shell = cc_panel_get_shell (CC_PANEL (panel));
- cc_shell_set_active_panel_from_id (shell, "sound", NULL);
+ cc_shell_set_active_panel_from_id (shell, "sound", NULL, NULL);
}
static void
@@ -639,7 +639,7 @@ typing_keyboard_preferences_clicked (GtkButton *button,
CcShell *shell;
shell = cc_panel_get_shell (CC_PANEL (panel));
- cc_shell_set_active_panel_from_id (shell, "keyboard", NULL);
+ cc_shell_set_active_panel_from_id (shell, "keyboard", NULL, NULL);
}
static void
@@ -709,7 +709,7 @@ pointing_mouse_preferences_clicked_cb (GtkButton *button,
CcShell *shell;
shell = cc_panel_get_shell (CC_PANEL (panel));
- cc_shell_set_active_panel_from_id (shell, "mouse", NULL);
+ cc_shell_set_active_panel_from_id (shell, "mouse", NULL, NULL);
}
static void
diff --git a/shell/control-center.c b/shell/control-center.c
index 167ebb6..a69eef2 100644
--- a/shell/control-center.c
+++ b/shell/control-center.c
@@ -127,7 +127,12 @@ application_command_line_cb (GApplication *application,
start_id = start_panels[0];
- if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), start_id, &err))
+ if (start_panels[1])
+ g_debug ("Extra argument: %s", start_panels[1]);
+ else
+ g_debug ("No extra argument");
+
+ if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), start_id, (const gchar**)start_panels+1, &err))
{
g_warning ("Could not load setting panel \"%s\": %s", start_id,
(err) ? err->message : "Unknown error");
diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c
index 676e990..200c680 100644
--- a/shell/gnome-control-center.c
+++ b/shell/gnome-control-center.c
@@ -111,6 +111,7 @@ get_icon_name_from_g_icon (GIcon *gicon)
static void
activate_panel (GnomeControlCenter *shell,
const gchar *id,
+ const gchar **argv,
const gchar *desktop_file,
const gchar *name,
GIcon *gicon)
@@ -153,7 +154,7 @@ activate_panel (GnomeControlCenter *shell,
const gchar *icon_name;
/* create the panel plugin */
- panel = g_object_new (panel_type, "shell", shell, NULL);
+ panel = g_object_new (panel_type, "shell", shell, "argv", argv, NULL);
gtk_lock_button_set_permission (GTK_LOCK_BUTTON (priv->lock_button),
cc_panel_get_permission (CC_PANEL (panel)));
@@ -234,7 +235,7 @@ item_activated_cb (CcShellCategoryView *view,
{
GError *err = NULL;
- if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), id, &err))
+ if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), id, NULL, &err))
{
/* TODO: show message to user */
if (err)
@@ -797,6 +798,7 @@ notebook_switch_page_cb (GtkNotebook *book,
static gboolean
_shell_set_active_panel_from_id (CcShell *shell,
const gchar *start_id,
+ const gchar **argv,
GError **err)
{
GtkTreeIter iter;
@@ -852,8 +854,8 @@ _shell_set_active_panel_from_id (CcShell *shell,
{
gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), CAPPLET_PAGE);
- activate_panel (GNOME_CONTROL_CENTER (shell), start_id, desktop, name,
- gicon);
+ activate_panel (GNOME_CONTROL_CENTER (shell), start_id, argv, desktop,
+ name, gicon);
g_free (name);
g_free (desktop);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]