Bug 622934 - Migrate from dbus-glib to glib's GDBus

Drop the glib-dbus dependency and port stuff to GDBus. Use it
unconditionally if not on Windows or OSX. It seels to work just like
before but I have no idea if everything is really correct.
This commit is contained in:
Michael Natterer 2013-05-24 23:25:47 +02:00
parent 564e6010fd
commit c4460e846b
9 changed files with 211 additions and 240 deletions

20
INSTALL
View File

@ -57,10 +57,7 @@ header files installed.
and fontconfig 2.2.0 or newer. Older versions are known to have
bugs that seriously affect the stability of GIMP.
7. We use dbus-glib if available. Grab it from
http://dbus.freedesktop.org/releases/dbus-glib/
8. Access of remote files is implemented in the URI plug-in. There
7. Access of remote files is implemented in the URI plug-in. There
are several possible implementations for this. The implementation
used is determined when you configure GIMP. By default the
GIO/GVfs backend is used. If you don't have GVfs support on your
@ -68,27 +65,27 @@ header files installed.
configure. The configure script will then try to detect another
method for accessing remote files.
9. The file-compressor plug-in requires zlib, libbzip2, and liblzma to
8. The file-compressor plug-in requires zlib, libbzip2, and liblzma to
be installed. All these libraries are required dependencies.
10. You may want to install other third party libraries or programs
9. You may want to install other third party libraries or programs
that are needed for some of the available plug-ins. We recommend to
check that the following libraries are installed: lcms, libpng,
libjpeg, libpoppler, libtiff, webkit, libmng, librsvg, libwmf,
libgs (Ghostscript), libaa and libjasper.
11. The Python extension requires Python development headers to be
10. The Python extension requires Python development headers to be
present. You will also need PyGTK and the respective development
headers.
12. Configure GIMP by running the `configure' script. You may want
11. Configure GIMP by running the `configure' script. You may want
to pass some options to it, see below.
13. Build GIMP by running `make'. The use of GNU make is recommended.
12. Build GIMP by running `make'. The use of GNU make is recommended.
If you need to tweak the build to make it work with other flavours
of make, we'd appreciate if you'd send us a patch with the changes.
14. Install GIMP by running `make install'. In order to avoid clashes
13. Install GIMP by running `make install'. In order to avoid clashes
with other versions of GIMP, we install a binary called gimp-2.8.
By default there's also a link created so that you can type 'gimp'
to start gimp-2.8.
@ -204,9 +201,6 @@ These are:
--without-alsa. If you don't want to compile ALSA support into the
MIDI input controller module, you can use the --without-alsa option.
--without-dbus. If you want to build without D-Bus support, you can
pass --without-dbus to the configure script.
--without-linux-input. If you don't want to compile the Linux Input
controller module, you can use the --without-linux-input option.

3
app/gui/.gitignore vendored
View File

@ -3,6 +3,7 @@
/.deps
/.libs
/*.lo
/gimpdbusservice-glue.h
/gimpdbusservice-generated.c
/gimpdbusservice-generated.h
/libappgui.a
/libappgui.la

View File

@ -9,6 +9,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(GIO_UNIX_CFLAGS) \
$(GEGL_CFLAGS) \
$(GTK_CFLAGS) \
$(DBUS_GLIB_CFLAGS) \
@ -41,7 +42,9 @@ libappgui_a_sources = \
ige-mac-menu.c \
ige-mac-menu.h
libappgui_a_built_sources = gimpdbusservice-glue.h
libappgui_a_built_sources = \
gimpdbusservice-generated.c \
gimpdbusservice-generated.h
libappgui_a_SOURCES = $(libappgui_a_built_sources) $(libappgui_a_sources)
@ -52,10 +55,13 @@ EXTRA_DIST = \
# rules to generate built sources
#
# setup autogeneration dependencies
gen_sources = gimpdbusservice-glue.h
gen_sources = $(libappgui_a_built_sources)
CLEANFILES = $(gen_sources)
$(srcdir)/gimpdbusservice.c: gimpdbusservice-glue.h
$(srcdir)/gimpdbusservice.c: $(libappgui_a_built_sources)
gimpdbusservice-glue.h: $(srcdir)/dbus-service.xml
$(DBUS_BINDING_TOOL) --mode=glib-server --prefix=gimp $< > $(@F)
$(libappgui_a_built_sources): $(srcdir)/dbus-service.xml
$(GDBUS_CODEGEN) --interface-prefix org.gimp.GIMP. \
--generate-c-code gimpdbusservice-generated \
--c-namespace GimpDBusService \
$(srcdir)/dbus-service.xml

View File

@ -1,12 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/org/gimp/GIMP/UI">
<node>
<interface name="org.gimp.GIMP.UI">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="gimp_dbus_service" />
<method name="Open">
<arg type="s" name="uri" direction="in" />
<arg type="b" name="success" direction="out" />

View File

@ -3,6 +3,7 @@
*
* GimpDBusService
* Copyright (C) 2007, 2008 Sven Neumann <sven@gimp.org>
* Copyright (C) 2013 Michael Natterer <mitch@gimp.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
@ -20,11 +21,8 @@
#include "config.h"
#if HAVE_DBUS_GLIB
#include <gegl.h>
#include <gtk/gtk.h>
#include <dbus/dbus-glib.h>
#include "gui-types.h"
@ -37,15 +35,8 @@
#include "display/gimpdisplayshell.h"
#include "gimpdbusservice.h"
#include "gimpdbusservice-glue.h"
enum
{
OPENED,
LAST_SIGNAL
};
typedef struct
{
gchar *uri;
@ -53,53 +44,51 @@ typedef struct
} OpenData;
static void gimp_dbus_service_class_init (GimpDBusServiceClass *klass);
static void gimp_dbus_service_ui_iface_init (GimpDBusServiceUIIface *iface);
static void gimp_dbus_service_init (GimpDBusService *service);
static void gimp_dbus_service_dispose (GObject *object);
static void gimp_dbus_service_finalize (GObject *object);
static void gimp_dbus_service_dispose (GObject *object);
static void gimp_dbus_service_finalize (GObject *object);
static void gimp_dbus_service_gimp_opened (Gimp *gimp,
const gchar *uri,
GimpDBusService *service);
static gboolean gimp_dbus_service_activate (GimpDBusServiceUI *service,
GDBusMethodInvocation *invocation);
static gboolean gimp_dbus_service_open (GimpDBusServiceUI *service,
GDBusMethodInvocation *invocation,
const gchar *uri);
static gboolean gimp_dbus_service_queue_open (GimpDBusService *service,
const gchar *uri,
gboolean as_new);
static gboolean gimp_dbus_service_open_as_new (GimpDBusServiceUI *service,
GDBusMethodInvocation *invocation,
const gchar *uri);
static gboolean gimp_dbus_service_open_idle (GimpDBusService *service);
static OpenData * gimp_dbus_service_open_data_new (GimpDBusService *service,
const gchar *uri,
gboolean as_new);
static void gimp_dbus_service_open_data_free (OpenData *data);
static void gimp_dbus_service_gimp_opened (Gimp *gimp,
const gchar *uri,
GimpDBusService *service);
static gboolean gimp_dbus_service_queue_open (GimpDBusService *service,
const gchar *uri,
gboolean as_new);
static gboolean gimp_dbus_service_open_idle (GimpDBusService *service);
static OpenData * gimp_dbus_service_open_data_new (GimpDBusService *service,
const gchar *uri,
gboolean as_new);
static void gimp_dbus_service_open_data_free (OpenData *data);
G_DEFINE_TYPE (GimpDBusService, gimp_dbus_service, G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_CODE (GimpDBusService, gimp_dbus_service,
GIMP_DBUS_SERVICE_TYPE_UI_SKELETON,
G_IMPLEMENT_INTERFACE (GIMP_DBUS_SERVICE_TYPE_UI,
gimp_dbus_service_ui_iface_init))
#define parent_class gimp_dbus_service_parent_class
static guint gimp_dbus_service_signals[LAST_SIGNAL] = { 0 };
static void
gimp_dbus_service_class_init (GimpDBusServiceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
gimp_dbus_service_signals[OPENED] =
g_signal_new ("opened",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpDBusServiceClass, opened),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
object_class->dispose = gimp_dbus_service_dispose;
object_class->finalize = gimp_dbus_service_finalize;
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
&dbus_glib_gimp_object_info);
}
static void
@ -108,6 +97,14 @@ gimp_dbus_service_init (GimpDBusService *service)
service->queue = g_queue_new ();
}
static void
gimp_dbus_service_ui_iface_init (GimpDBusServiceUIIface *iface)
{
iface->handle_activate = gimp_dbus_service_activate;
iface->handle_open = gimp_dbus_service_open;
iface->handle_open_as_new = gimp_dbus_service_open_as_new;
}
GObject *
gimp_dbus_service_new (Gimp *gimp)
{
@ -160,53 +157,55 @@ gimp_dbus_service_finalize (GObject *object)
}
gboolean
gimp_dbus_service_open (GimpDBusService *service,
const gchar *uri,
gboolean *success,
GError **dbus_error)
gimp_dbus_service_activate (GimpDBusServiceUI *service,
GDBusMethodInvocation *invocation)
{
g_return_val_if_fail (GIMP_IS_DBUS_SERVICE (service), FALSE);
g_return_val_if_fail (uri != NULL, FALSE);
g_return_val_if_fail (success != NULL, FALSE);
*success = gimp_dbus_service_queue_open (service, uri, FALSE);
return TRUE;
}
gboolean
gimp_dbus_service_open_as_new (GimpDBusService *service,
const gchar *uri,
gboolean *success,
GError **dbus_error)
{
g_return_val_if_fail (GIMP_IS_DBUS_SERVICE (service), FALSE);
g_return_val_if_fail (uri != NULL, FALSE);
g_return_val_if_fail (success != NULL, FALSE);
*success = gimp_dbus_service_queue_open (service, uri, TRUE);
return TRUE;
}
gboolean
gimp_dbus_service_activate (GimpDBusService *service,
GError **dbus_error)
{
GimpObject *display;
g_return_val_if_fail (GIMP_IS_DBUS_SERVICE (service), FALSE);
Gimp *gimp = GIMP_DBUS_SERVICE (service)->gimp;
/* We want to be called again later in case that GIMP is not fully
* started yet.
*/
if (! gimp_is_restored (service->gimp))
return TRUE;
if (gimp_is_restored (gimp))
{
GimpObject *display;
display = gimp_container_get_first_child (service->gimp->displays);
display = gimp_container_get_first_child (gimp->displays);
if (display)
gimp_display_shell_present (gimp_display_get_shell (GIMP_DISPLAY (display)));
if (display)
gimp_display_shell_present (gimp_display_get_shell (GIMP_DISPLAY (display)));
}
gimp_dbus_service_ui_complete_activate (service, invocation);
return TRUE;
}
gboolean
gimp_dbus_service_open (GimpDBusServiceUI *service,
GDBusMethodInvocation *invocation,
const gchar *uri)
{
gboolean success;
success = gimp_dbus_service_queue_open (GIMP_DBUS_SERVICE (service),
uri, FALSE);
gimp_dbus_service_ui_complete_open (service, invocation, success);
return TRUE;
}
gboolean
gimp_dbus_service_open_as_new (GimpDBusServiceUI *service,
GDBusMethodInvocation *invocation,
const gchar *uri)
{
gboolean success;
success = gimp_dbus_service_queue_open (GIMP_DBUS_SERVICE (service),
uri, TRUE);
gimp_dbus_service_ui_complete_open_as_new (service, invocation, success);
return TRUE;
}
@ -216,7 +215,7 @@ gimp_dbus_service_gimp_opened (Gimp *gimp,
const gchar *uri,
GimpDBusService *service)
{
g_signal_emit (service, gimp_dbus_service_signals[OPENED], 0, uri);
g_signal_emit_by_name (service, "opened", uri);
}
/*
@ -297,6 +296,3 @@ gimp_dbus_service_open_data_free (OpenData *data)
g_free (data->uri);
g_slice_free (OpenData, data);
}
#endif /* HAVE_DBUS_GLIB */

View File

@ -3,6 +3,7 @@
*
* GimpDBusService
* Copyright (C) 2007, 2008 Sven Neumann <sven@gimp.org>
* Copyright (C) 2013 Michael Natterer <mitch@gimp.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
@ -21,12 +22,16 @@
#ifndef __GIMP_DBUS_SERVICE_H__
#define __GIMP_DBUS_SERVICE_H__
G_BEGIN_DECLS
#include "gimpdbusservice-generated.h"
#define GIMP_DBUS_SERVICE_NAME "org.gimp.GIMP.UI"
#define GIMP_DBUS_SERVICE_PATH "/org/gimp/GIMP/UI"
#define GIMP_DBUS_SERVICE_INTERFACE "org.gimp.GIMP.UI"
/* service name and path should really be org.gimp.GIMP and
* /org/gimp/GIMP and only the interface be called UI.
*/
#define GIMP_DBUS_SERVICE_NAME "org.gimp.GIMP.UI"
#define GIMP_DBUS_SERVICE_PATH "/org/gimp/GIMP/UI"
#define GIMP_DBUS_INTERFACE_NAME "org.gimp.GIMP.UI"
#define GIMP_DBUS_INTERFACE_PATH "/org/gimp/GIMP/UI"
#define GIMP_TYPE_DBUS_SERVICE (gimp_dbus_service_get_type ())
@ -42,7 +47,7 @@ typedef struct _GimpDBusServiceClass GimpDBusServiceClass;
struct _GimpDBusService
{
GObject parent_instance;
GimpDBusServiceUISkeleton parent_instance;
Gimp *gimp;
GQueue *queue;
@ -51,30 +56,13 @@ struct _GimpDBusService
struct _GimpDBusServiceClass
{
GObjectClass parent_class;
/* signals */
void (* opened) (GimpDBusService *service,
const gchar *uri);
GimpDBusServiceUISkeletonClass parent_class;
};
GType gimp_dbus_service_get_type (void) G_GNUC_CONST;
GType gimp_dbus_service_get_type (void) G_GNUC_CONST;
GObject * gimp_dbus_service_new (Gimp *gimp);
GObject * gimp_dbus_service_new (Gimp *gimp);
gboolean gimp_dbus_service_open (GimpDBusService *service,
const gchar *uri,
gboolean *success,
GError **dbus_error);
gboolean gimp_dbus_service_open_as_new (GimpDBusService *service,
const gchar *uri,
gboolean *success,
GError **dbus_error);
gboolean gimp_dbus_service_activate (GimpDBusService *service,
GError **dbus_error);
G_END_DECLS
#endif /* __GIMP_DBUS_SERVICE_H__ */

View File

@ -29,12 +29,6 @@
#include <sys/param.h>
#endif
#if HAVE_DBUS_GLIB
#define DBUS_API_SUBJECT_TO_CHANGE
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#endif
#include "gui/gui-types.h"
#include "core/gimp.h"
@ -48,27 +42,30 @@
#include "gui-unique.h"
#if HAVE_DBUS_GLIB
static void gui_dbus_service_init (Gimp *gimp);
static void gui_dbus_service_exit (void);
static DBusGConnection *dbus_connection = NULL;
#endif
#ifdef G_OS_WIN32
static void gui_unique_win32_init (Gimp *gimp);
static void gui_unique_win32_exit (void);
static Gimp *unique_gimp = NULL;
static HWND proxy_window = NULL;
#endif
static Gimp *unique_gimp = NULL;
static HWND proxy_window = NULL;
#elifdef GDK_WINDOWING_QUARTZ
#ifdef GDK_WINDOWING_QUARTZ
static void gui_unique_mac_init (Gimp *gimp);
static void gui_unique_mac_exit (void);
static Gimp *unique_gimp = NULL;
AEEventHandlerUPP open_document_callback_proc;
static Gimp *unique_gimp = NULL;
AEEventHandlerUPP open_document_callback_proc;
#else
static void gui_dbus_service_init (Gimp *gimp);
static void gui_dbus_service_exit (void);
static GDBusObjectManagerServer *dbus_manager = NULL;
static guint dbus_name_id = 0;
#endif
@ -77,12 +74,10 @@ gui_unique_init (Gimp *gimp)
{
#ifdef G_OS_WIN32
gui_unique_win32_init (gimp);
#elif HAVE_DBUS_GLIB
gui_dbus_service_init (gimp);
#endif
#ifdef GDK_WINDOWING_QUARTZ
#elifdef GDK_WINDOWING_QUARTZ
gui_unique_mac_init (gimp);
#else
gui_dbus_service_init (gimp);
#endif
}
@ -91,58 +86,14 @@ gui_unique_exit (void)
{
#ifdef G_OS_WIN32
gui_unique_win32_exit ();
#elif HAVE_DBUS_GLIB
#elifdef GDK_WINDOWING_QUARTZ
gui_unique_mac_exit ();
#else
gui_dbus_service_exit ();
#endif
#ifdef GDK_WINDOWING_QUARTZ
gui_unique_mac_exit ();
#endif
}
#if HAVE_DBUS_GLIB
static void
gui_dbus_service_init (Gimp *gimp)
{
GError *error = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (dbus_connection == NULL);
dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (dbus_connection)
{
GObject *service = gimp_dbus_service_new (gimp);
dbus_bus_request_name (dbus_g_connection_get_connection (dbus_connection),
GIMP_DBUS_SERVICE_NAME, 0, NULL);
dbus_g_connection_register_g_object (dbus_connection,
GIMP_DBUS_SERVICE_PATH, service);
}
else
{
g_printerr ("%s\n", error->message);
g_error_free (error);
}
}
static void
gui_dbus_service_exit (void)
{
if (dbus_connection)
{
dbus_g_connection_unref (dbus_connection);
dbus_connection = NULL;
}
}
#endif /* HAVE_DBUS_GLIB */
#ifdef G_OS_WIN32
typedef struct
@ -275,10 +226,7 @@ gui_unique_win32_exit (void)
DestroyWindow (proxy_window);
}
#endif /* G_OS_WIN32 */
#ifdef GDK_WINDOWING_QUARTZ
#elifdef GDK_WINDOWING_QUARTZ
static gboolean
gui_unique_mac_idle_open (gchar *data)
@ -379,4 +327,66 @@ gui_unique_mac_exit (void)
DisposeAEEventHandlerUPP(open_document_callback_proc);
}
#endif /* GDK_WINDOWING_QUARTZ */
#else
static void
gui_dbus_bus_acquired (GDBusConnection *connection,
const gchar *name,
Gimp *gimp)
{
GDBusObjectSkeleton *object;
GObject *service;
/* this should use GIMP_DBUS_SERVICE_PATH, but that's historically wrong */
dbus_manager = g_dbus_object_manager_server_new ("/org/gimp/GIMP");
object = g_dbus_object_skeleton_new (GIMP_DBUS_INTERFACE_PATH);
service = gimp_dbus_service_new (gimp);
g_dbus_object_skeleton_add_interface (object,
G_DBUS_INTERFACE_SKELETON (service));
g_object_unref (service);
g_dbus_object_manager_server_export (dbus_manager, object);
g_object_unref (object);
g_dbus_object_manager_server_set_connection (dbus_manager, connection);
}
static void
gui_dbus_name_acquired (GDBusConnection *connection,
const gchar *name,
Gimp *gimp)
{
}
static void
gui_dbus_name_lost (GDBusConnection *connection,
const gchar *name,
Gimp *gimp)
{
}
static void
gui_dbus_service_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (dbus_name_id == 0);
dbus_name_id = g_bus_own_name (G_BUS_TYPE_SESSION,
GIMP_DBUS_SERVICE_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
(GBusAcquiredCallback) gui_dbus_bus_acquired,
(GBusNameAcquiredCallback) gui_dbus_name_acquired,
(GBusNameLostCallback) gui_dbus_name_lost,
gimp, NULL);
}
static void
gui_dbus_service_exit (void)
{
g_bus_unown_name (dbus_name_id);
g_object_unref (dbus_manager);
}
#endif

