[Xfce4-commits] <xfce4-panel:devel> * Add marshal for libxfce4panel's size signal. * Some code style improvements. * Implement DBUs get for PanelNumber. * Open correct panel number in wrapper using PanelNumber.
Nick Schermer
nick at xfce.org
Tue Aug 11 20:24:01 CEST 2009
Updating branch refs/heads/devel
to 83d4e14ccf096d15b1ad27d3b7abbb2a2c34fdd8 (commit)
from 43b9ab0b5b80fa58089c1046f5216ed47d10b750 (commit)
commit 83d4e14ccf096d15b1ad27d3b7abbb2a2c34fdd8
Author: Nick Schermer <nick at xfce.org>
Date: Sat Aug 16 00:00:34 2008 +0200
* Add marshal for libxfce4panel's size signal.
* Some code style improvements.
* Implement DBUs get for PanelNumber.
* Open correct panel number in wrapper using PanelNumber.
libxfce4panel/Makefile.am | 25 ++++++++
libxfce4panel/xfce-panel-convenience.c | 2 +-
libxfce4panel/xfce-panel-convenience.h | 1 +
libxfce4panel/xfce-panel-plugin-provider.c | 2 +-
libxfce4panel/xfce-panel-plugin.c | 14 +++-
libxfce4panel/xfce-panel-plugin.h | 90 ++++++++++++++--------------
panel/panel-dbus-service.c | 45 +++++++++++++-
wrapper/main.c | 35 +++++++++--
8 files changed, 155 insertions(+), 59 deletions(-)
diff --git a/libxfce4panel/Makefile.am b/libxfce4panel/Makefile.am
index 05620c2..ca6235f 100644
--- a/libxfce4panel/Makefile.am
+++ b/libxfce4panel/Makefile.am
@@ -10,6 +10,10 @@ INCLUDES = \
lib_LTLIBRARIES = \
libxfce4panel.la
+libxfce4panel_built_sources = \
+ libxfce4panel-marshal.c \
+ libxfce4panel-marshal.h
+
libxfce4panel_headers = \
libxfce4panel.h \
xfce-arrow-button.h \
@@ -25,6 +29,7 @@ libxfce4panel_include_HEADERS = \
$(libxfce4panel_headers)
libxfce4panel_la_SOURCES = \
+ $(libxfce4panel_built_sources) \
$(libxfce4panel_headers) \
xfce-arrow-button.c \
xfce-hvbox.c \
@@ -55,4 +60,24 @@ libxfce4panel_la_LIBADD = \
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libxfce4panel-1.0.pc
+EXTRA_DIST = \
+ libxfce4panel-marshal.list
+
+#
+# Build sources
+#
+if MAINTAINER_MODE
+libxfce4panel-marshal.h: libxfce4panel-marshal.list Makefile
+ glib-genmarshal --prefix=_libxfce4panel_marshal --internal --header $< > $@
+
+libxfce4panel-marshal.c: libxfce4panel-marshal.list Makefile
+ glib-genmarshal --prefix=_libxfce4panel_marshal --body $< > $@
+
+DISTCLEANFILES = \
+ $(libxfce4panel_built_sources)
+
+BUILT_SOURCES = \
+ $(libxfce4panel_built_sources)
+endif
+
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/libxfce4panel/xfce-panel-convenience.c b/libxfce4panel/xfce-panel-convenience.c
index 42d9c64..34a47cf 100644
--- a/libxfce4panel/xfce-panel-convenience.c
+++ b/libxfce4panel/xfce-panel-convenience.c
@@ -85,7 +85,7 @@ xfce_panel_create_toggle_button (void)
* otherwise.
**/
gboolean
-xfce_panel_allow_customization (void )
+xfce_panel_allow_customization (void)
{
static gboolean allow_customization = FALSE;
static gboolean checked = FALSE;
diff --git a/libxfce4panel/xfce-panel-convenience.h b/libxfce4panel/xfce-panel-convenience.h
index c90429e..b6bef92 100644
--- a/libxfce4panel/xfce-panel-convenience.h
+++ b/libxfce4panel/xfce-panel-convenience.h
@@ -35,6 +35,7 @@ GtkWidget *xfce_panel_create_toggle_button (void) G_GNUC_MALLOC G_GNUC_WARN_UNU
gboolean xfce_panel_allow_customization (void);
+/* TODO this one should be removed... */
void xfce_panel_cairo_set_source_rgba (cairo_t *cr,
GdkColor *color,
gdouble alpha);
diff --git a/libxfce4panel/xfce-panel-plugin-provider.c b/libxfce4panel/xfce-panel-plugin-provider.c
index 538aa2b..0459a76 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.c
+++ b/libxfce4panel/xfce-panel-plugin-provider.c
@@ -117,7 +117,7 @@ xfce_panel_plugin_provider_base_init (gpointer klass)
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
-
+
provider_signals[LOCK_PANEL] =
g_signal_new (I_("lock-panel"),
G_TYPE_FROM_CLASS (klass),
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 672edc0..db30391 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -26,6 +26,7 @@
#include <glib/gstdio.h>
#include <libxfce4util/libxfce4util.h>
+#include <libxfce4panel/libxfce4panel-marshal.h>
#include <libxfce4panel/xfce-panel-macros.h>
#include <libxfce4panel/xfce-panel-enums.h>
#include <libxfce4panel/xfce-panel-plugin.h>
@@ -257,9 +258,9 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (XfcePanelPluginClass, size_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_accumulator_true_handled, NULL,
+ _libxfce4panel_marshal_BOOLEAN__INT,
+ G_TYPE_BOOLEAN, 1, G_TYPE_INT);
/**
* XfcePanelPlugin::screen-position-changed
@@ -768,6 +769,7 @@ xfce_panel_plugin_set_size (XfcePanelPluginProvider *provider,
gint size)
{
XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
+ gboolean handled = FALSE;
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
@@ -778,7 +780,11 @@ xfce_panel_plugin_set_size (XfcePanelPluginProvider *provider,
plugin->priv->size = size;
/* emit signal */
- g_signal_emit (G_OBJECT (plugin), plugin_signals[SIZE_CHANGED], 0, size);
+ g_signal_emit (G_OBJECT (plugin), plugin_signals[SIZE_CHANGED], 0, size, &handled);
+
+ /* handle the size when not done by the plugin */
+ if (handled == FALSE)
+ gtk_widget_set_size_request (GTK_WIDGET (plugin), size, size);
}
}
diff --git a/libxfce4panel/xfce-panel-plugin.h b/libxfce4panel/xfce-panel-plugin.h
index 6d30947..23118aa 100644
--- a/libxfce4panel/xfce-panel-plugin.h
+++ b/libxfce4panel/xfce-panel-plugin.h
@@ -45,16 +45,16 @@ struct _XfcePanelPluginClass
GtkEventBoxClass __parent__;
/*< signals >*/
- void (*screen_position_changed) (XfcePanelPlugin *plugin,
- gint position);
- void (*size_changed) (XfcePanelPlugin *plugin,
- gint size);
- void (*orientation_changed) (XfcePanelPlugin *plugin,
- GtkOrientation orientation);
- void (*free_data) (XfcePanelPlugin *plugin);
- void (*save) (XfcePanelPlugin *plugin);
- void (*about) (XfcePanelPlugin *plugin);
- void (*configure_plugin) (XfcePanelPlugin *plugin);
+ void (*screen_position_changed) (XfcePanelPlugin *plugin,
+ gint position);
+ gboolean (*size_changed) (XfcePanelPlugin *plugin,
+ gint size);
+ void (*orientation_changed) (XfcePanelPlugin *plugin,
+ GtkOrientation orientation);
+ void (*free_data) (XfcePanelPlugin *plugin);
+ void (*save) (XfcePanelPlugin *plugin);
+ void (*about) (XfcePanelPlugin *plugin);
+ void (*configure_plugin) (XfcePanelPlugin *plugin);
/*< private >*/
void (*reserved1) (void);
@@ -79,64 +79,64 @@ struct _XfcePanelPlugin
GType xfce_panel_plugin_get_type (void) G_GNUC_CONST;
-const gchar *xfce_panel_plugin_get_name (XfcePanelPlugin *plugin);
+const gchar *xfce_panel_plugin_get_name (XfcePanelPlugin *plugin);
-const gchar *xfce_panel_plugin_get_display_name (XfcePanelPlugin *plugin);
+const gchar *xfce_panel_plugin_get_display_name (XfcePanelPlugin *plugin);
-const gchar *xfce_panel_plugin_get_id (XfcePanelPlugin *plugin);
+const gchar *xfce_panel_plugin_get_id (XfcePanelPlugin *plugin);
gboolean xfce_panel_plugin_get_arguments (XfcePanelPlugin *plugin,
gchar ***arguments);
-gint xfce_panel_plugin_get_size (XfcePanelPlugin *plugin);
+gint xfce_panel_plugin_get_size (XfcePanelPlugin *plugin);
-gboolean xfce_panel_plugin_get_expand (XfcePanelPlugin *plugin);
+gboolean xfce_panel_plugin_get_expand (XfcePanelPlugin *plugin);
-void xfce_panel_plugin_set_expand (XfcePanelPlugin *plugin,
- gboolean expand);
+void xfce_panel_plugin_set_expand (XfcePanelPlugin *plugin,
+ gboolean expand);
-GtkOrientation xfce_panel_plugin_get_orientation (XfcePanelPlugin *plugin);
+GtkOrientation xfce_panel_plugin_get_orientation (XfcePanelPlugin *plugin);
-XfceScreenPosition xfce_panel_plugin_get_screen_position (XfcePanelPlugin *plugin);
+XfceScreenPosition xfce_panel_plugin_get_screen_position (XfcePanelPlugin *plugin);
-void xfce_panel_plugin_take_window (XfcePanelPlugin *plugin,
- GtkWindow *window);
+void xfce_panel_plugin_take_window (XfcePanelPlugin *plugin,
+ GtkWindow *window);
-void xfce_panel_plugin_add_action_widget (XfcePanelPlugin *plugin,
- GtkWidget *widget);
+void xfce_panel_plugin_add_action_widget (XfcePanelPlugin *plugin,
+ GtkWidget *widget);
-void xfce_panel_plugin_menu_insert_item (XfcePanelPlugin *plugin,
- GtkMenuItem *item);
+void xfce_panel_plugin_menu_insert_item (XfcePanelPlugin *plugin,
+ GtkMenuItem *item);
-void xfce_panel_plugin_menu_show_configure (XfcePanelPlugin *plugin);
+void xfce_panel_plugin_menu_show_configure (XfcePanelPlugin *plugin);
-void xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin);
+void xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin);
-void xfce_panel_plugin_block_menu (XfcePanelPlugin *plugin);
+void xfce_panel_plugin_block_menu (XfcePanelPlugin *plugin);
-void xfce_panel_plugin_unblock_menu (XfcePanelPlugin *plugin);
+void xfce_panel_plugin_unblock_menu (XfcePanelPlugin *plugin);
-void xfce_panel_plugin_register_menu (XfcePanelPlugin *plugin,
- GtkMenu *menu);
+void xfce_panel_plugin_register_menu (XfcePanelPlugin *plugin,
+ GtkMenu *menu);
-GtkArrowType xfce_panel_plugin_arrow_type (XfcePanelPlugin *plugin);
+GtkArrowType xfce_panel_plugin_arrow_type (XfcePanelPlugin *plugin);
-void xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
- GtkWidget *menu_widget,
- GtkWidget *attach_widget,
- gint *x,
- gint *y);
+void xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
+ GtkWidget *menu_widget,
+ GtkWidget *attach_widget,
+ gint *x,
+ gint *y);
-void xfce_panel_plugin_position_menu (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer panel_plugin);
+void xfce_panel_plugin_position_menu (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ gpointer panel_plugin);
-gchar *xfce_panel_plugin_lookup_rc_file (XfcePanelPlugin *plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+gchar *xfce_panel_plugin_lookup_rc_file (XfcePanelPlugin *plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-gchar *xfce_panel_plugin_save_location (XfcePanelPlugin *plugin,
- gboolean create) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+gchar *xfce_panel_plugin_save_location (XfcePanelPlugin *plugin,
+ gboolean create) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
G_END_DECLS
diff --git a/panel/panel-dbus-service.c b/panel/panel-dbus-service.c
index b204a9a..65986b2 100644
--- a/panel/panel-dbus-service.c
+++ b/panel/panel-dbus-service.c
@@ -91,6 +91,7 @@ panel_dbus_service_class_init (PanelDBusServiceClass *klass)
/**
* Emited when a plugin property changes
**/
+ /* TODO implement this */
dbus_service_signals[PROPERTY_CHANGED] =
g_signal_new (I_("property-changed"),
G_TYPE_FROM_CLASS (gobject_class),
@@ -158,7 +159,7 @@ panel_dbus_service_display_preferences_dialog (PanelDBusService *service,
GError **error)
{
PanelApplication *application;
-
+
panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -274,9 +275,47 @@ panel_dbus_service_get_property (PanelDBusService *service,
GValue *value,
GError *error)
{
- g_message ("Plugin '%s' requested property '%s'", plugin_id, property);
+ PanelModuleFactory *factory;
+ PanelApplication *application;
+ XfcePanelPluginProvider *provider;
+ GtkWidget *window;
+ gboolean succeed = FALSE;
- return TRUE;
+ panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
+ panel_return_val_if_fail (plugin_id != NULL, FALSE);
+ panel_return_val_if_fail (property != NULL, FALSE);
+
+ /* get the module factory */
+ factory = panel_module_factory_get ();
+
+ /* get the plugin */
+ provider = panel_module_factory_get_plugin (factory, plugin_id);
+ if (G_LIKELY (provider))
+ {
+ if (strcmp ("PanelNumber", property) == 0)
+ {
+ /* get the plugin's panel window */
+ window = gtk_widget_get_toplevel (GTK_WIDGET (provider));
+
+ /* initialize the value */
+ g_value_init (value, G_TYPE_UINT);
+
+ /* get the panel number from the application */
+ application = panel_application_get ();
+ g_value_set_uint (value, panel_application_get_window_index (application, PANEL_WINDOW (window)));
+ g_object_unref (G_OBJECT (application));
+
+ succeed = TRUE;
+ }
+ }
+
+ /* release the factory */
+ g_object_unref (G_OBJECT (factory));
+
+ /* check if we return a good value */
+ panel_return_val_if_fail (!succeed || G_TYPE_CHECK_VALUE (value), FALSE);
+
+ return succeed;
}
diff --git a/wrapper/main.c b/wrapper/main.c
index abc0c48..9c57c24 100644
--- a/wrapper/main.c
+++ b/wrapper/main.c
@@ -146,7 +146,7 @@ dbus_proxy_provider_move_item (XfcePanelPluginProvider *provider,
DBusGProxy *dbus_proxy)
{
GError *error = NULL;
-
+
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
/* call */
@@ -166,9 +166,22 @@ dbus_proxy_provider_add_new_items (XfcePanelPluginProvider *provider,
{
gchar *name;
GError *error = NULL;
-
+ guint active_panel = 0;
+ GValue value = { 0, };
+
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+ /* try to get the panel number of this plugin */
+ if (wrapper_dbus_client_get_property (dbus_proxy, xfce_panel_plugin_provider_get_id (provider),
+ "PanelNumber", &value, NULL))
+ {
+ /* set the panel number */
+ active_panel = g_value_get_uint (&value);
+
+ /* unset */
+ g_value_unset (&value);
+ }
+
/* create a screen name */
name = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (provider)));
@@ -191,14 +204,26 @@ dbus_proxy_provider_panel_preferences (XfcePanelPluginProvider *provider,
{
gchar *name;
GError *error = NULL;
-
+ guint active_panel = 0;
+ GValue value = { 0, };
+
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+ /* try to get the panel number of this plugin */
+ if (wrapper_dbus_client_get_property (dbus_proxy, xfce_panel_plugin_provider_get_id (provider),
+ "PanelNumber", &value, NULL))
+ {
+ /* set the panel number */
+ active_panel = g_value_get_uint (&value);
+
+ /* unset */
+ g_value_unset (&value);
+ }
+
/* create a screen name */
name = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (provider)));
/* call */
- /* TODO implement active panel */
if (!wrapper_dbus_client_display_preferences_dialog (dbus_proxy, name, 0, &error))
{
g_critical ("DBus error: %s", error->message);
@@ -216,7 +241,7 @@ dbus_proxy_provider_remove (XfcePanelPluginProvider *provider,
DBusGProxy *dbus_proxy)
{
GError *error = NULL;
-
+
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
/* call */
More information about the Xfce4-commits
mailing list