summaryrefslogtreecommitdiff
path: root/gio
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2012-04-05 23:26:12 +0200
committerGiovanni Campagna <gcampagna@src.gnome.org>2012-04-14 02:44:25 +0200
commitbb7f3e0cbd89d0a55630e02dba562303c038a445 (patch)
treef5f74ce211c4e90f4f68d474df4be7b6217f9600 /gio
parent79013634abe3a627d867f7054aaedb453b83d831 (diff)
downloadglib-bb7f3e0cbd89d0a55630e02dba562303c038a445.tar.gz
GDesktopAppInfo: add an accessor for StartupWMClass
Components using GIO to do window to application matching can use that field to retrieve potential candidates. https://bugzilla.gnome.org/show_bug.cgi?id=673659
Diffstat (limited to 'gio')
-rw-r--r--gio/gdesktopappinfo.c26
-rw-r--r--gio/gdesktopappinfo.h2
-rw-r--r--gio/gio.symbols1
-rw-r--r--gio/tests/appinfo-test.desktop2
-rw-r--r--gio/tests/appinfo.c15
5 files changed, 45 insertions, 1 deletions
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index 4afa6dcef..7078dab3e 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -65,6 +65,7 @@
#define GENERIC_NAME_KEY "GenericName"
#define FULL_NAME_KEY "X-GNOME-FullName"
#define KEYWORDS_KEY "Keywords"
+#define STARTUP_WM_CLASS_KEY "StartupWMClass"
enum {
PROP_0,
@@ -106,13 +107,13 @@ struct _GDesktopAppInfo
char *binary;
char *path;
char *categories;
+ char *startup_wm_class;
guint nodisplay : 1;
guint hidden : 1;
guint terminal : 1;
guint startup_notify : 1;
guint no_fuse : 1;
- /* FIXME: what about StartupWMClass ? */
};
typedef enum {
@@ -185,6 +186,7 @@ g_desktop_app_info_finalize (GObject *object)
g_free (info->binary);
g_free (info->path);
g_free (info->categories);
+ g_free (info->startup_wm_class);
G_OBJECT_CLASS (g_desktop_app_info_parent_class)->finalize (object);
}
@@ -330,6 +332,7 @@ g_desktop_app_info_load_from_keyfile (GDesktopAppInfo *info,
info->no_fuse = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, "X-GIO-NoFuse", NULL) != FALSE;
info->hidden = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_HIDDEN, NULL) != FALSE;
info->categories = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_CATEGORIES, NULL);
+ info->startup_wm_class = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, STARTUP_WM_CLASS_KEY, NULL);
info->icon = NULL;
if (info->icon_name)
@@ -3394,3 +3397,24 @@ g_desktop_app_info_lookup_get_default_for_uri_scheme (GDesktopAppInfoLookup *loo
}
G_GNUC_END_IGNORE_DEPRECATIONS
+
+/**
+ * g_desktop_app_info_get_startup_wm_class:
+ * @app_info: a #GDesktopAppInfo that supports startup notify
+ *
+ * Retrieves the StartupWMClass field from @app_info. This represents the
+ * WM_CLASS property of the main window of the application, if launched through
+ * @app_info.
+ *
+ * Returns: (transfer none): the startup WM class, or %NULL if none is set
+ * in the desktop file.
+ *
+ * Since: 2.34
+ */
+const char *
+g_desktop_app_info_get_startup_wm_class (GDesktopAppInfo *app_info)
+{
+ g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (app_info), NULL);
+
+ return app_info->startup_wm_class;
+}
diff --git a/gio/gdesktopappinfo.h b/gio/gdesktopappinfo.h
index fcc41ed84..8cb387190 100644
--- a/gio/gdesktopappinfo.h
+++ b/gio/gdesktopappinfo.h
@@ -56,6 +56,8 @@ const char * const *g_desktop_app_info_get_keywords (GDesktopAppInfo *info);
gboolean g_desktop_app_info_get_nodisplay (GDesktopAppInfo *info);
gboolean g_desktop_app_info_get_show_in (GDesktopAppInfo *info,
const gchar *desktop_env);
+GLIB_AVAILABLE_IN_2_34
+const char * g_desktop_app_info_get_startup_wm_class (GDesktopAppInfo *info);
GDesktopAppInfo *g_desktop_app_info_new (const char *desktop_id);
gboolean g_desktop_app_info_get_is_hidden (GDesktopAppInfo *info);
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 2489a0b8c..d632d49bf 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -106,6 +106,7 @@ g_desktop_app_info_get_is_hidden
g_desktop_app_info_get_keywords
g_desktop_app_info_get_nodisplay
g_desktop_app_info_get_show_in
+g_desktop_app_info_get_startup_wm_class
g_desktop_app_info_get_type
g_desktop_app_info_launch_uris_as_manager
g_desktop_app_info_lookup_get_type
diff --git a/gio/tests/appinfo-test.desktop b/gio/tests/appinfo-test.desktop
index 0a64cfbe2..f2b873afe 100644
--- a/gio/tests/appinfo-test.desktop
+++ b/gio/tests/appinfo-test.desktop
@@ -8,3 +8,5 @@ Comment=GAppInfo example
Comment[de]=GAppInfo Beispiel
Exec=./appinfo-test --option
Icon=testicon
+StartupNotify=true
+StartupWMClass=appinfo-class
diff --git a/gio/tests/appinfo.c b/gio/tests/appinfo.c
index d0a820757..bb24669a6 100644
--- a/gio/tests/appinfo.c
+++ b/gio/tests/appinfo.c
@@ -273,6 +273,20 @@ test_environment (void)
g_object_unref (ctx);
}
+static void
+test_startup_wm_class (void)
+{
+ GDesktopAppInfo *appinfo;
+ const char *wm_class;
+
+ appinfo = g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
+ wm_class = g_desktop_app_info_get_startup_wm_class (appinfo);
+
+ g_assert_cmpstr (wm_class, ==, "appinfo-class");
+
+ g_object_unref (appinfo);
+}
+
int
main (int argc, char *argv[])
{
@@ -288,6 +302,7 @@ main (int argc, char *argv[])
g_test_add_func ("/appinfo/tryexec", test_tryexec);
g_test_add_func ("/appinfo/associations", test_associations);
g_test_add_func ("/appinfo/environment", test_environment);
+ g_test_add_func ("/appinfo/startup-wm-class", test_startup_wm_class);
return g_test_run ();
}