diff --git a/installer/gpick.wxs b/installer/gpick.wxs index 172092c..5c6cc8b 100644 --- a/installer/gpick.wxs +++ b/installer/gpick.wxs @@ -168,8 +168,8 @@ - - + + diff --git a/source/dbus/Control.cpp b/source/dbus/Control.cpp index 0975d35..a5402c2 100644 --- a/source/dbus/Control.cpp +++ b/source/dbus/Control.cpp @@ -16,131 +16,208 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "Control.h" +#ifndef WIN32 #include "DbusInterface.h" - #include using namespace std; -static GDBusObjectManagerServer *manager = nullptr; - -typedef struct DbusInterface { - bool (*on_control_activate_floating_picker)(void *userdata); - bool (*on_single_instance_activate)(void *userdata); - void *userdata; -}DbusInterface; - -static DbusInterface dbus_interface; - -static gboolean on_control_activate_floating_picker(GpickControl *control, GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusInterface *dbus_interface = reinterpret_cast(user_data); - bool result = dbus_interface->on_control_activate_floating_picker(dbus_interface->userdata); - gpick_control_complete_activate_floating_picker(control, invocation); - return result; -} - -static gboolean on_single_instance_activate(GpickSingleInstance *single_instance, GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusInterface *dbus_interface = reinterpret_cast(user_data); - bool result = dbus_interface->on_single_instance_activate(dbus_interface->userdata); - gpick_single_instance_complete_activate(single_instance, invocation); - return result; -} - -static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) +namespace dbus { - GpickObjectSkeleton *object; - manager = g_dbus_object_manager_server_new ("/gpick"); - - GpickControl *control; - object = gpick_object_skeleton_new("/gpick/Control"); - control = gpick_control_skeleton_new(); - gpick_object_skeleton_set_control(object, control); - g_object_unref(control); - - g_signal_connect(control, "handle-activate-floating-picker", G_CALLBACK(on_control_activate_floating_picker), user_data); - g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object)); - g_object_unref(object); - - GpickSingleInstance *single_instance; - object = gpick_object_skeleton_new("/gpick/SingleInstance"); - single_instance = gpick_single_instance_skeleton_new(); - gpick_object_skeleton_set_single_instance(object, single_instance); - g_object_unref(single_instance); - - g_signal_connect(single_instance, "handle-activate", G_CALLBACK(on_single_instance_activate), user_data); - g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object)); - g_object_unref(object); - - g_dbus_object_manager_server_set_connection(manager, connection); -} - -static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) -{ -} - -static void on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data) -{ -} - -guint gpick_own_name(bool (*on_control_activate_floating_picker)(void *userdata), bool (*on_single_instance_activate)(void *userdata), void *userdata) -{ - dbus_interface.on_control_activate_floating_picker = on_control_activate_floating_picker; - dbus_interface.on_single_instance_activate = on_single_instance_activate; - dbus_interface.userdata = userdata; - return g_bus_own_name(G_BUS_TYPE_SESSION, "com.google.code.gpick", GBusNameOwnerFlags(G_BUS_NAME_OWNER_FLAGS_REPLACE), on_bus_acquired, on_name_acquired, on_name_lost, &dbus_interface, nullptr); -} - -void gpick_unown_name(guint bus_id) -{ - g_bus_unown_name(bus_id); -} - -GDBusObjectManager* gpick_get_manager() -{ - GDBusObjectManager *manager; - GError *error = nullptr; - manager = gpick_object_manager_client_new_for_bus_sync(G_BUS_TYPE_SESSION, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, "com.google.code.gpick", "/gpick", nullptr, &error); - if (manager == nullptr) { - cerr << "Error getting object manager client: " << error->message << endl; - g_error_free (error); - return 0; + class Control::Impl + { + public: + Control *m_decl; + GDBusObjectManagerServer *m_manager; + guint m_bus_id; + Impl(Control *decl): + m_decl(decl), + m_manager(nullptr), + m_bus_id(0) + { + } + void ownName() + { + m_bus_id = g_bus_own_name(G_BUS_TYPE_SESSION, "org.gpick", GBusNameOwnerFlags(G_BUS_NAME_OWNER_FLAGS_REPLACE), (GBusAcquiredCallback)on_bus_acquired, (GBusNameAcquiredCallback)on_name_acquired, (GBusNameLostCallback)on_name_lost, this, nullptr); + } + void unownName() + { + g_bus_unown_name(m_bus_id); + m_bus_id = 0; + } + GDBusObjectManager* getManager() + { + GDBusObjectManager *manager; + GError *error = nullptr; + manager = gpick_object_manager_client_new_for_bus_sync(G_BUS_TYPE_SESSION, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, "org.gpick", "/org/gpick", nullptr, &error); + if (manager == nullptr) { + cerr << "Error getting object manager client: " << error->message << endl; + g_error_free (error); + return 0; + } + return manager; + } + bool activateFloatingPicker() + { + GDBusObjectManager *manager = getManager(); + if (!manager) return false; + GError *error = nullptr; + GDBusInterface *interface = g_dbus_object_manager_get_interface(manager, "/org/gpick/Control", "org.gpick.Control"); + bool result = false; + if (interface){ + if (!gpick_control_call_activate_floating_picker_sync(GPICK_CONTROL(interface), nullptr, &error)){ + cerr << "Error calling \"Control.ActivateFloatingPicker\": " << error->message << endl; + g_error_free (error); + }else result = true; + g_object_unref(interface); + } + g_object_unref(manager); + return result; + } + bool checkIfRunning() + { + GDBusObjectManager *manager = getManager(); + if (!manager) return false; + GError *error = nullptr; + GDBusInterface *interface = g_dbus_object_manager_get_interface(manager, "/org/gpick/Control", "org.gpick.Control"); + bool result = false; + if (interface){ + if (!gpick_control_call_check_if_running_sync(GPICK_CONTROL(interface), nullptr, &error)){ + cerr << "Error calling \"Control.CheckIfRunning\": " << error->message << endl; + g_error_free (error); + }else result = true; + g_object_unref(interface); + } + g_object_unref(manager); + return result; + } + bool singleInstanceActivate() + { + GDBusObjectManager *manager = getManager(); + if (!manager) return false; + GError *error = nullptr; + GDBusInterface *interface = g_dbus_object_manager_get_interface(manager, "/org/gpick/SingleInstance", "org.gpick.SingleInstance"); + bool result = false; + if (interface){ + if (!gpick_single_instance_call_activate_sync(GPICK_SINGLE_INSTANCE(interface), nullptr, &error)){ + cerr << "Error calling \"SingleInstance.Activate\": " << error->message << endl; + g_error_free (error); + }else result = true; + g_object_unref(interface); + } + g_object_unref(manager); + return result; + } + static gboolean on_control_activate_floating_picker(GpickControl *control, GDBusMethodInvocation *invocation, Impl *impl) + { + bool result = impl->m_decl->onActivateFloatingPicker(); + gpick_control_complete_activate_floating_picker(control, invocation); + return result; + } + static gboolean on_control_check_if_running(GpickControl *control, GDBusMethodInvocation *invocation, Impl*) + { + gpick_control_complete_activate_floating_picker(control, invocation); + return true; + } + static gboolean on_single_instance_activate(GpickSingleInstance *single_instance, GDBusMethodInvocation *invocation, Impl *impl) + { + bool result = impl->m_decl->onSingleInstanceActivate(); + gpick_single_instance_complete_activate(single_instance, invocation); + return result; + } + static void on_bus_acquired(GDBusConnection *connection, const gchar *name, Impl *impl) + { + auto manager = g_dbus_object_manager_server_new("/org/gpick"); + impl->m_manager = manager; + + GpickObjectSkeleton *object; + object = gpick_object_skeleton_new("/org/gpick/Control"); + GpickControl *control; + control = gpick_control_skeleton_new(); + gpick_object_skeleton_set_control(object, control); + g_object_unref(control); + + g_signal_connect(control, "handle-activate-floating-picker", G_CALLBACK(on_control_activate_floating_picker), impl); + g_signal_connect(control, "handle-check-if-running", G_CALLBACK(on_control_check_if_running), impl); + g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object)); + g_object_unref(object); + + GpickSingleInstance *single_instance; + object = gpick_object_skeleton_new("/org/gpick/SingleInstance"); + single_instance = gpick_single_instance_skeleton_new(); + gpick_object_skeleton_set_single_instance(object, single_instance); + g_object_unref(single_instance); + + g_signal_connect(single_instance, "handle-activate", G_CALLBACK(on_single_instance_activate), impl); + g_dbus_object_manager_server_export(manager, G_DBUS_OBJECT_SKELETON(object)); + g_object_unref(object); + + g_dbus_object_manager_server_set_connection(manager, connection); + } + static void on_name_acquired(GDBusConnection *connection, const gchar *name, Impl*) + { + } + static void on_name_lost(GDBusConnection *connection, const gchar *name, Impl*) + { + }; + }; + Control::Control() + { + m_impl = make_unique(this); } - return manager; -} - -bool gpick_control_activate_floating_picker() -{ - GDBusObjectManager *manager = gpick_get_manager(); - if (!manager) return false; - GError *error = nullptr; - GDBusInterface *interface = g_dbus_object_manager_get_interface(manager, "/gpick/Control", "com.google.code.gpick.Control"); - bool result = false; - if (interface){ - if (!gpick_control_call_activate_floating_picker_sync(GPICK_CONTROL(interface), nullptr, &error)){ - cerr << "Error calling \"Control.ActivateFloatingPicker\": " << error->message << endl; - g_error_free (error); - }else result = true; - g_object_unref(interface); + Control::~Control() + { + } + void Control::ownName() + { + m_impl->ownName(); + } + void Control::unownName() + { + m_impl->unownName(); + } + bool Control::singleInstanceActivate() + { + return m_impl->singleInstanceActivate(); + } + bool Control::activateFloatingPicker() + { + return m_impl->activateFloatingPicker(); + } + bool Control::checkIfRunning() + { + return m_impl->checkIfRunning(); } - g_object_unref(manager); - return result; } - -bool gpick_single_instance_activate() +#else +namespace dbus { - GDBusObjectManager *manager = gpick_get_manager(); - if (!manager) return false; - GError *error = nullptr; - GDBusInterface *interface = g_dbus_object_manager_get_interface(manager, "/gpick/SingleInstance", "com.google.code.gpick.SingleInstance"); - bool result = false; - if (interface){ - if (!gpick_single_instance_call_activate_sync(GPICK_SINGLE_INSTANCE(interface), nullptr, &error)){ - cerr << "Error calling \"SingleInstance.Activate\": " << error->message << endl; - g_error_free (error); - }else result = true; - g_object_unref(interface); + class Control::Impl + { + }; + Control::Control() + { + } + Control::~Control() + { + } + void Control::ownName() + { + } + void Control::unownName() + { + } + bool Control::singleInstanceActivate() + { + return false; + } + bool Control::activateFloatingPicker() + { + return false; + } + bool Control::checkIfRunning() + { + return false; } - g_object_unref(manager); - return result; } +#endif diff --git a/source/dbus/Control.h b/source/dbus/Control.h index 92f4b6e..5b28bb5 100644 --- a/source/dbus/Control.h +++ b/source/dbus/Control.h @@ -16,33 +16,29 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef UI_DBUS_CONTROL_H_ -#define UI_DBUS_CONTROL_H_ - -#include - -/** \file source/dbus/Control.h - * \brief D-Bus interface and functions. - */ - -/** - * Try to get ownership of a bus. - */ -guint gpick_own_name(bool (*on_control_activate_floating_picker)(void *userdata), bool (*on_single_instance_activate)(void *userdata), void *userdata); - -/** - * Release ownership of a bus. - */ -void gpick_unown_name(guint bus_id); - -/** - * Activate main window in a remove Gpick instance. - */ -bool gpick_single_instance_activate(); - -/** - * Activate floating color picker in a remote Gpick instance. - */ -bool gpick_control_activate_floating_picker(); - -#endif /* UI_DBUS_CONTROL_H_ */ +#ifndef GPICK_DBUS_CONTROL_H_ +#define GPICK_DBUS_CONTROL_H_ + +#include +#include +namespace dbus +{ + class Control + { + public: + Control(); + ~Control(); + void ownName(); + void unownName(); + bool singleInstanceActivate(); + bool activateFloatingPicker(); + bool checkIfRunning(); + std::function onActivateFloatingPicker; + std::function onSingleInstanceActivate; + private: + class Impl; + std::unique_ptr m_impl; + }; +} + +#endif /* GPICK_DBUS_CONTROL_H_ */ diff --git a/source/dbus/DbusInterface.c b/source/dbus/DbusInterface.c index 0c78518..8815c65 100644 --- a/source/dbus/DbusInterface.c +++ b/source/dbus/DbusInterface.c @@ -1,5 +1,5 @@ /* - * Generated by gdbus-codegen 2.32.3. DO NOT EDIT. + * Generated by gdbus-codegen 2.48.0. DO NOT EDIT. * * The license of this code is the same as for the source it was derived from. */ @@ -10,6 +10,7 @@ #include "DbusInterface.h" +#include #ifdef G_OS_UNIX # include #endif @@ -124,7 +125,12 @@ _g_value_equal (const GValue *a, const GValue *b) ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b)); break; case G_TYPE_DOUBLE: - ret = (g_value_get_double (a) == g_value_get_double (b)); + { + /* Avoid -Wfloat-equal warnings by doing a direct bit compare */ + gdouble da = g_value_get_double (a); + gdouble db = g_value_get_double (b); + ret = memcmp (&da, &db, sizeof (gdouble)) == 0; + } break; case G_TYPE_STRING: ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0); @@ -143,25 +149,25 @@ _g_value_equal (const GValue *a, const GValue *b) } /* ------------------------------------------------------------------------ - * Code for interface com.google.code.gpick.SingleInstance + * Code for interface org.gpick.SingleInstance * ------------------------------------------------------------------------ */ /** * SECTION:GpickSingleInstance * @title: GpickSingleInstance - * @short_description: Generated C code for the com.google.code.gpick.SingleInstance D-Bus interface + * @short_description: Generated C code for the org.gpick.SingleInstance D-Bus interface * - * This section contains code for working with the com.google.code.gpick.SingleInstance D-Bus interface in C. + * This section contains code for working with the org.gpick.SingleInstance D-Bus interface in C. */ -/* ---- Introspection data for com.google.code.gpick.SingleInstance ---- */ +/* ---- Introspection data for org.gpick.SingleInstance ---- */ static const _ExtendedGDBusMethodInfo _gpick_single_instance_method_info_activate = { { -1, - "Activate", + (gchar *) "Activate", NULL, NULL, NULL @@ -180,7 +186,7 @@ static const _ExtendedGDBusInterfaceInfo _gpick_single_instance_interface_info = { { -1, - "com.google.code.gpick.SingleInstance", + (gchar *) "org.gpick.SingleInstance", (GDBusMethodInfo **) &_gpick_single_instance_method_info_pointers, NULL, NULL, @@ -193,14 +199,14 @@ static const _ExtendedGDBusInterfaceInfo _gpick_single_instance_interface_info = /** * gpick_single_instance_interface_info: * - * Gets a machine-readable description of the com.google.code.gpick.SingleInstance D-Bus interface. + * Gets a machine-readable description of the org.gpick.SingleInstance D-Bus interface. * * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free. */ GDBusInterfaceInfo * gpick_single_instance_interface_info (void) { - return (GDBusInterfaceInfo *) &_gpick_single_instance_interface_info; + return (GDBusInterfaceInfo *) &_gpick_single_instance_interface_info.parent_struct; } /** @@ -224,7 +230,7 @@ gpick_single_instance_override_properties (GObjectClass *klass, guint property_i /** * GpickSingleInstance: * - * Abstract interface type for the D-Bus interface com.google.code.gpick.SingleInstance. + * Abstract interface type for the D-Bus interface org.gpick.SingleInstance. */ /** @@ -232,9 +238,12 @@ gpick_single_instance_override_properties (GObjectClass *klass, guint property_i * @parent_iface: The parent interface. * @handle_activate: Handler for the #GpickSingleInstance::handle-activate signal. * - * Virtual table for the D-Bus interface com.google.code.gpick.SingleInstance. + * Virtual table for the D-Bus interface org.gpick.SingleInstance. */ +typedef GpickSingleInstanceIface GpickSingleInstanceInterface; +G_DEFINE_INTERFACE (GpickSingleInstance, gpick_single_instance, G_TYPE_OBJECT); + static void gpick_single_instance_default_init (GpickSingleInstanceIface *iface) { @@ -244,7 +253,7 @@ gpick_single_instance_default_init (GpickSingleInstanceIface *iface) * @object: A #GpickSingleInstance. * @invocation: A #GDBusMethodInvocation. * - * Signal emitted when a remote caller is invoking the Activate() D-Bus method. + * Signal emitted when a remote caller is invoking the Activate() D-Bus method. * * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call gpick_single_instance_complete_activate() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned. * @@ -263,9 +272,6 @@ gpick_single_instance_default_init (GpickSingleInstanceIface *iface) } -typedef GpickSingleInstanceIface GpickSingleInstanceInterface; -G_DEFINE_INTERFACE (GpickSingleInstance, gpick_single_instance, G_TYPE_OBJECT); - /** * gpick_single_instance_call_activate: * @proxy: A #GpickSingleInstanceProxy. @@ -273,7 +279,7 @@ G_DEFINE_INTERFACE (GpickSingleInstance, gpick_single_instance, G_TYPE_OBJECT); * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. * @user_data: User data to pass to @callback. * - * Asynchronously invokes the Activate() D-Bus method on @proxy. + * Asynchronously invokes the Activate() D-Bus method on @proxy. * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. * You can then call gpick_single_instance_call_activate_finish() to get the result of the operation. * @@ -329,7 +335,7 @@ gpick_single_instance_call_activate_finish ( * @cancellable: (allow-none): A #GCancellable or %NULL. * @error: Return location for error or %NULL. * - * Synchronously invokes the Activate() D-Bus method on @proxy. The calling thread is blocked until a reply is received. + * Synchronously invokes the Activate() D-Bus method on @proxy. The calling thread is blocked until a reply is received. * * See gpick_single_instance_call_activate() for the asynchronous version of this method. * @@ -363,7 +369,7 @@ gpick_single_instance_call_activate_sync ( * @object: A #GpickSingleInstance. * @invocation: (transfer full): A #GDBusMethodInvocation. * - * Helper function used in service implementations to finish handling invocations of the Activate() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. + * Helper function used in service implementations to finish handling invocations of the Activate() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. * * This method will free @invocation, you cannot use it afterwards. */ @@ -398,9 +404,16 @@ struct _GpickSingleInstanceProxyPrivate static void gpick_single_instance_proxy_iface_init (GpickSingleInstanceIface *iface); +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 +G_DEFINE_TYPE_WITH_CODE (GpickSingleInstanceProxy, gpick_single_instance_proxy, G_TYPE_DBUS_PROXY, + G_ADD_PRIVATE (GpickSingleInstanceProxy) + G_IMPLEMENT_INTERFACE (GPICK_TYPE_SINGLE_INSTANCE, gpick_single_instance_proxy_iface_init)); + +#else G_DEFINE_TYPE_WITH_CODE (GpickSingleInstanceProxy, gpick_single_instance_proxy, G_TYPE_DBUS_PROXY, G_IMPLEMENT_INTERFACE (GPICK_TYPE_SINGLE_INSTANCE, gpick_single_instance_proxy_iface_init)); +#endif static void gpick_single_instance_proxy_finalize (GObject *object) { @@ -413,7 +426,7 @@ static void gpick_single_instance_proxy_get_property (GObject *object, guint prop_id, GValue *value, - GParamSpec *pspec) + GParamSpec *pspec G_GNUC_UNUSED) { } @@ -421,13 +434,13 @@ static void gpick_single_instance_proxy_set_property (GObject *object, guint prop_id, const GValue *value, - GParamSpec *pspec) + GParamSpec *pspec G_GNUC_UNUSED) { } static void gpick_single_instance_proxy_g_signal (GDBusProxy *proxy, - const gchar *sender_name, + const gchar *sender_name G_GNUC_UNUSED, const gchar *signal_name, GVariant *parameters) { @@ -438,7 +451,7 @@ gpick_single_instance_proxy_g_signal (GDBusProxy *proxy, guint num_params; guint n; guint signal_id; - info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info, signal_name); + info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info.parent_struct, signal_name); if (info == NULL) return; num_params = g_variant_n_children (parameters); @@ -480,7 +493,7 @@ gpick_single_instance_proxy_g_properties_changed (GDBusProxy *_proxy, g_variant_get (changed_properties, "a{sv}", &iter); while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { - info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info, key); + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info.parent_struct, key); g_datalist_remove_data (&proxy->priv->qdata, key); if (info != NULL) g_object_notify (G_OBJECT (proxy), info->hyphen_name); @@ -488,7 +501,7 @@ gpick_single_instance_proxy_g_properties_changed (GDBusProxy *_proxy, g_variant_iter_free (iter); for (n = 0; invalidated_properties[n] != NULL; n++) { - info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info, invalidated_properties[n]); + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info.parent_struct, invalidated_properties[n]); g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]); if (info != NULL) g_object_notify (G_OBJECT (proxy), info->hyphen_name); @@ -498,7 +511,12 @@ gpick_single_instance_proxy_g_properties_changed (GDBusProxy *_proxy, static void gpick_single_instance_proxy_init (GpickSingleInstanceProxy *proxy) { +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 + proxy->priv = gpick_single_instance_proxy_get_instance_private (proxy); +#else proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, GPICK_TYPE_SINGLE_INSTANCE_PROXY, GpickSingleInstanceProxyPrivate); +#endif + g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), gpick_single_instance_interface_info ()); } @@ -508,8 +526,6 @@ gpick_single_instance_proxy_class_init (GpickSingleInstanceProxyClass *klass) GObjectClass *gobject_class; GDBusProxyClass *proxy_class; - g_type_class_add_private (klass, sizeof (GpickSingleInstanceProxyPrivate)); - gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = gpick_single_instance_proxy_finalize; gobject_class->get_property = gpick_single_instance_proxy_get_property; @@ -519,6 +535,9 @@ gpick_single_instance_proxy_class_init (GpickSingleInstanceProxyClass *klass) proxy_class->g_signal = gpick_single_instance_proxy_g_signal; proxy_class->g_properties_changed = gpick_single_instance_proxy_g_properties_changed; +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 + g_type_class_add_private (klass, sizeof (GpickSingleInstanceProxyPrivate)); +#endif } static void @@ -536,7 +555,7 @@ gpick_single_instance_proxy_iface_init (GpickSingleInstanceIface *iface) * @callback: A #GAsyncReadyCallback to call when the request is satisfied. * @user_data: User data to pass to @callback. * - * Asynchronously creates a proxy for the D-Bus interface com.google.code.gpick.SingleInstance. See g_dbus_proxy_new() for more details. + * Asynchronously creates a proxy for the D-Bus interface org.gpick.SingleInstance. See g_dbus_proxy_new() for more details. * * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. * You can then call gpick_single_instance_proxy_new_finish() to get the result of the operation. @@ -553,7 +572,7 @@ gpick_single_instance_proxy_new ( GAsyncReadyCallback callback, gpointer user_data) { - g_async_initable_new_async (GPICK_TYPE_SINGLE_INSTANCE_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.SingleInstance", NULL); + g_async_initable_new_async (GPICK_TYPE_SINGLE_INSTANCE_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.gpick.SingleInstance", NULL); } /** @@ -590,7 +609,7 @@ gpick_single_instance_proxy_new_finish ( * @cancellable: (allow-none): A #GCancellable or %NULL. * @error: Return location for error or %NULL * - * Synchronously creates a proxy for the D-Bus interface com.google.code.gpick.SingleInstance. See g_dbus_proxy_new_sync() for more details. + * Synchronously creates a proxy for the D-Bus interface org.gpick.SingleInstance. See g_dbus_proxy_new_sync() for more details. * * The calling thread is blocked until a reply is received. * @@ -608,7 +627,7 @@ gpick_single_instance_proxy_new_sync ( GError **error) { GInitable *ret; - ret = g_initable_new (GPICK_TYPE_SINGLE_INSTANCE_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.SingleInstance", NULL); + ret = g_initable_new (GPICK_TYPE_SINGLE_INSTANCE_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.gpick.SingleInstance", NULL); if (ret != NULL) return GPICK_SINGLE_INSTANCE (ret); else @@ -643,7 +662,7 @@ gpick_single_instance_proxy_new_for_bus ( GAsyncReadyCallback callback, gpointer user_data) { - g_async_initable_new_async (GPICK_TYPE_SINGLE_INSTANCE_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.SingleInstance", NULL); + g_async_initable_new_async (GPICK_TYPE_SINGLE_INSTANCE_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.gpick.SingleInstance", NULL); } /** @@ -698,7 +717,7 @@ gpick_single_instance_proxy_new_for_bus_sync ( GError **error) { GInitable *ret; - ret = g_initable_new (GPICK_TYPE_SINGLE_INSTANCE_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.SingleInstance", NULL); + ret = g_initable_new (GPICK_TYPE_SINGLE_INSTANCE_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.gpick.SingleInstance", NULL); if (ret != NULL) return GPICK_SINGLE_INSTANCE (ret); else @@ -732,9 +751,9 @@ struct _GpickSingleInstanceSkeletonPrivate static void _gpick_single_instance_skeleton_handle_method_call ( - GDBusConnection *connection, - const gchar *sender, - const gchar *object_path, + GDBusConnection *connection G_GNUC_UNUSED, + const gchar *sender G_GNUC_UNUSED, + const gchar *object_path G_GNUC_UNUSED, const gchar *interface_name, const gchar *method_name, GVariant *parameters, @@ -796,10 +815,10 @@ _gpick_single_instance_skeleton_handle_method_call ( static GVariant * _gpick_single_instance_skeleton_handle_get_property ( - GDBusConnection *connection, - const gchar *sender, - const gchar *object_path, - const gchar *interface_name, + GDBusConnection *connection G_GNUC_UNUSED, + const gchar *sender G_GNUC_UNUSED, + const gchar *object_path G_GNUC_UNUSED, + const gchar *interface_name G_GNUC_UNUSED, const gchar *property_name, GError **error, gpointer user_data) @@ -810,7 +829,7 @@ _gpick_single_instance_skeleton_handle_get_property ( _ExtendedGDBusPropertyInfo *info; GVariant *ret; ret = NULL; - info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info, property_name); + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info.parent_struct, property_name); g_assert (info != NULL); pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); if (pspec == NULL) @@ -829,10 +848,10 @@ _gpick_single_instance_skeleton_handle_get_property ( static gboolean _gpick_single_instance_skeleton_handle_set_property ( - GDBusConnection *connection, - const gchar *sender, - const gchar *object_path, - const gchar *interface_name, + GDBusConnection *connection G_GNUC_UNUSED, + const gchar *sender G_GNUC_UNUSED, + const gchar *object_path G_GNUC_UNUSED, + const gchar *interface_name G_GNUC_UNUSED, const gchar *property_name, GVariant *variant, GError **error, @@ -844,7 +863,7 @@ _gpick_single_instance_skeleton_handle_set_property ( _ExtendedGDBusPropertyInfo *info; gboolean ret; ret = FALSE; - info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info, property_name); + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_single_instance_interface_info.parent_struct, property_name); g_assert (info != NULL); pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); if (pspec == NULL) @@ -868,17 +887,18 @@ static const GDBusInterfaceVTable _gpick_single_instance_skeleton_vtable = { _gpick_single_instance_skeleton_handle_method_call, _gpick_single_instance_skeleton_handle_get_property, - _gpick_single_instance_skeleton_handle_set_property + _gpick_single_instance_skeleton_handle_set_property, + {NULL} }; static GDBusInterfaceInfo * -gpick_single_instance_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton) +gpick_single_instance_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) { return gpick_single_instance_interface_info (); } static GDBusInterfaceVTable * -gpick_single_instance_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton) +gpick_single_instance_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) { return (GDBusInterfaceVTable *) &_gpick_single_instance_skeleton_vtable; } @@ -899,7 +919,7 @@ gpick_single_instance_skeleton_dbus_interface_get_properties (GDBusInterfaceSkel if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) { GVariant *value; - value = _gpick_single_instance_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "com.google.code.gpick.SingleInstance", info->name, NULL, skeleton); + value = _gpick_single_instance_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.gpick.SingleInstance", info->name, NULL, skeleton); if (value != NULL) { g_variant_take_ref (value); @@ -918,9 +938,16 @@ gpick_single_instance_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_sk } static void gpick_single_instance_skeleton_iface_init (GpickSingleInstanceIface *iface); +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 G_DEFINE_TYPE_WITH_CODE (GpickSingleInstanceSkeleton, gpick_single_instance_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, + G_ADD_PRIVATE (GpickSingleInstanceSkeleton) G_IMPLEMENT_INTERFACE (GPICK_TYPE_SINGLE_INSTANCE, gpick_single_instance_skeleton_iface_init)); +#else +G_DEFINE_TYPE_WITH_CODE (GpickSingleInstanceSkeleton, gpick_single_instance_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, + G_IMPLEMENT_INTERFACE (GPICK_TYPE_SINGLE_INSTANCE, gpick_single_instance_skeleton_iface_init)); + +#endif static void gpick_single_instance_skeleton_finalize (GObject *object) { @@ -936,7 +963,12 @@ gpick_single_instance_skeleton_finalize (GObject *object) static void gpick_single_instance_skeleton_init (GpickSingleInstanceSkeleton *skeleton) { +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 + skeleton->priv = gpick_single_instance_skeleton_get_instance_private (skeleton); +#else skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, GPICK_TYPE_SINGLE_INSTANCE_SKELETON, GpickSingleInstanceSkeletonPrivate); +#endif + g_mutex_init (&skeleton->priv->lock); skeleton->priv->context = g_main_context_ref_thread_default (); } @@ -947,8 +979,6 @@ gpick_single_instance_skeleton_class_init (GpickSingleInstanceSkeletonClass *kla GObjectClass *gobject_class; GDBusInterfaceSkeletonClass *skeleton_class; - g_type_class_add_private (klass, sizeof (GpickSingleInstanceSkeletonPrivate)); - gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = gpick_single_instance_skeleton_finalize; @@ -957,6 +987,10 @@ gpick_single_instance_skeleton_class_init (GpickSingleInstanceSkeletonClass *kla skeleton_class->get_properties = gpick_single_instance_skeleton_dbus_interface_get_properties; skeleton_class->flush = gpick_single_instance_skeleton_dbus_interface_flush; skeleton_class->get_vtable = gpick_single_instance_skeleton_dbus_interface_get_vtable; + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 + g_type_class_add_private (klass, sizeof (GpickSingleInstanceSkeletonPrivate)); +#endif } static void @@ -967,7 +1001,7 @@ gpick_single_instance_skeleton_iface_init (GpickSingleInstanceIface *iface) /** * gpick_single_instance_skeleton_new: * - * Creates a skeleton object for the D-Bus interface com.google.code.gpick.SingleInstance. + * Creates a skeleton object for the D-Bus interface org.gpick.SingleInstance. * * Returns: (transfer full) (type GpickSingleInstanceSkeleton): The skeleton object. */ @@ -978,25 +1012,25 @@ gpick_single_instance_skeleton_new (void) } /* ------------------------------------------------------------------------ - * Code for interface com.google.code.gpick.Control + * Code for interface org.gpick.Control * ------------------------------------------------------------------------ */ /** * SECTION:GpickControl * @title: GpickControl - * @short_description: Generated C code for the com.google.code.gpick.Control D-Bus interface + * @short_description: Generated C code for the org.gpick.Control D-Bus interface * - * This section contains code for working with the com.google.code.gpick.Control D-Bus interface in C. + * This section contains code for working with the org.gpick.Control D-Bus interface in C. */ -/* ---- Introspection data for com.google.code.gpick.Control ---- */ +/* ---- Introspection data for org.gpick.Control ---- */ static const _ExtendedGDBusMethodInfo _gpick_control_method_info_activate_floating_picker = { { -1, - "ActivateFloatingPicker", + (gchar *) "ActivateFloatingPicker", NULL, NULL, NULL @@ -1005,9 +1039,23 @@ static const _ExtendedGDBusMethodInfo _gpick_control_method_info_activate_floati FALSE }; +static const _ExtendedGDBusMethodInfo _gpick_control_method_info_check_if_running = +{ + { + -1, + (gchar *) "CheckIfRunning", + NULL, + NULL, + NULL + }, + "handle-check-if-running", + FALSE +}; + static const _ExtendedGDBusMethodInfo * const _gpick_control_method_info_pointers[] = { &_gpick_control_method_info_activate_floating_picker, + &_gpick_control_method_info_check_if_running, NULL }; @@ -1015,7 +1063,7 @@ static const _ExtendedGDBusInterfaceInfo _gpick_control_interface_info = { { -1, - "com.google.code.gpick.Control", + (gchar *) "org.gpick.Control", (GDBusMethodInfo **) &_gpick_control_method_info_pointers, NULL, NULL, @@ -1028,14 +1076,14 @@ static const _ExtendedGDBusInterfaceInfo _gpick_control_interface_info = /** * gpick_control_interface_info: * - * Gets a machine-readable description of the com.google.code.gpick.Control D-Bus interface. + * Gets a machine-readable description of the org.gpick.Control D-Bus interface. * * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free. */ GDBusInterfaceInfo * gpick_control_interface_info (void) { - return (GDBusInterfaceInfo *) &_gpick_control_interface_info; + return (GDBusInterfaceInfo *) &_gpick_control_interface_info.parent_struct; } /** @@ -1059,17 +1107,21 @@ gpick_control_override_properties (GObjectClass *klass, guint property_id_begin) /** * GpickControl: * - * Abstract interface type for the D-Bus interface com.google.code.gpick.Control. + * Abstract interface type for the D-Bus interface org.gpick.Control. */ /** * GpickControlIface: * @parent_iface: The parent interface. * @handle_activate_floating_picker: Handler for the #GpickControl::handle-activate-floating-picker signal. + * @handle_check_if_running: Handler for the #GpickControl::handle-check-if-running signal. * - * Virtual table for the D-Bus interface com.google.code.gpick.Control. + * Virtual table for the D-Bus interface org.gpick.Control. */ +typedef GpickControlIface GpickControlInterface; +G_DEFINE_INTERFACE (GpickControl, gpick_control, G_TYPE_OBJECT); + static void gpick_control_default_init (GpickControlIface *iface) { @@ -1079,7 +1131,7 @@ gpick_control_default_init (GpickControlIface *iface) * @object: A #GpickControl. * @invocation: A #GDBusMethodInvocation. * - * Signal emitted when a remote caller is invoking the ActivateFloatingPicker() D-Bus method. + * Signal emitted when a remote caller is invoking the ActivateFloatingPicker() D-Bus method. * * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call gpick_control_complete_activate_floating_picker() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned. * @@ -1096,10 +1148,29 @@ gpick_control_default_init (GpickControlIface *iface) 1, G_TYPE_DBUS_METHOD_INVOCATION); -} + /** + * GpickControl::handle-check-if-running: + * @object: A #GpickControl. + * @invocation: A #GDBusMethodInvocation. + * + * Signal emitted when a remote caller is invoking the CheckIfRunning() D-Bus method. + * + * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call gpick_control_complete_check_if_running() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned. + * + * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run. + */ + g_signal_new ("handle-check-if-running", + G_TYPE_FROM_INTERFACE (iface), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GpickControlIface, handle_check_if_running), + g_signal_accumulator_true_handled, + NULL, + g_cclosure_marshal_generic, + G_TYPE_BOOLEAN, + 1, + G_TYPE_DBUS_METHOD_INVOCATION); -typedef GpickControlIface GpickControlInterface; -G_DEFINE_INTERFACE (GpickControl, gpick_control, G_TYPE_OBJECT); +} /** * gpick_control_call_activate_floating_picker: @@ -1108,7 +1179,7 @@ G_DEFINE_INTERFACE (GpickControl, gpick_control, G_TYPE_OBJECT); * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. * @user_data: User data to pass to @callback. * - * Asynchronously invokes the ActivateFloatingPicker() D-Bus method on @proxy. + * Asynchronously invokes the ActivateFloatingPicker() D-Bus method on @proxy. * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. * You can then call gpick_control_call_activate_floating_picker_finish() to get the result of the operation. * @@ -1164,7 +1235,7 @@ gpick_control_call_activate_floating_picker_finish ( * @cancellable: (allow-none): A #GCancellable or %NULL. * @error: Return location for error or %NULL. * - * Synchronously invokes the ActivateFloatingPicker() D-Bus method on @proxy. The calling thread is blocked until a reply is received. + * Synchronously invokes the ActivateFloatingPicker() D-Bus method on @proxy. The calling thread is blocked until a reply is received. * * See gpick_control_call_activate_floating_picker() for the asynchronous version of this method. * @@ -1193,12 +1264,104 @@ gpick_control_call_activate_floating_picker_sync ( return _ret != NULL; } +/** + * gpick_control_call_check_if_running: + * @proxy: A #GpickControlProxy. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. + * @user_data: User data to pass to @callback. + * + * Asynchronously invokes the CheckIfRunning() D-Bus method on @proxy. + * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. + * You can then call gpick_control_call_check_if_running_finish() to get the result of the operation. + * + * See gpick_control_call_check_if_running_sync() for the synchronous, blocking version of this method. + */ +void +gpick_control_call_check_if_running ( + GpickControl *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_dbus_proxy_call (G_DBUS_PROXY (proxy), + "CheckIfRunning", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + callback, + user_data); +} + +/** + * gpick_control_call_check_if_running_finish: + * @proxy: A #GpickControlProxy. + * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to gpick_control_call_check_if_running(). + * @error: Return location for error or %NULL. + * + * Finishes an operation started with gpick_control_call_check_if_running(). + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +gpick_control_call_check_if_running_finish ( + GpickControl *proxy, + GAsyncResult *res, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "()"); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + +/** + * gpick_control_call_check_if_running_sync: + * @proxy: A #GpickControlProxy. + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @error: Return location for error or %NULL. + * + * Synchronously invokes the CheckIfRunning() D-Bus method on @proxy. The calling thread is blocked until a reply is received. + * + * See gpick_control_call_check_if_running() for the asynchronous version of this method. + * + * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set. + */ +gboolean +gpick_control_call_check_if_running_sync ( + GpickControl *proxy, + GCancellable *cancellable, + GError **error) +{ + GVariant *_ret; + _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), + "CheckIfRunning", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + cancellable, + error); + if (_ret == NULL) + goto _out; + g_variant_get (_ret, + "()"); + g_variant_unref (_ret); +_out: + return _ret != NULL; +} + /** * gpick_control_complete_activate_floating_picker: * @object: A #GpickControl. * @invocation: (transfer full): A #GDBusMethodInvocation. * - * Helper function used in service implementations to finish handling invocations of the ActivateFloatingPicker() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. + * Helper function used in service implementations to finish handling invocations of the ActivateFloatingPicker() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. * * This method will free @invocation, you cannot use it afterwards. */ @@ -1211,6 +1374,24 @@ gpick_control_complete_activate_floating_picker ( g_variant_new ("()")); } +/** + * gpick_control_complete_check_if_running: + * @object: A #GpickControl. + * @invocation: (transfer full): A #GDBusMethodInvocation. + * + * Helper function used in service implementations to finish handling invocations of the CheckIfRunning() D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar. + * + * This method will free @invocation, you cannot use it afterwards. + */ +void +gpick_control_complete_check_if_running ( + GpickControl *object, + GDBusMethodInvocation *invocation) +{ + g_dbus_method_invocation_return_value (invocation, + g_variant_new ("()")); +} + /* ------------------------------------------------------------------------ */ /** @@ -1233,9 +1414,16 @@ struct _GpickControlProxyPrivate static void gpick_control_proxy_iface_init (GpickControlIface *iface); +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 G_DEFINE_TYPE_WITH_CODE (GpickControlProxy, gpick_control_proxy, G_TYPE_DBUS_PROXY, + G_ADD_PRIVATE (GpickControlProxy) G_IMPLEMENT_INTERFACE (GPICK_TYPE_CONTROL, gpick_control_proxy_iface_init)); +#else +G_DEFINE_TYPE_WITH_CODE (GpickControlProxy, gpick_control_proxy, G_TYPE_DBUS_PROXY, + G_IMPLEMENT_INTERFACE (GPICK_TYPE_CONTROL, gpick_control_proxy_iface_init)); + +#endif static void gpick_control_proxy_finalize (GObject *object) { @@ -1248,7 +1436,7 @@ static void gpick_control_proxy_get_property (GObject *object, guint prop_id, GValue *value, - GParamSpec *pspec) + GParamSpec *pspec G_GNUC_UNUSED) { } @@ -1256,13 +1444,13 @@ static void gpick_control_proxy_set_property (GObject *object, guint prop_id, const GValue *value, - GParamSpec *pspec) + GParamSpec *pspec G_GNUC_UNUSED) { } static void gpick_control_proxy_g_signal (GDBusProxy *proxy, - const gchar *sender_name, + const gchar *sender_name G_GNUC_UNUSED, const gchar *signal_name, GVariant *parameters) { @@ -1273,7 +1461,7 @@ gpick_control_proxy_g_signal (GDBusProxy *proxy, guint num_params; guint n; guint signal_id; - info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_gpick_control_interface_info, signal_name); + info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_gpick_control_interface_info.parent_struct, signal_name); if (info == NULL) return; num_params = g_variant_n_children (parameters); @@ -1315,7 +1503,7 @@ gpick_control_proxy_g_properties_changed (GDBusProxy *_proxy, g_variant_get (changed_properties, "a{sv}", &iter); while (g_variant_iter_next (iter, "{&sv}", &key, NULL)) { - info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_control_interface_info, key); + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_control_interface_info.parent_struct, key); g_datalist_remove_data (&proxy->priv->qdata, key); if (info != NULL) g_object_notify (G_OBJECT (proxy), info->hyphen_name); @@ -1323,7 +1511,7 @@ gpick_control_proxy_g_properties_changed (GDBusProxy *_proxy, g_variant_iter_free (iter); for (n = 0; invalidated_properties[n] != NULL; n++) { - info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_control_interface_info, invalidated_properties[n]); + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_control_interface_info.parent_struct, invalidated_properties[n]); g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]); if (info != NULL) g_object_notify (G_OBJECT (proxy), info->hyphen_name); @@ -1333,7 +1521,12 @@ gpick_control_proxy_g_properties_changed (GDBusProxy *_proxy, static void gpick_control_proxy_init (GpickControlProxy *proxy) { +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 + proxy->priv = gpick_control_proxy_get_instance_private (proxy); +#else proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, GPICK_TYPE_CONTROL_PROXY, GpickControlProxyPrivate); +#endif + g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), gpick_control_interface_info ()); } @@ -1343,8 +1536,6 @@ gpick_control_proxy_class_init (GpickControlProxyClass *klass) GObjectClass *gobject_class; GDBusProxyClass *proxy_class; - g_type_class_add_private (klass, sizeof (GpickControlProxyPrivate)); - gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = gpick_control_proxy_finalize; gobject_class->get_property = gpick_control_proxy_get_property; @@ -1354,6 +1545,9 @@ gpick_control_proxy_class_init (GpickControlProxyClass *klass) proxy_class->g_signal = gpick_control_proxy_g_signal; proxy_class->g_properties_changed = gpick_control_proxy_g_properties_changed; +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 + g_type_class_add_private (klass, sizeof (GpickControlProxyPrivate)); +#endif } static void @@ -1371,7 +1565,7 @@ gpick_control_proxy_iface_init (GpickControlIface *iface) * @callback: A #GAsyncReadyCallback to call when the request is satisfied. * @user_data: User data to pass to @callback. * - * Asynchronously creates a proxy for the D-Bus interface com.google.code.gpick.Control. See g_dbus_proxy_new() for more details. + * Asynchronously creates a proxy for the D-Bus interface org.gpick.Control. See g_dbus_proxy_new() for more details. * * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from. * You can then call gpick_control_proxy_new_finish() to get the result of the operation. @@ -1388,7 +1582,7 @@ gpick_control_proxy_new ( GAsyncReadyCallback callback, gpointer user_data) { - g_async_initable_new_async (GPICK_TYPE_CONTROL_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.Control", NULL); + g_async_initable_new_async (GPICK_TYPE_CONTROL_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.gpick.Control", NULL); } /** @@ -1425,7 +1619,7 @@ gpick_control_proxy_new_finish ( * @cancellable: (allow-none): A #GCancellable or %NULL. * @error: Return location for error or %NULL * - * Synchronously creates a proxy for the D-Bus interface com.google.code.gpick.Control. See g_dbus_proxy_new_sync() for more details. + * Synchronously creates a proxy for the D-Bus interface org.gpick.Control. See g_dbus_proxy_new_sync() for more details. * * The calling thread is blocked until a reply is received. * @@ -1443,7 +1637,7 @@ gpick_control_proxy_new_sync ( GError **error) { GInitable *ret; - ret = g_initable_new (GPICK_TYPE_CONTROL_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.Control", NULL); + ret = g_initable_new (GPICK_TYPE_CONTROL_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.gpick.Control", NULL); if (ret != NULL) return GPICK_CONTROL (ret); else @@ -1478,7 +1672,7 @@ gpick_control_proxy_new_for_bus ( GAsyncReadyCallback callback, gpointer user_data) { - g_async_initable_new_async (GPICK_TYPE_CONTROL_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.Control", NULL); + g_async_initable_new_async (GPICK_TYPE_CONTROL_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.gpick.Control", NULL); } /** @@ -1533,7 +1727,7 @@ gpick_control_proxy_new_for_bus_sync ( GError **error) { GInitable *ret; - ret = g_initable_new (GPICK_TYPE_CONTROL_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "com.google.code.gpick.Control", NULL); + ret = g_initable_new (GPICK_TYPE_CONTROL_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.gpick.Control", NULL); if (ret != NULL) return GPICK_CONTROL (ret); else @@ -1567,9 +1761,9 @@ struct _GpickControlSkeletonPrivate static void _gpick_control_skeleton_handle_method_call ( - GDBusConnection *connection, - const gchar *sender, - const gchar *object_path, + GDBusConnection *connection G_GNUC_UNUSED, + const gchar *sender G_GNUC_UNUSED, + const gchar *object_path G_GNUC_UNUSED, const gchar *interface_name, const gchar *method_name, GVariant *parameters, @@ -1631,10 +1825,10 @@ _gpick_control_skeleton_handle_method_call ( static GVariant * _gpick_control_skeleton_handle_get_property ( - GDBusConnection *connection, - const gchar *sender, - const gchar *object_path, - const gchar *interface_name, + GDBusConnection *connection G_GNUC_UNUSED, + const gchar *sender G_GNUC_UNUSED, + const gchar *object_path G_GNUC_UNUSED, + const gchar *interface_name G_GNUC_UNUSED, const gchar *property_name, GError **error, gpointer user_data) @@ -1645,7 +1839,7 @@ _gpick_control_skeleton_handle_get_property ( _ExtendedGDBusPropertyInfo *info; GVariant *ret; ret = NULL; - info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_control_interface_info, property_name); + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_control_interface_info.parent_struct, property_name); g_assert (info != NULL); pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); if (pspec == NULL) @@ -1664,10 +1858,10 @@ _gpick_control_skeleton_handle_get_property ( static gboolean _gpick_control_skeleton_handle_set_property ( - GDBusConnection *connection, - const gchar *sender, - const gchar *object_path, - const gchar *interface_name, + GDBusConnection *connection G_GNUC_UNUSED, + const gchar *sender G_GNUC_UNUSED, + const gchar *object_path G_GNUC_UNUSED, + const gchar *interface_name G_GNUC_UNUSED, const gchar *property_name, GVariant *variant, GError **error, @@ -1679,7 +1873,7 @@ _gpick_control_skeleton_handle_set_property ( _ExtendedGDBusPropertyInfo *info; gboolean ret; ret = FALSE; - info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_control_interface_info, property_name); + info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_gpick_control_interface_info.parent_struct, property_name); g_assert (info != NULL); pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name); if (pspec == NULL) @@ -1703,17 +1897,18 @@ static const GDBusInterfaceVTable _gpick_control_skeleton_vtable = { _gpick_control_skeleton_handle_method_call, _gpick_control_skeleton_handle_get_property, - _gpick_control_skeleton_handle_set_property + _gpick_control_skeleton_handle_set_property, + {NULL} }; static GDBusInterfaceInfo * -gpick_control_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton) +gpick_control_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) { return gpick_control_interface_info (); } static GDBusInterfaceVTable * -gpick_control_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton) +gpick_control_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED) { return (GDBusInterfaceVTable *) &_gpick_control_skeleton_vtable; } @@ -1734,7 +1929,7 @@ gpick_control_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_s if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) { GVariant *value; - value = _gpick_control_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "com.google.code.gpick.Control", info->name, NULL, skeleton); + value = _gpick_control_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.gpick.Control", info->name, NULL, skeleton); if (value != NULL) { g_variant_take_ref (value); @@ -1753,9 +1948,16 @@ gpick_control_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton) } static void gpick_control_skeleton_iface_init (GpickControlIface *iface); +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 +G_DEFINE_TYPE_WITH_CODE (GpickControlSkeleton, gpick_control_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, + G_ADD_PRIVATE (GpickControlSkeleton) + G_IMPLEMENT_INTERFACE (GPICK_TYPE_CONTROL, gpick_control_skeleton_iface_init)); + +#else G_DEFINE_TYPE_WITH_CODE (GpickControlSkeleton, gpick_control_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON, G_IMPLEMENT_INTERFACE (GPICK_TYPE_CONTROL, gpick_control_skeleton_iface_init)); +#endif static void gpick_control_skeleton_finalize (GObject *object) { @@ -1771,7 +1973,12 @@ gpick_control_skeleton_finalize (GObject *object) static void gpick_control_skeleton_init (GpickControlSkeleton *skeleton) { +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 + skeleton->priv = gpick_control_skeleton_get_instance_private (skeleton); +#else skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, GPICK_TYPE_CONTROL_SKELETON, GpickControlSkeletonPrivate); +#endif + g_mutex_init (&skeleton->priv->lock); skeleton->priv->context = g_main_context_ref_thread_default (); } @@ -1782,8 +1989,6 @@ gpick_control_skeleton_class_init (GpickControlSkeletonClass *klass) GObjectClass *gobject_class; GDBusInterfaceSkeletonClass *skeleton_class; - g_type_class_add_private (klass, sizeof (GpickControlSkeletonPrivate)); - gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = gpick_control_skeleton_finalize; @@ -1792,6 +1997,10 @@ gpick_control_skeleton_class_init (GpickControlSkeletonClass *klass) skeleton_class->get_properties = gpick_control_skeleton_dbus_interface_get_properties; skeleton_class->flush = gpick_control_skeleton_dbus_interface_flush; skeleton_class->get_vtable = gpick_control_skeleton_dbus_interface_get_vtable; + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 + g_type_class_add_private (klass, sizeof (GpickControlSkeletonPrivate)); +#endif } static void @@ -1802,7 +2011,7 @@ gpick_control_skeleton_iface_init (GpickControlIface *iface) /** * gpick_control_skeleton_new: * - * Creates a skeleton object for the D-Bus interface com.google.code.gpick.Control. + * Creates a skeleton object for the D-Bus interface org.gpick.Control. * * Returns: (transfer full) (type GpickControlSkeleton): The skeleton object. */ @@ -1838,13 +2047,16 @@ gpick_control_skeleton_new (void) * Virtual table for the #GpickObject interface. */ +typedef GpickObjectIface GpickObjectInterface; +G_DEFINE_INTERFACE_WITH_CODE (GpickObject, gpick_object, G_TYPE_OBJECT, g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_DBUS_OBJECT)); + static void gpick_object_default_init (GpickObjectIface *iface) { /** * GpickObject:single-instance: * - * The #GpickSingleInstance instance corresponding to the D-Bus interface com.google.code.gpick.SingleInstance, if any. + * The #GpickSingleInstance instance corresponding to the D-Bus interface org.gpick.SingleInstance, if any. * * Connect to the #GObject::notify signal to get informed of property changes. */ @@ -1853,7 +2065,7 @@ gpick_object_default_init (GpickObjectIface *iface) /** * GpickObject:control: * - * The #GpickControl instance corresponding to the D-Bus interface com.google.code.gpick.Control, if any. + * The #GpickControl instance corresponding to the D-Bus interface org.gpick.Control, if any. * * Connect to the #GObject::notify signal to get informed of property changes. */ @@ -1861,21 +2073,18 @@ gpick_object_default_init (GpickObjectIface *iface) } -typedef GpickObjectIface GpickObjectInterface; -G_DEFINE_INTERFACE_WITH_CODE (GpickObject, gpick_object, G_TYPE_OBJECT, g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_DBUS_OBJECT)); - /** * gpick_object_get_single_instance: * @object: A #GpickObject. * - * Gets the #GpickSingleInstance instance for the D-Bus interface com.google.code.gpick.SingleInstance on @object, if any. + * Gets the #GpickSingleInstance instance for the D-Bus interface org.gpick.SingleInstance on @object, if any. * * Returns: (transfer full): A #GpickSingleInstance that must be freed with g_object_unref() or %NULL if @object does not implement the interface. */ GpickSingleInstance *gpick_object_get_single_instance (GpickObject *object) { GDBusInterface *ret; - ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.SingleInstance"); + ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gpick.SingleInstance"); if (ret == NULL) return NULL; return GPICK_SINGLE_INSTANCE (ret); @@ -1885,14 +2094,14 @@ GpickSingleInstance *gpick_object_get_single_instance (GpickObject *object) * gpick_object_get_control: * @object: A #GpickObject. * - * Gets the #GpickControl instance for the D-Bus interface com.google.code.gpick.Control on @object, if any. + * Gets the #GpickControl instance for the D-Bus interface org.gpick.Control on @object, if any. * * Returns: (transfer full): A #GpickControl that must be freed with g_object_unref() or %NULL if @object does not implement the interface. */ GpickControl *gpick_object_get_control (GpickObject *object) { GDBusInterface *ret; - ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.Control"); + ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gpick.Control"); if (ret == NULL) return NULL; return GPICK_CONTROL (ret); @@ -1912,7 +2121,7 @@ GpickControl *gpick_object_get_control (GpickObject *object) GpickSingleInstance *gpick_object_peek_single_instance (GpickObject *object) { GDBusInterface *ret; - ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.SingleInstance"); + ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gpick.SingleInstance"); if (ret == NULL) return NULL; g_object_unref (ret); @@ -1932,7 +2141,7 @@ GpickSingleInstance *gpick_object_peek_single_instance (GpickObject *object) GpickControl *gpick_object_peek_control (GpickObject *object) { GDBusInterface *ret; - ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.Control"); + ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gpick.Control"); if (ret == NULL) return NULL; g_object_unref (ret); @@ -1943,7 +2152,12 @@ GpickControl *gpick_object_peek_control (GpickObject *object) static void gpick_object_notify (GDBusObject *object, GDBusInterface *interface) { - g_object_notify (G_OBJECT (object), ((_ExtendedGDBusInterfaceInfo *) g_dbus_interface_get_info (interface))->hyphen_name); + _ExtendedGDBusInterfaceInfo *info = (_ExtendedGDBusInterfaceInfo *) g_dbus_interface_get_info (interface); + /* info can be NULL if the other end is using a D-Bus interface we don't know + * anything about, for example old generated code in this process talking to + * newer generated code in the other process. */ + if (info != NULL) + g_object_notify (G_OBJECT (object), info->hyphen_name); } /** @@ -1960,7 +2174,7 @@ gpick_object_notify (GDBusObject *object, GDBusInterface *interface) */ static void -gpick_object_proxy__gpick_object_iface_init (GpickObjectIface *iface) +gpick_object_proxy__gpick_object_iface_init (GpickObjectIface *iface G_GNUC_UNUSED) { } @@ -1977,14 +2191,14 @@ G_DEFINE_TYPE_WITH_CODE (GpickObjectProxy, gpick_object_proxy, G_TYPE_DBUS_OBJEC G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, gpick_object_proxy__g_dbus_object_iface_init)); static void -gpick_object_proxy_init (GpickObjectProxy *object) +gpick_object_proxy_init (GpickObjectProxy *object G_GNUC_UNUSED) { } static void gpick_object_proxy_set_property (GObject *gobject, guint prop_id, - const GValue *value, + const GValue *value G_GNUC_UNUSED, GParamSpec *pspec) { G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); @@ -2002,12 +2216,12 @@ gpick_object_proxy_get_property (GObject *gobject, switch (prop_id) { case 1: - interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.SingleInstance"); + interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gpick.SingleInstance"); g_value_take_object (value, interface); break; case 2: - interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.Control"); + interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gpick.Control"); g_value_take_object (value, interface); break; @@ -2061,7 +2275,7 @@ gpick_object_proxy_new (GDBusConnection *connection, */ static void -gpick_object_skeleton__gpick_object_iface_init (GpickObjectIface *iface) +gpick_object_skeleton__gpick_object_iface_init (GpickObjectIface *iface G_GNUC_UNUSED) { } @@ -2078,7 +2292,7 @@ G_DEFINE_TYPE_WITH_CODE (GpickObjectSkeleton, gpick_object_skeleton, G_TYPE_DBUS G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, gpick_object_skeleton__g_dbus_object_iface_init)); static void -gpick_object_skeleton_init (GpickObjectSkeleton *object) +gpick_object_skeleton_init (GpickObjectSkeleton *object G_GNUC_UNUSED) { } @@ -2102,7 +2316,7 @@ gpick_object_skeleton_set_property (GObject *gobject, } else { - g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "com.google.code.gpick.SingleInstance"); + g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.gpick.SingleInstance"); } break; @@ -2115,7 +2329,7 @@ gpick_object_skeleton_set_property (GObject *gobject, } else { - g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "com.google.code.gpick.Control"); + g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.gpick.Control"); } break; @@ -2137,12 +2351,12 @@ gpick_object_skeleton_get_property (GObject *gobject, switch (prop_id) { case 1: - interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.SingleInstance"); + interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gpick.SingleInstance"); g_value_take_object (value, interface); break; case 2: - interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "com.google.code.gpick.Control"); + interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gpick.Control"); g_value_take_object (value, interface); break; @@ -2184,7 +2398,7 @@ gpick_object_skeleton_new (const gchar *object_path) * @object: A #GpickObjectSkeleton. * @interface_: (allow-none): A #GpickSingleInstance or %NULL to clear the interface. * - * Sets the #GpickSingleInstance instance for the D-Bus interface com.google.code.gpick.SingleInstance on @object. + * Sets the #GpickSingleInstance instance for the D-Bus interface org.gpick.SingleInstance on @object. */ void gpick_object_skeleton_set_single_instance (GpickObjectSkeleton *object, GpickSingleInstance *interface_) { @@ -2196,7 +2410,7 @@ void gpick_object_skeleton_set_single_instance (GpickObjectSkeleton *object, Gpi * @object: A #GpickObjectSkeleton. * @interface_: (allow-none): A #GpickControl or %NULL to clear the interface. * - * Sets the #GpickControl instance for the D-Bus interface com.google.code.gpick.Control on @object. + * Sets the #GpickControl instance for the D-Bus interface org.gpick.Control on @object. */ void gpick_object_skeleton_set_control (GpickObjectSkeleton *object, GpickControl *interface_) { @@ -2233,12 +2447,12 @@ void gpick_object_skeleton_set_control (GpickObjectSkeleton *object, GpickContro G_DEFINE_TYPE (GpickObjectManagerClient, gpick_object_manager_client, G_TYPE_DBUS_OBJECT_MANAGER_CLIENT); static void -gpick_object_manager_client_init (GpickObjectManagerClient *manager) +gpick_object_manager_client_init (GpickObjectManagerClient *manager G_GNUC_UNUSED) { } static void -gpick_object_manager_client_class_init (GpickObjectManagerClientClass *klass) +gpick_object_manager_client_class_init (GpickObjectManagerClientClass *klass G_GNUC_UNUSED) { } @@ -2254,7 +2468,7 @@ gpick_object_manager_client_class_init (GpickObjectManagerClientClass *klass) * Returns: A #GDBusProxy-derived #GType if @interface_name is not %NULL, otherwise the #GType for #GpickObjectProxy. */ GType -gpick_object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data) +gpick_object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager G_GNUC_UNUSED, const gchar *object_path G_GNUC_UNUSED, const gchar *interface_name, gpointer user_data G_GNUC_UNUSED) { static gsize once_init_value = 0; static GHashTable *lookup_hash; @@ -2265,8 +2479,8 @@ gpick_object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager, c if (g_once_init_enter (&once_init_value)) { lookup_hash = g_hash_table_new (g_str_hash, g_str_equal); - g_hash_table_insert (lookup_hash, "com.google.code.gpick.SingleInstance", GSIZE_TO_POINTER (GPICK_TYPE_SINGLE_INSTANCE_PROXY)); - g_hash_table_insert (lookup_hash, "com.google.code.gpick.Control", GSIZE_TO_POINTER (GPICK_TYPE_CONTROL_PROXY)); + g_hash_table_insert (lookup_hash, (gpointer) "org.gpick.SingleInstance", GSIZE_TO_POINTER (GPICK_TYPE_SINGLE_INSTANCE_PROXY)); + g_hash_table_insert (lookup_hash, (gpointer) "org.gpick.Control", GSIZE_TO_POINTER (GPICK_TYPE_CONTROL_PROXY)); g_once_init_leave (&once_init_value, 1); } ret = (GType) GPOINTER_TO_SIZE (g_hash_table_lookup (lookup_hash, interface_name)); @@ -2453,3 +2667,5 @@ gpick_object_manager_client_new_for_bus_sync ( else return NULL; } + + diff --git a/source/dbus/DbusInterface.h b/source/dbus/DbusInterface.h index 02df5f1..e48d3f4 100644 --- a/source/dbus/DbusInterface.h +++ b/source/dbus/DbusInterface.h @@ -1,5 +1,5 @@ /* - * Generated by gdbus-codegen 2.32.3. DO NOT EDIT. + * Generated by gdbus-codegen 2.48.0. DO NOT EDIT. * * The license of this code is the same as for the source it was derived from. */ @@ -13,7 +13,7 @@ G_BEGIN_DECLS /* ------------------------------------------------------------------------ */ -/* Declarations for com.google.code.gpick.SingleInstance */ +/* Declarations for org.gpick.SingleInstance */ #define GPICK_TYPE_SINGLE_INSTANCE (gpick_single_instance_get_type ()) #define GPICK_SINGLE_INSTANCE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPICK_TYPE_SINGLE_INSTANCE, GpickSingleInstance)) @@ -93,6 +93,10 @@ struct _GpickSingleInstanceProxyClass GType gpick_single_instance_proxy_get_type (void) G_GNUC_CONST; +#if GLIB_CHECK_VERSION(2, 44, 0) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GpickSingleInstanceProxy, g_object_unref) +#endif + void gpick_single_instance_proxy_new ( GDBusConnection *connection, GDBusProxyFlags flags, @@ -159,11 +163,15 @@ struct _GpickSingleInstanceSkeletonClass GType gpick_single_instance_skeleton_get_type (void) G_GNUC_CONST; +#if GLIB_CHECK_VERSION(2, 44, 0) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GpickSingleInstanceSkeleton, g_object_unref) +#endif + GpickSingleInstance *gpick_single_instance_skeleton_new (void); /* ------------------------------------------------------------------------ */ -/* Declarations for com.google.code.gpick.Control */ +/* Declarations for org.gpick.Control */ #define GPICK_TYPE_CONTROL (gpick_control_get_type ()) #define GPICK_CONTROL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPICK_TYPE_CONTROL, GpickControl)) @@ -182,6 +190,10 @@ struct _GpickControlIface GpickControl *object, GDBusMethodInvocation *invocation); + gboolean (*handle_check_if_running) ( + GpickControl *object, + GDBusMethodInvocation *invocation); + }; GType gpick_control_get_type (void) G_GNUC_CONST; @@ -195,6 +207,10 @@ void gpick_control_complete_activate_floating_picker ( GpickControl *object, GDBusMethodInvocation *invocation); +void gpick_control_complete_check_if_running ( + GpickControl *object, + GDBusMethodInvocation *invocation); + /* D-Bus method calls: */ @@ -214,6 +230,22 @@ gboolean gpick_control_call_activate_floating_picker_sync ( GCancellable *cancellable, GError **error); +void gpick_control_call_check_if_running ( + GpickControl *proxy, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean gpick_control_call_check_if_running_finish ( + GpickControl *proxy, + GAsyncResult *res, + GError **error); + +gboolean gpick_control_call_check_if_running_sync ( + GpickControl *proxy, + GCancellable *cancellable, + GError **error); + /* ---- */ @@ -243,6 +275,10 @@ struct _GpickControlProxyClass GType gpick_control_proxy_get_type (void) G_GNUC_CONST; +#if GLIB_CHECK_VERSION(2, 44, 0) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GpickControlProxy, g_object_unref) +#endif + void gpick_control_proxy_new ( GDBusConnection *connection, GDBusProxyFlags flags, @@ -309,6 +345,10 @@ struct _GpickControlSkeletonClass GType gpick_control_skeleton_get_type (void) G_GNUC_CONST; +#if GLIB_CHECK_VERSION(2, 44, 0) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GpickControlSkeleton, g_object_unref) +#endif + GpickControl *gpick_control_skeleton_new (void); @@ -359,6 +399,11 @@ struct _GpickObjectProxyClass }; GType gpick_object_proxy_get_type (void) G_GNUC_CONST; + +#if GLIB_CHECK_VERSION(2, 44, 0) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GpickObjectProxy, g_object_unref) +#endif + GpickObjectProxy *gpick_object_proxy_new (GDBusConnection *connection, const gchar *object_path); #define GPICK_TYPE_OBJECT_SKELETON (gpick_object_skeleton_get_type ()) @@ -385,6 +430,11 @@ struct _GpickObjectSkeletonClass }; GType gpick_object_skeleton_get_type (void) G_GNUC_CONST; + +#if GLIB_CHECK_VERSION(2, 44, 0) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GpickObjectSkeleton, g_object_unref) +#endif + GpickObjectSkeleton *gpick_object_skeleton_new (const gchar *object_path); void gpick_object_skeleton_set_single_instance (GpickObjectSkeleton *object, GpickSingleInstance *interface_); void gpick_object_skeleton_set_control (GpickObjectSkeleton *object, GpickControl *interface_); @@ -414,6 +464,10 @@ struct _GpickObjectManagerClientClass GDBusObjectManagerClientClass parent_class; }; +#if GLIB_CHECK_VERSION(2, 44, 0) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GpickObjectManagerClient, g_object_unref) +#endif + GType gpick_object_manager_client_get_type (void) G_GNUC_CONST; GType gpick_object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data); diff --git a/source/dbus/SConscript b/source/dbus/SConscript index 15fb591..5a5fced 100644 --- a/source/dbus/SConscript +++ b/source/dbus/SConscript @@ -12,7 +12,7 @@ if not local_env.GetOption('clean') and not env['TOOLCHAIN'] == 'msvc': if not env['BUILD_TARGET'] == 'win32': sources = local_env.Glob('*.c') + local_env.Glob('*.cpp') else: - sources = local_env.Glob('win32dummy/*.cpp') + sources = local_env.Glob('*.cpp') objects = local_env.StaticObject(source = [sources]) Return('objects') diff --git a/source/dbus/interface.xml b/source/dbus/interface.xml index 282d5b8..663f2a9 100644 --- a/source/dbus/interface.xml +++ b/source/dbus/interface.xml @@ -1,11 +1,13 @@ - - + + - + + + diff --git a/source/main.cpp b/source/main.cpp index 1ca738e..50256ff 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -34,6 +34,7 @@ static gboolean output_picked_color = FALSE; static gboolean output_without_newline = FALSE; static gboolean single_color_pick_mode = FALSE; static gboolean version_information = FALSE; +static gboolean do_not_start = FALSE; static GOptionEntry commandline_entries[] = { {"geometry", 'g', 0, G_OPTION_ARG_STRING, &commandline_geometry, "Window geometry", "GEOMETRY"}, @@ -41,6 +42,7 @@ static GOptionEntry commandline_entries[] = {"single", 's', 0, G_OPTION_ARG_NONE, &single_color_pick_mode, "Pick one color and exit", nullptr}, {"output", 'o', 0, G_OPTION_ARG_NONE, &output_picked_color, "Output picked color", nullptr}, {"no-newline", 0, 0, G_OPTION_ARG_NONE, &output_without_newline, "Output picked color without newline", nullptr}, + {"no-start", 0, 0, G_OPTION_ARG_NONE, &do_not_start, "Do not start Gpick if it is not already running", nullptr}, {"version", 'v', 0, G_OPTION_ARG_NONE, &version_information, "Print version information", nullptr}, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &commandline_filename, nullptr, "[FILE...]"}, {nullptr} @@ -77,7 +79,9 @@ int main(int argc, char **argv) options.output_picked_color = output_picked_color; options.output_without_newline = output_without_newline; options.single_color_pick_mode = single_color_pick_mode; - AppArgs *args = app_create_main(&options); + options.do_not_start = do_not_start; + int return_value = 0; + AppArgs *args = app_create_main(&options, return_value); if (args){ if (!single_color_pick_mode){ if (commandline_filename){ @@ -98,5 +102,5 @@ int main(int argc, char **argv) } } g_option_context_free(context); - return 0; + return return_value; } diff --git a/source/uiApp.cpp b/source/uiApp.cpp index 7561f41..a668870 100644 --- a/source/uiApp.cpp +++ b/source/uiApp.cpp @@ -85,7 +85,6 @@ typedef struct AppArgs{ uiStatusIcon* status_icon; FloatingPicker floating_picker; AppOptions options; - guint bus_id; struct dynvSystem *params; GlobalState *gs; char* current_filename; @@ -94,6 +93,7 @@ typedef struct AppArgs{ gint x, y; gint width, height; bool initialization; + dbus::Control dbus_control; }AppArgs; static void app_release(AppArgs *args); @@ -1368,21 +1368,6 @@ bool app_is_autoload_enabled(AppArgs *args) return dynv_get_bool_wd(args->params, "main.save_restore_palette", true); } -static bool app_on_control_activate_floating_picker(void *userdata) -{ - AppArgs *args = reinterpret_cast(userdata); - floating_picker_activate(args->floating_picker, false, false); - return true; -} - -static bool app_on_single_instance_activate(void *userdata) -{ - AppArgs *args = reinterpret_cast(userdata); - status_icon_set_visible(args->status_icon, false); - main_show_window(args->window, args->params); - return true; -} - static void app_initialize_variables(AppArgs *args) { args->current_filename = 0; @@ -1430,7 +1415,7 @@ static void app_initialize_picker(AppArgs *args, GtkWidget *notebook) gtk_widget_show(widget); } -AppArgs* app_create_main(const AppOptions *options) +AppArgs* app_create_main(const AppOptions *options, int &return_value) { AppArgs* args = new AppArgs; args->initialization = true; @@ -1444,15 +1429,33 @@ AppArgs* app_create_main(const AppOptions *options) args->initialization = false; return args; // No main UI initialization needed }else{ - args->bus_id = gpick_own_name(app_on_control_activate_floating_picker, app_on_single_instance_activate, args); + args->dbus_control.onActivateFloatingPicker = [args]{ + floating_picker_activate(args->floating_picker, false, false); + return true; + }; + args->dbus_control.onSingleInstanceActivate = [args]{ + status_icon_set_visible(args->status_icon, false); + main_show_window(args->window, args->params); + return true; + }; + args->dbus_control.ownName(); bool cancel_startup = false; if (!cancel_startup && args->options.floating_picker_mode){ - if (gpick_control_activate_floating_picker()){ + if (args->dbus_control.activateFloatingPicker()){ + cancel_startup = true; + }else if (args->options.do_not_start){ + return_value = 1; + cancel_startup = true; + } + } + if (args->options.do_not_start){ + if (args->dbus_control.checkIfRunning()){ + return_value = 1; cancel_startup = true; } } if (!cancel_startup && dynv_get_bool_wd(args->gs->getSettings(), "gpick.main.single_instance", false)){ - if (gpick_single_instance_activate()){ + if (args->dbus_control.singleInstanceActivate()){ cancel_startup = true; } } @@ -1706,7 +1709,7 @@ int app_run(AppArgs *args) floating_picker_activate(args->floating_picker, false, false); gtk_main(); app_save_recent_file_list(args); - gpick_unown_name(args->bus_id); + args->dbus_control.unownName(); status_icon_destroy(args->status_icon); } args->gs->writeSettings(); diff --git a/source/uiApp.h b/source/uiApp.h index 2b2084a..45978d2 100644 --- a/source/uiApp.h +++ b/source/uiApp.h @@ -35,9 +35,10 @@ struct AppOptions bool output_picked_color; bool output_without_newline; bool single_color_pick_mode; + bool do_not_start; }; -AppArgs* app_create_main(const AppOptions *options); +AppArgs* app_create_main(const AppOptions *options, int &return_value); int app_load_file(AppArgs *args, const char *filename, bool autoload = false); int app_run(AppArgs *args); int app_parse_geometry(AppArgs *args, const char *geometry);