Author: jannis Date: 2009-05-14 14:58:16 +0000 (Thu, 14 May 2009) New Revision: 29957
Added: libexo/branches/exo-thumbnailers/exo-thumbnailers/ libexo/branches/exo-thumbnailers/exo-thumbnailers/Makefile.am libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-generic-thumbnailer.c libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-generic-thumbnailer.h libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service-dbus.xml libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service-main.c libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service.c libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service.h libexo/branches/exo-thumbnailers/exo-thumbnailers/org.xfce.ExoThumbnailer.service.in Removed: libexo/branches/exo-thumbnailers/exo-thumbnailers/Makefile.am libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-generic-thumbnailer.c libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-generic-thumbnailer.h libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service-dbus.xml libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service-main.c libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service.c libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service.h libexo/branches/exo-thumbnailers/exo-thumbnailers/org.xfce.ExoThumbnailer.service.in Modified: libexo/branches/exo-thumbnailers/ libexo/branches/exo-thumbnailers/AUTHORS libexo/branches/exo-thumbnailers/ChangeLog libexo/branches/exo-thumbnailers/Makefile.am libexo/branches/exo-thumbnailers/configure.in.in libexo/branches/exo-thumbnailers/docs/manual/es/ libexo/branches/exo-thumbnailers/docs/manual/id/ libexo/branches/exo-thumbnailers/docs/manual/it/ libexo/branches/exo-thumbnailers/docs/manual/pt_BR/ libexo/branches/exo-thumbnailers/docs/manual/tr/ Log: Err. I really want this in the branch, not in trunk. Property changes on: libexo/branches/exo-thumbnailers ___________________________________________________________________ Added: svn:mergeinfo + /libexo/trunk:29956 Modified: libexo/branches/exo-thumbnailers/AUTHORS =================================================================== --- libexo/branches/exo-thumbnailers/AUTHORS 2009-05-14 14:42:26 UTC (rev 29956) +++ libexo/branches/exo-thumbnailers/AUTHORS 2009-05-14 14:58:16 UTC (rev 29957) @@ -1,4 +1,5 @@ Benedikt Meurer <be...@xfce.org> +Jannis Pohlmann <jan...@xfce.org> Parts of this library are based on code from libegg, Gtk+, the GNOME project and the ROX Filer. Modified: libexo/branches/exo-thumbnailers/ChangeLog =================================================================== --- libexo/branches/exo-thumbnailers/ChangeLog 2009-05-14 14:42:26 UTC (rev 29956) +++ libexo/branches/exo-thumbnailers/ChangeLog 2009-05-14 14:58:16 UTC (rev 29957) @@ -1,3 +1,17 @@ +2009-05-14 Jannis Pohlmann <jan...@xfce.org> + + * configure.in.in, Makefile.am, exo-thumbnailers/Makefile.am, + exo-thumbnailers/exo-generic-thumbnailer.{c,h}, + exo-thumbnailers/exo-thumbnailer-service-dbus.xml, + exo-thumbnailers/exu-thumbnailer-service-main.c, + exo-thumbnailers/exo-thumbnailer-service.{c,h}: Initial import of a + raw skeleton for the implementation of the Thumbnailer Specification. + ExoGenericThumbnailer implements org.freedesktop.thumbnailer.Generic and + ExoThumbnailerService is the D-Bus service that establishes the D-Bus + connection and makes sure the thumbnailer service always runs only once. + There seems to be something wrong right now, though. I can't get the + service to be recognized by D-Bus properly at all ... + 2009-05-12 Jannis Pohlmann <jan...@xfce.org> * docs/reference/exo-sections.txt, docs/reference/tmpl/exo-job.sgml: Modified: libexo/branches/exo-thumbnailers/Makefile.am =================================================================== --- libexo/branches/exo-thumbnailers/Makefile.am 2009-05-14 14:42:26 UTC (rev 29956) +++ libexo/branches/exo-thumbnailers/Makefile.am 2009-05-14 14:58:16 UTC (rev 29957) @@ -18,6 +18,7 @@ exo-mount \ $(EXO_MOUNT_NOTIFY_SUBDIR) \ exo-open \ + exo-thumbnailers \ docs \ icons \ pixmaps \ Modified: libexo/branches/exo-thumbnailers/configure.in.in =================================================================== --- libexo/branches/exo-thumbnailers/configure.in.in 2009-05-14 14:42:26 UTC (rev 29956) +++ libexo/branches/exo-thumbnailers/configure.in.in 2009-05-14 14:58:16 UTC (rev 29957) @@ -146,6 +146,8 @@ dnl *********************************** dnl *** Check for required packages *** dnl *********************************** +XDT_CHECK_PACKAGE([DBUS], [dbus-1], [1.0.0]) +XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.72]) XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.16.0]) XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.16.0]) XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.14.0]) @@ -426,6 +428,7 @@ exo-mount-notify/Makefile exo-open/Makefile exo-support/Makefile +exo-thumbnailers/Makefile icons/Makefile icons/24x24/Makefile icons/48x48/Makefile Property changes on: libexo/branches/exo-thumbnailers/docs/manual/es ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: libexo/branches/exo-thumbnailers/docs/manual/id ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: libexo/branches/exo-thumbnailers/docs/manual/it ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: libexo/branches/exo-thumbnailers/docs/manual/pt_BR ___________________________________________________________________ Deleted: svn:mergeinfo - Property changes on: libexo/branches/exo-thumbnailers/docs/manual/tr ___________________________________________________________________ Deleted: svn:mergeinfo - Copied: libexo/branches/exo-thumbnailers/exo-thumbnailers/Makefile.am (from rev 29956, libexo/trunk/exo-thumbnailers/Makefile.am) =================================================================== --- libexo/branches/exo-thumbnailers/exo-thumbnailers/Makefile.am (rev 0) +++ libexo/branches/exo-thumbnailers/exo-thumbnailers/Makefile.am 2009-05-14 14:58:16 UTC (rev 29957) @@ -0,0 +1,77 @@ +INCLUDES = \ + -I$(top_srcdir) \ + -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \ + -DEXO_COMPILATION + +libexec_PROGRAMS = \ + exo-thumbnailer-service + +exo_thumbnailer_service_built_sources = \ + exo-generic-thumbnailer-dbus-bindings.h + +exo_thumbnailer_service_SOURCES = \ + exo-generic-thumbnailer.c \ + exo-generic-thumbnailer.h \ + exo-thumbnailer-service.c \ + exo-thumbnailer-service.h \ + exo-thumbnailer-service-main.c \ + $(exo_thumbnailer_service_built_sources) + +exo_thumbnailer_service_CFLAGS = \ + -DG_LOG_DOMAIN=\"exo-thumbnailer-service\" \ + $(DBUS_CFLAGS) \ + $(DBUS_GLIB_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GTHREAD_CFLAGS) \ + $(GTK_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) + +exo_thumbnailer_service_LDFLAGS = \ + -no-undefined + +exo_thumbnailer_service_LDADD = \ + $(DBUS_LIBS) \ + $(DBUS_GLIB_LIBS) \ + $(GLIB_LIBS) \ + $(GTHREAD_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(top_builddir)/exo/libexo-$(LIBEXO_VERSION_MAJOR).$(LIBEXO_VERSION_MINOR).la + +servicedir = $(datadir)/dbus-1/services +service_in_files = org.xfce.ExoThumbnailer.service.in +service_DATA = $(service_in_files:.service.in=.service) + +%.service: %.service.in + sed -e "s,\...@libexecdir\@,$(libexecdir),g" < $< > $@ + +CLEANFILES = \ + $(service_DATA) + +EXTRA_DIST = \ + $(service_in_files) + +## +## Rules to auto-generate built sources +## +## This is a bit tricky with automake, and non-trivial to implement. The +## rules below seem to work fine and don't seem to break the build, but +## they are only enabled in maintainer mode, so arbitrary users don't get +## trapped in automake's oddities. Therefore we ship the autogenerated +## files as part of the dist tarball. +## +if MAINTAINER_MODE + +DISTCLEANFILES = \ + $(exo_thumbnailer_service_built_sources) + +BUILT_SOURCES = \ + $(exo_thumbnailer_service_built_sources) + +exo-generic-thumbnailer-dbus-bindings.h: exo-thumbnailer-service-dbus.xml Makefile + dbus-binding-tool --mode=glib-server --prefix=exo_generic_thumbnailer $< > $@ +endif + +EXTRADIST = \ + exo-thumbnailer-service-dbus.xml + +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: Copied: libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-generic-thumbnailer.c (from rev 29956, libexo/trunk/exo-thumbnailers/exo-generic-thumbnailer.c) =================================================================== --- libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-generic-thumbnailer.c (rev 0) +++ libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-generic-thumbnailer.c 2009-05-14 14:58:16 UTC (rev 29957) @@ -0,0 +1,234 @@ +/* vi:set et ai sw=2 sts=2 ts=2: */ +/*- + * Copyright (c) 2009 Jannis Pohlmann <jan...@xfce.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <glib.h> +#include <glib-object.h> + +#include <exo-thumbnailers/exo-generic-thumbnailer.h> +#include <exo-thumbnailers/exo-generic-thumbnailer-dbus-bindings.h> + + + +#define EXO_GENERIC_THUMBNAILER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EXO_TYPE_GENERIC_THUMBNAILER, ExoGenericThumbnailerPrivate)) + + + +/* Property identifiers */ +enum +{ + PROP_0, +}; + + + +static void exo_generic_thumbnailer_class_init (ExoGenericThumbnailerClass *klass); +static void exo_generic_thumbnailer_init (ExoGenericThumbnailer *thumbnailer); +static void exo_generic_thumbnailer_constructed (GObject *object); +static void exo_generic_thumbnailer_finalize (GObject *object); +static void exo_generic_thumbnailer_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void exo_generic_thumbnailer_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); + + + +struct _ExoGenericThumbnailerClass +{ + GObjectClass __parent__; +}; + +struct _ExoGenericThumbnailer +{ + GObject __parent__; + + ExoGenericThumbnailerPrivate *priv; +}; + +struct _ExoGenericThumbnailerPrivate +{ + gint placeholder; +}; + + + +static GObjectClass *exo_generic_thumbnailer_parent_class = NULL; + + + +GType +exo_generic_thumbnailer_get_type (void) +{ + static GType type = G_TYPE_INVALID; + + if (G_UNLIKELY (type == G_TYPE_INVALID)) + { + type = g_type_register_static_simple (G_TYPE_OBJECT, + "ExoGenericThumbnailer", + sizeof (ExoGenericThumbnailerClass), + (GClassInitFunc) exo_generic_thumbnailer_class_init, + sizeof (ExoGenericThumbnailer), + (GInstanceInitFunc) exo_generic_thumbnailer_init, + 0); + } + + return type; +} + + + +static void +exo_generic_thumbnailer_class_init (ExoGenericThumbnailerClass *klass) +{ + GObjectClass *gobject_class; + + g_type_class_add_private (klass, sizeof (ExoGenericThumbnailerPrivate)); + + /* Determine the parent type class */ + exo_generic_thumbnailer_parent_class = g_type_class_peek_parent (klass); + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->constructed = exo_generic_thumbnailer_constructed; + gobject_class->finalize = exo_generic_thumbnailer_finalize; + gobject_class->get_property = exo_generic_thumbnailer_get_property; + gobject_class->set_property = exo_generic_thumbnailer_set_property; + + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), + &dbus_glib_exo_generic_thumbnailer_object_info); +} + + + +static void +exo_generic_thumbnailer_init (ExoGenericThumbnailer *thumbnailer) +{ + thumbnailer->priv = EXO_GENERIC_THUMBNAILER_GET_PRIVATE (thumbnailer); +} + + + +static void +exo_generic_thumbnailer_constructed (GObject *object) +{ +} + + + +static void +exo_generic_thumbnailer_finalize (GObject *object) +{ + (*G_OBJECT_CLASS (exo_generic_thumbnailer_parent_class)->finalize) (object); +} + + + +static void +exo_generic_thumbnailer_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + switch (prop_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + + +static void +exo_generic_thumbnailer_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (prop_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + + +ExoGenericThumbnailer * +exo_generic_thumbnailer_get_default (void) +{ + static ExoGenericThumbnailer *thumbnailer = NULL; + + if (G_UNLIKELY (thumbnailer == NULL)) + { + thumbnailer = g_object_new (EXO_TYPE_GENERIC_THUMBNAILER, NULL); + g_object_add_weak_pointer (G_OBJECT (thumbnailer), (gpointer) &thumbnailer); + } + else + { + g_object_ref (thumbnailer); + } + + return thumbnailer; +} + + + +gboolean +exo_generic_thumbnailer_queue (ExoGenericThumbnailer *thumbnailer, + const gchar **uris, + const gchar **mime_hints, + guint32 unqueue_handle, + guint32 *handle, + GError **error) +{ + gint n; + + g_debug ("exo_generic_thumbnailer_queue:"); + + return TRUE; + + g_debug (" uris = "); + for (n = 0; uris[n] != NULL; ++n) + g_debug (" %s", uris[n]); + + g_debug (" mime_hints = "); + for (n = 0; mime_hints[n] != NULL; ++n) + g_debug (" %s", mime_hints[n]); + + return TRUE; +} + + + +gboolean +exo_generic_thumbnailer_test (ExoGenericThumbnailer *thumbnailer, + GError **error) +{ + g_debug ("Test"); + return TRUE; +} Copied: libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-generic-thumbnailer.h (from rev 29956, libexo/trunk/exo-thumbnailers/exo-generic-thumbnailer.h) =================================================================== --- libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-generic-thumbnailer.h (rev 0) +++ libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-generic-thumbnailer.h 2009-05-14 14:58:16 UTC (rev 29957) @@ -0,0 +1,53 @@ +/* vi:set et ai sw=2 sts=2 ts=2: */ +/*- + * Copyright (c) 2009 Jannis Pohlmann <jan...@xfce.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __EXO_GENERIC_THUMBNAILER_H__ +#define __EXO_GENERIC_THUMBNAILER_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS; + +#define EXO_TYPE_GENERIC_THUMBNAILER (exo_generic_thumbnailer_get_type ()) +#define EXO_GENERIC_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXO_TYPE_GENERIC_THUMBNAILER, ExoGenericThumbnailer)) +#define EXO_GENERIC_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EXO_TYPE_GENERIC_THUMBNAILER, ExoGenericThumbnailerClass)) +#define EXO_IS_GENERIC_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EXO_TYPE_GENERIC_THUMBNAILER)) +#define EXO_IS_GENERIC_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EXO_TYPE_GENERIC_THUMBNAILER) +#define EXO_GENERIC_THUMBNAILER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EXO_TYPE_GENERIC_THUMBNAILER, ExoGenericThumbnailerClass)) + +typedef struct _ExoGenericThumbnailerPrivate ExoGenericThumbnailerPrivate; +typedef struct _ExoGenericThumbnailerClass ExoGenericThumbnailerClass; +typedef struct _ExoGenericThumbnailer ExoGenericThumbnailer; + +GType exo_generic_thumbnailer_get_type (void) G_GNUC_CONST; + +ExoGenericThumbnailer *exo_generic_thumbnailer_get_default (void) G_GNUC_WARN_UNUSED_RESULT; +gboolean exo_generic_thumbnailer_queue (ExoGenericThumbnailer *thumbnailer, + const gchar **uris, + const gchar **mime_hints, + guint32 unqueue_handle, + guint32 *handle, + GError **error); +gboolean exo_generic_thumbnailer_test (ExoGenericThumbnailer *thumbnailer, + GError **error); + +G_END_DECLS; + +#endif /* !__EXO_GENERIC_THUMBNAILER_H__ */ Copied: libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service-dbus.xml (from rev 29956, libexo/trunk/exo-thumbnailers/exo-thumbnailer-service-dbus.xml) =================================================================== --- libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service-dbus.xml (rev 0) +++ libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service-dbus.xml 2009-05-14 14:58:16 UTC (rev 29957) @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node name="/org/freedesktop/Thumbnailer"> + <interface name="org.freedesktop.thumbnailer.Generic"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="exo_generic_thumbnailer"/> + <annotation name="org.freedesktop.DBus.GLib.ClientCSymbol" value="exo_thumbnailer_proxy"/> + + <method name="Queue"> + <arg type="as" name="uris" direction="in" /> + <arg type="as" name="mime_hints" direction="in" /> + <arg type="u" name="handle_to_unqueue" direction="in" /> + <arg type="u" name="handle" direction="out" /> + </method> + + <method name="Test"> + </method> + </interface> +</node> Copied: libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service-main.c (from rev 29956, libexo/trunk/exo-thumbnailers/exo-thumbnailer-service-main.c) =================================================================== --- libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service-main.c (rev 0) +++ libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service-main.c 2009-05-14 14:58:16 UTC (rev 29957) @@ -0,0 +1,76 @@ +/* vi:set et ai sw=2 sts=2 ts=2: */ +/*- + * Copyright (c) 2009 Jannis Pohlmann <jan...@xfce.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif + +#include <glib.h> + +#include <libxfce4util/libxfce4util.h> + +#include <exo-thumbnailers/exo-thumbnailer-service.h> + + + +int +main (int argc, + char **argv) +{ + ExoThumbnailerService *service; + GMainLoop *main_loop; + GError *error = NULL; + + xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); + + g_set_application_name (_("Exo Thumbnailer Service")); + +#ifdef G_ENABLE_DEBUG + g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); +#endif + + /* initialize the type system */ + g_type_init (); + + /* initialize the threading system */ + if (!g_thread_supported ()) + g_thread_init (NULL); + + service = exo_thumbnailer_service_new_unique (&error); + if (G_UNLIKELY (service == NULL)) + { + g_critical (_("Failed to start the exo thumbnailer service: %s"), error->message); + g_error_free (error); + return EXIT_FAILURE; + } + + main_loop = g_main_loop_new (NULL, FALSE); + + g_main_loop_run (main_loop); + + g_object_unref (service); + g_main_loop_unref (main_loop); + + return EXIT_SUCCESS; +} Copied: libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service.c (from rev 29956, libexo/trunk/exo-thumbnailers/exo-thumbnailer-service.c) =================================================================== --- libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service.c (rev 0) +++ libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service.c 2009-05-14 14:58:16 UTC (rev 29957) @@ -0,0 +1,275 @@ +/* vi:set et ai sw=2 sts=2 ts=2: */ +/*- + * Copyright (c) 2009 Jannis Pohlmann <jan...@xfce.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <glib.h> +#include <glib-object.h> + +#include <dbus/dbus.h> +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include <exo/exo-private.h> +#include <exo-thumbnailers/exo-generic-thumbnailer.h> +#include <exo-thumbnailers/exo-thumbnailer-service.h> + + + +#define EXO_THUMBNAILER_SERVICE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EXO_TYPE_THUMBNAILER_SERVICE, ExoThumbnailerServicePrivate)) + + + +/* Property identifiers */ +enum +{ + PROP_0, +}; + + + +static void exo_thumbnailer_service_class_init (ExoThumbnailerServiceClass *klass); +static void exo_thumbnailer_service_init (ExoThumbnailerService *service); +static void exo_thumbnailer_service_constructed (GObject *object); +static void exo_thumbnailer_service_finalize (GObject *object); +static void exo_thumbnailer_service_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void exo_thumbnailer_service_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static gboolean exo_thumbnailer_service_start (ExoThumbnailerService *service, + GError **error); +static DBusHandlerResult exo_thumbnailer_service_handle_dbus_disconnect (DBusConnection *connection, + DBusMessage *message, + void *user_data); + + + +struct _ExoThumbnailerServiceClass +{ + GObjectClass __parent__; +}; + +struct _ExoThumbnailerService +{ + GObject __parent__; + + ExoThumbnailerServicePrivate *priv; +}; + +struct _ExoThumbnailerServicePrivate +{ + DBusGConnection *connection; + ExoGenericThumbnailer *thumbnailer; +}; + + + +static GObjectClass *exo_thumbnailer_service_parent_class = NULL; + + + +GType +exo_thumbnailer_service_get_type (void) +{ + static GType type = G_TYPE_INVALID; + + if (G_UNLIKELY (type == G_TYPE_INVALID)) + { + type = g_type_register_static_simple (G_TYPE_OBJECT, + "ExoThumbnailerService", + sizeof (ExoThumbnailerServiceClass), + (GClassInitFunc) exo_thumbnailer_service_class_init, + sizeof (ExoThumbnailerService), + (GInstanceInitFunc) exo_thumbnailer_service_init, + 0); + } + + return type; +} + + + +static void +exo_thumbnailer_service_class_init (ExoThumbnailerServiceClass *klass) +{ + GObjectClass *gobject_class; + + g_type_class_add_private (klass, sizeof (ExoThumbnailerServicePrivate)); + + /* Determine the parent type class */ + exo_thumbnailer_service_parent_class = g_type_class_peek_parent (klass); + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->constructed = exo_thumbnailer_service_constructed; + gobject_class->finalize = exo_thumbnailer_service_finalize; + gobject_class->get_property = exo_thumbnailer_service_get_property; + gobject_class->set_property = exo_thumbnailer_service_set_property; +} + + + +static void +exo_thumbnailer_service_init (ExoThumbnailerService *service) +{ + service->priv = EXO_THUMBNAILER_SERVICE_GET_PRIVATE (service); + service->priv->connection = NULL; + service->priv->thumbnailer = exo_generic_thumbnailer_get_default (); +} + + + +static void +exo_thumbnailer_service_constructed (GObject *object) +{ +} + + + +static void +exo_thumbnailer_service_finalize (GObject *object) +{ + ExoThumbnailerService *service = EXO_THUMBNAILER_SERVICE (object); + + g_object_unref (service->priv->thumbnailer); + + if (service->priv->connection != NULL) + dbus_g_connection_unref (service->priv->connection); + + (*G_OBJECT_CLASS (exo_thumbnailer_service_parent_class)->finalize) (object); +} + + + +static void +exo_thumbnailer_service_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + switch (prop_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + + +static void +exo_thumbnailer_service_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (prop_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + + +static gboolean +exo_thumbnailer_service_start (ExoThumbnailerService *service, + GError **error) +{ + DBusError dbus_error; + gint result; + + _exo_return_val_if_fail (EXO_IS_THUMBNAILER_SERVICE (service), FALSE); + _exo_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + service->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, error); + if (G_UNLIKELY (service->priv->connection == NULL)) + return FALSE; + + dbus_g_connection_register_g_object (service->priv->connection, "/org/freedesktop/Thumbnailer", + G_OBJECT (service->priv->thumbnailer)); + + dbus_connection_add_filter (dbus_g_connection_get_connection (service->priv->connection), + exo_thumbnailer_service_handle_dbus_disconnect, + service, NULL); + + dbus_error_init (&dbus_error); + + result = dbus_bus_request_name (dbus_g_connection_get_connection (service->priv->connection), + "org.freedesktop.thumbnailer.Generic", + DBUS_NAME_FLAG_DO_NOT_QUEUE, &dbus_error); + + if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) + { + if (dbus_error_is_set (&dbus_error)) + { + if (error != NULL) + dbus_set_g_error (error, &dbus_error); + + dbus_error_free (&dbus_error); + } + else if (error != NULL) + { + g_set_error (error, DBUS_GERROR, DBUS_GERROR_FAILED, + _("Another org.freedesktop.thumbnailer.Generic is already running")); + } + + return FALSE; + } + + return TRUE; +} + + + +static DBusHandlerResult +exo_thumbnailer_service_handle_dbus_disconnect (DBusConnection *connection, + DBusMessage *message, + void *user_data) +{ + g_debug ("disconnect"); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + + + +ExoThumbnailerService * +exo_thumbnailer_service_new_unique (GError **error) +{ + ExoThumbnailerService *service = NULL; + + _exo_return_val_if_fail (error == NULL || *error == NULL, NULL); + + service = g_object_new (EXO_TYPE_THUMBNAILER_SERVICE, NULL); + + if (!exo_thumbnailer_service_start (service, error)) + { + g_object_unref (service); + return NULL; + } + + return service; +} Copied: libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service.h (from rev 29956, libexo/trunk/exo-thumbnailers/exo-thumbnailer-service.h) =================================================================== --- libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service.h (rev 0) +++ libexo/branches/exo-thumbnailers/exo-thumbnailers/exo-thumbnailer-service.h 2009-05-14 14:58:16 UTC (rev 29957) @@ -0,0 +1,45 @@ +/* vi:set et ai sw=2 sts=2 ts=2: */ +/*- + * Copyright (c) 2009 Jannis Pohlmann <jan...@xfce.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __EXO_THUMBNAILER_SERVICE_H__ +#define __EXO_THUMBNAILER_SERVICE_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS; + +#define EXO_TYPE_THUMBNAILER_SERVICE (exo_thumbnailer_service_get_type ()) +#define EXO_THUMBNAILER_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXO_TYPE_THUMBNAILER_SERVICE, ExoThumbnailerService)) +#define EXO_THUMBNAILER_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EXO_TYPE_THUMBNAILER_SERVICE, ExoThumbnailerServiceClass)) +#define EXO_IS_THUMBNAILER_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EXO_TYPE_THUMBNAILER_SERVICE)) +#define EXO_IS_THUMBNAILER_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EXO_TYPE_THUMBNAILER_SERVICE) +#define EXO_THUMBNAILER_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EXO_TYPE_THUMBNAILER_SERVICE, ExoThumbnailerServiceClass)) + +typedef struct _ExoThumbnailerServicePrivate ExoThumbnailerServicePrivate; +typedef struct _ExoThumbnailerServiceClass ExoThumbnailerServiceClass; +typedef struct _ExoThumbnailerService ExoThumbnailerService; + +GType exo_thumbnailer_service_get_type (void) G_GNUC_CONST; + +ExoThumbnailerService *exo_thumbnailer_service_new_unique (GError **error) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; + +G_END_DECLS; + +#endif /* !__EXO_THUMBNAILER_SERVICE_H__ */ Copied: libexo/branches/exo-thumbnailers/exo-thumbnailers/org.xfce.ExoThumbnailer.service.in (from rev 29956, libexo/trunk/exo-thumbnailers/org.xfce.ExoThumbnailer.service.in) =================================================================== --- libexo/branches/exo-thumbnailers/exo-thumbnailers/org.xfce.ExoThumbnailer.service.in (rev 0) +++ libexo/branches/exo-thumbnailers/exo-thumbnailers/org.xfce.ExoThumbnailer.service.in 2009-05-14 14:58:16 UTC (rev 29957) @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.freedesktop.thumbnailer +ex...@libexecdir@/exo-thumbnailer-service _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits