From 2e05f7170a8c7fb0525334815361c72c08d3894a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Wed, 6 Jul 2016 19:56:47 +0200
Subject: [PATCH] app: Add a construct-only app-info property
This will allow us to create a ShellApp from JS code, for instance
for .desktop files that aren't known to the AppSystem.
---
src/shell-app.c | 45 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 41 insertions(+), 4 deletions(-)
diff --git a/src/shell-app.c b/src/shell-app.c
index 1593c89..03369e5 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -96,7 +96,8 @@ enum {
PROP_ID,
PROP_DBUS_ID,
PROP_ACTION_GROUP,
- PROP_MENU
+ PROP_MENU,
+ PROP_APP_INFO
};
enum {
@@ -138,6 +139,29 @@ shell_app_get_property (GObject *gobject,
if (app->running_state)
g_value_set_object (value, app->running_state->remote_menu);
break;
+ case PROP_APP_INFO:
+ if (app->info)
+ g_value_set_object (value, app->info);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+shell_app_set_property (GObject *gobject,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ShellApp *app = SHELL_APP (gobject);
+
+ switch (prop_id)
+ {
+ case PROP_APP_INFO:
+ _shell_app_set_app_info (app, g_value_get_object (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -806,9 +830,9 @@ _shell_app_new (GDesktopAppInfo *info)
{
ShellApp *app;
- app = g_object_new (SHELL_TYPE_APP, NULL);
-
- _shell_app_set_app_info (app, info);
+ app = g_object_new (SHELL_TYPE_APP,
+ "app-info", info,
+ NULL);
return app;
}
@@ -1405,6 +1429,7 @@ shell_app_class_init(ShellAppClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = shell_app_get_property;
+ gobject_class->set_property = shell_app_set_property;
gobject_class->dispose = shell_app_dispose;
gobject_class->finalize = shell_app_finalize;
@@ -1483,5 +1508,17 @@ shell_app_class_init(ShellAppClass *klass)
"The primary menu exported by the remote application",
G_TYPE_MENU_MODEL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ /**
+ * ShellApp:app-info:
+ *
+ * The #GDesktopAppInfo associated with this ShellApp, if any.
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_APP_INFO,
+ g_param_spec_object ("app-info",
+ "DesktopAppInfo",
+ "The DesktopAppInfo associated with this app",
+ G_TYPE_DESKTOP_APP_INFO,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
}
--
2.7.4
From fef6ef9c90cea5f8a9f13651e2fb1deb03013c7f Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 12 Jul 2016 14:16:41 -0400
Subject: [PATCH] fixup! app: Add a construct-only app-info property
---
src/shell-app.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/shell-app.c b/src/shell-app.c
index 36aa47a..9cea064 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -969,61 +969,63 @@ ShellApp *
_shell_app_new_for_window (MetaWindow *window)
{
ShellApp *app;
app = g_object_new (SHELL_TYPE_APP, NULL);
app->window_id_string = g_strdup_printf ("window:%d", meta_window_get_stable_sequence (window));
_shell_app_add_window (app, window);
return app;
}
ShellApp *
_shell_app_new (GDesktopAppInfo *info)
{
ShellApp *app;
app = g_object_new (SHELL_TYPE_APP,
"app-info", info,
NULL);
return app;
}
void
_shell_app_set_app_info (ShellApp *app,
GDesktopAppInfo *info)
{
g_clear_object (&app->info);
- app->info = g_object_ref (info);
+
+ if (info)
+ app->info = g_object_ref (info);
if (app->name_collation_key != NULL)
g_free (app->name_collation_key);
app->name_collation_key = g_utf8_collate_key (shell_app_get_name (app), -1);
}
static void
shell_app_state_transition (ShellApp *app,
ShellAppState state)
{
if (app->state == state)
return;
g_return_if_fail (!(app->state == SHELL_APP_STATE_RUNNING &&
state == SHELL_APP_STATE_STARTING));
app->state = state;
_shell_app_system_notify_app_state_changed (shell_app_system_get_default (), app);
g_object_notify (G_OBJECT (app), "state");
}
static void
shell_app_on_unmanaged (MetaWindow *window,
ShellApp *app)
{
_shell_app_remove_window (app, window);
}
static void
shell_app_on_user_time_changed (MetaWindow *window,
--
2.7.4