[gnome-flashback] desktop: open file on double click
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] desktop: open file on double click
- Date: Sun, 10 Nov 2019 20:47:38 +0000 (UTC)
commit 22e26d41552e11a496c91326681027b378b29fa5
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Nov 10 22:44:54 2019 +0200
desktop: open file on double click
gnome-flashback/libdesktop/gf-icon.c | 37 ++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
---
diff --git a/gnome-flashback/libdesktop/gf-icon.c b/gnome-flashback/libdesktop/gf-icon.c
index 9eab1b9..4f308d1 100644
--- a/gnome-flashback/libdesktop/gf-icon.c
+++ b/gnome-flashback/libdesktop/gf-icon.c
@@ -79,6 +79,40 @@ update_state (GfIcon *self)
gtk_widget_set_state_flags (GTK_WIDGET (self), state, TRUE);
}
+static void
+launch_default_for_uri_cb (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error;
+
+ error = NULL;
+ g_app_info_launch_default_for_uri_finish (res, &error);
+
+ if (error != NULL)
+ {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("%s", error->message);
+
+ g_error_free (error);
+ return;
+ }
+}
+
+static void
+icon_open (GfIcon *self)
+{
+ char *uri;
+
+ uri = g_file_get_uri (self->file);
+
+ g_app_info_launch_default_for_uri_async (uri, NULL, NULL,
+ launch_default_for_uri_cb,
+ NULL);
+
+ g_free (uri);
+}
+
static void
multi_press_pressed_cb (GtkGestureMultiPress *gesture,
gint n_press,
@@ -130,6 +164,9 @@ multi_press_pressed_cb (GtkGestureMultiPress *gesture,
}
gf_icon_set_selected (self, selected, flags);
+
+ if (n_press == 2)
+ icon_open (self);
}
else if (button == GDK_BUTTON_SECONDARY)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]