summaryrefslogtreecommitdiff
path: root/mate-panel/libpanel-util
diff options
context:
space:
mode:
authorDenis Gorodnichev <[email protected]>2017-01-02 23:29:52 +0300
committerlukefromdc <[email protected]>2017-01-13 19:12:06 -0500
commit7ee450758e4f2bee13aa8ff967a5795a6dcdc91f (patch)
tree9352174371cbb4c5af49342f4797e4a8514a751c /mate-panel/libpanel-util
parenta27e6eaffa7e3bf72381b63dc9cfecc06125fce2 (diff)
downloadmate-panel-7ee450758e4f2bee13aa8ff967a5795a6dcdc91f.tar.bz2
mate-panel-7ee450758e4f2bee13aa8ff967a5795a6dcdc91f.tar.xz
support desktop actions
Diffstat (limited to 'mate-panel/libpanel-util')
-rw-r--r--mate-panel/libpanel-util/panel-launch.c37
-rw-r--r--mate-panel/libpanel-util/panel-launch.h10
-rw-r--r--mate-panel/libpanel-util/panel-show.c20
3 files changed, 38 insertions, 29 deletions
diff --git a/mate-panel/libpanel-util/panel-launch.c b/mate-panel/libpanel-util/panel-launch.c
index 59ca900a..0f4d7033 100644
--- a/mate-panel/libpanel-util/panel-launch.c
+++ b/mate-panel/libpanel-util/panel-launch.c
@@ -95,9 +95,10 @@ gather_pid_callback (GDesktopAppInfo *gapp,
}
gboolean
-panel_app_info_launch_uris (GAppInfo *appinfo,
+panel_app_info_launch_uris (GDesktopAppInfo *appinfo,
GList *uris,
GdkScreen *screen,
+ const gchar *action,
guint32 timestamp,
GError **error)
{
@@ -115,23 +116,28 @@ panel_app_info_launch_uris (GAppInfo *appinfo,
gdk_app_launch_context_set_timestamp (context, timestamp);
local_error = NULL;
- retval = g_desktop_app_info_launch_uris_as_manager ((GDesktopAppInfo*)appinfo, uris,
- (GAppLaunchContext *) context,
+ if (action == NULL) {
+ retval = g_desktop_app_info_launch_uris_as_manager (appinfo, uris,
+ G_APP_LAUNCH_CONTEXT (context),
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
NULL, NULL, gather_pid_callback, appinfo,
&local_error);
+ } else {
+ g_desktop_app_info_launch_action (appinfo, action, G_APP_LAUNCH_CONTEXT (context));
+ retval = TRUE;
+ }
g_object_unref (context);
if ((local_error == NULL) && (retval == TRUE))
return TRUE;
- return _panel_launch_handle_error (g_app_info_get_name ((GAppInfo*) appinfo),
+ return _panel_launch_handle_error (g_app_info_get_name (G_APP_INFO(appinfo)),
screen, local_error, error);
}
gboolean
-panel_app_info_launch_uri (GAppInfo *appinfo,
+panel_app_info_launch_uri (GDesktopAppInfo *appinfo,
const gchar *uri,
GdkScreen *screen,
guint32 timestamp,
@@ -149,7 +155,7 @@ panel_app_info_launch_uri (GAppInfo *appinfo,
uris = g_list_prepend (uris, (gpointer) uri);
retval = panel_app_info_launch_uris (appinfo, uris,
- screen, timestamp, error);
+ screen, NULL, timestamp, error);
g_list_free (uris);
@@ -157,30 +163,23 @@ panel_app_info_launch_uri (GAppInfo *appinfo,
}
gboolean
-panel_launch_key_file (GKeyFile *keyfile,
+panel_app_info_launch (GDesktopAppInfo *appinfo,
GList *uri_list,
GdkScreen *screen,
+ const gchar *action,
GError **error)
{
- GDesktopAppInfo *appinfo;
gboolean retval;
- g_return_val_if_fail (keyfile != NULL, FALSE);
+ g_return_val_if_fail (appinfo != NULL, FALSE);
g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- appinfo = g_desktop_app_info_new_from_keyfile (keyfile);
-
- if (appinfo == NULL)
- return FALSE;
-
- retval = panel_app_info_launch_uris (G_APP_INFO (appinfo),
- uri_list, screen,
+ retval = panel_app_info_launch_uris (appinfo,
+ uri_list, screen, action,
gtk_get_current_event_time (),
error);
- g_object_unref (appinfo);
-
return retval;
}
@@ -213,7 +212,7 @@ panel_launch_desktop_file (const char *desktop_file,
if (appinfo == NULL)
return FALSE;
- retval = panel_app_info_launch_uris (G_APP_INFO (appinfo), NULL, screen,
+ retval = panel_app_info_launch_uris (appinfo, NULL, screen, NULL,
gtk_get_current_event_time (),
error);
diff --git a/mate-panel/libpanel-util/panel-launch.h b/mate-panel/libpanel-util/panel-launch.h
index 1e4033b1..b98b8ca4 100644
--- a/mate-panel/libpanel-util/panel-launch.h
+++ b/mate-panel/libpanel-util/panel-launch.h
@@ -25,28 +25,30 @@
#ifndef PANEL_LAUNCH_H
#define PANEL_LAUNCH_H
-#include <gio/gio.h>
+#include <gio/gdesktopappinfo.h>
#include <gdk/gdk.h>
#ifdef __cplusplus
extern "C" {
#endif
-gboolean panel_app_info_launch_uris (GAppInfo *appinfo,
+gboolean panel_app_info_launch_uris (GDesktopAppInfo *appinfo,
GList *uris,
GdkScreen *screen,
+ const gchar *action,
guint32 timestamp,
GError **error);
-gboolean panel_app_info_launch_uri (GAppInfo *appinfo,
+gboolean panel_app_info_launch_uri (GDesktopAppInfo *appinfo,
const gchar *uri,
GdkScreen *screen,
guint32 timestamp,
GError **error);
-gboolean panel_launch_key_file (GKeyFile *keyfile,
+gboolean panel_app_info_launch (GDesktopAppInfo *appinfo,
GList *uri_list,
GdkScreen *screen,
+ const gchar *action,
GError **error);
gboolean panel_launch_desktop_file (const char *desktop_file,
diff --git a/mate-panel/libpanel-util/panel-show.c b/mate-panel/libpanel-util/panel-show.c
index 6c80a142..2eeee2ec 100644
--- a/mate-panel/libpanel-util/panel-show.c
+++ b/mate-panel/libpanel-util/panel-show.c
@@ -159,7 +159,7 @@ static gboolean panel_show_caja_search_uri(GdkScreen* screen, const gchar* uri,
return FALSE;
}
- ret = panel_app_info_launch_uri((GAppInfo*) appinfo, uri, screen, timestamp, error);
+ ret = panel_app_info_launch_uri(appinfo, uri, screen, timestamp, error);
g_object_unref(appinfo);
return ret;
@@ -191,8 +191,11 @@ panel_show_uri_force_mime_type (GdkScreen *screen,
GError **error)
{
GFile *file;
- GAppInfo *app;
+ GAppInfo *appinfo;
gboolean ret;
+ GdkDisplay *display;
+ GdkAppLaunchContext *context;
+ GList *uris;
g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
g_return_val_if_fail (uri != NULL, FALSE);
@@ -200,18 +203,23 @@ panel_show_uri_force_mime_type (GdkScreen *screen,
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
file = g_file_new_for_uri (uri);
- app = g_app_info_get_default_for_type (mime_type,
+ appinfo = g_app_info_get_default_for_type (mime_type,
!g_file_is_native (file));
g_object_unref (file);
- if (app == NULL) {
+ if (appinfo == NULL) {
/* no application for the mime type, so let's fallback on
* automatic detection */
return panel_show_uri (screen, uri, timestamp, error);
}
- ret = panel_app_info_launch_uri (app, uri, screen, timestamp, error);
- g_object_unref (app);
+ uris = g_list_append (NULL, (gpointer)uri);
+ display = gdk_screen_get_display (screen);
+ context = gdk_display_get_app_launch_context (display);
+ ret = g_app_info_launch_uris (appinfo, uris, G_APP_LAUNCH_CONTEXT(context), error);
+ g_object_unref (context);
+ g_list_free (uris);
+ g_object_unref (appinfo);
return ret;
}