2016-09-02 19:12:16 +02:00
|
|
|
From 8469e4ac57f3b5d3efbf533ba23512612997ffff Mon Sep 17 00:00:00 2001
|
2014-06-13 21:25:58 +02:00
|
|
|
From: Felix Zhang <fezhang@suse.com>
|
2016-09-02 19:12:16 +02:00
|
|
|
Date: Fri, 2 Sep 2016 14:55:12 +0800
|
2014-06-13 21:25:58 +02:00
|
|
|
Subject: [PATCH] allow extra tools in shell
|
|
|
|
|
|
|
|
---
|
2016-09-02 19:12:16 +02:00
|
|
|
shell/cc-panel-loader.c | 28 ++++++++++++++++++++++++++--
|
|
|
|
shell/cc-window.c | 41 +++++++++++++++++++++++++++++++++++++++++
|
|
|
|
2 files changed, 67 insertions(+), 2 deletions(-)
|
2014-06-13 21:25:58 +02:00
|
|
|
|
2016-09-02 19:12:16 +02:00
|
|
|
diff --git a/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
|
|
|
|
index de9c5df..e24fc6e 100644
|
|
|
|
--- a/shell/cc-panel-loader.c
|
|
|
|
+++ b/shell/cc-panel-loader.c
|
|
|
|
@@ -102,6 +102,12 @@ static struct {
|
2014-06-13 21:25:58 +02:00
|
|
|
#ifdef BUILD_WACOM
|
2016-09-02 19:12:16 +02:00
|
|
|
PANEL_TYPE("wacom", cc_wacom_panel_get_type ),
|
2014-06-13 21:25:58 +02:00
|
|
|
#endif
|
2016-09-02 19:12:16 +02:00
|
|
|
+ PANEL_TYPE("ca.desrt.dconf-editor", NULL ),
|
|
|
|
+ PANEL_TYPE("gnome-tweak-tool", NULL ),
|
|
|
|
+ PANEL_TYPE("gpk-prefs", NULL ),
|
|
|
|
+ PANEL_TYPE("itweb-settings", NULL ),
|
|
|
|
+ PANEL_TYPE("tracker-preferences", NULL ),
|
|
|
|
+ PANEL_TYPE("YaST", NULL ),
|
2014-06-13 21:25:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
GList *
|
2016-09-02 19:12:16 +02:00
|
|
|
@@ -133,7 +139,8 @@ parse_categories (GDesktopAppInfo *app)
|
|
|
|
{
|
|
|
|
if (strcmp (split[i], "HardwareSettings") == 0)
|
|
|
|
retval = CC_CATEGORY_HARDWARE;
|
|
|
|
- else if (strcmp (split[i], "X-GNOME-PersonalSettings") == 0)
|
|
|
|
+ else if ((strcmp (split[i], "X-GNOME-PersonalSettings") == 0)
|
|
|
|
+ || (strcmp (split[i], "X-GNOME-DesktopSettings") == 0))
|
|
|
|
retval = CC_CATEGORY_PERSONAL;
|
|
|
|
else if (strcmp (split[i], "X-GNOME-SystemSettings") == 0)
|
|
|
|
retval = CC_CATEGORY_SYSTEM;
|
|
|
|
@@ -158,17 +165,33 @@ cc_panel_loader_fill_model (CcShellModel *model)
|
2014-08-07 18:55:15 +02:00
|
|
|
{
|
|
|
|
GDesktopAppInfo *app;
|
2014-06-13 21:25:58 +02:00
|
|
|
char *desktop_name;
|
2014-08-07 18:55:15 +02:00
|
|
|
+ char *name;
|
2014-06-13 21:25:58 +02:00
|
|
|
int category;
|
|
|
|
|
2014-08-07 18:55:15 +02:00
|
|
|
+#ifndef CC_PANEL_LOADER_NO_GTYPES
|
2016-09-02 19:12:16 +02:00
|
|
|
+ if (all_panels[i].get_type == NULL)
|
|
|
|
+ {
|
|
|
|
+ desktop_name = g_strconcat (all_panels[i].name,
|
|
|
|
+ ".desktop", NULL);
|
|
|
|
+ name = g_strconcat ("suse-",all_panels[i].name, NULL);
|
2014-08-23 13:52:28 +02:00
|
|
|
+ }
|
2014-06-13 21:25:58 +02:00
|
|
|
+ else
|
2014-08-07 18:55:15 +02:00
|
|
|
+#endif
|
|
|
|
+ {
|
|
|
|
desktop_name = g_strconcat ("gnome-", all_panels[i].name,
|
|
|
|
"-panel.desktop", NULL);
|
2014-10-12 13:20:39 +02:00
|
|
|
+ name = g_strconcat (all_panels[i].name, NULL);
|
2014-08-07 18:55:15 +02:00
|
|
|
+ }
|
2014-06-13 21:25:58 +02:00
|
|
|
app = g_desktop_app_info_new (desktop_name);
|
|
|
|
g_free (desktop_name);
|
|
|
|
|
2016-09-02 19:12:16 +02:00
|
|
|
if (app == NULL)
|
|
|
|
{
|
|
|
|
+ if (!g_str_has_prefix(name, "suse-"))
|
|
|
|
+ {
|
|
|
|
g_warning ("Ignoring broken panel %s (missing desktop file)",
|
|
|
|
all_panels[i].name);
|
|
|
|
+ }
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -176,7 +199,8 @@ cc_panel_loader_fill_model (CcShellModel *model)
|
2014-08-07 18:55:15 +02:00
|
|
|
if (G_UNLIKELY (category < 0))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
- cc_shell_model_add_item (model, category, G_APP_INFO (app), all_panels[i].name);
|
|
|
|
+ cc_shell_model_add_item (model, category, G_APP_INFO (app), name);
|
2016-09-02 19:12:16 +02:00
|
|
|
+ g_free (name);
|
2014-08-07 18:55:15 +02:00
|
|
|
g_object_unref (app);
|
|
|
|
}
|
|
|
|
}
|
2016-09-02 19:12:16 +02:00
|
|
|
diff --git a/shell/cc-window.c b/shell/cc-window.c
|
|
|
|
index 7c85f5c..d10ba9e 100644
|
|
|
|
--- a/shell/cc-window.c
|
|
|
|
+++ b/shell/cc-window.c
|
2014-08-23 13:52:28 +02:00
|
|
|
@@ -140,6 +140,41 @@ get_icon_name_from_g_icon (GIcon *gicon)
|
2014-06-13 21:25:58 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static void
|
|
|
|
+suse_activate_desktop (const gchar *id)
|
|
|
|
+{
|
|
|
|
+ GDesktopAppInfo *appinfo;
|
|
|
|
+ const gchar *desktop_file;
|
|
|
|
+ GdkScreen *screen;
|
|
|
|
+ GdkDisplay *display;
|
|
|
|
+ GdkAppLaunchContext *context;
|
|
|
|
+ GError *error;
|
|
|
|
+
|
|
|
|
+ desktop_file = g_strconcat ("/usr/share/applications/", id,
|
|
|
|
+ ".desktop", NULL);
|
|
|
|
+ appinfo = g_desktop_app_info_new_from_filename (desktop_file);
|
2014-08-07 18:55:15 +02:00
|
|
|
+ if (appinfo == NULL)
|
|
|
|
+ return;
|
2014-06-13 21:25:58 +02:00
|
|
|
+
|
|
|
|
+ screen = gdk_screen_get_default();
|
|
|
|
+ display = gdk_screen_get_display (screen);
|
|
|
|
+ context = gdk_display_get_app_launch_context (display);
|
|
|
|
+ gdk_app_launch_context_set_screen (context, screen);
|
|
|
|
+ gdk_app_launch_context_set_timestamp (context, gtk_get_current_event_time ());
|
|
|
|
+
|
|
|
|
+ error = NULL;
|
|
|
|
+ g_app_info_launch_uris (G_APP_INFO (appinfo), NULL,
|
|
|
|
+ (GAppLaunchContext *) context,
|
|
|
|
+ &error);
|
|
|
|
+ if (error) {
|
|
|
|
+ g_printerr ("Could not launch '%s': %s\n", id, error->message);
|
|
|
|
+ g_clear_error (&error);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ g_object_unref (context);
|
|
|
|
+ g_object_unref (appinfo);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static gboolean
|
|
|
|
activate_panel (CcWindow *self,
|
|
|
|
const gchar *id,
|
2016-09-02 19:12:16 +02:00
|
|
|
@@ -153,6 +188,12 @@ activate_panel (CcWindow *self,
|
2014-08-07 18:55:15 +02:00
|
|
|
|
2014-06-13 21:25:58 +02:00
|
|
|
if (!id)
|
|
|
|
return FALSE;
|
2014-08-07 18:55:15 +02:00
|
|
|
+ if (g_str_has_prefix(id, "suse-"))
|
2014-06-13 21:25:58 +02:00
|
|
|
+ {
|
2014-08-07 18:55:15 +02:00
|
|
|
+ /* we strip suse- prefix from the id we got to retrieve .desktop on disk */
|
|
|
|
+ suse_activate_desktop (id+strlen("suse-"));
|
2014-06-13 21:25:58 +02:00
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
2014-08-07 18:55:15 +02:00
|
|
|
|
2014-06-13 21:25:58 +02:00
|
|
|
priv->current_panel = GTK_WIDGET (cc_panel_loader_load_by_name (CC_SHELL (self), id, parameters));
|
|
|
|
cc_shell_set_active_panel (CC_SHELL (self), CC_PANEL (priv->current_panel));
|
2016-09-02 19:12:16 +02:00
|
|
|
--
|
|
|
|
2.6.6
|
|
|
|
|