[gnome-panel/bonobo-less] Bump glib requirements and use GDBus instead of eggdbus
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/bonobo-less] Bump glib requirements and use GDBus instead of eggdbus
- Date: Tue, 18 May 2010 17:23:47 +0000 (UTC)
commit 28b98072b81be05911989c1b1c5d2fc09430c202
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Tue May 18 19:20:19 2010 +0200
Bump glib requirements and use GDBus instead of eggdbus
Makefile.am | 1 -
configure.in | 8 +-
data/Makefile.am | 3 -
data/panel-applet.xml | 35 -
gnome-panel/Makefile.am | 39 +-
gnome-panel/panel-applet-container.c | 1123 +++++++-------------
gnome-panel/panel-applet-container.h | 177 +---
gnome-panel/panel-applet-frame.c | 219 +++--
gnome-panel/panel-marshal.list | 1 +
.../panel-test-applets.c | 29 +-
.../panel-test-applets.ui | 0
libpanel-applet/Makefile.am | 61 +-
libpanel-applet/panel-applet-factory.c | 244 +++--
libpanel-applet/panel-applet-factory.xml | 14 -
libpanel-applet/panel-applet.c | 436 +++++++-
libpanel-applet/panel-applet.h | 1 +
16 files changed, 1141 insertions(+), 1250 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index ebeb1c8..0e8f899 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,5 @@
SUBDIRS = \
po \
- data \
icons \
gnome-panel \
libpanel-applet \
diff --git a/configure.in b/configure.in
index 1d9b503..ad065a9 100644
--- a/configure.in
+++ b/configure.in
@@ -57,7 +57,7 @@ AC_CHECK_FUNCS(_NSGetEnviron)
LIBGNOME_DESKTOP_REQUIRED=2.24.0
GDK_PIXBUF_REQUIRED=2.7.1
PANGO_REQUIRED=1.15.4
-GLIB_REQUIRED=2.18.0
+GLIB_REQUIRED=2.25.5
GTK_REQUIRED=2.15.1
LIBWNCK_REQUIRED=2.19.5
GCONF_REQUIRED=2.6.1
@@ -67,18 +67,17 @@ LIBEDATASERVER_REQUIRED=1.2.0
LIBEDATASERVERUI_REQUIRED=1.2.0
CAIRO_REQUIRED=1.0.0
DBUS_GLIB_REQUIRED=0.60
-EGG_DBUS_REQUIRED=0.5
GWEATHER_REQUIRED=2.27.90
dnl pkg-config dependency checks
PKG_CHECK_MODULES(EGG_SMCLIENT, ice sm gtk+-2.0)
-PKG_CHECK_MODULES(PANEL, gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED pango >= $PANGO_REQUIRED gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED gio-unix-2.0 >= $GLIB_REQUIRED gnome-desktop-2.0 >= $LIBGNOME_DESKTOP_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgnome-menu >= $LIBGNOME_MENU_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED libcanberra-gtk eggdbus-1 >= $EGG_DBUS_REQUIRED)
+PKG_CHECK_MODULES(PANEL, gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED pango >= $PANGO_REQUIRED gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED gio-unix-2.0 >= $GLIB_REQUIRED gnome-desktop-2.0 >= $LIBGNOME_DESKTOP_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgnome-menu >= $LIBGNOME_MENU_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED libcanberra-gtk)
AC_SUBST(PANEL_CFLAGS)
AC_SUBST(PANEL_LIBS)
-PKG_CHECK_MODULES(LIBPANEL_APPLET, gtk+-2.0 >= $GTK_REQUIRED gconf-2.0 >= $GCONF_REQUIRED eggdbus-1 >= $EGG_DBUS_REQUIRED)
+PKG_CHECK_MODULES(LIBPANEL_APPLET, gtk+-2.0 >= $GTK_REQUIRED gconf-2.0 >= $GCONF_REQUIRED gio-2.0 >= $GLIB_REQUIRED gio-unix-2.0 >= $GLIB_REQUIRED)
AC_SUBST(LIBPANEL_APPLET_CFLAGS)
AC_SUBST(LIBPANEL_APPLET_LIBS)
@@ -309,7 +308,6 @@ AC_SUBST(REBUILD)
AC_OUTPUT([
Makefile
-data/Makefile
icons/Makefile
icons/16x16/Makefile
icons/22x22/Makefile
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index b847691..be9e130 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -16,7 +16,6 @@ INCLUDES = \
-DDATADIR=\""$(datadir)"\" \
-DPANEL_APPLETS_DIR=\"$(appletsdir)\" \
-DGMENU_I_KNOW_THIS_IS_UNSTABLE \
- -DEGG_DBUS_I_KNOW_API_IS_SUBJECT_TO_CHANGE \
$(DISABLE_DEPRECATED_CFLAGS) \
$(PANEL_CFLAGS) \
$(WARN_CFLAGS) \
@@ -32,31 +31,10 @@ STANDARD_PROPERTIES_CFLAGS = \
bin_PROGRAMS = \
gnome-panel \
- gnome-desktop-item-edit
-
-$(gnome_panel_OBJECTS): $(BUILT_SOURCES)
-
-panel-built-sources.stamp: $(top_srcdir)/data/panel-applet.xml
- eggdbus-binding-tool \
- --namespace "_Panel" \
- --dbus-namespace "org.gnome.panel.applet" \
- --introspection-xml $(top_srcdir)/data/panel-applet.xml \
- --stamp-file panel-built-sources.stamp
-
-EGGDBUS_SRCLIST = \
- _panelbindingstypes.h \
- _panelbindings.h \
- _panelbindings.c \
- _panelbindingsmarshal.h \
- _panelbindingsmarshal.c \
- _panelapplet.h \
- _panelapplet.c \
- _panelappletorient.h \
- _panelappletorient.c
+ gnome-desktop-item-edit \
+ panel-test-applets
BUILT_SOURCES = \
- panel-built-sources.stamp \
- $(EGGDBUS_SRCLIST) \
panel-typebuiltins.c \
panel-typebuiltins.h \
panel-marshal.c \
@@ -162,7 +140,6 @@ panel_headers = \
$(NULL)
gnome_panel_SOURCES = \
- $(EGGDBUS_SRCLIST) \
$(panel_sources) \
$(panel_headers) \
$(NULL)
@@ -192,7 +169,8 @@ gnome_desktop_item_edit_LDADD = \
uidir = $(datadir)/gnome-panel/ui
ui_DATA = \
panel-properties-dialog.ui \
- panel-run-dialog.ui
+ panel-run-dialog.ui \
+ panel-test-applets.ui
libexec_SCRIPTS = gnome-panel-add
@@ -203,6 +181,15 @@ gnome-panel-add: gnome-panel-add.in Makefile
< $< > $@
$(AM_V_at)chmod a+x $@
+panel_test_applets_SOURCES = \
+ panel-applet-container.c \
+ panel-applets-manager.c \
+ panel-marshal.c \
+ panel-test-applets.c
+
+panel_test_applets_LDFLAGS = -export-dynamic
+panel_test_applets_LDADD = $(PANEL_LIBS)
+
EXTRA_DIST = \
$(ui_DATA) \
nothing.cP \
diff --git a/gnome-panel/panel-applet-container.c b/gnome-panel/panel-applet-container.c
index 75f977a..d501390 100644
--- a/gnome-panel/panel-applet-container.c
+++ b/gnome-panel/panel-applet-container.c
@@ -21,19 +21,20 @@
*/
#include <string.h>
-#include <gobject/gvaluecollector.h>
-#include <eggdbus/eggdbus.h>
#include "panel-applet-container.h"
-#include "_panelapplet.h"
+#include "panel-marshal.h"
struct _PanelAppletContainerPrivate {
- EggDBusConnection *connection;
- EggDBusObjectProxy *applet_proxy;
- gchar *bus_name;
+ GDBusProxy *applet_proxy;
+
+ guint proxy_watcher_id;
+ guint name_watcher_id;
+ gchar *bus_name;
- GtkWidget *socket;
+ guint32 xid;
+ GtkWidget *socket;
- GHashTable *pending_ops;
+ GHashTable *pending_ops;
};
enum {
@@ -41,6 +42,7 @@ enum {
APPLET_MOVE,
APPLET_REMOVE,
APPLET_LOCK,
+ CHILD_PROPERTY_CHANGED,
LAST_SIGNAL
};
@@ -48,20 +50,18 @@ static guint signals[LAST_SIGNAL];
typedef struct {
const gchar *name;
- GType type;
- const gchar *signature;
const gchar *dbus_name;
} AppletPropertyInfo;
static const AppletPropertyInfo applet_properties [] = {
- { "prefs-key", G_TYPE_STRING, "s", "PrefsKey" },
- { "orient", G_TYPE_UINT, "u", "Orient" },
- { "size", G_TYPE_UINT, "u", "Size" },
- { "size-hints", G_TYPE_OBJECT, "i", "SizeHints" },
- { "background", G_TYPE_STRING, "s", "Background" },
- { "flags", G_TYPE_UINT, "u", "Flags" },
- { "locked", G_TYPE_BOOLEAN, "b", "Locked" },
- { "locked-down", G_TYPE_BOOLEAN, "b", "LockedDown" }
+ { "prefs-key", "PrefsKey" },
+ { "orient", "Orient" },
+ { "size", "Size" },
+ { "size-hints", "SizeHints" },
+ { "background", "Background" },
+ { "flags", "Flags" },
+ { "locked", "Locked" },
+ { "locked-down", "LockedDown" }
};
#define PANEL_APPLET_CONTAINER_GET_PRIVATE(o) \
@@ -137,6 +137,16 @@ panel_applet_container_dispose (GObject *object)
container->priv->bus_name = NULL;
}
+ if (container->priv->name_watcher_id > 0) {
+ g_bus_unwatch_name (container->priv->name_watcher_id);
+ container->priv->name_watcher_id = 0;
+ }
+
+ if (container->priv->proxy_watcher_id > 0) {
+ g_bus_unwatch_proxy (container->priv->proxy_watcher_id);
+ container->priv->proxy_watcher_id = 0;
+ }
+
if (container->priv->applet_proxy) {
g_object_unref (container->priv->applet_proxy);
container->priv->applet_proxy = NULL;
@@ -194,24 +204,18 @@ panel_applet_container_class_init (PanelAppletContainerClass *klass)
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE,
1, G_TYPE_BOOLEAN);
-}
-
-static _PanelAppletOrient
-get_panel_applet_orient (PanelOrientation orientation)
-{
- switch (orientation) {
- case PANEL_ORIENTATION_TOP:
- return _PANEL_APPLET_ORIENT_DOWN;
- case PANEL_ORIENTATION_BOTTOM:
- return _PANEL_APPLET_ORIENT_UP;
- case PANEL_ORIENTATION_LEFT:
- return _PANEL_APPLET_ORIENT_RIGHT;
- case PANEL_ORIENTATION_RIGHT:
- return _PANEL_APPLET_ORIENT_LEFT;
- default:
- g_assert_not_reached ();
- break;
- }
+ signals[CHILD_PROPERTY_CHANGED] =
+ g_signal_new ("child-property-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE |
+ G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS,
+ G_STRUCT_OFFSET (PanelAppletContainerClass, child_property_changed),
+ NULL,
+ NULL,
+ panel_marshal_VOID__STRING_POINTER,
+ G_TYPE_NONE, 2,
+ G_TYPE_STRING,
+ G_TYPE_POINTER);
}
static const AppletPropertyInfo *
@@ -229,209 +233,129 @@ panel_applet_container_child_property_get_info (const gchar *property_name)
return NULL;
}
-static void
-set_applet_property_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
+GtkWidget *
+panel_applet_container_new (void)
{
- GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
- PanelAppletContainer *container;
- GError *error = NULL;
-
- if (!egg_dbus_properties_set_finish (EGG_DBUS_PROPERTIES (source_object), res, &error)) {
- if (!g_error_matches (error, EGG_DBUS_ERROR, EGG_DBUS_ERROR_CANCELLED))
- g_warning ("Error setting property: %s\n", error->message);
- g_simple_async_result_set_from_error (result, error);
- g_error_free (error);
- }
+ GtkWidget *container;
- container = PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
- g_hash_table_remove (container->priv->pending_ops, result);
- g_simple_async_result_complete (result);
- g_object_unref (result);
+ container = GTK_WIDGET (g_object_new (PANEL_TYPE_APPLET_CONTAINER, NULL));
- /* g_async_result_get_source_object returns new ref */
- g_object_unref (container);
+ return container;
}
-static void
-panel_applet_container_set_applet_property (PanelAppletContainer *container,
- const gchar *property_name,
- EggDBusVariant *variant,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+static gboolean
+panel_applet_container_plug_removed (PanelAppletContainer *container)
{
- EggDBusObjectProxy *proxy = container->priv->applet_proxy;
- GSimpleAsyncResult *result;
-
- if (!proxy)
- return;
-
- result = g_simple_async_result_new (G_OBJECT (container),
- callback,
- user_data,
- panel_applet_container_set_applet_property);
-
- if (cancellable)
- g_object_ref (cancellable);
- else
- cancellable = g_cancellable_new ();
- g_hash_table_insert (container->priv->pending_ops, result, cancellable);
-
- egg_dbus_properties_set (EGG_DBUS_QUERY_INTERFACE_PROPERTIES (proxy),
- EGG_DBUS_CALL_FLAGS_NONE,
- PANEL_APPLET_INTERFACE,
- property_name,
- variant,
- cancellable,
- set_applet_property_cb,
- result);
-}
+ if (!container->priv->applet_proxy)
+ return FALSE;
-static void
-get_applet_property_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
- PanelAppletContainer *container;
- EggDBusVariant *variant = NULL;
- GError *error = NULL;
+ panel_applet_container_cancel_pending_operations (container);
- if (!egg_dbus_properties_get_finish (EGG_DBUS_PROPERTIES (source_object), &variant, res, &error)) {
- if (!g_error_matches (error, EGG_DBUS_ERROR, EGG_DBUS_ERROR_CANCELLED))
- g_warning ("Error getting property: %s\n", error->message);
- g_simple_async_result_set_from_error (result, error);
- g_error_free (error);
- } else {
- g_simple_async_result_set_op_res_gpointer (result, variant,
- (GDestroyNotify)g_object_unref);
+ if (container->priv->name_watcher_id > 0) {
+ g_bus_unwatch_name (container->priv->name_watcher_id);
+ container->priv->name_watcher_id = 0;
+ }
+ if (container->priv->proxy_watcher_id > 0) {
+ g_bus_unwatch_proxy (container->priv->proxy_watcher_id);
+ container->priv->proxy_watcher_id = 0;
}
- container = PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
- g_hash_table_remove (container->priv->pending_ops, result);
- g_simple_async_result_complete (result);
- g_object_unref (result);
-
- /* g_async_result_get_source_object returns new ref */
- g_object_unref (container);
-}
-
-static void
-panel_applet_container_get_applet_property (PanelAppletContainer *container,
- const gchar *property_name,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- EggDBusObjectProxy *proxy = container->priv->applet_proxy;
- GSimpleAsyncResult *result;
-
- if (!proxy)
- return;
-
- result = g_simple_async_result_new (G_OBJECT (container),
- callback,
- user_data,
- panel_applet_container_get_applet_property);
- if (cancellable)
- g_object_ref (cancellable);
- else
- cancellable = g_cancellable_new ();
- g_hash_table_insert (container->priv->pending_ops, result, cancellable);
-
- egg_dbus_properties_get (EGG_DBUS_QUERY_INTERFACE_PROPERTIES (proxy),
- EGG_DBUS_CALL_FLAGS_NONE,
- PANEL_APPLET_INTERFACE,
- property_name,
- cancellable,
- get_applet_property_cb,
- result);
-}
-
-GtkWidget *
-panel_applet_container_new (void)
-{
- GtkWidget *container;
-
- container = GTK_WIDGET (g_object_new (PANEL_TYPE_APPLET_CONTAINER, NULL));
+ g_object_unref (container->priv->applet_proxy);
+ container->priv->applet_proxy = NULL;
- return container;
-}
+ g_signal_emit (container, signals[APPLET_BROKEN], 0);
-static void
-panel_applet_container_child_move (_PanelApplet *instance,
- PanelAppletContainer *container)
-{
- g_signal_emit_by_name (container, "applet-move");
+ /* Continue destroying, in case of reloading
+ * a new frame widget is created
+ */
+ return FALSE;
}
static void
-panel_applet_container_child_remove (_PanelApplet *instance,
+panel_applet_container_child_signal (GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
PanelAppletContainer *container)
{
- g_signal_emit_by_name (container, "applet-remove");
+ if (g_strcmp0 (signal_name, "Move") == 0) {
+ g_signal_emit (container, signals[APPLET_MOVE], 0);
+ } else if (g_strcmp0 (signal_name, "RemoveFromPanel") == 0) {
+ g_signal_emit (container, signals[APPLET_REMOVE], 0);
+ } else if (g_strcmp0 (signal_name, "Lock") == 0) {
+ g_signal_emit (container, signals[APPLET_LOCK], 0, TRUE);
+ } else if (g_strcmp0 (signal_name, "Unlock") == 0) {
+ g_signal_emit (container, signals[APPLET_LOCK], 0, FALSE);
+ }
}
static void
-panel_applet_container_child_lock (_PanelApplet *instance,
- PanelAppletContainer *container)
-{
- g_signal_emit_by_name (container, "applet-lock", TRUE);
-}
+on_property_changed (GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ PanelAppletContainer *container)
+{
+ GVariant *props;
+ GVariantIter iter;
+ GVariant *value;
+ gchar *key;
+
+ g_variant_get (parameters, "(s a{sv}*)", NULL, &props, NULL);
+
+ g_variant_iter_init (&iter, props);
+ while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) {
+ if (g_strcmp0 (key, "Flags") == 0) {
+ g_signal_emit (container, signals[CHILD_PROPERTY_CHANGED],
+ g_quark_from_string ("flags"),
+ "flags", value);
+ } else if (g_strcmp0 (key, "SizeHints") == 0) {
+ g_signal_emit (container, signals[CHILD_PROPERTY_CHANGED],
+ g_quark_from_string ("size-hints"),
+ "size-hints", value);
+ }
+ }
-static void
-panel_applet_container_child_unlock (_PanelApplet *instance,
- PanelAppletContainer *container)
-{
- g_signal_emit_by_name (container, "applet-lock", FALSE);
+ g_variant_unref (props);
}
static void
-panel_applet_container_child_size_hints_changed (_PanelApplet *instance,
- GParamSpec *pscpec,
- PanelAppletContainer *container)
+on_proxy_appeared (GDBusConnection *connection,
+ const gchar *name,
+ const gchar *name_owner,
+ GDBusProxy *proxy,
+ gpointer user_data)
{
- /* FIXME: this is very inefficient, EgDBusChanged already
- * contains a map with the new prop values, but we don't have
- * access to that signal. Calling g_object_get() here would
- * call GetAll synchronously so we emit the prop change and
- * frame will ask again the value of the prop
- */
- g_signal_emit_by_name (container, "child-notify::size-hints", pscpec);
-}
+ GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ PanelAppletContainer *container;
-static void
-panel_applet_container_child_flags_changed (_PanelApplet *instance,
- GParamSpec *pscpec,
- PanelAppletContainer *container)
-{
- /* FIXME: this is very inefficient, EgDBusChanged already
- * contains a map with the new prop values, but we don't have
- * access to that signal. Calling g_object_get() here would
- * call GetAll synchronously so we emit the prop change and
- * frame will ask again the value of the prop
- */
- g_signal_emit_by_name (container, "child-notify::flags", pscpec);
-}
+ container = PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
-static gboolean
-panel_applet_container_plug_removed (PanelAppletContainer *container)
-{
- if (!container->priv->applet_proxy)
- return FALSE;
+ container->priv->applet_proxy = g_object_ref (proxy);
+ g_signal_connect (container->priv->applet_proxy, "g-signal",
+ G_CALLBACK (panel_applet_container_child_signal),
+ container);
+ g_dbus_connection_signal_subscribe (connection,
+ name_owner,
+ "org.freedesktop.DBus.Properties",
+ "PropertiesChanged",
+ g_dbus_proxy_get_object_path (proxy),
+ PANEL_APPLET_INTERFACE,
+ (GDBusSignalCallback)on_property_changed,
+ container, NULL);
- panel_applet_container_cancel_pending_operations (container);
- g_object_unref (container->priv->applet_proxy);
- container->priv->applet_proxy = NULL;
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
- g_signal_emit (container, signals[APPLET_BROKEN], 0);
+ if (container->priv->xid > 0) {
+ gtk_socket_add_id (GTK_SOCKET (container->priv->socket),
+ container->priv->xid);
+ }
- /* Continue destroying, in case of reloading
- * a new frame widget is created
- */
- return FALSE;
+ /* g_async_result_get_source_object returns new ref */
+ g_object_unref (container);
}
static void
@@ -439,86 +363,102 @@ get_applet_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- EggDBusConnection *connection = EGG_DBUS_CONNECTION (source_object);
+ GDBusConnection *connection = G_DBUS_CONNECTION (source_object);
GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
PanelAppletContainer *container;
- EggDBusMessage *reply;
- guint32 xid = 0;
+ GVariant *retvals;
+ const gchar *applet_path;
GError *error = NULL;
container = PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
- reply = egg_dbus_connection_send_message_with_reply_finish (connection, res, &error);
- if (reply) {
- gchar *applet_path;
-
- if (egg_dbus_message_extract_object_path (reply, &applet_path, &error)) {
- container->priv->applet_proxy =
- egg_dbus_connection_get_object_proxy (container->priv->connection,
- container->priv->bus_name,
- applet_path);
- g_signal_connect (_PANEL_QUERY_INTERFACE_APPLET (container->priv->applet_proxy),
- "move",
- G_CALLBACK (panel_applet_container_child_move),
- container);
- g_signal_connect (_PANEL_QUERY_INTERFACE_APPLET (container->priv->applet_proxy),
- "remove-from-panel",
- G_CALLBACK (panel_applet_container_child_remove),
- container);
- g_signal_connect (_PANEL_QUERY_INTERFACE_APPLET (container->priv->applet_proxy),
- "lock",
- G_CALLBACK (panel_applet_container_child_lock),
- container);
- g_signal_connect (_PANEL_QUERY_INTERFACE_APPLET (container->priv->applet_proxy),
- "unlock",
- G_CALLBACK (panel_applet_container_child_unlock),
- container);
- /* Frame is only interested in size-hints and flags so
- * we don't notify any other property changes.
- * Connecting directly to egg-dbus-changed would be better
- * but it doesn't work :-(
- */
- g_signal_connect (_PANEL_QUERY_INTERFACE_APPLET (container->priv->applet_proxy),
- "notify::size-hints",
- G_CALLBACK (panel_applet_container_child_size_hints_changed),
- container);
- g_signal_connect (_PANEL_QUERY_INTERFACE_APPLET (container->priv->applet_proxy),
- "notify::flags",
- G_CALLBACK (panel_applet_container_child_flags_changed),
- container);
- g_free (applet_path);
- egg_dbus_message_extract_uint (reply, &xid, &error);
- }
- g_object_unref (reply);
- }
-
- if (error) {
+ retvals = g_dbus_connection_call_finish (connection, res, &error);
+ if (!retvals) {
g_simple_async_result_set_from_error (result, error);
g_error_free (error);
- }
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
- g_simple_async_result_complete (result);
- g_object_unref (result);
+ return;
+ }
- if (xid > 0)
- gtk_socket_add_id (GTK_SOCKET (container->priv->socket), xid);
+ container = PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
+ g_variant_get (retvals, "(&ou)", &applet_path, &container->priv->xid);
+
+ container->priv->proxy_watcher_id =
+ g_bus_watch_proxy_on_connection (connection,
+ container->priv->bus_name,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ applet_path,
+ PANEL_APPLET_INTERFACE,
+ G_TYPE_DBUS_PROXY,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ (GBusProxyAppearedCallback)on_proxy_appeared,
+ NULL,
+ result,
+ NULL);
+ g_variant_unref (retvals);
/* g_async_result_get_source_object returns new ref */
g_object_unref (container);
}
+typedef struct {
+ GSimpleAsyncResult *result;
+ gchar *factory_id;
+ GVariant *parameters;
+ GCancellable *cancellable;
+} AppletFactoryData;
+
+static void
+applet_factory_data_free (AppletFactoryData *data)
+{
+ g_free (data->factory_id);
+ if (data->cancellable)
+ g_object_unref (data->cancellable);
+
+ g_free (data);
+}
+
+static void
+on_factory_appeared (GDBusConnection *connection,
+ const gchar *name,
+ const gchar *name_owner,
+ AppletFactoryData *data)
+{
+ PanelAppletContainer *container;
+ gchar *object_path;
+
+ container = PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (data->result)));
+ container->priv->bus_name = g_strdup (name_owner);
+ object_path = g_strdup_printf (PANEL_APPLET_FACTORY_OBJECT_PATH, data->factory_id);
+ g_dbus_connection_call (connection,
+ name_owner,
+ object_path,
+ PANEL_APPLET_FACTORY_INTERFACE,
+ "GetApplet",
+ data->parameters,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ data->cancellable,
+ get_applet_cb,
+ data->result);
+ g_free (object_path);
+
+ g_bus_unwatch_name (container->priv->name_watcher_id);
+}
+
static void
panel_applet_container_get_applet (PanelAppletContainer *container,
const gchar *iid,
- EggDBusHashMap *props,
+ GVariant *props,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- EggDBusMessage *message;
GSimpleAsyncResult *result;
+ AppletFactoryData *data;
gint screen;
gchar *bus_name;
- gchar *object_path;
gchar *factory_id;
gchar *applet_id;
@@ -527,20 +467,6 @@ panel_applet_container_get_applet (PanelAppletContainer *container,
user_data,
panel_applet_container_get_applet);
- if (!container->priv->connection) {
- container->priv->connection = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SESSION);
- if (!container->priv->connection) {
- g_simple_async_result_set_error (result,
- EGG_DBUS_ERROR,
- EGG_DBUS_ERROR_DBUS_FAILED,
- "%s", "Failed to connect to the D-BUS daemon");
- g_simple_async_result_complete (result);
- g_object_unref (result);
-
- return;
- }
- }
-
applet_id = g_strrstr (iid, "::");
if (!applet_id) {
g_simple_async_result_set_error (result,
@@ -558,97 +484,24 @@ panel_applet_container_get_applet (PanelAppletContainer *container,
screen = gdk_screen_get_number (gtk_widget_get_screen (container->priv->socket));
- object_path = g_strdup_printf (PANEL_APPLET_FACTORY_OBJECT_PATH, factory_id);
- bus_name = g_strdup_printf (PANEL_APPLET_BUS_NAME, factory_id);
-
- if (container->priv->bus_name)
- g_free (container->priv->bus_name);
- container->priv->bus_name = bus_name;
-
- message = egg_dbus_connection_new_message_for_method_call (container->priv->connection,
- NULL,
- bus_name,
- object_path,
- PANEL_APPLET_FACTORY_INTERFACE,
- "GetApplet");
- egg_dbus_message_append_string (message, applet_id, NULL);
- egg_dbus_message_append_int (message, screen, NULL);
- egg_dbus_message_append_map (message, props, "s", "v", NULL);
-
- egg_dbus_connection_send_message_with_reply (container->priv->connection,
- EGG_DBUS_CALL_FLAGS_NONE,
- message,
- NULL,
- cancellable,
- get_applet_cb,
- result);
- g_free (factory_id);
- g_free (object_path);
- g_object_unref (message);
-}
-
-static EggDBusHashMap *
-contruct_properties_map (PanelAppletContainer *container,
- const gchar *first_prop_name,
- va_list var_args)
-{
- EggDBusHashMap *map;
- const gchar *name;
-
- map = egg_dbus_hash_map_new (G_TYPE_STRING,
- g_free,
- EGG_DBUS_TYPE_VARIANT,
- g_object_unref);
-
- name = first_prop_name;
- while (name) {
- const AppletPropertyInfo *info;
- EggDBusVariant *variant;
- GValue *value;
- gchar *error = NULL;
-
- info = panel_applet_container_child_property_get_info (name);
- if (!info) {
- g_warning ("%s: Applet has no child property named `%s'",
- G_STRLOC, name);
- break;
- }
+ data = g_new (AppletFactoryData, 1);
+ data->result = result;
+ data->factory_id = factory_id;
+ data->parameters = g_variant_new ("(si*)", applet_id, screen, props);
+ data->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
- value = g_new0 (GValue, 1);
- g_value_init (value, info->type);
- G_VALUE_COLLECT (value, var_args, 0, &error);
- if (error) {
- g_warning ("%s: %s", G_STRLOC, error);
- g_free (error);
- g_value_unset (value);
- g_free (value);
-
- break;
- }
-
- if (G_VALUE_HOLDS_STRING (value) &&
- strlen (g_value_get_string (value)) == 0) {
- name = va_arg (var_args, gchar*);
- continue;
- }
-
- /* For some reason libpanel-applet and panel use
- * a different logic for orientation, so we need
- * to convert it. We should fix this.
- */
- if (strcmp (name, "orient") == 0) {
- _PanelAppletOrient orient;
-
- orient = get_panel_applet_orient (g_value_get_uint (value));
- g_value_set_uint (value, orient);
- }
+ bus_name = g_strdup_printf (PANEL_APPLET_BUS_NAME, factory_id);
- variant = egg_dbus_variant_new_for_gvalue (value, info->signature);
- egg_dbus_hash_map_insert (map, g_strdup (name), variant);
- name = va_arg (var_args, gchar*);
- }
+ container->priv->name_watcher_id =
+ g_bus_watch_name (G_BUS_TYPE_SESSION,
+ bus_name,
+ G_BUS_NAME_WATCHER_FLAGS_AUTO_START,
+ (GBusNameAppearedCallback) on_factory_appeared,
+ NULL,
+ data,
+ (GDestroyNotify)applet_factory_data_free);
- return map;
+ g_free (bus_name);
}
void
@@ -657,24 +510,15 @@ panel_applet_container_add (PanelAppletContainer *container,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data,
- const gchar *first_prop_name,
- ...)
+ GVariant *properties)
{
- EggDBusHashMap *map;
- va_list var_args;
-
g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container));
g_return_if_fail (iid != NULL);
panel_applet_container_cancel_pending_operations (container);
- va_start (var_args, first_prop_name);
- map = contruct_properties_map (container, first_prop_name, var_args);
- va_end (var_args);
-
- panel_applet_container_get_applet (container, iid, map, cancellable,
- callback, user_data);
- g_object_unref (map);
+ panel_applet_container_get_applet (container, iid, properties,
+ cancellable, callback, user_data);
}
gboolean
@@ -690,100 +534,50 @@ panel_applet_container_add_finish (PanelAppletContainer *container,
}
/* Child Properties */
-void
-panel_applet_container_child_set_property (PanelAppletContainer *container,
- const gchar *property_name,
- const GValue *value,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+static void
+set_applet_property_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
- const AppletPropertyInfo *info;
- EggDBusVariant *variant;
+ GDBusConnection *connection = G_DBUS_CONNECTION (source_object);
+ GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ PanelAppletContainer *container;
+ GVariant *retvals;
+ GError *error = NULL;
- info = panel_applet_container_child_property_get_info (property_name);
- if (!info) {
- g_simple_async_report_error_in_idle (G_OBJECT (container),
- callback, user_data,
- PANEL_APPLET_CONTAINER_ERROR,
- PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY,
- "%s: Applet has no child property named `%s'",
- G_STRLOC, property_name);
- return;
+ retvals = g_dbus_connection_call_finish (connection, res, &error);
+ if (!retvals) {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Error setting property: %s\n", error->message);
+ g_simple_async_result_set_from_error (result, error);
+ g_error_free (error);
+ } else {
+ g_variant_unref (retvals);
}
- variant = egg_dbus_variant_new_for_gvalue (value, info->signature);
- panel_applet_container_set_applet_property (container,
- info->dbus_name,
- variant,
- cancellable,
- callback,
- user_data);
- g_object_unref (variant);
-}
-
-gboolean
-panel_applet_container_child_set_property_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
-
- g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == panel_applet_container_set_applet_property);
+ container = PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
+ g_hash_table_remove (container->priv->pending_ops, result);
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
- return !g_simple_async_result_propagate_error (simple, error);
+ /* g_async_result_get_source_object returns new ref */
+ g_object_unref (container);
}
void
-panel_applet_container_child_set_uint (PanelAppletContainer *container,
- const gchar *property_name,
- guint value,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
+panel_applet_container_child_set (PanelAppletContainer *container,
+ const gchar *property_name,
+ const GVariant *value,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GDBusProxy *proxy = container->priv->applet_proxy;
const AppletPropertyInfo *info;
- EggDBusVariant *variant;
+ GSimpleAsyncResult *result;
- info = panel_applet_container_child_property_get_info (property_name);
- if (!info) {
- g_simple_async_report_error_in_idle (G_OBJECT (container),
- callback, user_data,
- PANEL_APPLET_CONTAINER_ERROR,
- PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY,
- "%s: Applet has no child property named `%s'",
- G_STRLOC, property_name);
+ if (!proxy)
return;
- }
-
- variant = egg_dbus_variant_new_for_uint (value);
- panel_applet_container_set_applet_property (container,
- info->dbus_name,
- variant,
- cancellable,
- callback,
- user_data);
- g_object_unref (variant);
-}
-
-gboolean
-panel_applet_container_child_set_uint_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error)
-{
- return panel_applet_container_child_set_property_finish (container, result, error);
-}
-
-void
-panel_applet_container_child_set_boolean (PanelAppletContainer *container,
- const gchar *property_name,
- gboolean value,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- const AppletPropertyInfo *info;
- EggDBusVariant *variant;
info = panel_applet_container_child_property_get_info (property_name);
if (!info) {
@@ -796,131 +590,94 @@ panel_applet_container_child_set_boolean (PanelAppletContainer *container,
return;
}
- variant = egg_dbus_variant_new_for_boolean (value);
- panel_applet_container_set_applet_property (container,
- info->dbus_name,
- variant,
- cancellable,
- callback,
- user_data);
- g_object_unref (variant);
-}
-
-gboolean
-panel_applet_container_child_set_boolean_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error)
-{
- return panel_applet_container_child_set_property_finish (container, result, error);
-}
-
-void
-panel_applet_container_child_set_string (PanelAppletContainer *container,
- const gchar *property_name,
- const gchar *value,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- const AppletPropertyInfo *info;
- EggDBusVariant *variant;
+ result = g_simple_async_result_new (G_OBJECT (container),
+ callback,
+ user_data,
+ panel_applet_container_child_set);
- info = panel_applet_container_child_property_get_info (property_name);
- if (!info) {
- g_simple_async_report_error_in_idle (G_OBJECT (container),
- callback, user_data,
- PANEL_APPLET_CONTAINER_ERROR,
- PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY,
- "%s: Applet has no child property named `%s'",
- G_STRLOC, property_name);
- return;
- }
+ if (cancellable)
+ g_object_ref (cancellable);
+ else
+ cancellable = g_cancellable_new ();
+ g_hash_table_insert (container->priv->pending_ops, result, cancellable);
- variant = egg_dbus_variant_new_for_string (value);
- panel_applet_container_set_applet_property (container,
- info->dbus_name,
- variant,
- cancellable,
- callback,
- user_data);
- g_object_unref (variant);
+ g_dbus_connection_call (g_dbus_proxy_get_connection (proxy),
+ g_dbus_proxy_get_unique_bus_name (proxy),
+ g_dbus_proxy_get_object_path (proxy),
+ "org.freedesktop.DBus.Properties",
+ "Set",
+ g_variant_new ("(ssv)",
+ g_dbus_proxy_get_interface_name (proxy),
+ info->dbus_name,
+ value),
+ G_DBUS_CALL_FLAGS_NO_AUTO_START,
+ -1, cancellable,
+ set_applet_property_cb,
+ result);
}
gboolean
-panel_applet_container_child_set_string_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error)
+panel_applet_container_child_set_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error)
{
- return panel_applet_container_child_set_property_finish (container, result, error);
-}
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
-void
-panel_applet_container_child_set_size_hints (PanelAppletContainer *container,
- const gint *size_hints,
- guint n_hints,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- const AppletPropertyInfo *info;
- EggDBusVariant *variant;
- EggDBusArraySeq *seq;
- gint i;
-
- info = panel_applet_container_child_property_get_info ("size-hints");
-
- seq = egg_dbus_array_seq_new (G_TYPE_INT, NULL, NULL, NULL);
- for (i = 0; i < n_hints; i++)
- egg_dbus_array_seq_add_fixed (seq, (guint64)size_hints[i]);
- variant = egg_dbus_variant_new_for_seq (seq, info->signature);
- g_object_unref (seq);
- panel_applet_container_set_applet_property (container,
- info->dbus_name,
- variant,
- cancellable,
- callback,
- user_data);
- g_object_unref (variant);
-}
+ g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == panel_applet_container_child_set);
-gboolean
-panel_applet_container_child_set_size_hints_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error)
-{
- return panel_applet_container_child_set_property_finish (container, result, error);
+ return !g_simple_async_result_propagate_error (simple, error);
}
-void
-panel_applet_container_child_set_orientation (PanelAppletContainer *container,
- PanelOrientation orientation,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+static void
+get_applet_property_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
- panel_applet_container_child_set_uint (container, "orient",
- get_panel_applet_orient (orientation),
- cancellable, callback, user_data);
-}
+ GDBusConnection *connection = G_DBUS_CONNECTION (source_object);
+ GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ PanelAppletContainer *container;
+ GVariant *retvals;
+ GError *error = NULL;
-gboolean
-panel_applet_container_child_set_orientation_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error)
-{
- return panel_applet_container_child_set_property_finish (container, result, error);
-}
+ retvals = g_dbus_connection_call_finish (connection, res, &error);
+ if (!retvals) {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Error getting property: %s\n", error->message);
+ g_simple_async_result_set_from_error (result, error);
+ g_error_free (error);
+ } else {
+ GVariant *value, *item;
+
+ item = g_variant_get_child_value (retvals, 0);
+ value = g_variant_get_variant (item);
+ g_variant_unref (item);
+ g_simple_async_result_set_op_res_gpointer (result, value,
+ (GDestroyNotify)g_variant_unref);
+ g_variant_unref (retvals);
+ }
+ container = PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
+ g_hash_table_remove (container->priv->pending_ops, result);
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+ /* g_async_result_get_source_object returns new ref */
+ g_object_unref (container);
+}
void
-panel_applet_container_child_get_property (PanelAppletContainer *container,
- const gchar *property_name,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+panel_applet_container_child_get (PanelAppletContainer *container,
+ const gchar *property_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
+ GDBusProxy *proxy = container->priv->applet_proxy;
const AppletPropertyInfo *info;
+ GSimpleAsyncResult *result;
+
+ if (!proxy)
+ return;
info = panel_applet_container_child_property_get_info (property_name);
if (!info) {
@@ -933,167 +690,43 @@ panel_applet_container_child_get_property (PanelAppletContainer *container,
return;
}
- panel_applet_container_get_applet_property (container,
- info->dbus_name,
- cancellable,
- callback,
- user_data);
-}
-
-gboolean
-panel_applet_container_child_get_property_finish (PanelAppletContainer *container,
- GValue *value,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- EggDBusVariant *variant;
-
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
-
- variant = EGG_DBUS_VARIANT (g_simple_async_result_get_op_res_gpointer (simple));
- *value = *egg_dbus_variant_get_gvalue (variant);
- g_value_copy (egg_dbus_variant_get_gvalue (variant), value);
-
- return TRUE;
-}
-
-void
-panel_applet_container_child_get_uint (PanelAppletContainer *container,
- const gchar *property_name,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- panel_applet_container_child_get_property (container,
- property_name,
- cancellable,
- callback,
- user_data);
-}
-
-gboolean
-panel_applet_container_child_get_uint_finish (PanelAppletContainer *container,
- guint *value,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- EggDBusVariant *variant;
-
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
-
- variant = EGG_DBUS_VARIANT (g_simple_async_result_get_op_res_gpointer (simple));
- *value = egg_dbus_variant_get_uint (variant);
-
- return TRUE;
-}
-
-void
-panel_applet_container_child_get_boolean (PanelAppletContainer *container,
- const gchar *property_name,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- panel_applet_container_child_get_property (container,
- property_name,
- cancellable,
- callback,
- user_data);
-}
-
-gboolean
-panel_applet_container_child_get_boolean_finish (PanelAppletContainer *container,
- gboolean *value,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- EggDBusVariant *variant;
-
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
-
- variant = EGG_DBUS_VARIANT (g_simple_async_result_get_op_res_gpointer (simple));
- *value = egg_dbus_variant_get_boolean (variant);
-
- return TRUE;
-}
-
-void
-panel_applet_container_child_get_string (PanelAppletContainer *container,
- const gchar *property_name,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- panel_applet_container_child_get_property (container,
- property_name,
- cancellable,
- callback,
- user_data);
-}
+ result = g_simple_async_result_new (G_OBJECT (container),
+ callback,
+ user_data,
+ panel_applet_container_child_get);
+ if (cancellable)
+ g_object_ref (cancellable);
+ else
+ cancellable = g_cancellable_new ();
+ g_hash_table_insert (container->priv->pending_ops, result, cancellable);
-gboolean
-panel_applet_container_child_get_string_finish (PanelAppletContainer *container,
- gchar **value,
- GAsyncResult *result,
- GError **error)
+ g_dbus_connection_call (g_dbus_proxy_get_connection (proxy),
+ g_dbus_proxy_get_unique_bus_name (proxy),
+ g_dbus_proxy_get_object_path (proxy),
+ "org.freedesktop.DBus.Properties",
+ "Get",
+ g_variant_new ("(ss)",
+ g_dbus_proxy_get_interface_name (proxy),
+ info->dbus_name),
+ G_DBUS_CALL_FLAGS_NO_AUTO_START,
+ -1, cancellable,
+ get_applet_property_cb,
+ result);
+}
+
+GVariant *
+panel_applet_container_child_get_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- EggDBusVariant *variant;
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
-
- variant = EGG_DBUS_VARIANT (g_simple_async_result_get_op_res_gpointer (simple));
- *value = g_strdup (egg_dbus_variant_get_string (variant));
-
- return TRUE;
-}
-
-void
-panel_applet_container_child_get_size_hints (PanelAppletContainer *container,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- panel_applet_container_child_get_property (container,
- "size-hints",
- cancellable,
- callback,
- user_data);
-}
-
-gboolean
-panel_applet_container_child_get_size_hints_finish (PanelAppletContainer *container,
- gint **size_hints,
- guint *n_elements,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- EggDBusVariant *variant;
- EggDBusArraySeq *seq;
- gint i;
+ g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == panel_applet_container_child_get);
if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
+ return NULL;
- variant = EGG_DBUS_VARIANT (g_simple_async_result_get_op_res_gpointer (simple));
- seq = egg_dbus_variant_get_seq (variant);
- *n_elements = egg_dbus_array_seq_get_size (seq);
- *size_hints = *n_elements > 0 ? g_new (gint, *n_elements) : NULL;
- for (i = 0; i < *n_elements; i++) {
- size_hints[0][i] = egg_dbus_array_seq_get_fixed (seq, i);
-
- }
- g_object_unref (seq);
-
- return TRUE;
+ return g_variant_ref (g_simple_async_result_get_op_res_gpointer (simple));
}
static void
@@ -1101,20 +734,19 @@ child_popup_menu_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- EggDBusConnection *connection = EGG_DBUS_CONNECTION (source_object);
+ GDBusConnection *connection = G_DBUS_CONNECTION (source_object);
GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
- EggDBusMessage *reply;
+ GVariant *retvals;
GError *error = NULL;
- reply = egg_dbus_connection_send_message_with_reply_finish (connection, res, &error);
- if (error) {
+ retvals = g_dbus_connection_call_finish (connection, res, &error);
+ if (!retvals) {
g_simple_async_result_set_from_error (result, error);
g_error_free (error);
+ } else {
+ g_variant_unref (retvals);
}
- if (reply)
- g_object_unref (reply);
-
g_simple_async_result_complete (result);
g_object_unref (result);
}
@@ -1127,9 +759,8 @@ panel_applet_container_child_popup_menu (PanelAppletContainer *container,
GAsyncReadyCallback callback,
gpointer user_data)
{
- EggDBusMessage *message;
GSimpleAsyncResult *result;
- EggDBusObjectProxy *proxy = container->priv->applet_proxy;
+ GDBusProxy *proxy = container->priv->applet_proxy;
if (!proxy)
return;
@@ -1139,24 +770,16 @@ panel_applet_container_child_popup_menu (PanelAppletContainer *container,
user_data,
panel_applet_container_child_popup_menu);
- message = egg_dbus_connection_new_message_for_method_call (container->priv->connection,
- NULL,
- egg_dbus_object_proxy_get_name (proxy),
- egg_dbus_object_proxy_get_object_path (proxy),
- PANEL_APPLET_INTERFACE,
- "PopupMenu");
- egg_dbus_message_append_uint (message, button, NULL);
- egg_dbus_message_append_uint (message, timestamp, NULL);
-
- egg_dbus_connection_send_message_with_reply (container->priv->connection,
- EGG_DBUS_CALL_FLAGS_NONE,
- message,
- NULL,
- cancellable,
- child_popup_menu_cb,
- result);
- g_object_unref (message);
-
+ g_dbus_connection_call (g_dbus_proxy_get_connection (proxy),
+ g_dbus_proxy_get_unique_bus_name (proxy),
+ g_dbus_proxy_get_object_path (proxy),
+ PANEL_APPLET_INTERFACE,
+ "PopupMenu",
+ g_variant_new ("(uu)", button, timestamp),
+ G_DBUS_CALL_FLAGS_NO_AUTO_START,
+ -1, cancellable,
+ child_popup_menu_cb,
+ result);
}
gboolean
diff --git a/gnome-panel/panel-applet-container.h b/gnome-panel/panel-applet-container.h
index 3bd745c..130bf16 100644
--- a/gnome-panel/panel-applet-container.h
+++ b/gnome-panel/panel-applet-container.h
@@ -57,135 +57,58 @@ struct _PanelAppletContainerClass {
GtkEventBoxClass parent_class;
/* Signals */
- void (*applet_broken) (PanelAppletContainer *container);
- void (*applet_move) (PanelAppletContainer *container);
- void (*applet_remove) (PanelAppletContainer *container);
- void (*applet_lock) (PanelAppletContainer *container,
- gboolean locked);
+ void (*applet_broken) (PanelAppletContainer *container);
+ void (*applet_move) (PanelAppletContainer *container);
+ void (*applet_remove) (PanelAppletContainer *container);
+ void (*applet_lock) (PanelAppletContainer *container,
+ gboolean locked);
+ void (*child_property_changed) (PanelAppletContainer *container,
+ const gchar *property_name,
+ GVariant *value);
};
-GType panel_applet_container_get_type (void) G_GNUC_CONST;
-GQuark panel_applet_container_error_quark (void) G_GNUC_CONST;
-GtkWidget *panel_applet_container_new (void);
-
-
-void panel_applet_container_add (PanelAppletContainer *container,
- const gchar *iid,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data,
- const gchar *first_prop_name,
- ...);
-gboolean panel_applet_container_add_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error);
-void panel_applet_container_child_popup_menu (PanelAppletContainer *container,
- guint button,
- guint32 timestamp,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean panel_applet_container_child_popup_menu_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error);
-void panel_applet_container_child_set_property (PanelAppletContainer *container,
- const gchar *property_name,
- const GValue *value,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean panel_applet_container_child_set_property_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error);
-void panel_applet_container_child_set_uint (PanelAppletContainer *container,
- const gchar *property_name,
- guint value,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean panel_applet_container_child_set_uint_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error);
-void panel_applet_container_child_set_boolean (PanelAppletContainer *container,
- const gchar *property_name,
- gboolean value,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean panel_applet_container_child_set_boolean_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error);
-void panel_applet_container_child_set_string (PanelAppletContainer *container,
- const gchar *property_name,
- const gchar *value,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean panel_applet_container_child_set_string_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error);
-void panel_applet_container_child_set_size_hints (PanelAppletContainer *container,
- const gint *size_hints,
- guint n_hints,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean panel_applet_container_child_set_size_hints_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error);
-void panel_applet_container_child_set_orientation (PanelAppletContainer *container,
- PanelOrientation orientation,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean panel_applet_container_child_set_orientation_finish (PanelAppletContainer *container,
- GAsyncResult *result,
- GError **error);
-void panel_applet_container_child_get_property (PanelAppletContainer *container,
- const gchar *property_name,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean panel_applet_container_child_get_property_finish (PanelAppletContainer *container,
- GValue *value,
- GAsyncResult *result,
- GError **error);
-void panel_applet_container_child_get_uint (PanelAppletContainer *container,
- const gchar *property_name,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean panel_applet_container_child_get_uint_finish (PanelAppletContainer *container,
- guint *value,
- GAsyncResult *result,
- GError **error);
-void panel_applet_container_child_get_boolean (PanelAppletContainer *container,
- const gchar *property_name,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean panel_applet_container_child_get_boolean_finish (PanelAppletContainer *container,
- gboolean *value,
- GAsyncResult *result,
- GError **error);
-void panel_applet_container_child_get_string (PanelAppletContainer *container,
- const gchar *property_name,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean panel_applet_container_child_get_string_finish (PanelAppletContainer *container,
- gchar **value,
- GAsyncResult *result,
- GError **error);
-void panel_applet_container_child_get_size_hints (PanelAppletContainer *container,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean panel_applet_container_child_get_size_hints_finish (PanelAppletContainer *container,
- gint **size_hints,
- guint *n_elements,
- GAsyncResult *result,
- GError **error);
+GType panel_applet_container_get_type (void) G_GNUC_CONST;
+GQuark panel_applet_container_error_quark (void) G_GNUC_CONST;
+GtkWidget *panel_applet_container_new (void);
+
+
+void panel_applet_container_add (PanelAppletContainer *container,
+ const gchar *iid,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data,
+ GVariant *properties);
+gboolean panel_applet_container_add_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_popup_menu (PanelAppletContainer *container,
+ guint button,
+ guint32 timestamp,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_popup_menu_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error);
+
+void panel_applet_container_child_set (PanelAppletContainer *container,
+ const gchar *property_name,
+ const GVariant *value,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_set_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_get (PanelAppletContainer *container,
+ const gchar *property_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+GVariant *panel_applet_container_child_get_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error);
+
G_END_DECLS
#endif /* __PANEL_APPLET_CONTAINER_H__ */
diff --git a/gnome-panel/panel-applet-frame.c b/gnome-panel/panel-applet-frame.c
index 41f4189..868fbd3 100644
--- a/gnome-panel/panel-applet-frame.c
+++ b/gnome-panel/panel-applet-frame.c
@@ -92,21 +92,12 @@ static char *panel_applet_frame_get_background_string (PanelAppletFrame *fram
PanelBackgroundType type);
static void
-panel_applet_frame_get_flags_cb (PanelAppletContainer *container,
- GAsyncResult *res,
- PanelAppletFrame *frame)
+panel_applet_frame_update_flags (PanelAppletFrame *frame,
+ guint flags)
{
gboolean major;
gboolean minor;
gboolean old_has_handle;
- guint flags;
- GError *error = NULL;
-
- if (!panel_applet_container_child_get_uint_finish (container, &flags, res, &error)) {
- g_warning ("%s\n", error->message);
- g_error_free (error);
- return;
- }
major = flags & APPLET_EXPAND_MAJOR;
minor = flags & APPLET_EXPAND_MINOR;
@@ -128,21 +119,10 @@ panel_applet_frame_get_flags_cb (PanelAppletContainer *container,
}
static void
-panel_applet_frame_get_size_hints_cb (PanelAppletContainer *container,
- GAsyncResult *res,
- PanelAppletFrame *frame)
+panel_applet_frame_update_size_hints (PanelAppletFrame *frame,
+ gint *size_hints,
+ guint n_elements)
{
- gint *size_hints = NULL;
- guint n_elements;
- GError *error = NULL;
-
- if (!panel_applet_container_child_get_size_hints_finish (container, &size_hints,
- &n_elements, res, &error)) {
- g_warning ("%s\n", error->message);
- g_error_free (error);
- return;
- }
-
if (frame->priv->has_handle) {
gint extra_size = HANDLE_SIZE + 1;
gint i;
@@ -151,6 +131,7 @@ panel_applet_frame_get_size_hints_cb (PanelAppletContainer *container,
size_hints[i] += extra_size;
}
+ /* It takes the ownership of size-hints array */
panel_widget_set_applet_size_hints (frame->priv->panel,
GTK_WIDGET (frame),
size_hints,
@@ -158,23 +139,76 @@ panel_applet_frame_get_size_hints_cb (PanelAppletContainer *container,
}
static void
+panel_applet_frame_get_flags_cb (PanelAppletContainer *container,
+ GAsyncResult *res,
+ PanelAppletFrame *frame)
+{
+ GVariant *value;
+ GError *error = NULL;
+
+ value = panel_applet_container_child_get_finish (container, res, &error);
+ if (!value) {
+ g_warning ("%s\n", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ panel_applet_frame_update_flags (frame, g_variant_get_uint32 (value));
+ g_variant_unref (value);
+}
+
+static void
+panel_applet_frame_get_size_hints_cb (PanelAppletContainer *container,
+ GAsyncResult *res,
+ PanelAppletFrame *frame)
+{
+ GVariant *value;
+ const gint *sz;
+ gint *size_hints = NULL;
+ gsize n_elements;
+ GError *error = NULL;
+
+ value = panel_applet_container_child_get_finish (container, res, &error);
+ if (!value) {
+ g_warning ("%s\n", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ sz = g_variant_get_fixed_array (value, &n_elements, sizeof (gint32));
+ if (n_elements > 0) {
+ size_hints = g_new (gint32, n_elements);
+ memcpy (size_hints, sz, n_elements * sizeof (gint32));
+ }
+ panel_applet_frame_update_size_hints (frame, size_hints, n_elements);
+ g_variant_unref (value);
+}
+
+static void
panel_applet_frame_flags_changed (PanelAppletContainer *container,
- GParamSpec *pspec,
+ const gchar *prop_name,
+ GVariant *value,
PanelAppletFrame *frame)
{
- panel_applet_container_child_get_uint (container, "flags", NULL,
- (GAsyncReadyCallback)panel_applet_frame_get_flags_cb,
- frame);
+ panel_applet_frame_update_flags (frame, g_variant_get_uint32 (value));
}
static void
panel_applet_frame_size_hints_changed (PanelAppletContainer *container,
- GParamSpec *pspec,
+ const gchar *prop_name,
+ GVariant *value,
PanelAppletFrame *frame)
{
- panel_applet_container_child_get_size_hints (container, NULL,
- (GAsyncReadyCallback)panel_applet_frame_get_size_hints_cb,
- frame);
+ const gint *sz;
+ gint *size_hints = NULL;
+ gsize n_elements;
+
+ sz = g_variant_get_fixed_array (value, &n_elements, sizeof (gint32));
+ if (n_elements > 0) {
+ size_hints = g_new (gint32, n_elements);
+ memcpy (size_hints, sz, n_elements * sizeof (gint32));
+ }
+ panel_applet_frame_update_size_hints (frame, size_hints, n_elements);
}
static void
@@ -182,16 +216,16 @@ panel_applet_frame_init_properties (PanelAppletFrame *frame)
{
PanelAppletContainer *container = PANEL_APPLET_CONTAINER (frame);
- panel_applet_container_child_get_uint (container, "flags", NULL,
- (GAsyncReadyCallback)panel_applet_frame_get_flags_cb,
- frame);
- panel_applet_container_child_get_size_hints (container, NULL,
- (GAsyncReadyCallback)panel_applet_frame_get_size_hints_cb,
- frame);
- g_signal_connect (container, "child-notify::flags",
+ panel_applet_container_child_get (container, "flags", NULL,
+ (GAsyncReadyCallback)panel_applet_frame_get_flags_cb,
+ frame);
+ panel_applet_container_child_get (container, "size-hints", NULL,
+ (GAsyncReadyCallback)panel_applet_frame_get_size_hints_cb,
+ frame);
+ g_signal_connect (container, "child-property-changed::flags",
G_CALLBACK (panel_applet_frame_flags_changed),
frame);
- g_signal_connect (container, "child-notify::size-hints",
+ g_signal_connect (container, "child-property-changed::size-hints",
G_CALLBACK (panel_applet_frame_size_hints_changed),
frame);
}
@@ -215,12 +249,12 @@ panel_applet_frame_sync_menu_state (PanelAppletFrame *frame)
locked = panel_widget_get_applet_locked (panel_widget, GTK_WIDGET (frame));
locked_down = panel_lockdown_get_locked_down ();
- panel_applet_container_child_set_boolean (PANEL_APPLET_CONTAINER (frame),
- "locked", lockable && locked,
- NULL, NULL, NULL);
- panel_applet_container_child_set_boolean (PANEL_APPLET_CONTAINER (frame),
- "locked-down", locked_down,
- NULL, NULL, NULL);
+ panel_applet_container_child_set (PANEL_APPLET_CONTAINER (frame),
+ "locked", g_variant_new_boolean (lockable && locked),
+ NULL, NULL, NULL);
+ panel_applet_container_child_set (PANEL_APPLET_CONTAINER (frame),
+ "locked-down", g_variant_new_boolean (locked_down),
+ NULL, NULL, NULL);
}
enum {
@@ -314,6 +348,28 @@ panel_applet_frame_loading_failed (PanelAppletFrame *frame,
gtk_widget_destroy (GTK_WIDGET (frame));
}
+static guint
+get_panel_applet_orient (PanelOrientation orientation)
+{
+ /* For some reason libpanel-applet and panel use
+ * a different logic for orientation, so we need
+ * to convert it. We should fix this.
+ */
+ switch (orientation) {
+ case PANEL_ORIENTATION_TOP:
+ return 1;
+ case PANEL_ORIENTATION_BOTTOM:
+ return 0;
+ case PANEL_ORIENTATION_LEFT:
+ return 3;
+ case PANEL_ORIENTATION_RIGHT:
+ return 2;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
static void
panel_applet_frame_activated (PanelAppletContainer *container,
GAsyncResult *res,
@@ -374,8 +430,10 @@ panel_applet_frame_load (const gchar *iid,
{
PanelAppletFrame *frame;
PanelAppletFrameActivating *frame_act;
+ GVariantBuilder builder;
gchar *prefs_key;
gchar *background;
+ guint orient;
g_return_if_fail (iid != NULL);
g_return_if_fail (panel != NULL);
@@ -409,18 +467,35 @@ panel_applet_frame_load (const gchar *iid,
background = panel_applet_frame_get_background_string (frame,
frame->priv->panel,
frame->priv->panel->background.type);
+ orient = get_panel_applet_orient (panel_widget_get_applet_orientation (frame->priv->panel));
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_add (&builder, "{sv}",
+ "prefs-key",
+ g_variant_new_string (prefs_key));
+ g_variant_builder_add (&builder, "{sv}",
+ "orient",
+ g_variant_new_uint32 (orient));
+ g_variant_builder_add (&builder, "{sv}",
+ "size",
+ g_variant_new_uint32 (frame->priv->panel->sz));
+ g_variant_builder_add (&builder, "{sv}",
+ "locked",
+ g_variant_new_boolean (locked));
+ g_variant_builder_add (&builder, "{sv}",
+ "locked-down",
+ g_variant_new_boolean (panel_lockdown_get_locked_down ()));
+ if (background) {
+ g_variant_builder_add (&builder, "{sv}",
+ "background",
+ g_variant_new_string (background));
+ }
panel_applet_container_add (PANEL_APPLET_CONTAINER (frame),
frame->priv->iid, NULL,
(GAsyncReadyCallback)panel_applet_frame_activated,
frame_act,
- "prefs-key", prefs_key,
- "background", background ? background : "",
- "orient", panel_widget_get_applet_orientation (frame->priv->panel),
- "size", frame->priv->panel->sz,
- "locked", locked,
- "locked-down", panel_lockdown_get_locked_down (),
- NULL);
+ g_variant_builder_end (&builder));
g_free (prefs_key);
g_free (background);
}
@@ -473,9 +548,9 @@ static void
change_orientation_cb (PanelAppletContainer *container,
GAsyncResult *res)
{
- GError *error = NULL;
+ GError *error = NULL;
- if (!panel_applet_container_child_set_orientation_finish (container, res, &error)) {
+ if (!panel_applet_container_child_set_finish (container, res, &error)) {
g_warning ("%s\n", error->message);
g_error_free (error);
@@ -493,19 +568,21 @@ panel_applet_frame_change_orientation (PanelAppletFrame *frame,
return;
frame->priv->orientation = orientation;
- panel_applet_container_child_set_orientation (PANEL_APPLET_CONTAINER (frame),
- orientation,
- NULL,
- (GAsyncReadyCallback)change_orientation_cb,
- NULL);
+ panel_applet_container_child_set (PANEL_APPLET_CONTAINER (frame),
+ "orient",
+ g_variant_new_uint32 (get_panel_applet_orient (orientation)),
+ NULL,
+ (GAsyncReadyCallback)change_orientation_cb,
+ NULL);
}
void
panel_applet_frame_change_size (PanelAppletFrame *frame,
guint size)
{
- panel_applet_container_child_set_uint (PANEL_APPLET_CONTAINER (frame),
- "size", size, NULL, NULL, NULL);
+ panel_applet_container_child_set (PANEL_APPLET_CONTAINER (frame),
+ "size", g_variant_new_uint32 (size),
+ NULL, NULL, NULL);
}
static char *
@@ -548,9 +625,10 @@ container_child_background_set (GObject *source_object,
PanelAppletContainer *container = PANEL_APPLET_CONTAINER (source_object);
PanelAppletFrame *frame = PANEL_APPLET_FRAME (source_object);
- panel_applet_container_child_set_string_finish (container, res, NULL);
+ panel_applet_container_child_set_finish (container, res, NULL);
- g_object_unref (frame->priv->bg_cancellable);
+ if (frame->priv->bg_cancellable)
+ g_object_unref (frame->priv->bg_cancellable);
frame->priv->bg_cancellable = NULL;
}
@@ -579,11 +657,12 @@ panel_applet_frame_change_background (PanelAppletFrame *frame,
g_cancellable_cancel (frame->priv->bg_cancellable);
frame->priv->bg_cancellable = g_cancellable_new ();
- panel_applet_container_child_set_string (PANEL_APPLET_CONTAINER (frame),
- "background", bg_str,
- frame->priv->bg_cancellable,
- container_child_background_set,
- NULL);
+ panel_applet_container_child_set (PANEL_APPLET_CONTAINER (frame),
+ "background",
+ g_variant_new_string (bg_str),
+ frame->priv->bg_cancellable,
+ container_child_background_set,
+ NULL);
g_free (bg_str);
}
}
diff --git a/gnome-panel/panel-marshal.list b/gnome-panel/panel-marshal.list
index f6da0c1..7893b88 100644
--- a/gnome-panel/panel-marshal.list
+++ b/gnome-panel/panel-marshal.list
@@ -1,2 +1,3 @@
BOOLEAN:VOID
VOID:STRING,STRING
+VOID:STRING,POINTER
diff --git a/libpanel-applet/panel-test-applets.c b/gnome-panel/panel-test-applets.c
similarity index 92%
rename from libpanel-applet/panel-test-applets.c
rename to gnome-panel/panel-test-applets.c
index c61716f..283e7dd 100644
--- a/libpanel-applet/panel-test-applets.c
+++ b/gnome-panel/panel-test-applets.c
@@ -12,8 +12,6 @@
#include <gtk/gtk.h>
#include <gconf/gconf.h>
-#include "panel-applet.h"
-
#include <gnome-panel/panel-applet-container.h>
#include <gnome-panel/panel-applets-manager.h>
@@ -138,8 +136,9 @@ load_applet_into_window (const char *title,
guint size,
guint orientation)
{
- GtkWidget *container;
- GtkWidget *applet_window;
+ GtkWidget *container;
+ GtkWidget *applet_window;
+ GVariantBuilder builder;
container = panel_applet_container_new ();
@@ -153,14 +152,18 @@ load_applet_into_window (const char *title,
G_CALLBACK (applet_broken_cb),
applet_window);
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_add (&builder, "{sv}",
+ "prefs-key", g_variant_new_string (prefs_key));
+ g_variant_builder_add (&builder, "{sv}",
+ "size", g_variant_new_uint32 (size));
+ g_variant_builder_add (&builder, "{sv}",
+ "orient", g_variant_new_uint32 (orientation));
panel_applet_container_add (PANEL_APPLET_CONTAINER (container),
title, NULL,
(GAsyncReadyCallback)applet_activated_cb,
applet_window,
- "prefs-key", prefs_key,
- "size", size,
- "orient", orientation,
- NULL);
+ g_variant_builder_end (&builder));
}
static void
@@ -322,9 +325,11 @@ main (int argc, char **argv)
return 1;
}
- applets_dir = g_strdup_printf ("%s:./", PANEL_APPLETS_DIR);
- g_setenv ("PANEL_APPLETS_DIR", applets_dir, FALSE);
- g_free (applets_dir);
+ if (g_file_test ("../libpanel-applet", G_FILE_TEST_IS_DIR)) {
+ applets_dir = g_strdup_printf ("%s:../libpanel-applet", PANEL_APPLETS_DIR);
+ g_setenv ("PANEL_APPLETS_DIR", applets_dir, FALSE);
+ g_free (applets_dir);
+ }
panel_applets_manager_init ();
@@ -338,7 +343,7 @@ main (int argc, char **argv)
builder = gtk_builder_new ();
gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
- uifile = PANEL_APPLET_BUILDERDIR "/panel-test-applets.ui";
+ uifile = BUILDERDIR "/panel-test-applets.ui";
gtk_builder_add_from_file (builder, uifile, &error);
if (error) {
diff --git a/libpanel-applet/panel-test-applets.ui b/gnome-panel/panel-test-applets.ui
similarity index 100%
rename from libpanel-applet/panel-test-applets.ui
rename to gnome-panel/panel-test-applets.ui
diff --git a/libpanel-applet/Makefile.am b/libpanel-applet/Makefile.am
index ef3db76..9ce4110 100644
--- a/libpanel-applet/Makefile.am
+++ b/libpanel-applet/Makefile.am
@@ -1,9 +1,7 @@
INCLUDES = \
-I$(top_builddir)/libpanel-applet \
-DPANEL_APPLET_DATADIR=\""$(datadir)"\" \
- -DPANEL_APPLET_BUILDERDIR=\""$(uidir)"\" \
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
- -DEGG_DBUS_I_KNOW_API_IS_SUBJECT_TO_CHANGE \
$(LIBPANEL_APPLET_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS) \
$(WARN_CFLAGS)
@@ -34,58 +32,13 @@ libpanel_appletinclude_HEADERS = \
panel-applet-gconf.h \
panel-applet-enums.h
-libpanel_applet_dbus_xml = \
- $(top_srcdir)/data/panel-applet.xml \
- $(top_srcdir)/libpanel-applet/panel-applet-factory.xml
-
-libpanel-applet-built-sources.stamp: $(libpanel_applet_dbus_xml)
- eggdbus-binding-tool \
- --namespace "_Panel" \
- --dbus-namespace "org.gnome.panel.applet" \
- --introspection-xml $(top_srcdir)/libpanel-applet/panel-applet-factory.xml \
- --introspection-xml $(top_srcdir)/data/panel-applet.xml \
- --stamp-file libpanel-applet-built-sources.stamp
-
-EGGDBUS_SRCLIST = \
- _panelappletfactory.h \
- _panelappletfactory.c \
- _panelbindingstypes.h \
- _panelbindings.h \
- _panelbindings.c \
- _panelbindingsmarshal.h \
- _panelbindingsmarshal.c \
- _panelapplet.h \
- _panelapplet.c \
- _panelappletorient.h \
- _panelappletorient.c
-
noinst_PROGRAMS = test-dbus-applet
-bin_PROGRAMS = panel-test-applets
-
-panel_test_applets_CFLAGS = \
- -I$(top_srcdir)/gnome-panel \
- -DPANEL_APPLETS_DIR=\"$(appletsdir)\"
-
-panel_test_applets_SOURCES = \
- $(top_srcdir)/gnome-panel/panel-applet-container.h \
- $(top_srcdir)/gnome-panel/panel-applet-container.c \
- $(top_srcdir)/gnome-panel/panel-applets-manager.h \
- $(top_srcdir)/gnome-panel/panel-applets-manager.c \
- panel-test-applets.c
-
-panel_test_applets_LDFLAGS = -export-dynamic
-panel_test_applets_LDADD = \
- $(LIBPANEL_APPLET_LIBS) \
- libpanel-applet-2.la
-
-test_dbus_applet_LDADD = \
- $(LIBPANEL_APPLET_LIBS) \
- libpanel-applet-2.la
+test_dbus_applet_LDADD = \
+ $(LIBPANEL_APPLET_LIBS) \
+ libpanel-applet-2.la
BUILT_SOURCES = \
- libpanel-applet-built-sources.stamp \
- $(EGGDBUS_SRCLIST) \
panel-applet-enums.c \
panel-applet-enums.h \
panel-applet-marshal.c \
@@ -95,12 +48,9 @@ $(libpanel_applet_2_la_OBJECTS) $(test_dbus_applet_OBJECTS): $(BUILT_SOURCES)
EXTRA_DIST = \
GNOME_Panel_TestApplet.panel-applet.in \
- panel-applet-factory.xml \
panel-applet-marshal.list \
- _panelbindingsmarshal.list \
libpanelapplet-2.0.pc.in \
- libpanelapplet-2.0-uninstalled.pc.in \
- panel-test-applets.ui
+ libpanelapplet-2.0-uninstalled.pc.in
panel-applet-marshal.h: panel-applet-marshal.list $(GLIB_GENMARSHAL)
$(AM_V_GEN)$(GLIB_GENMARSHAL) $< --header --prefix=panel_applet_marshal > $@
@@ -139,9 +89,6 @@ panel-applet-enums.h: @REBUILD@ $(panel_applet_enum_headers)
--eprod "GType @enum_name _get_type (void);\n" \
$(panel_applet_enum_headers) > $@
-uidir = $(datadir)/gnome-panel/ui
-ui_DATA = panel-test-applets.ui
-
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libpanelapplet-2.0.pc
diff --git a/libpanel-applet/panel-applet-factory.c b/libpanel-applet/panel-applet-factory.c
index 6e1984d..6895521 100644
--- a/libpanel-applet/panel-applet-factory.c
+++ b/libpanel-applet/panel-applet-factory.c
@@ -20,16 +20,12 @@
*/
#include "panel-applet-factory.h"
-#include "_panelappletfactory.h"
#include "panel-applet.h"
-#include "_panelapplet.h"
struct _PanelAppletFactory {
GObject base;
gchar *factory_id;
- EggDBusConnection *connection;
-
guint n_applets;
GType applet_type;
GClosure *closure;
@@ -41,24 +37,14 @@ struct _PanelAppletFactoryClass {
#define PANEL_APPLET_FACTORY_OBJECT_PATH "/org/gnome/panel/applet/%s"
#define PANEL_APPLET_FACTORY_SERVICE_NAME "org.gnome.panel.applet.%s"
-#define PANEL_APPLET_OBJECT_PATH "/org/gnome/panel/applet/%s/%d"
-
-
-static void panel_applet_factory_factory_iface_init (_PanelAppletFactoryIface *iface);
-G_DEFINE_TYPE_WITH_CODE (PanelAppletFactory, panel_applet_factory, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (_PANEL_TYPE_APPLET_FACTORY, panel_applet_factory_factory_iface_init));
+G_DEFINE_TYPE (PanelAppletFactory, panel_applet_factory, G_TYPE_OBJECT)
static void
panel_applet_factory_finalize (GObject *object)
{
PanelAppletFactory *factory = PANEL_APPLET_FACTORY (object);
- if (factory->connection) {
- g_object_unref (factory->connection);
- factory->connection = NULL;
- }
-
if (factory->factory_id) {
g_free (factory->factory_id);
factory->factory_id = NULL;
@@ -93,135 +79,181 @@ panel_applet_factory_applet_removed (PanelAppletFactory *factory,
g_object_unref (factory);
}
-/* PanelAppletFactory Interface */
-static gboolean
-set_property (EggDBusHashMap *hash_map,
- gchar *name,
- EggDBusVariant *variant,
- GObject *applet)
+PanelAppletFactory *
+panel_applet_factory_new (const gchar *factory_id,
+ GType applet_type,
+ GClosure *closure)
{
- g_object_set_property (applet, name, egg_dbus_variant_get_gvalue (variant));
+ PanelAppletFactory *factory;
- return FALSE;
+ factory = PANEL_APPLET_FACTORY (g_object_new (PANEL_TYPE_APPLET_FACTORY, NULL));
+ factory->factory_id = g_strdup (factory_id);
+ factory->applet_type = applet_type;
+ factory->closure = g_closure_ref (closure);
+
+ return factory;
}
static void
-panel_applet_factory_get_applet (_PanelAppletFactory *_factory,
- const gchar *applet_id,
- gint screen_num,
- EggDBusHashMap *props,
- EggDBusMethodInvocation *method_invocation)
+set_applet_constructor_properties (GObject *applet,
+ GVariant *props)
{
- PanelAppletFactory *factory = PANEL_APPLET_FACTORY (_factory);
- GObject *applet;
- gchar *object_path;
- GdkScreen *screen;
- guint32 xid;
- static gint id = 0;
+ GVariantIter iter;
+ GVariant *value;
+ gchar *key;
+
+ g_variant_iter_init (&iter, props);
+ while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) {
+ switch (g_variant_classify (value)) {
+ case G_VARIANT_CLASS_UINT32: {
+ guint32 v = g_variant_get_uint32 (value);
+
+ g_object_set (applet, key, v, NULL);
+ }
+ break;
+ case G_VARIANT_CLASS_STRING: {
+ const gchar *v = g_variant_get_string (value, NULL);
+
+ g_object_set (applet, key, v, NULL);
+ }
+ break;
+ case G_VARIANT_CLASS_BOOLEAN: {
+ gboolean v = g_variant_get_boolean (value);
+
+ g_object_set (applet, key, v, NULL);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+
+static void
+panel_applet_factory_get_applet (PanelAppletFactory *factory,
+ GDBusConnection *connection,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation)
+{
+ GObject *applet;
+ const gchar *applet_id;
+ gint screen_num;
+ GVariant *props;
+ GdkScreen *screen;
+ guint32 xid;
+ const gchar *object_path;
+
+ g_variant_get (parameters, "(&si a{sv})", &applet_id, &screen_num, &props);
applet = g_object_new (factory->applet_type,
"id", applet_id,
+ "connection", connection,
"closure", factory->closure,
NULL);
factory->n_applets++;
-
- object_path = g_strdup_printf (PANEL_APPLET_OBJECT_PATH, applet_id, id++);
- egg_dbus_connection_register_interface (factory->connection,
- object_path,
- _PANEL_TYPE_APPLET,
- G_OBJECT (applet),
- G_TYPE_INVALID);
g_object_weak_ref (applet, (GWeakNotify)panel_applet_factory_applet_removed, factory);
- egg_dbus_hash_map_foreach (props,
- (EggDBusHashMapForeachFunc)set_property,
- applet);
+ set_applet_constructor_properties (applet, props);
+ g_variant_unref (props);
screen = screen_num != -1 ?
gdk_display_get_screen (gdk_display_get_default (), screen_num) :
gdk_screen_get_default ();
+
xid = panel_applet_get_xid (PANEL_APPLET (applet), screen);
+ object_path = panel_applet_get_object_path (PANEL_APPLET (applet));
- _panel_applet_factory_handle_get_applet_finish (method_invocation, object_path, xid);
- g_free (object_path);
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(ou)", object_path, xid));
}
static void
-panel_applet_factory_factory_iface_init (_PanelAppletFactoryIface *factory_iface)
+method_call_cb (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
{
- factory_iface->handle_get_applet = panel_applet_factory_get_applet;
+ PanelAppletFactory *factory = PANEL_APPLET_FACTORY (user_data);
+
+ if (g_strcmp0 (method_name, "GetApplet") == 0) {
+ panel_applet_factory_get_applet (factory, connection, parameters, invocation);
+ }
}
-PanelAppletFactory *
-panel_applet_factory_new (const gchar *factory_id,
- GType applet_type,
- GClosure *closure)
+static const gchar introspection_xml[] =
+ "<node>"
+ "<interface name='org.gnome.panel.applet.AppletFactory'>"
+ "<method name='GetApplet'>"
+ "<arg name='applet_id' type='s' direction='in'/>"
+ "<arg name='screen' type='i' direction='in'/>"
+ "<arg name='props' type='a{sv}' direction='in'/>"
+ "<arg name='applet' type='o' direction='out'/>"
+ "<arg name='xid' type='u' direction='out'/>"
+ "</method>"
+ "</interface>"
+ "</node>";
+
+static const GDBusInterfaceVTable interface_vtable = {
+ method_call_cb,
+ NULL,
+ NULL
+};
+
+static GDBusNodeInfo *introspection_data = NULL;
+
+static void
+on_name_acquired (GDBusConnection *connection,
+ const gchar *name,
+ PanelAppletFactory *factory)
{
- PanelAppletFactory *factory;
+ gchar *object_path;
+ GError *error = NULL;
- factory = PANEL_APPLET_FACTORY (g_object_new (PANEL_TYPE_APPLET_FACTORY, NULL));
- factory->factory_id = g_strdup (factory_id);
- factory->applet_type = applet_type;
- factory->closure = g_closure_ref (closure);
+ if (!introspection_data)
+ introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
+ object_path = g_strdup_printf (PANEL_APPLET_FACTORY_OBJECT_PATH, factory->factory_id);
+ g_dbus_connection_register_object (connection,
+ object_path,
+ introspection_data->interfaces[0],
+ &interface_vtable,
+ factory, NULL,
+ &error);
+ if (error) {
+ g_printerr ("Failed to register object %s: %s\n", object_path, error->message);
+ g_error_free (error);
+ }
- return factory;
+ g_free (object_path);
+}
+
+static void
+on_name_lost (GDBusConnection *connection,
+ const gchar *name,
+ PanelAppletFactory *factory)
+{
+ g_object_unref (factory);
}
gboolean
panel_applet_factory_register_service (PanelAppletFactory *factory)
{
- guint request_name_result;
- gchar *service_name;
- gchar *object_path;
- GError *error = NULL;
-
- if (!factory->connection) {
- factory->connection = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SESSION);
- if (!factory->connection) {
- g_printerr ("Failed to connect to the D-BUS daemon\n");
-
- return FALSE;
- }
- }
+ gchar *service_name;
service_name = g_strdup_printf (PANEL_APPLET_FACTORY_SERVICE_NAME, factory->factory_id);
- if (!egg_dbus_bus_request_name_sync (egg_dbus_connection_get_bus (factory->connection),
- EGG_DBUS_CALL_FLAGS_NONE,
- service_name,
- EGG_DBUS_REQUEST_NAME_FLAGS_DO_NOT_QUEUE,
- &request_name_result,
- NULL,
- &error)) {
- g_printerr ("Failed to acquire daemon name: %s", error->message);
- g_error_free (error);
- g_free (service_name);
-
- return FALSE;
- }
+ g_bus_own_name (G_BUS_TYPE_SESSION,
+ service_name,
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL,
+ (GBusNameAcquiredCallback) on_name_acquired,
+ (GBusNameLostCallback) on_name_lost,
+ factory, NULL);
g_free (service_name);
- switch (request_name_result) {
- case EGG_DBUS_REQUEST_NAME_REPLY_EXISTS:
- g_printerr ("Panel applet already running, exiting.\n");
-
- return FALSE;
- case EGG_DBUS_REQUEST_NAME_REPLY_ALREADY_OWNED:
- case EGG_DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
- object_path = g_strdup_printf (PANEL_APPLET_FACTORY_OBJECT_PATH, factory->factory_id);
- egg_dbus_connection_register_interface (factory->connection,
- object_path,
- _PANEL_TYPE_APPLET_FACTORY,
- G_OBJECT (factory),
- G_TYPE_INVALID);
- g_free (object_path);
-
- break;
- default:
- g_printerr ("Not primary owner of the service, exiting.\n");
-
- return FALSE;
- }
-
return TRUE;
}
diff --git a/libpanel-applet/panel-applet.c b/libpanel-applet/panel-applet.c
index ee90f00..d8d157c 100644
--- a/libpanel-applet/panel-applet.c
+++ b/libpanel-applet/panel-applet.c
@@ -42,7 +42,6 @@
#include <X11/Xatom.h>
#include "panel-applet.h"
-#include "_panelapplet.h"
#include "panel-applet-factory.h"
#include "panel-applet-marshal.h"
#include "panel-applet-enums.h"
@@ -53,9 +52,12 @@ struct _PanelAppletPrivate {
GtkWidget *plug;
GtkWidget *applet;
GConfClient *client;
+ GDBusConnection *connection;
char *id;
GClosure *closure;
+ char *object_path;
+ guint object_id;
char *prefs_key;
GtkUIManager *ui_manager;
@@ -95,6 +97,7 @@ enum {
PROP_0,
PROP_ID,
PROP_CLOSURE,
+ PROP_CONNECTION,
PROP_PREFS_KEY,
PROP_ORIENT,
PROP_SIZE,
@@ -115,7 +118,7 @@ static void panel_applet_menu_cmd_move (GtkAction *action,
PanelApplet *applet);
static void panel_applet_menu_cmd_lock (GtkAction *action,
PanelApplet *applet);
-static void panel_applet_applet_iface_init (_PanelAppletIface *iface);
+static void panel_applet_register_object (PanelApplet *applet);
static const gchar panel_menu_ui[] =
"<ui>\n"
@@ -144,8 +147,10 @@ static const GtkToggleActionEntry menu_toggle_entries[] = {
G_CALLBACK (panel_applet_menu_cmd_lock) }
};
-G_DEFINE_TYPE_WITH_CODE (PanelApplet, panel_applet, GTK_TYPE_EVENT_BOX,
- G_IMPLEMENT_INTERFACE (_PANEL_TYPE_APPLET, panel_applet_applet_iface_init));
+G_DEFINE_TYPE (PanelApplet, panel_applet, GTK_TYPE_EVENT_BOX)
+
+#define PANEL_APPLET_INTERFACE "org.gnome.panel.applet.Applet"
+#define PANEL_APPLET_OBJECT_PATH "/org/gnome/panel/applet/%s/%d"
static void
panel_applet_associate_schemas_in_dir (GConfClient *client,
@@ -343,6 +348,34 @@ panel_applet_set_flags (PanelApplet *applet,
applet->priv->flags = flags;
g_object_notify (G_OBJECT (applet), "flags");
+
+ if (applet->priv->connection) {
+ GVariantBuilder *builder;
+ GVariantBuilder *invalidated_builder;
+ GError *error = NULL;
+
+ builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+ invalidated_builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
+
+ g_variant_builder_add (builder, "{sv}", "Flags",
+ g_variant_new_uint32 (applet->priv->flags));
+
+ g_dbus_connection_emit_signal (applet->priv->connection,
+ NULL,
+ applet->priv->object_path,
+ "org.freedesktop.DBus.Properties",
+ "PropertiesChanged",
+ g_variant_new ("(sa{sv}as)",
+ PANEL_APPLET_INTERFACE,
+ builder,
+ invalidated_builder),
+ &error);
+ if (error) {
+ g_printerr ("Failed to send signal PropertiesChanged::Flags: %s\n",
+ error->message);
+ g_error_free (error);
+ }
+ }
}
static void
@@ -399,21 +432,40 @@ panel_applet_set_size_hints (PanelApplet *applet,
applet->priv->size_hints[i] = size_hints[i] + base_size;
g_object_notify (G_OBJECT (applet), "size-hints");
-}
-
-static void
-panel_applet_set_size_hints_from_seq (PanelApplet *applet,
- EggDBusArraySeq *seq)
-{
- gint i;
- gint n_elements;
-
- n_elements = egg_dbus_array_seq_get_size (seq);
- panel_applet_size_hints_ensure (applet, n_elements);
- for (i = 0; i < n_elements; i++)
- applet->priv->size_hints[i] = egg_dbus_array_seq_get_fixed (seq, i);
- g_object_notify (G_OBJECT (applet), "size-hints");
+ if (applet->priv->connection) {
+ GVariantBuilder *builder;
+ GVariantBuilder *invalidated_builder;
+ GVariant **children;
+ GError *error = NULL;
+
+ builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+ invalidated_builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
+
+ children = g_new (GVariant *, applet->priv->size_hints_len);
+ for (i = 0; i < n_elements; i++)
+ children[i] = g_variant_new_int32 (applet->priv->size_hints[i]);
+ g_variant_builder_add (builder, "{sv}", "SizeHints",
+ g_variant_new_array (G_VARIANT_TYPE_INT32,
+ children, applet->priv->size_hints_len));
+ g_free (children);
+
+ g_dbus_connection_emit_signal (applet->priv->connection,
+ NULL,
+ applet->priv->object_path,
+ "org.freedesktop.DBus.Properties",
+ "PropertiesChanged",
+ g_variant_new ("(sa{sv}as)",
+ PANEL_APPLET_INTERFACE,
+ builder,
+ invalidated_builder),
+ &error);
+ if (error) {
+ g_printerr ("Failed to send signal PropertiesChanged::SizeHints: %s\n",
+ error->message);
+ g_error_free (error);
+ }
+ }
}
guint
@@ -498,8 +550,24 @@ panel_applet_set_locked (PanelApplet *applet,
panel_applet_menu_update_actions (applet);
- g_signal_emit_by_name (applet, locked ? "lock" : "unlock");
g_object_notify (G_OBJECT (applet), "locked");
+
+ if (applet->priv->connection) {
+ GError *error = NULL;
+
+ g_dbus_connection_emit_signal (applet->priv->connection,
+ NULL,
+ applet->priv->object_path,
+ PANEL_APPLET_INTERFACE,
+ locked ? "Lock" : "Unlock",
+ NULL, &error);
+ if (error) {
+ g_printerr ("Failed to send signal %s: %s\n",
+ locked ? "Lock" : "Unlock",
+ error->message);
+ g_error_free (error);
+ }
+ }
}
gboolean
@@ -689,14 +757,44 @@ static void
panel_applet_menu_cmd_remove (GtkAction *action,
PanelApplet *applet)
{
- g_signal_emit_by_name (applet, "remove-from-panel");
+ GError *error = NULL;
+
+ if (!applet->priv->connection)
+ return;
+
+ g_dbus_connection_emit_signal (applet->priv->connection,
+ NULL,
+ applet->priv->object_path,
+ PANEL_APPLET_INTERFACE,
+ "RemoveFromPanel",
+ NULL, &error);
+ if (error) {
+ g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
+ error->message);
+ g_error_free (error);
+ }
}
static void
panel_applet_menu_cmd_move (GtkAction *action,
PanelApplet *applet)
{
- g_signal_emit_by_name (applet, "move");
+ GError *error = NULL;
+
+ if (!applet->priv->connection)
+ return;
+
+ g_dbus_connection_emit_signal (applet->priv->connection,
+ NULL,
+ applet->priv->object_path,
+ PANEL_APPLET_INTERFACE,
+ "Move",
+ NULL, &error);
+ if (error) {
+ g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
+ error->message);
+ g_error_free (error);
+ }
}
static void
@@ -762,6 +860,20 @@ panel_applet_finalize (GObject *object)
{
PanelApplet *applet = PANEL_APPLET (object);
+ if (applet->priv->connection) {
+ if (applet->priv->object_id)
+ g_dbus_connection_unregister_object (applet->priv->connection,
+ applet->priv->object_id);
+ applet->priv->object_id = 0;
+ g_object_unref (applet->priv->connection);
+ applet->priv->connection = NULL;
+ }
+
+ if (applet->priv->object_path) {
+ g_free (applet->priv->object_path);
+ applet->priv->object_path = NULL;
+ }
+
panel_applet_set_preferences_key (applet, NULL);
if (applet->priv->client)
@@ -1516,11 +1628,14 @@ panel_applet_get_property (GObject *object,
case PROP_CLOSURE:
g_value_set_pointer (value, applet->priv->closure);
break;
+ case PROP_CONNECTION:
+ g_value_set_object (value, applet->priv->connection);
+ break;
case PROP_PREFS_KEY:
g_value_set_string (value, applet->priv->prefs_key);
break;
case PROP_ORIENT:
- g_value_set_enum (value, applet->priv->orient);
+ g_value_set_uint (value, applet->priv->orient);
break;
case PROP_SIZE:
g_value_set_uint (value, applet->priv->size);
@@ -1532,14 +1647,17 @@ panel_applet_get_property (GObject *object,
g_value_set_uint (value, applet->priv->flags);
break;
case PROP_SIZE_HINTS: {
- EggDBusArraySeq *array;
- gint i;
+ GVariant **children;
+ GVariant *variant;
+ gint i;
- array = egg_dbus_array_seq_new (G_TYPE_INT, NULL, NULL, NULL);
+ children = g_new (GVariant *, applet->priv->size_hints_len);
for (i = 0; i < applet->priv->size_hints_len; i++)
- egg_dbus_array_seq_add_fixed (array, applet->priv->size_hints[i]);
- g_value_take_object (value, array);
-
+ children[i] = g_variant_new_int32 (applet->priv->size_hints[i]);
+ variant = g_variant_new_array (G_VARIANT_TYPE_INT32,
+ children, applet->priv->size_hints_len);
+ g_free (children);
+ g_value_set_pointer (value, variant);
}
break;
case PROP_LOCKED:
@@ -1570,11 +1688,14 @@ panel_applet_set_property (GObject *object,
g_closure_set_marshal (applet->priv->closure,
panel_applet_marshal_BOOLEAN__STRING);
break;
+ case PROP_CONNECTION:
+ applet->priv->connection = g_value_dup_object (value);
+ break;
case PROP_PREFS_KEY:
panel_applet_set_preferences_key (applet, g_value_get_string (value));
break;
case PROP_ORIENT:
- panel_applet_set_orient (applet, g_value_get_enum (value));
+ panel_applet_set_orient (applet, g_value_get_uint (value));
break;
case PROP_SIZE:
panel_applet_set_size (applet, g_value_get_uint (value));
@@ -1585,8 +1706,14 @@ panel_applet_set_property (GObject *object,
case PROP_FLAGS:
panel_applet_set_flags (applet, g_value_get_uint (value));
break;
- case PROP_SIZE_HINTS:
- panel_applet_set_size_hints_from_seq (applet, g_value_get_object (value));
+ case PROP_SIZE_HINTS: {
+ const int *size_hints;
+ gsize n_elements;
+
+ size_hints = g_variant_get_fixed_array (g_value_get_pointer (value),
+ &n_elements, sizeof (gint32));
+ panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
+ }
break;
case PROP_LOCKED:
panel_applet_set_locked (applet, g_value_get_boolean (value));
@@ -1700,6 +1827,14 @@ panel_applet_init (PanelApplet *applet)
}
static void
+panel_applet_constructed (GObject *object)
+{
+ PanelApplet *applet = PANEL_APPLET (object);
+
+ panel_applet_register_object (applet);
+}
+
+static void
panel_applet_class_init (PanelAppletClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
@@ -1709,6 +1844,7 @@ panel_applet_class_init (PanelAppletClass *klass)
gobject_class->get_property = panel_applet_get_property;
gobject_class->set_property = panel_applet_set_property;
+ gobject_class->constructed = panel_applet_constructed;
klass->move_focus_out_of_applet = panel_applet_move_focus_out_of_applet;
widget_class->button_press_event = panel_applet_button_press;
@@ -1735,12 +1871,74 @@ panel_applet_class_init (PanelAppletClass *klass)
g_object_class_install_property (gobject_class,
PROP_CLOSURE,
g_param_spec_pointer ("closure",
- "GClocure",
+ "GClosure",
"The Applet closure",
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READWRITE));
-
- g_assert (_panel_applet_override_properties (gobject_class, PROP_PREFS_KEY) == PROP_LOCKED_DOWN);
+ g_object_class_install_property (gobject_class,
+ PROP_CONNECTION,
+ g_param_spec_object ("connection",
+ "Connection",
+ "The DBus Connection",
+ G_TYPE_DBUS_CONNECTION,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_PREFS_KEY,
+ g_param_spec_string ("prefs-key",
+ "PrefsKey",
+ "GConf Preferences Key",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_ORIENT,
+ g_param_spec_uint ("orient",
+ "Orient",
+ "Panel Applet Orientation",
+ 0, G_MAXUINT, 0, /* FIXME */
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_SIZE,
+ g_param_spec_uint ("size",
+ "Size",
+ "Panel Applet Size",
+ 0, G_MAXUINT, 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_BACKGROUND,
+ g_param_spec_string ("background",
+ "Background",
+ "Panel Applet Background",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_FLAGS,
+ g_param_spec_uint ("flags",
+ "Flags",
+ "Panel Applet flags",
+ 0, G_MAXUINT, 0, /* FIXME */
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_SIZE_HINTS,
+ /* FIXME: value_array? */
+ g_param_spec_pointer ("size-hints",
+ "SizeHints",
+ "Panel Applet Size Hints",
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_LOCKED,
+ g_param_spec_boolean ("locked",
+ "Locked",
+ "Whether Panel Applet is locked",
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_LOCKED_DOWN,
+ g_param_spec_boolean ("locked-down",
+ "LockedDown",
+ "Whether Panel Applet is locked down",
+ FALSE,
+ G_PARAM_READWRITE));
panel_applet_signals [CHANGE_ORIENT] =
g_signal_new ("change_orient",
@@ -1809,21 +2007,160 @@ panel_applet_new (void)
return GTK_WIDGET (applet);
}
-/* Panel Applet Interface */
static void
-panel_applet_handle_popup_menu (_PanelApplet *instance,
- guint button,
- guint time,
- EggDBusMethodInvocation *method_invocation)
+method_call_cb (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
{
- panel_applet_menu_popup (PANEL_APPLET (instance), button, time);
- _panel_applet_handle_popup_menu_finish (method_invocation);
+ PanelApplet *applet = PANEL_APPLET (user_data);
+
+ if (g_strcmp0 (method_name, "PopupMenu") == 0) {
+ guint button;
+ guint time;
+
+ g_variant_get (parameters, "(uu)", &button, &time);
+ panel_applet_menu_popup (applet, button, time);
+
+ g_dbus_method_invocation_return_value (invocation, NULL);
+ }
}
+static GVariant *
+get_property_cb (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GError **error,
+ gpointer user_data)
+{
+ PanelApplet *applet = PANEL_APPLET (user_data);
+ GVariant *retval = NULL;
+
+ if (g_strcmp0 (property_name, "PrefsKey") == 0) {
+ retval = g_variant_new_string (applet->priv->prefs_key ?
+ applet->priv->prefs_key : "");
+ } else if (g_strcmp0 (property_name, "Orient") == 0) {
+ retval = g_variant_new_uint32 (applet->priv->orient);
+ } else if (g_strcmp0 (property_name, "Size") == 0) {
+ retval = g_variant_new_uint32 (applet->priv->size);
+ } else if (g_strcmp0 (property_name, "Background") == 0) {
+ retval = g_variant_new_string (applet->priv->background ?
+ applet->priv->background : "");
+ } else if (g_strcmp0 (property_name, "Flags") == 0) {
+ retval = g_variant_new_uint32 (applet->priv->flags);
+ } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
+ GVariant **children;
+ gint i;
+
+ children = g_new (GVariant *, applet->priv->size_hints_len);
+ for (i = 0; i < applet->priv->size_hints_len; i++)
+ children[i] = g_variant_new_int32 (applet->priv->size_hints[i]);
+ retval = g_variant_new_array (G_VARIANT_TYPE_INT32,
+ children, applet->priv->size_hints_len);
+ g_free (children);
+ } else if (g_strcmp0 (property_name, "Locked") == 0) {
+ retval = g_variant_new_boolean (applet->priv->locked);
+ } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
+ retval = g_variant_new_boolean (applet->priv->locked_down);
+ }
+
+ return retval;
+}
+
+static gboolean
+set_property_cb (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GVariant *value,
+ GError **error,
+ gpointer user_data)
+{
+ PanelApplet *applet = PANEL_APPLET (user_data);
+
+ if (g_strcmp0 (property_name, "PrefsKey") == 0) {
+ panel_applet_set_preferences_key (applet, g_variant_get_string (value, NULL));
+ } else if (g_strcmp0 (property_name, "Orient") == 0) {
+ panel_applet_set_orient (applet, g_variant_get_uint32 (value));
+ } else if (g_strcmp0 (property_name, "Size") == 0) {
+ panel_applet_set_size (applet, g_variant_get_uint32 (value));
+ } else if (g_strcmp0 (property_name, "Background") == 0) {
+ panel_applet_set_background_string (applet, g_variant_get_string (value, NULL));
+ } else if (g_strcmp0 (property_name, "Flags") == 0) {
+ panel_applet_set_flags (applet, g_variant_get_uint32 (value));
+ } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
+ const int *size_hints;
+ gsize n_elements;
+
+ size_hints = g_variant_get_fixed_array (value, &n_elements, sizeof (gint32));
+ panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
+ } else if (g_strcmp0 (property_name, "Locked") == 0) {
+ panel_applet_set_locked (applet, g_variant_get_boolean (value));
+ } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
+ panel_applet_set_locked_down (applet, g_variant_get_boolean (value));
+ }
+
+ return TRUE;
+}
+
+static const gchar introspection_xml[] =
+ "<node>"
+ "<interface name='org.gnome.panel.applet.Applet'>"
+ "<method name='PopupMenu'>"
+ "<arg name='button' type='u' direction='in'/>"
+ "<arg name='time' type='u' direction='in'/>"
+ "</method>"
+ "<property name='PrefsKey' type='s' access='readwrite'/>"
+ "<property name='Orient' type='u' access='readwrite' />"
+ "<property name='Size' type='u' access='readwrite'/>"
+ "<property name='Background' type='s' access='readwrite'/>"
+ "<property name='Flags' type='u' access='readwrite'/>"
+ "<property name='SizeHints' type='ai' access='readwrite'/>"
+ "<property name='Locked' type='b' access='readwrite'/>"
+ "<property name='LockedDown' type='b' access='readwrite'/>"
+ "<signal name='Move' />"
+ "<signal name='RemoveFromPanel' />"
+ "<signal name='Lock' />"
+ "<signal name='Unlock' />"
+ "</interface>"
+ "</node>";
+
+static const GDBusInterfaceVTable interface_vtable = {
+ method_call_cb,
+ get_property_cb,
+ set_property_cb
+};
+
+static GDBusNodeInfo *introspection_data = NULL;
+
static void
-panel_applet_applet_iface_init (_PanelAppletIface *iface)
-{
- iface->handle_popup_menu = panel_applet_handle_popup_menu;
+panel_applet_register_object (PanelApplet *applet)
+{
+ GError *error = NULL;
+ static gint id = 0;
+
+ if (!introspection_data)
+ introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
+
+ applet->priv->object_path = g_strdup_printf (PANEL_APPLET_OBJECT_PATH, applet->priv->id, id++);
+ applet->priv->object_id =
+ g_dbus_connection_register_object (applet->priv->connection,
+ applet->priv->object_path,
+ introspection_data->interfaces[0],
+ &interface_vtable,
+ applet, NULL,
+ &error);
+ if (!applet->priv->object_id) {
+ g_printerr ("Failed to register object %s: %s\n", applet->priv->object_path, error->message);
+ g_error_free (error);
+ }
}
static void
@@ -1831,6 +2168,11 @@ panel_applet_factory_main_finalized (gpointer data,
GObject *object)
{
gtk_main_quit ();
+
+ if (introspection_data) {
+ g_dbus_node_info_unref (introspection_data);
+ introspection_data = NULL;
+ }
}
static int (*_x_error_func) (Display *, XErrorEvent *);
@@ -1949,3 +2291,9 @@ panel_applet_get_xid (PanelApplet *applet,
return gtk_plug_get_id (GTK_PLUG (applet->priv->plug));
}
+
+const gchar *
+panel_applet_get_object_path (PanelApplet *applet)
+{
+ return applet->priv->object_path;
+}
diff --git a/libpanel-applet/panel-applet.h b/libpanel-applet/panel-applet.h
index 250be91..db64040 100644
--- a/libpanel-applet/panel-applet.h
+++ b/libpanel-applet/panel-applet.h
@@ -93,6 +93,7 @@ GType panel_applet_get_type (void) G_GNUC_CONST;
GtkWidget *panel_applet_new (void);
guint32 panel_applet_get_xid (PanelApplet *applet,
GdkScreen *screen);
+const gchar *panel_applet_get_object_path (PanelApplet *applet);
PanelAppletOrient panel_applet_get_orient (PanelApplet *applet);
void panel_applet_set_orient (PanelApplet *applet,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]