[gnome-photos/wip/uajain/dzl_file_manager_show: 11/11] local-item: Pre-select local files in a Flatpak-friendly way
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/uajain/dzl_file_manager_show: 11/11] local-item: Pre-select local files in a Flatpak-friendly way
- Date: Sat, 3 Feb 2018 14:04:01 +0000 (UTC)
commit 0cadae913acd3762c15b84853fe974615bf39e42
Author: Umang Jain <mailumangjain gmail com>
Date: Fri Feb 2 15:50:57 2018 +0530
local-item: Pre-select local files in a Flatpak-friendly way
Instead of trying to query GAppInfo for the default inode/directory
handler, use org.freedesktop.FileManager1:ShowItems with a hole poked
in the sandbox to permit access.
Turns out that libdazzle already provides a convenient wrapper around
org.freedesktop.FileManager1:ShowItems for a single URI. This is as
good an excuse as any to start using libdazzle and dropping the
copy-pasted src/egg-*.[ch] code.
https://gitlab.gnome.org/GNOME/gnome-photos/issues/7
configure.ac | 2 ++
flatpak/org.gnome.Photos.json | 11 ++++++++
src/Makefile.am | 2 ++
src/photos-local-item.c | 65 ++++---------------------------------------
4 files changed, 20 insertions(+), 60 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 344c3307..6ee1be81 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,6 +37,7 @@ AC_SUBST(LIBM)
GLIB_GSETTINGS
CAIRO_MIN_VERSION=1.14.0
+DAZZLE_MIN_VERSION=3.26.0
GDATA_MIN_VERSION=0.15.2
GDK_PIXBUF_MIN_VERSION=2.32
GEGL_MIN_VERSION=0.3.28
@@ -99,6 +100,7 @@ AC_SUBST(LIBRT)
PKG_CHECK_MODULES(BABL, [babl])
PKG_CHECK_MODULES(CAIRO, [cairo >= $CAIRO_MIN_VERSION cairo-gobject])
+PKG_CHECK_MODULES(DAZZLE, [libdazzle-1.0 >= $DAZZLE_MIN_VERSION])
PKG_CHECK_MODULES(GFBGRAPH, [libgfbgraph-0.2 >= $GFBGRAPH_MIN_VERSION])
PKG_CHECK_MODULES(GDATA, [libgdata >= $GDATA_MIN_VERSION])
PKG_CHECK_MODULES(GEGL, [gegl-0.3 >= $GEGL_MIN_VERSION])
diff --git a/flatpak/org.gnome.Photos.json b/flatpak/org.gnome.Photos.json
index 1c8a49bd..973b9c95 100644
--- a/flatpak/org.gnome.Photos.json
+++ b/flatpak/org.gnome.Photos.json
@@ -17,6 +17,7 @@
"--socket=wayland",
"--socket=x11",
"--talk-name=ca.desrt.dconf",
+ "--talk-name=org.freedesktop.FileManager1",
"--talk-name=org.freedesktop.Tracker1",
"--talk-name=org.freedesktop.Tracker1.Miner.Extract",
"--talk-name=com.intel.dleyna-renderer",
@@ -69,6 +70,16 @@
}
]
},
+ {
+ "name": "libdazzle",
+ "buildsystem": "meson",
+ "sources": [
+ {
+ "type": "git",
+ "url": "https://gitlab.gnome.org/GNOME/libdazzle.git"
+ }
+ ]
+ },
{
"name": "librest",
"config-opts": [ "--disable-introspection" ],
diff --git a/src/Makefile.am b/src/Makefile.am
index bab99056..34aa2cea 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -395,6 +395,7 @@ AM_CPPFLAGS = \
-DPACKAGE_LOCALE_DIR=\""${datadir}/locale"\" \
$(BABL_CFLAGS) \
$(CAIRO_CFLAGS) \
+ $(DAZZLE_CFLAGS) \
$(GDATA_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
$(GEOCODE_CFLAGS) \
@@ -424,6 +425,7 @@ gnome_photos_LDFLAGS = \
gnome_photos_LDADD = \
$(BABL_LIBS) \
$(CAIRO_LIBS) \
+ $(DAZZLE_LIBS) \
$(GDATA_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(GEOCODE_LIBS) \
diff --git a/src/photos-local-item.c b/src/photos-local-item.c
index b88d4a48..f7f161c7 100644
--- a/src/photos-local-item.c
+++ b/src/photos-local-item.c
@@ -20,12 +20,12 @@
/* Based on code from:
* + Documents
- * + GLib
*/
#include "config.h"
+#include <dazzle.h>
#include <gexiv2/gexiv2.h>
#include <gio/gio.h>
#include <glib.h>
@@ -55,80 +55,25 @@ G_DEFINE_TYPE_WITH_CODE (PhotosLocalItem, photos_local_item, PHOTOS_TYPE_BASE_IT
static gboolean
photos_local_item_source_widget_activate_link (GtkLinkButton *button, gpointer user_data)
{
- g_autoptr (GAppInfo) default_app = NULL;
- g_autoptr (GAppInfo) nautilus_app = NULL;
- g_autoptr (GAppLaunchContext) ctx = NULL;
+ g_autoptr (GFile) file = NULL;
PhotosLocalItem *self;
gboolean ret_val = GDK_EVENT_PROPAGATE;
- const gchar *commandline = "nautilus --select";
- const gchar *default_app_id;
- const gchar *source_uri;
const gchar *uri;
- g_autofree gchar *command_line = NULL;
- g_autofree gchar *source_uri_scheme = NULL;
g_return_val_if_fail (GTK_IS_LINK_BUTTON (button), GDK_EVENT_PROPAGATE);
g_return_val_if_fail (PHOTOS_IS_LOCAL_ITEM (user_data), GDK_EVENT_PROPAGATE);
self = PHOTOS_LOCAL_ITEM (user_data);
- source_uri = gtk_link_button_get_uri (button);
-
- /* Even though g_file_query_default_handler calls
- * g_app_info_get_default_for_uri_scheme, we have to do it here in
- * case GFile can't parse source_uri correctly.
- *
- * See glib/gio/gappinfo.c
- */
-
- source_uri_scheme = g_uri_parse_scheme (source_uri);
- if (source_uri_scheme != NULL && source_uri_scheme[0] != '\0')
- default_app = g_app_info_get_default_for_uri_scheme (source_uri_scheme);
-
- if (default_app == NULL)
- {
- g_autoptr (GFile) source_link = NULL;
-
- source_link = g_file_new_for_uri (source_uri);
-
- {
- g_autoptr (GError) error = NULL;
-
- default_app = g_file_query_default_handler (source_link, NULL, &error);
- if (error != NULL)
- {
- g_warning ("Unable to query default handler for %s: %s", source_uri, error->message);
- goto out;
- }
- }
- }
-
- g_return_val_if_fail (G_IS_APP_INFO (default_app), GDK_EVENT_PROPAGATE);
-
- default_app_id = g_app_info_get_id (default_app);
- if (g_strcmp0 (default_app_id, "org.gnome.Nautilus.desktop") != 0)
- goto out;
-
- {
- g_autoptr (GError) error = NULL;
-
- nautilus_app = g_app_info_create_from_commandline (commandline, NULL, G_APP_INFO_CREATE_NONE, &error);
- if (error != NULL)
- {
- g_warning ("Unable to create GAppInfo from '%s': %s", commandline, error->message);
- goto out;
- }
- }
-
uri = photos_base_item_get_uri (PHOTOS_BASE_ITEM (self));
- ctx = photos_utils_new_app_launch_context_from_widget (GTK_WIDGET (button));
+ file = g_file_new_for_uri (uri);
{
g_autoptr (GError) error = NULL;
- if (!photos_glib_app_info_launch_uri (nautilus_app, uri, ctx, &error))
+ if (!dzl_file_manager_show (file, &error))
{
- g_warning ("Unable to launch '%s': %s", commandline, error->message);
+ g_warning ("Unable to use org.freedesktop.FileManager1 for %s: %s", uri, error->message);
goto out;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]