View File

@ -118,7 +118,7 @@ gimp_unique_dbus_open (const gchar **filenames,
result = g_dbus_connection_call_sync (connection,
GIMP_DBUS_SERVICE_NAME,
GIMP_DBUS_SERVICE_PATH,
GIMP_DBUS_SERVICE_INTERFACE,
GIMP_DBUS_INTERFACE_NAME,
method,
g_variant_new ("(s)",
uri),
@ -149,7 +149,7 @@ gimp_unique_dbus_open (const gchar **filenames,
result = g_dbus_connection_call_sync (connection,
GIMP_DBUS_SERVICE_NAME,
GIMP_DBUS_SERVICE_PATH,
GIMP_DBUS_SERVICE_INTERFACE,
GIMP_DBUS_INTERFACE_NAME,
"Activate",
NULL,
NULL,

View File

@ -58,7 +58,6 @@ m4_define([wmf_required_version], [0.2.8])
m4_define([pygtk_required_version], [2.10.4])
m4_define([poppler_required_version], [0.12.4])
m4_define([libcurl_required_version], [7.15.1])
m4_define([dbus_glib_required_version], [0.70])
m4_define([libgudev_required_version], [167])
m4_define([exif_required_version], [0.6.15])
m4_define([lcms_required_version], [2.2])
@ -496,6 +495,15 @@ PKG_CHECK_MODULES(GMODULE_NO_EXPORT, gmodule-no-export-2.0)
PKG_CHECK_MODULES(GIO, gio-2.0)
if test "$os_win32" != "yes"; then
PKG_CHECK_MODULES(GIO_UNIX, gio-unix-2.0)
fi
AC_PATH_PROG(GDBUS_CODEGEN, gdbus-codegen, no)
if test "x$GDBUS_CODEGEN" = xno; then
AC_MSG_ERROR([Could not find gdbus-codegen in your PATH])
fi
AC_MSG_CHECKING([if GLib is version 2.31.0 or newer])
if $PKG_CONFIG --atleast-version=2.31.0 glib-2.0; then
have_glib_2_31=yes
@ -1694,35 +1702,6 @@ fi
AM_CONDITIONAL(HAVE_DX_DINPUT, test "x$have_dx_dinput" = xyes)
###############################
# Check for D-Bus GLib bindings
###############################
AC_ARG_WITH(dbus, [ --without-dbus build without D-Bus support])
have_dbus_glib="no (disabled)"
if test "x$with_dbus" != xno; then
PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 >= dbus_glib_required_version,
have_dbus_glib=yes,
have_dbus_glib=no)
fi
if test "x$have_dbus_glib" = xyes; then
AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no)
if test "x$DBUS_BINDING_TOOL" = xno; then
AC_MSG_WARN([Could not find dbus-binding-tool in your PATH])
have_dbus_glib="no (dbus-binding-tool not found)"
fi
fi
if test "x$have_dbus_glib" = xyes; then
AC_DEFINE(HAVE_DBUS_GLIB, 1,
[Define to 1 if D-Bus GLib bindings are available])
GIMP_COMMAND='gimp-gimp_app_version'
fi
####################
# Check for libgudev
####################