[Xfce4-commits] [xfce/xfdesktop] 27/34: Port xfdesktop-thumbnailer to GDBus
noreply at xfce.org
noreply at xfce.org
Sun Apr 16 07:07:01 CEST 2017
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository xfce/xfdesktop.
commit 80913e9c073af4883beaaf4f890f57306ac2bf25
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Wed Jun 8 19:36:10 2016 +0300
Port xfdesktop-thumbnailer to GDBus
---
.gitignore | 2 +
common/Makefile.am | 15 +++-
common/tumbler-service-dbus.xml | 55 ++++++++++++++
common/xfdesktop-thumbnailer.c | 163 ++++++++++++++++++++--------------------
configure.ac.in | 25 +-----
5 files changed, 151 insertions(+), 109 deletions(-)
diff --git a/.gitignore b/.gitignore
index b5a06ef..abd4a52 100644
--- a/.gitignore
+++ b/.gitignore
@@ -68,3 +68,5 @@ src/xfdesktop-file-manager-proxy.c
src/xfdesktop-thunar-proxy.c
src/xfdesktop-trash-proxy.c
ChangeLog
+config.h.in~
+cov-int/
diff --git a/common/Makefile.am b/common/Makefile.am
index 731ca74..bc9c97c 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -2,7 +2,9 @@ noinst_LTLIBRARIES = libxfdesktop.la
libxfdesktop_built_sources = \
xfdesktop-marshal.c \
- xfdesktop-marshal.h
+ xfdesktop-marshal.h \
+ tumbler.c \
+ tumbler.h
libxfdesktop_la_SOURCES = \
$(libxfdesktop_built_sources) \
@@ -15,8 +17,8 @@ libxfdesktop_la_CFLAGS = \
-I$(top_srcdir)/src \
$(LIBXFCE4UTIL_CFLAGS) \
$(GTK_CFLAGS) \
- -DDBUS_API_SUBJECT_TO_CHANGE \
- $(DBUS_CFLAGS)
+ $(GIO_CFLAGS) \
+ $(GIO_UNIX_CFLAGS)
if MAINTAINER_MODE
@@ -28,6 +30,13 @@ xfdesktop-marshal.c: xfdesktop-marshal.list Makefile
$(AM_V_GEN) echo '#include "xfdesktop-marshal.h"' > $@ \
&& glib-genmarshal --prefix=xfdesktop_marshal --body $< >> $@
+tumbler.c tumbler.h : $(srcdir)/tumbler-service-dbus.xml Makefile.am
+ gdbus-codegen \
+ --c-namespace=Tumbler \
+ --interface-prefix=org.freedesktop.thumbnails. \
+ --generate-c-code=tumbler \
+ $(srcdir)/tumbler-service-dbus.xml
+
DISTCLEANFILES = \
$(libxfdesktop_built_sources)
diff --git a/common/tumbler-service-dbus.xml b/common/tumbler-service-dbus.xml
new file mode 100644
index 0000000..9076691
--- /dev/null
+++ b/common/tumbler-service-dbus.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/org/freedesktop/thumbnails/Thumbnailer1">
+ <interface name="org.freedesktop.thumbnails.Thumbnailer1">
+ <method name="Queue">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="as" name="uris" direction="in" />
+ <arg type="as" name="mime_types" direction="in" />
+ <arg type="s" name="flavor" direction="in" />
+ <arg type="s" name="scheduler" direction="in" />
+ <arg type="u" name="handle_to_unqueue" direction="in" />
+ <arg type="u" name="handle" direction="out" />
+ </method>
+
+ <method name="Dequeue">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="u" name="handle" direction="in" />
+ </method>
+
+ <method name="GetSupported">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
+ <arg type="as" name="uri_schemes" direction="out" />
+ <arg type="as" name="mime_types" direction="out" />
+ </method>
+
+ <method name="GetSchedulers">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
+ <arg type="as" name="schedulers" direction="out" />
+ </method>
+
+ <method name="GetFlavors">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
+ <arg type="as" name="flavors" direction="out" />
+ </method>
+
+ <signal name="Started">
+ <arg type="u" name="handle" />
+ </signal>
+
+ <signal name="Finished">
+ <arg type="u" name="handle" />
+ </signal>
+
+ <signal name="Ready">
+ <arg type="u" name="handle" />
+ <arg type="as" name="uris" />
+ </signal>
+
+ <signal name="Error">
+ <arg type="u" name="handle" />
+ <arg type="as" name="failed_uris" />
+ <arg type="i" name="error_code" />
+ <arg type="s" name="message" />
+ </signal>
+ </interface>
+</node>
diff --git a/common/xfdesktop-thumbnailer.c b/common/xfdesktop-thumbnailer.c
index 2cdd2f9..9367350 100644
--- a/common/xfdesktop-thumbnailer.c
+++ b/common/xfdesktop-thumbnailer.c
@@ -36,12 +36,11 @@
#include <gtk/gtk.h>
#include <gio/gio.h>
-#include <dbus/dbus-glib.h>
-
#include <libxfce4util/libxfce4util.h>
#include "xfdesktop-thumbnailer.h"
#include "xfdesktop-marshal.h"
#include "xfdesktop-common.h"
+#include "tumbler.h"
static void xfdesktop_thumbnailer_init(GObject *);
static void xfdesktop_thumbnailer_class_init(GObjectClass *);
@@ -49,13 +48,13 @@ static void xfdesktop_thumbnailer_class_init(GObjectClass *);
static void xfdesktop_thumbnailer_dispose(GObject *object);
static void xfdesktop_thumbnailer_finalize(GObject *object);
-static void xfdesktop_thumbnailer_request_finished_dbus(DBusGProxy *proxy,
- gint handle,
+static void xfdesktop_thumbnailer_request_finished_dbus(TumblerThumbnailer1 *proxy,
+ guint arg_handle,
gpointer data);
-static void xfdesktop_thumbnailer_thumbnail_ready_dbus(DBusGProxy *proxy,
- gint handle,
- const gchar **uri,
+static void xfdesktop_thumbnailer_thumbnail_ready_dbus(TumblerThumbnailer1 *proxy,
+ guint handle,
+ const gchar *const *uri,
gpointer data);
static gboolean xfdesktop_thumbnailer_queue_request_timer(XfdesktopThumbnailer *thumbnailer);
@@ -102,12 +101,12 @@ xfdesktop_thumbnailer_get_type(void)
struct _XfdesktopThumbnailerPriv
{
- DBusGProxy *proxy;
+ TumblerThumbnailer1 *proxy;
GSList *queue;
gchar **supported_mimetypes;
gboolean big_thumbnails;
- gint handle;
+ guint handle;
gint request_timer_id;
};
@@ -116,54 +115,47 @@ static void
xfdesktop_thumbnailer_init(GObject *object)
{
XfdesktopThumbnailer *thumbnailer;
- DBusGConnection *connection;
+ GDBusConnection *connection;
thumbnailer = XFDESKTOP_THUMBNAILER(object);
thumbnailer->priv = g_new0(XfdesktopThumbnailerPriv, 1);
- connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
+ connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
if(connection) {
- thumbnailer->priv->proxy = dbus_g_proxy_new_for_name(
+ thumbnailer->priv->proxy = tumbler_thumbnailer1_proxy_new_sync(
connection,
+ G_DBUS_PROXY_FLAGS_NONE,
"org.freedesktop.thumbnails.Thumbnailer1",
"/org/freedesktop/thumbnails/Thumbnailer1",
- "org.freedesktop.thumbnails.Thumbnailer1");
+ NULL,
+ NULL);
if(thumbnailer->priv->proxy) {
gchar **supported_uris = NULL;
gchar **supported_flavors = NULL;
- dbus_g_object_register_marshaller(
- (GClosureMarshal) xfdesktop_marshal_VOID__UINT_BOXED,
- G_TYPE_NONE, G_TYPE_UINT,
- G_TYPE_STRV, G_TYPE_INVALID);
-
- dbus_g_proxy_add_signal(
- thumbnailer->priv->proxy,
- "Finished", G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_add_signal(
- thumbnailer->priv->proxy,
- "Ready", G_TYPE_UINT, G_TYPE_STRV, G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal(
- thumbnailer->priv->proxy,
- "Finished", G_CALLBACK (xfdesktop_thumbnailer_request_finished_dbus),
- thumbnailer, NULL);
- dbus_g_proxy_connect_signal(
- thumbnailer->priv->proxy,
- "Ready", G_CALLBACK(xfdesktop_thumbnailer_thumbnail_ready_dbus),
- thumbnailer, NULL);
-
- dbus_g_proxy_call(thumbnailer->priv->proxy, "GetSupported", NULL, G_TYPE_INVALID,
- G_TYPE_STRV, &supported_uris,
- G_TYPE_STRV, &thumbnailer->priv->supported_mimetypes,
- G_TYPE_INVALID);
-
- dbus_g_proxy_call(thumbnailer->priv->proxy, "GetFlavors", NULL, G_TYPE_INVALID,
- G_TYPE_STRV, &supported_flavors,
- G_TYPE_INVALID);
+
+ g_signal_connect(thumbnailer->priv->proxy,
+ "finished",
+ G_CALLBACK (xfdesktop_thumbnailer_request_finished_dbus),
+ thumbnailer);
+ g_signal_connect(thumbnailer->priv->proxy,
+ "ready",
+ G_CALLBACK(xfdesktop_thumbnailer_thumbnail_ready_dbus),
+ thumbnailer);
+
+ tumbler_thumbnailer1_call_get_supported_sync(thumbnailer->priv->proxy,
+ &supported_uris,
+ &thumbnailer->priv->supported_mimetypes,
+ NULL,
+ NULL);
+
+ tumbler_thumbnailer1_call_get_flavors_sync(thumbnailer->priv->proxy,
+ &supported_flavors,
+ NULL,
+ NULL);
if(supported_flavors != NULL) {
gint n;
@@ -181,7 +173,7 @@ xfdesktop_thumbnailer_init(GObject *object)
g_strfreev(supported_uris);
}
- dbus_g_connection_unref(connection);
+ g_object_unref(connection);
}
}
@@ -322,11 +314,10 @@ xfdesktop_thumbnailer_queue_thumbnail(XfdesktopThumbnailer *thumbnailer,
g_source_remove(thumbnailer->priv->request_timer_id);
if(thumbnailer->priv->handle && thumbnailer->priv->proxy != NULL) {
- if(dbus_g_proxy_call(thumbnailer->priv->proxy,
- "Dequeue",
- NULL,
- G_TYPE_UINT, thumbnailer->priv->handle,
- G_TYPE_INVALID) == FALSE)
+ if(tumbler_thumbnailer1_call_dequeue_sync(thumbnailer->priv->proxy,
+ thumbnailer->priv->handle,
+ NULL,
+ NULL) == FALSE)
{
/* If this fails it usually means there's a thumbnail already
* being processed, no big deal */
@@ -379,11 +370,10 @@ xfdesktop_thumbnailer_dequeue_thumbnail(XfdesktopThumbnailer *thumbnailer,
g_source_remove(thumbnailer->priv->request_timer_id);
if(thumbnailer->priv->handle && thumbnailer->priv->proxy) {
- if(dbus_g_proxy_call(thumbnailer->priv->proxy,
- "Dequeue",
- NULL,
- G_TYPE_UINT, thumbnailer->priv->handle,
- G_TYPE_INVALID) == FALSE)
+ if(tumbler_thumbnailer1_call_dequeue_sync(thumbnailer->priv->proxy,
+ thumbnailer->priv->handle,
+ NULL,
+ NULL) == FALSE)
{
/* If this fails it usually means there's a thumbnail already
* being processed, no big deal */
@@ -453,17 +443,15 @@ xfdesktop_thumbnailer_queue_request_timer(XfdesktopThumbnailer *thumbnailer)
thumbnail_flavor = "normal";
if(thumbnailer->priv->proxy != NULL) {
- if(dbus_g_proxy_call(thumbnailer->priv->proxy,
- "Queue",
- &error,
- G_TYPE_STRV, uris,
- G_TYPE_STRV, mimetypes,
- G_TYPE_STRING, thumbnail_flavor,
- G_TYPE_STRING, "default",
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &thumbnailer->priv->handle,
- G_TYPE_INVALID) == FALSE)
+ if(tumbler_thumbnailer1_call_queue_sync(thumbnailer->priv->proxy,
+ (const gchar * const*)uris,
+ (const gchar * const*)mimetypes,
+ thumbnail_flavor,
+ "default",
+ 0,
+ &thumbnailer->priv->handle,
+ NULL,
+ &error) == FALSE)
{
if(error != NULL)
g_warning("DBUS-call failed: %s", error->message);
@@ -492,8 +480,8 @@ xfdesktop_thumbnailer_queue_request_timer(XfdesktopThumbnailer *thumbnailer)
}
static void
-xfdesktop_thumbnailer_request_finished_dbus(DBusGProxy *proxy,
- gint handle,
+xfdesktop_thumbnailer_request_finished_dbus(TumblerThumbnailer1 *proxy,
+ guint arg_handle,
gpointer data)
{
XfdesktopThumbnailer *thumbnailer = XFDESKTOP_THUMBNAILER(data);
@@ -504,9 +492,9 @@ xfdesktop_thumbnailer_request_finished_dbus(DBusGProxy *proxy,
}
static void
-xfdesktop_thumbnailer_thumbnail_ready_dbus(DBusGProxy *proxy,
- gint handle,
- const gchar **uri,
+xfdesktop_thumbnailer_thumbnail_ready_dbus(TumblerThumbnailer1 *proxy,
+ guint handle,
+ const gchar *const *uri,
gpointer data)
{
XfdesktopThumbnailer *thumbnailer = XFDESKTOP_THUMBNAILER(data);
@@ -601,34 +589,43 @@ xfdesktop_thumbnailer_thumbnail_ready_dbus(DBusGProxy *proxy,
void
xfdesktop_thumbnailer_delete_thumbnail(XfdesktopThumbnailer *thumbnailer, gchar *src_file)
{
- DBusGConnection *connection;
- gchar **uris;
+ GDBusConnection *connection;
+ GVariantBuilder builder;
GFile *file;
GError *error = NULL;
- static DBusGProxy *cache = NULL;
+ static GDBusProxy *cache = NULL;
if(!cache) {
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
if (connection != NULL) {
- cache = dbus_g_proxy_new_for_name(connection,
- "org.freedesktop.thumbnails.Cache1",
- "/org/freedesktop/thumbnails/Cache1",
- "org.freedesktop.thumbnails.Cache1");
-
- dbus_g_connection_unref(connection);
+ cache = g_dbus_proxy_new_sync(connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.freedesktop.thumbnails.Cache1",
+ "/org/freedesktop/thumbnails/Cache1",
+ "org.freedesktop.thumbnails.Cache1",
+ NULL,
+ NULL);
+
+ g_object_unref(connection);
}
}
file = g_file_new_for_path(src_file);
if(cache) {
- uris = g_new0 (gchar *, 2);
- uris[0] = g_file_get_uri(file);
- dbus_g_proxy_call(cache, "Delete", &error, G_TYPE_STRV, uris, G_TYPE_INVALID, G_TYPE_INVALID);
+ g_variant_builder_init(&builder, G_VARIANT_TYPE ("as"));
+ g_variant_builder_add(&builder, "s", g_file_get_uri(file));
+ g_dbus_proxy_call_sync(cache,
+ "Delete",
+ g_variant_new("(as)", &builder),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
if(error != NULL) {
g_warning("DBUS-call failed:%s", error->message);
}
- g_free(uris);
}
g_object_unref(file);
diff --git a/configure.ac.in b/configure.ac.in
index 328a8b6..1e3c0ab 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -21,8 +21,7 @@ m4_define([xfce_minimum_version], [4.12.0])
m4_define([garcon_minimum_version], [0.5.0])
m4_define([exo_minimum_version], [0.10.2])
m4_define([thunar_minimum_version], [1.2.0])
-m4_define([dbus_minimum_version], [0.84])
-m4_define([wnck_minimum_version], [3.20])
+m4_define([wnck_minimum_version], [2.30])
m4_define([intltool_minimum_version], [0.31])
m4_define([xfconf_minimum_version], [4.12.0])
m4_define([cairo_minimum_version], [1.6])
@@ -74,15 +73,6 @@ XDT_I18N([@LINGUAS@])
dnl Check for X11 installed
XDT_CHECK_LIBX11_REQUIRE
-dnl Check for dbus-binding-tool
-AC_ARG_VAR([DBUS_BINDING_TOOL], [Tool to generate C bindings from XML D-Bus interface definitions])
-AC_PATH_PROG([DBUS_BINDING_TOOL], [dbus-binding-tool], [no])
-if test x"$DBUS_BINDING_TOOL" = x"no"; then
- AC_MSG_ERROR([could not find dbus-binding-tool in \$PATH. You can run
- ./configure DBUS_BINDING_TOOL=/path/to/dbus-binding-tool to define
- a custom location for it.])
-fi
-
dnl define xfdesktop's short version (major.minor)
AC_DEFINE([XFDESKTOP_VERSION_SHORT], [xfdesktop_version_short], [Short version string of xfdesktop])
dnl replace the version in settings/xfce-backdrop-settings.desktop.in.in
@@ -90,11 +80,11 @@ AC_SUBST([XFDESKTOP_VERSION_SHORT], [xfdesktop_version_short])
dnl required
XDT_CHECK_PACKAGE([GIO], [gio-2.0], [glib_minimum_version])
+XDT_CHECK_PACKAGE([GIO_UNIX], [gio-unix-2.0], [glib_minimum_version])
XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [glib_minimum_version])
XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [glib_minimum_version])
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [glib_minimum_version])
XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [gtk_minimum_version])
-XDT_CHECK_PACKAGE([DBUS], [dbus-glib-1], [dbus_minimum_version])
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0],
[libxfce4util_minimum_version])
XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2],
@@ -104,8 +94,6 @@ XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [xfconf_minimum_version])
XDT_CHECK_PACKAGE([LIBEXO], [exo-2], [exo_minimum_version])
XDT_CHECK_PACKAGE([CAIRO], [cairo], [cairo_minimum_version])
-XDT_CHECK_OPTIONAL_PACKAGE([GIO_UNIX], [gio-unix-2.0], [glib_minimum_version], [gio-unix],
- [gio-unix, for special treatment of mount points on UNIX])
dnl do we want desktop icons at all?
AC_ARG_ENABLE([desktop-icons],
@@ -134,12 +122,8 @@ else
fi
if test "x$enable_desktop_icons" = "xyes" -a "x$enable_file_icons" = "xyes"; then
- enable_file_icons="no"
- if test "x$DBUS_VERSION" != "x"; then
- enable_file_icons="yes"
AC_DEFINE([ENABLE_FILE_ICONS], [1],
[Define if file icons should be enabled])
- fi
fi
AM_CONDITIONAL([ENABLE_FILE_ICONS], [test "x$enable_file_icons" = "xyes"])
@@ -224,11 +208,6 @@ echo "Build Configuration:"
echo "* Build desktop menu module: $build_desktop_menu"
echo "* Build support for desktop icons: $enable_desktop_icons"
echo " Include support for file/launcher icons: $enable_file_icons"
-if test x"$GIO_UNIX_FOUND" = x"yes"; then
-echo "* Special treatment for mount points on UNIX: yes"
-else
-echo "* Special treatment for mount points on UNIX: no"
-fi
if test x"$LIBNOTIFY_FOUND" = x"yes"; then
echo "* Mount notification support: yes"
else
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list