[Xfce4-commits] <xfce4-panel:devel> * Wrapper communication is now though dbus. * Dropped GObject plugin system, will add something better later. * Lots of cleanups.
Nick Schermer
nick at xfce.org
Tue Aug 11 20:22:46 CEST 2009
Updating branch refs/heads/devel
to 6b69b1fe5ab12ef250ed3ed93e875947d1d57eef (commit)
from 9318f5e7b328ec789fb8f6567032f62519c50a03 (commit)
commit 6b69b1fe5ab12ef250ed3ed93e875947d1d57eef
Author: Nick Schermer <nick at xfce.org>
Date: Sat Aug 9 16:22:28 2008 +0200
* Wrapper communication is now though dbus.
* Dropped GObject plugin system, will add something better later.
* Lots of cleanups.
libxfce4panel/libxfce4panel.h | 117 +----
libxfce4panel/xfce-panel-plugin-provider.c | 9 +
libxfce4panel/xfce-panel-plugin-provider.h | 21 +-
libxfce4panel/xfce-panel-plugin.c | 693 ++++++++++++--------
panel/Makefile.am | 24 +-
panel/main.c | 6 +-
panel/panel-application.c | 18 +-
panel/panel-dbus-client.c | 250 +++-----
panel/panel-dbus-service-infos.xml | 44 ++-
panel/panel-dbus-service.c | 137 ++++-
panel/panel-dbus-service.h | 8 +-
panel/panel-module-factory.c | 36 +-
panel/panel-module-factory.h | 5 +-
panel/panel-module.c | 9 +-
panel/panel-plugin-external.c | 297 +++-------
panel/panel-plugin-external.h | 13 +-
panel/panel-window.c | 2 -
plugins/clock/clock-analog.c | 50 ++-
plugins/clock/clock-analog.h | 20 +-
plugins/clock/clock-binary.c | 67 ++-
plugins/clock/clock-binary.h | 20 +-
plugins/clock/clock-dialog.c | 124 ++---
plugins/clock/clock-dialog.h | 2 +-
plugins/clock/clock-digital.c | 61 ++-
plugins/clock/clock-digital.h | 20 +-
plugins/clock/clock-lcd.c | 70 ++-
plugins/clock/clock-lcd.h | 20 +-
plugins/clock/clock.c | 972 +++++++++++++---------------
plugins/clock/clock.h | 123 ++--
plugins/systray/systray.desktop.in.in | 2 +-
plugins/systray/xfce-tray-manager.c | 27 -
wrapper/Makefile.am | 28 +-
wrapper/main.c | 321 ++++++++--
wrapper/wrapper-module.c | 205 ------
wrapper/wrapper-module.h | 52 --
wrapper/wrapper-plug.c | 280 +-------
wrapper/wrapper-plug.h | 11 +-
37 files changed, 1968 insertions(+), 2196 deletions(-)
diff --git a/libxfce4panel/libxfce4panel.h b/libxfce4panel/libxfce4panel.h
index fb87e59..bb34ca8 100644
--- a/libxfce4panel/libxfce4panel.h
+++ b/libxfce4panel/libxfce4panel.h
@@ -22,10 +22,6 @@
G_BEGIN_DECLS
-/* typedef for registering types, could be useful if we want
- * a real XfcePanelModule object in the feature */
-typedef GTypeModule XfcePanelModule;
-
#define LIBXFCE4PANEL_INSIDE_LIBXFCE4PANEL_H
#include <libxfce4panel/xfce-arrow-button.h>
@@ -37,112 +33,6 @@ typedef GTypeModule XfcePanelModule;
#undef LIBXFCE4PANEL_INSIDE_LIBXFCE4PANEL_H
-
-
-#define XFCE_PANEL_DEFINE_TYPE(TN, t_n, T_P) XFCE_PANEL_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
-#define XFCE_PANEL_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) XFCE_PANEL_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, _C_)
-#define XFCE_PANEL_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P) XFCE_PANEL_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {})
-#define XFCE_PANEL_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) XFCE_PANEL_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, _C_)
-
-#define XFCE_PANEL_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE) \
- static gpointer type_name##_parent_class = NULL; \
- static GType type_name##_type = G_TYPE_INVALID; \
- static void type_name##_init (TypeName *self); \
- static void type_name##_class_init (TypeName##Class *klass); \
- static void type_name##_class_intern_init (TypeName##Class *klass) \
- { \
- type_name##_parent_class = g_type_class_peek_parent (klass); \
- type_name##_class_init (klass); \
- } \
- \
- GType \
- type_name##_get_type (void) \
- { \
- return type_name##_type; \
- } \
- \
- void \
- type_name##_register_type (XfcePanelModule *xfce_panel_module) \
- { \
- GType xfce_panel_define_type_id; \
- static const GTypeInfo xfce_panel_define_type_info = \
- { \
- sizeof (TypeName##Class), \
- NULL, \
- NULL, \
- (GClassInitFunc) type_name##_class_intern_init, \
- NULL, \
- NULL, \
- sizeof (TypeName), \
- 0, \
- (GInstanceInitFunc) type_name##_init, \
- NULL, \
- }; \
- xfce_panel_define_type_id = g_type_module_register_type (G_TYPE_MODULE (xfce_panel_module), TYPE_PARENT, \
- #TypeName, &xfce_panel_define_type_info, flags); \
- { CODE ; } \
- type_name##_type = xfce_panel_define_type_id; \
- }
-
-#define XFCE_PANEL_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) \
- { \
- static const GInterfaceInfo xfce_panel_implement_interface_info = \
- { \
- (GInterfaceInitFunc) iface_init \
- }; \
- g_type_module_add_interface (G_TYPE_MODULE (xfce_panel_module), xfce_panel_define_type_id, \
- TYPE_IFACE, &xfce_panel_implement_interface_info); \
- }
-
-
-
-#define XFCE_PANEL_PLUGIN_REGISTER_OBJECT(type) \
- XFCE_PANEL_PLUGIN_REGISTER_OBJECT_EXTENDED (type, {})
-
-#define XFCE_PANEL_PLUGIN_REGISTER_OBJECT_WITH_CHECK(type, check_func) \
- XFCE_PANEL_PLUGIN_REGISTER_OBJECT_EXTENDED (type, {})
-
-#define XFCE_PANEL_PLUGIN_REGISTER_OBJECT_EXTENDED(type, CODE) \
- const gchar *plugin_init_name = NULL; \
- const gchar *plugin_init_id = NULL; \
- const gchar *plugin_init_display_name = NULL; \
- \
- G_MODULE_EXPORT XfcePanelPlugin * \
- xfce_panel_plugin_construct (const gchar *name, \
- const gchar *id, \
- const gchar *display_name, \
- gchar **arguments, \
- GdkScreen *screen) \
- { \
- XfcePanelPlugin *plugin; \
- extern const gchar *plugin_init_name; \
- extern const gchar *plugin_init_id; \
- extern const gchar *plugin_init_display_name; \
- extern gchar **plugin_init_arguments; \
- \
- panel_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); \
- panel_return_val_if_fail (name != NULL && id != NULL, NULL); \
- panel_return_val_if_fail (g_type_is_a (type, XFCE_TYPE_PANEL_PLUGIN), NULL); \
- \
- /* set the temporarily names for the init function */ \
- plugin_init_name = name; \
- plugin_init_id = id; \
- plugin_init_display_name = display_name; \
- plugin_init_arguments = arguments; \
- \
- CODE \
- \
- plugin = g_object_new (type, \
- "name", name, \
- "display-name", display_name, \
- "id", id, \
- "arguments", arguments, NULL); \
- \
- return plugin; \
- }
-
-
-
#define XFCE_PANEL_PLUGIN_REGISTER(init_func) \
XFCE_PANEL_PLUGIN_REGISTER_EXTENDED (init_func, {})
@@ -155,10 +45,8 @@ typedef GTypeModule XfcePanelModule;
{ \
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin)); \
\
- /* disconnect the realize signal */ \
g_signal_handlers_disconnect_by_func (G_OBJECT (plugin), G_CALLBACK (xfce_panel_plugin_realize), NULL); \
\
- /* run the plugin construct function */ \
(*construct_func) (plugin); \
} \
\
@@ -176,18 +64,15 @@ typedef GTypeModule XfcePanelModule;
\
CODE \
{ \
- /* create new internal plugin */ \
plugin = g_object_new (XFCE_TYPE_PANEL_PLUGIN, \
"name", name, \
- "display-name", display_name, \
"id", id, \
+ "display-name", display_name, \
"arguments", arguments, NULL); \
\
- /* signal to realize the plugin */ \
g_signal_connect_after (G_OBJECT (plugin), "realize", G_CALLBACK (xfce_panel_plugin_realize), NULL); \
} \
\
- /* return the plugin */ \
return plugin; \
}
diff --git a/libxfce4panel/xfce-panel-plugin-provider.c b/libxfce4panel/xfce-panel-plugin-provider.c
index 65e5d83..538aa2b 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.c
+++ b/libxfce4panel/xfce-panel-plugin-provider.c
@@ -36,6 +36,7 @@ enum
MOVE,
ADD_NEW_ITEMS,
PANEL_PREFERENCES,
+ LOCK_PANEL,
LAST_SIGNAL
};
@@ -116,6 +117,14 @@ 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),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
/* initialization finished */
initialized = TRUE;
diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h
index 4d62242..eb1ce93 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.h
+++ b/libxfce4panel/xfce-panel-plugin-provider.h
@@ -27,7 +27,6 @@ G_BEGIN_DECLS
typedef struct _XfcePanelPluginProviderIface XfcePanelPluginProviderIface;
typedef struct _XfcePanelPluginProvider XfcePanelPluginProvider;
-typedef enum _XfcePanelPluginMessage XfcePanelPluginMessage;
typedef XfcePanelPluginProvider *(*PluginConstructFunc) (const gchar *name,
const gchar *id,
@@ -35,25 +34,7 @@ typedef XfcePanelPluginProvider *(*PluginConstructFunc) (const gchar *name,
gchar **arguments,
GdkScreen *screen);
-typedef void (*PluginRegisterTypesFunc) (XfcePanelModule *module);
-enum _XfcePanelPluginMessage
-{
- MESSAGE_EXPAND_CHANGED,
- MESSAGE_MOVE_ITEM,
- MESSAGE_ADD_NEW_ITEMS,
- MESSAGE_PANEL_PREFERENCES,
- MESSAGE_SET_SIZE,
- MESSAGE_SET_ORIENTATION,
- MESSAGE_SET_SCREEN_POSITION,
- MESSAGE_SET_PLUG_ID,
- MESSAGE_SET_SENSITIVE,
- MESSAGE_SET_BACKGROUND_ALPHA,
- MESSAGE_SET_ACTIVE_PANEL,
- MESSAGE_SAVE,
- MESSAGE_REMOVE,
- MESSAGE_QUIT
-};
#define XFCE_TYPE_PANEL_PLUGIN_PROVIDER (xfce_panel_plugin_provider_get_type ())
#define XFCE_PANEL_PLUGIN_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_PANEL_PLUGIN_PROVIDER, XfcePanelPluginProvider))
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 03773ee..672edc0 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -57,8 +57,10 @@ static void xfce_panel_plugin_menu_move (XfcePanelPlugin
static void xfce_panel_plugin_menu_remove (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_menu_add_items (XfcePanelPlugin *plugin);
static void xfce_panel_plugin_menu_panel_preferences (XfcePanelPlugin *plugin);
-static GtkWidget *xfce_panel_plugin_menu_new (XfcePanelPlugin *plugin);
+static GtkMenu *xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin);
static gchar *xfce_panel_plugin_relative_filename (XfcePanelPlugin *plugin);
+static void xfce_panel_plugin_unregister_menu (GtkMenu *menu,
+ XfcePanelPlugin *plugin);
static void xfce_panel_plugin_set_size (XfcePanelPluginProvider *provider,
gint size);
static void xfce_panel_plugin_set_orientation (XfcePanelPluginProvider *provider,
@@ -105,10 +107,13 @@ struct _XfcePanelPluginPrivate
XfceScreenPosition screen_position;
/* plugin menu */
- GtkWidget *menu;
+ GtkMenu *menu;
- /* block the plugin menu */
- guint menu_blocked : 1;
+ /* menu block counter */
+ guint menu_blocked;
+
+ /* registered menu counter */
+ guint registered_menus;
};
@@ -117,14 +122,6 @@ static guint plugin_signals[LAST_SIGNAL];
-/* external plugin information for during plugin_init */
-const gchar *plugin_init_name = NULL;
-const gchar *plugin_init_id = NULL;
-const gchar *plugin_init_display_name = NULL;
-gchar **plugin_init_arguments = NULL;
-
-
-
G_DEFINE_TYPE_WITH_CODE (XfcePanelPlugin, xfce_panel_plugin, GTK_TYPE_EVENT_BOX,
G_IMPLEMENT_INTERFACE (XFCE_TYPE_PANEL_PLUGIN_PROVIDER, xfce_panel_plugin_provider_init));
@@ -150,7 +147,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
/**
* XfcePanelPlugin::about
- * @plugin : a #XfcePanelPlugin.
+ * @plugin : an #XfcePanelPlugin.
*
* This signal is emmitted when the About entry in the right-click
* menu is clicked. Plugin writes can use it to show information
@@ -170,7 +167,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
/**
* XfcePanelPlugin::configure-plugin
- * @plugin : a #XfcePanelPlugin.
+ * @plugin : an #XfcePanelPlugin.
*
* This signal is emmitted when the Properties entry in the right-click
* menu is clicked. Plugin writes can use this signal to open a
@@ -190,7 +187,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
/**
* XfcePanelPlugin::free-data
- * @plugin : a #XfcePanelPlugin.
+ * @plugin : an #XfcePanelPlugin.
*
* This signal is emmitted when the plugin is closing. Plugin
* writers should use this signal to free any allocated resources.
@@ -208,7 +205,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
/**
* XfcePanelPlugin::orientation-changed
- * @plugin : a #XfcePanelPlugin.
+ * @plugin : an #XfcePanelPlugin.
* @orientation : new #GtkOrientation of the panel.
*
* This signal is emmitted whenever the orientation of the panel
@@ -228,7 +225,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
/**
* XfcePanelPlugin::save
- * @plugin : a #XfcePanelPlugin.
+ * @plugin : an #XfcePanelPlugin.
*
* This signal is emitted when the plugin should save it's
* configuration. The signal is always emmitted before the plugin
@@ -248,7 +245,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
/**
* XfcePanelPlugin::size-changed
- * @plugin : a #XfcePanelPlugin.
+ * @plugin : an #XfcePanelPlugin.
* @size : the new size of the panel.
*
* This signal is emmitted whenever the size of the panel
@@ -266,7 +263,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
/**
* XfcePanelPlugin::screen-position-changed
- * @plugin : a #XfcePanelPlugin.
+ * @plugin : an #XfcePanelPlugin.
* @position : the new screen position of the panel.
*
* This signal is emmitted whenever the screen position of the panel
@@ -296,7 +293,9 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
"Name",
"Plugin internal name",
NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS
+ | G_PARAM_CONSTRUCT_ONLY));
/**
* XfcePanelPlugin:display-name:
@@ -312,7 +311,9 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
"Display Name",
"Plugin display name",
NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS
+ | G_PARAM_CONSTRUCT_ONLY));
/**
* XfcePanelPlugin:id:
@@ -328,19 +329,26 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
"ID",
"Unique plugin ID",
NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS
+ | G_PARAM_CONSTRUCT_ONLY));
/**
* XfcePanelPlugin:arguments:
*
- * TODO
+ * The argument the plugin was started with. If the plugin was not started with
+ * any arguments this value is %NULL. Plugin writer can use it to read the
+ * arguments array, but xfce_panel_plugin_get_arguments() is recommended.
**/
g_object_class_install_property (gobject_class,
PROP_ARGUMENTS,
- g_param_spec_pointer ("arguments",
- "Arguemnts",
- "Startup arguments for the plugin",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY));
+ g_param_spec_boxed ("arguments",
+ "Arguemnts",
+ "Startup arguments for the plugin",
+ G_TYPE_STRV,
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS
+ | G_PARAM_CONSTRUCT_ONLY));
}
@@ -361,7 +369,8 @@ xfce_panel_plugin_init (XfcePanelPlugin *plugin)
plugin->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
plugin->priv->screen_position = XFCE_SCREEN_POSITION_NONE;
plugin->priv->menu = NULL;
- plugin->priv->menu_blocked = FALSE;
+ plugin->priv->menu_blocked = 0;
+ plugin->priv->registered_menus = 0;
/* hide the event box window to make the plugin transparent */
gtk_event_box_set_visible_window (GTK_EVENT_BOX (plugin), FALSE);
@@ -388,24 +397,24 @@ xfce_panel_plugin_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (object);
+ XfcePanelPluginPrivate *private = XFCE_PANEL_PLUGIN (object)->priv;
switch (prop_id)
{
case PROP_NAME:
- g_value_set_static_string (value, plugin->priv->name);
+ g_value_set_static_string (value, private->name);
break;
case PROP_DISPLAY_NAME:
- g_value_set_static_string (value, plugin->priv->display_name);
+ g_value_set_static_string (value, private->display_name);
break;
case PROP_ID:
- g_value_set_static_string (value, plugin->priv->id);
+ g_value_set_static_string (value, private->id);
break;
case PROP_ARGUMENTS:
- g_value_set_pointer (value, plugin->priv->arguments);
+ g_value_set_boxed (value, private->arguments);
break;
default:
@@ -422,40 +431,24 @@ xfce_panel_plugin_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (object);
+ XfcePanelPluginPrivate *private = XFCE_PANEL_PLUGIN (object)->priv;
switch (prop_id)
{
case PROP_NAME:
- /* cleanup old name */
- g_free (plugin->priv->name);
-
- /* set new name */
- plugin->priv->name = g_value_dup_string (value);
+ private->name = g_value_dup_string (value);
break;
case PROP_DISPLAY_NAME:
- /* cleanup old name */
- g_free (plugin->priv->display_name);
-
- /* set new name */
- plugin->priv->display_name = g_value_dup_string (value);
+ private->display_name = g_value_dup_string (value);
break;
case PROP_ID:
- /* cleanup old id */
- g_free (plugin->priv->id);
-
- /* set new id */
- plugin->priv->id = g_value_dup_string (value);
+ private->id = g_value_dup_string (value);
break;
case PROP_ARGUMENTS:
- /* cleanup previous arguments */
- g_strfreev (plugin->priv->arguments);
-
- /* set new values */
- plugin->priv->arguments = g_strdupv (g_value_get_pointer (value));
+ private->arguments = g_value_dup_boxed (value);
break;
default:
@@ -484,7 +477,7 @@ xfce_panel_plugin_finalize (GObject *object)
/* destroy the menu */
if (plugin->priv->menu)
- gtk_widget_destroy (plugin->priv->menu);
+ gtk_widget_destroy (GTK_WIDGET (plugin->priv->menu));
/* cleanup */
g_free (plugin->priv->name);
@@ -503,25 +496,24 @@ xfce_panel_plugin_button_press_event (GtkWidget *widget,
{
XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (widget);
guint modifiers;
+ GtkMenu *menu;
panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (widget), FALSE);
/* get the default accelerator modifier mask */
modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
- if (plugin->priv->menu_blocked == FALSE
+ if (plugin->priv->menu_blocked == 0
&& (event->button == 3 || (event->button == 1 && modifiers == GDK_CONTROL_MASK)))
{
- /* create the menu if needed */
- if (G_UNLIKELY (plugin->priv->menu == NULL))
- plugin->priv->menu = xfce_panel_plugin_menu_new (plugin);
+ /* get the panel menu */
+ menu = xfce_panel_plugin_menu_get (plugin);
/* set the menu screen */
- gtk_menu_set_screen (GTK_MENU (plugin->priv->menu), gtk_widget_get_screen (widget));
+ gtk_menu_set_screen (menu, gtk_widget_get_screen (widget));
/* popup the menu */
- gtk_menu_popup (GTK_MENU (plugin->priv->menu), NULL, NULL,
- NULL, NULL, event->button, event->time);
+ gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
return TRUE;
}
@@ -559,7 +551,7 @@ xfce_panel_plugin_menu_move (XfcePanelPlugin *plugin)
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin));
- /* emit move signal */
+ /* move the plugin (provider signal) */
g_signal_emit_by_name (G_OBJECT (plugin), "move-item", 0);
}
@@ -587,7 +579,7 @@ xfce_panel_plugin_menu_remove (XfcePanelPlugin *plugin)
/* add hig buttons */
gtk_dialog_add_buttons (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
GTK_STOCK_REMOVE, GTK_RESPONSE_YES, NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO);
/* run the dialog */
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
@@ -622,7 +614,7 @@ xfce_panel_plugin_menu_add_items (XfcePanelPlugin *plugin)
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin));
- /* emit add-new-items signal */
+ /* open items dialog (provider signal) */
g_signal_emit_by_name (G_OBJECT (plugin), "add-new-items", 0);
}
@@ -634,14 +626,14 @@ xfce_panel_plugin_menu_panel_preferences (XfcePanelPlugin *plugin)
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin));
- /* emit panel-preferences signal */
+ /* open preferences dialog (provider signal) */
g_signal_emit_by_name (G_OBJECT (plugin), "panel-preferences", 0);
}
-static GtkWidget *
-xfce_panel_plugin_menu_new (XfcePanelPlugin *plugin)
+static GtkMenu *
+xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin)
{
GtkWidget *menu;
GtkWidget *item;
@@ -649,82 +641,88 @@ xfce_panel_plugin_menu_new (XfcePanelPlugin *plugin)
panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), NULL);
- /* create new menu */
- menu = gtk_menu_new ();
-
- /* attach to the plugin */
- gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (plugin), NULL);
-
- /* item with plugin name */
- item = gtk_menu_item_new_with_label (xfce_panel_plugin_get_display_name (plugin));
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_set_sensitive (item, FALSE);
- gtk_widget_show (item);
-
- /* separator */
- item = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
-
- /* properties item */
- item = gtk_image_menu_item_new_from_stock (GTK_STOCK_PROPERTIES, NULL);
- g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_properties), plugin);
- g_object_set_data (G_OBJECT (menu), I_("properties-item"), item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- /* about item */
- item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
- g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_about), plugin);
- g_object_set_data (G_OBJECT (menu), I_("about-item"), item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- /* move item */
- item = gtk_image_menu_item_new_with_mnemonic (_("_Move"));
- g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_move), plugin);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
-
- image = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- gtk_widget_show (image);
-
- /* separator */
- item = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
-
- /* remove */
- item = gtk_image_menu_item_new_from_stock (GTK_STOCK_REMOVE, NULL);
- g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_remove), plugin);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
-
- /* separator */
- item = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
-
- /* add new items */
- item = gtk_image_menu_item_new_with_mnemonic (_("Add _New Items..."));
- g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_add_items), plugin);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
-
- image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- gtk_widget_show (image);
-
- /* customize panel */
- item = gtk_image_menu_item_new_with_mnemonic (_("Panel Pr_eferences..."));
- g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_panel_preferences), plugin);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
-
- image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- gtk_widget_show (image);
-
- return menu;
+ if (G_UNLIKELY (plugin->priv->menu == NULL))
+ {
+ /* create new menu */
+ menu = gtk_menu_new ();
+
+ /* attach to the plugin */
+ gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (plugin), NULL);
+
+ /* item with plugin name */
+ item = gtk_menu_item_new_with_label (xfce_panel_plugin_get_display_name (plugin));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_set_sensitive (item, FALSE);
+ gtk_widget_show (item);
+
+ /* separator */
+ item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+
+ /* properties item */
+ item = gtk_image_menu_item_new_from_stock (GTK_STOCK_PROPERTIES, NULL);
+ g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_properties), plugin);
+ g_object_set_data (G_OBJECT (menu), I_("properties-item"), item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ /* about item */
+ item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
+ g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_about), plugin);
+ g_object_set_data (G_OBJECT (menu), I_("about-item"), item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ /* move item */
+ item = gtk_image_menu_item_new_with_mnemonic (_("_Move"));
+ g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_move), plugin);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+
+ image = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ gtk_widget_show (image);
+
+ /* separator */
+ item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+
+ /* remove */
+ item = gtk_image_menu_item_new_from_stock (GTK_STOCK_REMOVE, NULL);
+ g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_remove), plugin);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+
+ /* separator */
+ item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+
+ /* add new items */
+ item = gtk_image_menu_item_new_with_mnemonic (_("Add _New Items..."));
+ g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_add_items), plugin);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+
+ image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ gtk_widget_show (image);
+
+ /* customize panel */
+ item = gtk_image_menu_item_new_with_mnemonic (_("Panel Pr_eferences..."));
+ g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_panel_preferences), plugin);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+
+ image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ gtk_widget_show (image);
+
+ /* set panel menu */
+ plugin->priv->menu = GTK_MENU (menu);
+ }
+
+ return plugin->priv->menu;
}
@@ -744,63 +742,200 @@ xfce_panel_plugin_relative_filename (XfcePanelPlugin *plugin)
-const gchar *
+static void
+xfce_panel_plugin_unregister_menu (GtkMenu *menu,
+ XfcePanelPlugin *plugin)
+{
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
+ panel_return_if_fail (GTK_IS_MENU (menu));
+ panel_return_if_fail (plugin->priv->registered_menus > 0);
+
+ if (G_LIKELY (plugin->priv->registered_menus > 0))
+ {
+ /* decrease the counter */
+ plugin->priv->registered_menus--;
+
+ /* emit signal to unlock the panel (provider signal) */
+ if (G_LIKELY (plugin->priv->registered_menus == 0))
+ g_signal_emit_by_name (G_OBJECT (plugin), "lock-panel", FALSE);
+ }
+}
+
+
+
+static void
+xfce_panel_plugin_set_size (XfcePanelPluginProvider *provider,
+ gint size)
+{
+ XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
+
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
+
+ /* check if update is required */
+ if (G_LIKELY (xfce_panel_plugin_get_size (plugin) != size))
+ {
+ /* store new size */
+ plugin->priv->size = size;
+
+ /* emit signal */
+ g_signal_emit (G_OBJECT (plugin), plugin_signals[SIZE_CHANGED], 0, size);
+ }
+}
+
+
+
+static void
+xfce_panel_plugin_set_orientation (XfcePanelPluginProvider *provider,
+ GtkOrientation orientation)
+{
+ XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
+
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
+
+ /* check if update is required */
+ if (G_LIKELY (xfce_panel_plugin_get_orientation (plugin) != orientation))
+ {
+ /* store new size */
+ plugin->priv->orientation = orientation;
+
+ /* emit signal */
+ g_signal_emit (G_OBJECT (plugin), plugin_signals[ORIENTATION_CHANGED], 0, orientation);
+ }
+}
+
+
+
+static void
+xfce_panel_plugin_set_screen_position (XfcePanelPluginProvider *provider,
+ XfceScreenPosition screen_position)
+{
+ XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
+
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
+
+ /* check if update is required */
+ if (G_LIKELY (xfce_panel_plugin_get_screen_position (plugin) != screen_position))
+ {
+ /* store new screen position */
+ plugin->priv->screen_position = screen_position;
+
+ /* emit signal */
+ g_signal_emit (G_OBJECT (plugin), plugin_signals[SCREEN_POSITION_CHANGED], 0, screen_position);
+ }
+}
+
+
+
+static void
+xfce_panel_plugin_save (XfcePanelPluginProvider *provider)
+{
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
+
+ /* emit signal */
+ g_signal_emit (G_OBJECT (provider), plugin_signals[SAVE], 0);
+}
+
+
+
+static void
+xfce_panel_plugin_take_window_notify (gpointer data,
+ GObject *where_the_object_was)
+{
+ panel_return_if_fail (GTK_IS_WINDOW (data) || XFCE_IS_PANEL_PLUGIN (data));
+
+ /* release the opposite weak ref */
+ g_object_weak_unref (G_OBJECT (data), xfce_panel_plugin_take_window_notify, where_the_object_was);
+
+ /* destroy the dialog if the plugin was finalized */
+ if (GTK_IS_WINDOW (data))
+ gtk_widget_destroy (GTK_WIDGET (data));
+}
+
+
+
+/**
+ * xfce_panel_plugin_get_name:
+ * @plugin : an #XfcePanelPlugin.
+ *
+ * Return value: the name of the panel plugin.
+ **/
+G_CONST_RETURN gchar *
xfce_panel_plugin_get_name (XfcePanelPlugin *plugin)
{
g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), NULL);
- return plugin->priv->name ? plugin->priv->name : plugin_init_name;
+ return plugin->priv->name;
}
-const gchar *
+/**
+ * xfce_panel_plugin_get_display_name:
+ * @plugin : an #XfcePanelPlugin.
+ *
+ * Return value: the (translated) display name of the plugin.
+ **/
+G_CONST_RETURN gchar *
xfce_panel_plugin_get_display_name (XfcePanelPlugin *plugin)
{
+
+
g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), NULL);
- if (plugin->priv->display_name)
+ if (G_LIKELY (plugin->priv->display_name))
return plugin->priv->display_name;
- else if (plugin->priv->name)
- return plugin->priv->name;
- else
- return plugin_init_display_name;
+
+ return plugin->priv->name;
}
-const gchar *
+/**
+ * xfce_panel_plugin_get_id:
+ * @plugin :
+ *
+ * Return value: the unique id of the panel plugin.
+ **/
+G_CONST_RETURN gchar *
xfce_panel_plugin_get_id (XfcePanelPlugin *plugin)
{
g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), NULL);
- return plugin->priv->id ? plugin->priv->id : plugin_init_id;
+ return plugin->priv->id;
}
+/**
+ * xfce_panel_plugin_get_arguments:
+ * @plugin : an #XfcePanelPlugin.
+ * @arguments : return location for the argument vector.
+ *
+ * Return value: %TRUE @arguments was set, %FALSE otherwise.
+ *
+ * Since: 4.8.0
+ **/
gboolean
xfce_panel_plugin_get_arguments (XfcePanelPlugin *plugin,
gchar ***arguments)
{
g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), FALSE);
+ g_return_val_if_fail (arguments != NULL, FALSE);
- if (plugin->priv->arguments || plugin_init_arguments)
- {
- /* dupplicate the arguments */
- if (arguments != NULL)
- *arguments = g_strdupv (plugin->priv->arguments ? plugin->priv->arguments : plugin_init_arguments);
+ /* dupplicate the arguments */
+ *arguments = g_strdupv (plugin->priv->arguments);
- return TRUE;
- }
- else
- {
- return FALSE;
- }
+ return !!(plugin->priv->arguments != NULL);
}
+/**
+ * xfce_panel_plugin_get_size:
+ * @plugin : an #XfcePanelPlugin.
+ *
+ * Return value: the current size of the panel.
+ **/
gint
xfce_panel_plugin_get_size (XfcePanelPlugin *plugin)
{
@@ -811,27 +946,13 @@ xfce_panel_plugin_get_size (XfcePanelPlugin *plugin)
-static void
-xfce_panel_plugin_set_size (XfcePanelPluginProvider *provider,
- gint size)
-{
- XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
-
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
-
- /* check if update is required */
- if (G_LIKELY (xfce_panel_plugin_get_size (plugin) != size))
- {
- /* store new size */
- plugin->priv->size = size;
-
- /* emit signal */
- g_signal_emit (G_OBJECT (plugin), plugin_signals[SIZE_CHANGED], 0, size);
- }
-}
-
-
-
+/**
+ * xfce_panel_plugin_get_expand:
+ * @plugin : an #XfcePanelPlugin.
+ *
+ * Return value: %TRUE when the plugin should expand,
+ * %FALSE otherwise.
+ **/
gboolean
xfce_panel_plugin_get_expand (XfcePanelPlugin *plugin)
{
@@ -842,6 +963,10 @@ xfce_panel_plugin_get_expand (XfcePanelPlugin *plugin)
+/**
+ * xfce_panel_plugin_set_expand:
+ * @plugin : an #XfcePanelPlugin.
+ **/
void
xfce_panel_plugin_set_expand (XfcePanelPlugin *plugin,
gboolean expand)
@@ -864,6 +989,12 @@ xfce_panel_plugin_set_expand (XfcePanelPlugin *plugin,
+/**
+ * xfce_panel_plugin_get_orientation:
+ * @plugin : an #XfcePanelPlugin.
+ *
+ * Return value: the current #GtkOrientation of the panel.
+ **/
GtkOrientation
xfce_panel_plugin_get_orientation (XfcePanelPlugin *plugin)
{
@@ -874,27 +1005,12 @@ xfce_panel_plugin_get_orientation (XfcePanelPlugin *plugin)
-static void
-xfce_panel_plugin_set_orientation (XfcePanelPluginProvider *provider,
- GtkOrientation orientation)
-{
- XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
-
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
-
- /* check if update is required */
- if (G_LIKELY (xfce_panel_plugin_get_orientation (plugin) != orientation))
- {
- /* store new size */
- plugin->priv->orientation = orientation;
-
- /* emit signal */
- g_signal_emit (G_OBJECT (plugin), plugin_signals[ORIENTATION_CHANGED], 0, orientation);
- }
-}
-
-
-
+/**
+ * xfce_panel_plugin_get_screen_position:
+ * @plugin : an #XfcePanelPlugin.
+ *
+ * Return value: the current #XfceScreenPosition of the panel.
+ **/
XfceScreenPosition
xfce_panel_plugin_get_screen_position (XfcePanelPlugin *plugin)
{
@@ -905,54 +1021,13 @@ xfce_panel_plugin_get_screen_position (XfcePanelPlugin *plugin)
-static void
-xfce_panel_plugin_set_screen_position (XfcePanelPluginProvider *provider,
- XfceScreenPosition screen_position)
-{
- XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
-
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
-
- /* check if update is required */
- if (G_LIKELY (xfce_panel_plugin_get_screen_position (plugin) != screen_position))
- {
- /* store new screen position */
- plugin->priv->screen_position = screen_position;
-
- /* emit signal */
- g_signal_emit (G_OBJECT (plugin), plugin_signals[SCREEN_POSITION_CHANGED], 0, screen_position);
- }
-}
-
-
-
-static void
-xfce_panel_plugin_save (XfcePanelPluginProvider *provider)
-{
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
-
- /* emit signal */
- g_signal_emit (G_OBJECT (provider), plugin_signals[SAVE], 0);
-}
-
-
-
-static void
-xfce_panel_plugin_take_window_notify (gpointer data,
- GObject *where_the_object_was)
-{
- panel_return_if_fail (GTK_IS_WINDOW (data) || XFCE_IS_PANEL_PLUGIN (data));
-
- /* release the opposite weak ref */
- g_object_weak_unref (G_OBJECT (data), xfce_panel_plugin_take_window_notify, where_the_object_was);
-
- /* destroy the dialog if the plugin was finalized */
- if (GTK_IS_WINDOW (data))
- gtk_widget_destroy (GTK_WIDGET (data));
-}
-
-
-
+/**
+ * xfce_panel_plugin_take_window:
+ * @plugin : an #XfcePanelPlugin.
+ * @window : a #GtkWindow.
+ *
+ * Since: 4.8.0
+ **/
void
xfce_panel_plugin_take_window (XfcePanelPlugin *plugin,
GtkWindow *window)
@@ -967,6 +1042,11 @@ xfce_panel_plugin_take_window (XfcePanelPlugin *plugin,
+/**
+ * xfce_panel_plugin_add_action_widget:
+ * @plugin : an #XfcePanelPlugin.
+ * @widget : a #GtkWidget.
+ **/
void
xfce_panel_plugin_add_action_widget (XfcePanelPlugin *plugin,
GtkWidget *widget)
@@ -980,93 +1060,140 @@ xfce_panel_plugin_add_action_widget (XfcePanelPlugin *plugin,
+/**
+ * xfce_panel_plugin_menu_insert_item:
+ * @plugin : an #XfcePanelPlugin.
+ * @item : a #GtkMenuItem.
+ **/
void
xfce_panel_plugin_menu_insert_item (XfcePanelPlugin *plugin,
GtkMenuItem *item)
{
+ GtkMenu *menu;
+
g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
g_return_if_fail (GTK_IS_MENU_ITEM (item));
- /* create the plugin menu if needed */
- if (plugin->priv->menu == NULL)
- plugin->priv->menu = xfce_panel_plugin_menu_new (plugin);
+ /* get the panel menu */
+ menu = xfce_panel_plugin_menu_get (plugin);
/* insert the new item below the move entry */
- gtk_menu_shell_insert (GTK_MENU_SHELL (plugin->priv->menu), GTK_WIDGET (item), 5);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), GTK_WIDGET (item), 5);
}
+/**
+ * xfce_panel_plugin_menu_show_configure:
+ * @plugin : an #XfcePanelPlugin.
+ **/
void
xfce_panel_plugin_menu_show_configure (XfcePanelPlugin *plugin)
{
GtkWidget *item;
+ GtkMenu *menu;
g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
- /* create the plugin menu if needed */
- if (plugin->priv->menu == NULL)
- plugin->priv->menu = xfce_panel_plugin_menu_new (plugin);
+ /* get the panel menu */
+ menu = xfce_panel_plugin_menu_get (plugin);
/* get and show the properties item */
- item = g_object_get_data (G_OBJECT (plugin->priv->menu), I_("properties-item"));
+ item = g_object_get_data (G_OBJECT (menu), I_("properties-item"));
if (G_LIKELY (item))
gtk_widget_show (item);
}
+/**
+ * xfce_panel_plugin_menu_show_about:
+ * @plugin : an #XfcePanelPlugin.
+ **/
void
xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin)
{
GtkWidget *item;
+ GtkMenu *menu;
g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
- /* create the plugin menu if needed */
- if (plugin->priv->menu == NULL)
- plugin->priv->menu = xfce_panel_plugin_menu_new (plugin);
+ /* get the panel menu */
+ menu = xfce_panel_plugin_menu_get (plugin);
/* get and show the properties item */
- item = g_object_get_data (G_OBJECT (plugin->priv->menu), I_("about-item"));
+ item = g_object_get_data (G_OBJECT (menu), I_("about-item"));
if (G_LIKELY (item))
gtk_widget_show (item);
}
+/**
+ * xfce_panel_plugin_block_menu:
+ * plugin : an #XfcePanelPlugin.
+ **/
void
xfce_panel_plugin_block_menu (XfcePanelPlugin *plugin)
{
g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
- /* block the menu */
- plugin->priv->menu_blocked = TRUE;
+ /* increase block counter */
+ plugin->priv->menu_blocked++;
}
+/**
+ * xfce_panel_plugin_unblock_menu:
+ * plugin : an #XfcePanelPlugin.
+ **/
void
xfce_panel_plugin_unblock_menu (XfcePanelPlugin *plugin)
{
g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
+ g_return_if_fail (plugin->priv->menu_blocked > 0);
- /* block the menu */
- plugin->priv->menu_blocked = FALSE;
+ /* decrease block counter */
+ if (G_LIKELY (plugin->priv->menu_blocked > 0))
+ plugin->priv->menu_blocked--;
}
+/**
+ * xfce_panel_plugin_register_menu:
+ * @plugin : an #XfcePanelPlugin.
+ * @menu : a #GtkMenu.
+ **/
void
xfce_panel_plugin_register_menu (XfcePanelPlugin *plugin,
GtkMenu *menu)
{
g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
g_return_if_fail (GTK_IS_MENU (menu));
+
+ /* increase the counter */
+ plugin->priv->registered_menus++;
+
+ /* connect signal to menu to decrease counter */
+ g_signal_connect (G_OBJECT (menu), "deactivate", G_CALLBACK (xfce_panel_plugin_unregister_menu), plugin);
+
+ /* tell panel it needs to lock (provider signal) */
+ if (G_LIKELY (plugin->priv->registered_menus == 1))
+ g_signal_emit_by_name (G_OBJECT (plugin), "lock-panel", TRUE);
}
+/**
+ * xfce_panel_plugin_arrow_type:
+ * @plugin : an #XfcePanelPlugin.
+ *
+ * Return value: the #GtkArrowType to use.
+ *
+ * Since: 4.6.0
+ **/
GtkArrowType
xfce_panel_plugin_arrow_type (XfcePanelPlugin *plugin)
{
@@ -1110,6 +1237,16 @@ xfce_panel_plugin_arrow_type (XfcePanelPlugin *plugin)
+/**
+ * xfce_panel_plugin_position_widget:
+ * @plugin : an #XfcePanelPlugin.
+ * @menu_widget : a #GtkWidget that will be used as popup menu.
+ * @attach_widget : a #GtkWidget relative to which the menu should be positioned.
+ * @x : return location for the x coordinate.
+ * @y : return location for the x coordinate.
+ *
+ * Since: 4.6.0
+ **/
void
xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
GtkWidget *menu_widget,
@@ -1187,6 +1324,16 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
+/**
+ * xfce_panel_plugin_position_menu:
+ * @menu : a #GtkMenu.
+ * @x : return location for the x coordinate.
+ * @x : return location for the y coordinate.
+ * @push_in : keep inside the screen (see #GtkMenuPositionFunc)
+ * @panel_plugin : an #XfcePanelPlugin.
+ *
+ * Since: 4.6.0
+ **/
void
xfce_panel_plugin_position_menu (GtkMenu *menu,
gint *x,
@@ -1217,7 +1364,7 @@ xfce_panel_plugin_position_menu (GtkMenu *menu,
/**
* xfce_panel_plugin_lookup_rc_file:
- * @plugin : a #XfcePanelPlugin.
+ * @plugin : an #XfcePanelPlugin.
*
* Looks for the plugin resource file. This should be used to get the
* plugin read location of the config file. You should only use the
@@ -1252,7 +1399,7 @@ xfce_panel_plugin_lookup_rc_file (XfcePanelPlugin *plugin)
/**
* xfce_panel_plugin_save_location:
- * @plugin : a #XfcePanelPlugin.
+ * @plugin : an #XfcePanelPlugin.
* @create : whether to create missing directories.
*
* Returns the path that can be used to store configuration information.
diff --git a/panel/Makefile.am b/panel/Makefile.am
index 10e18e2..a49110d 100644
--- a/panel/Makefile.am
+++ b/panel/Makefile.am
@@ -16,7 +16,10 @@ bin_PROGRAMS = \
xfce4-panel
xfce4_panel_built_sources = \
- panel-dbus-service-infos.h
+ panel-dbus-service-infos.h \
+ panel-dbus-client-infos.h \
+ panel-marshal.h \
+ panel-marshal.c
xfce4_panel_SOURCES = \
$(xfce4_panel_built_sources) \
@@ -76,17 +79,28 @@ xfce4_panel_DEPENDENCIES = \
$(top_builddir)/libxfce4panel/libxfce4panel.la
if MAINTAINER_MODE
+
+panel-dbus-service-infos.h: $(srcdir)/panel-dbus-service-infos.xml Makefile
+ dbus-binding-tool --prefix=panel_dbus_service --mode=glib-server $< > $@
+
+panel-dbus-client-infos.h: $(srcdir)/panel-dbus-service-infos.xml Makefile
+ dbus-binding-tool --mode=glib-client $< > $@
+
+panel-marshal.h: $(srcdir)/panel-marshal.list Makefile
+ glib-genmarshal --header --prefix=panel_marshal $< > $@
+
+panel-marshal.c: $(srcdir)/panel-marshal.list Makefile
+ glib-genmarshal --body --prefix=panel_marshal $< > $@
+
DISTCLEANFILES = \
$(xfce4_panel_built_sources)
BUILT_SOURCES = \
$(xfce4_panel_built_sources)
-
-panel-dbus-service-infos.h: $(srcdir)/panel-dbus-service-infos.xml Makefile
- dbus-binding-tool --prefix=panel_dbus_service --mode=glib-server $(srcdir)/panel-dbus-service-infos.xml > panel-dbus-service-infos.h
endif
EXTRA_DIST = \
- panel-dbus-service-infos.xml
+ panel-dbus-service-infos.xml \
+ panel-marshal.list
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/panel/main.c b/panel/main.c
index a5af45a..647e616 100644
--- a/panel/main.c
+++ b/panel/main.c
@@ -92,7 +92,7 @@ main (gint argc, gchar **argv)
{
PanelApplication *application;
GError *error = NULL;
- GObject *dbus_service;
+ PanelDBusService *dbus_service;
extern gboolean dbus_quit_with_restart;
gboolean result;
guint i;
@@ -198,7 +198,7 @@ main (gint argc, gchar **argv)
application = panel_application_get ();
/* create dbus service */
- dbus_service = panel_dbus_service_new ();
+ dbus_service = panel_dbus_service_get ();
/* setup signal handlers to properly quit the main loop */
for (i = 0; i < G_N_ELEMENTS (signums); i++)
@@ -223,7 +223,7 @@ main (gint argc, gchar **argv)
if (dbus_quit_with_restart)
{
/* message */
- g_message (_("Restarting..."));
+ g_print ("%s\n\n", _("Restarting the Xfce Panel..."));
/* spawn ourselfs again */
g_spawn_command_line_async (argv[0], NULL);
diff --git a/panel/panel-application.c b/panel/panel-application.c
index bd158c4..15666b8 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -688,16 +688,26 @@ panel_application_save_xml_contents (PanelApplication *application)
GtkWidget *itembar;
GList *children, *lp;
XfcePanelPluginProvider *provider;
+ gchar *date_string;
+ GTimeVal stamp;
panel_return_val_if_fail (PANEL_IS_APPLICATION (application), NULL);
/* create string with some size to avoid reallocations */
contents = g_string_sized_new (3072);
+ /* create time string */
+ g_get_current_time (&stamp);
+ date_string = g_time_val_to_iso8601 (&stamp);
+
/* start xml file */
- contents = g_string_append (contents, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<!DOCTYPE config SYSTEM \"config.dtd\">\n"
- "<panels>\n");
+ g_string_append_printf (contents, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE config SYSTEM \"config.dtd\">\n"
+ "<!-- Generated on %s -->\n"
+ "<panels>\n", date_string);
+
+ /* cleanup */
+ g_free (date_string);
/* store each panel */
for (li = application->windows; li != NULL; li = li->next)
@@ -1061,7 +1071,7 @@ panel_application_add_new_item (PanelApplication *application,
panel_return_if_fail (plugin_name != NULL);
panel_return_if_fail (g_slist_length (application->windows) > 0);
- if (panel_module_factory_has_plugin (application->factory, plugin_name))
+ if (panel_module_factory_has_module (application->factory, plugin_name))
{
/* ask the user what panel to use if there is more then one */
if (g_slist_length (application->windows) > 1)
diff --git a/panel/panel-dbus-client.c b/panel/panel-dbus-client.c
index b3549d5..05101ad 100644
--- a/panel/panel-dbus-client.c
+++ b/panel/panel-dbus-client.c
@@ -21,145 +21,77 @@
#include <config.h>
#endif
-#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include <libxfce4util/libxfce4util.h>
#include <libxfce4panel/libxfce4panel.h>
#include <panel/panel-private.h>
#include <panel/panel-dbus-client.h>
#include <panel/panel-dbus-service.h>
+#include <panel/panel-dbus-client-infos.h>
-static gboolean
-panel_dbus_client_send_message (DBusMessage *message,
- GError **error)
+static DBusGProxy *
+panel_dbus_client_get_proxy (GError **error)
{
- DBusConnection *connection;
- DBusMessage *result;
- DBusError derror;
-
- /* initialize the dbus error */
- dbus_error_init (&derror);
-
- /* try to connect to the session bus */
- connection = dbus_bus_get (DBUS_BUS_SESSION, &derror);
- if (G_UNLIKELY (connection == NULL))
- {
- dbus_set_g_error (error, &derror);
- dbus_error_free (&derror);
- return FALSE;
- }
-
- /* send the message */
- result = dbus_connection_send_with_reply_and_block (connection, message, -1, &derror);
-
- /* check if no reply was received */
- if (result == NULL)
- {
- /* handle error */
- if (dbus_error_has_name (&derror, DBUS_ERROR_NAME_HAS_NO_OWNER))
- g_message (_("No running panel instance found."));
- else
- dbus_set_g_error (error, &derror);
-
- /* cleanup */
- dbus_error_free (&derror);
-
- return FALSE;
- }
-
- /* but maybe we received an error */
- if (G_UNLIKELY (dbus_message_get_type (result) == DBUS_MESSAGE_TYPE_ERROR))
- {
- dbus_set_error_from_message (&derror, result);
- dbus_set_g_error (error, &derror);
- dbus_message_unref (result);
- dbus_error_free (&derror);
-
- return FALSE;
- }
-
- /* it seems everything worked */
- dbus_message_unref (result);
-
- return TRUE;
-}
-
+ DBusGConnection *dbus_connection;
+ DBusGProxy *dbus_proxy;
+ /* try to open the dbus connection */
+ dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, error);
+ if (G_UNLIKELY (dbus_connection == NULL))
+ return NULL;
-static gboolean
-panel_dbus_client_display_dialog (GdkScreen *screen,
- const gchar *methode_name,
- GError **error)
-{
- gchar *display_name;
- DBusMessage *message;
- gboolean result;
-
- /* fallback to default screen if no other is specified */
- if (G_LIKELY (screen == NULL))
- screen = gdk_screen_get_default ();
+ /* get the proxy */
+ dbus_proxy = dbus_g_proxy_new_for_name (dbus_connection, PANEL_DBUS_SERVICE_INTERFACE,
+ PANEL_DBUS_SERVICE_PATH, PANEL_DBUS_SERVICE_INTERFACE);
- /* determine the display name for the screen */
- display_name = gdk_screen_make_display_name (screen);
+ return dbus_proxy;
+}
- /* generate the message */
- message = dbus_message_new_method_call (PANEL_DBUS_SERVICE_INTERFACE, PANEL_DBUS_SERVICE_PATH,
- PANEL_DBUS_SERVICE_INTERFACE, methode_name);
- dbus_message_set_auto_start (message, FALSE);
- dbus_message_append_args (message, DBUS_TYPE_STRING, &display_name, DBUS_TYPE_INVALID);
- /* send the message */
- result = panel_dbus_client_send_message (message, error);
- /* release the message */
- dbus_message_unref (message);
- /* cleanup */
- g_free (display_name);
+gboolean
+panel_dbus_client_check_client_running (GError **error)
+{
+ panel_return_val_if_fail (error == NULL || *error == NULL, TRUE);
- return result;
+ return FALSE;
}
gboolean
-panel_dbus_client_check_client_running (GError **error)
+panel_dbus_client_display_preferences_dialog (GdkScreen *screen,
+ GError **error)
{
- DBusConnection *connection;
- DBusError derror;
- gboolean result;
+ gchar *name;
+ gboolean result;
+ DBusGProxy *dbus_proxy;
- panel_return_val_if_fail (error == NULL || *error == NULL, TRUE);
-
- /* initialize the dbus error */
- dbus_error_init (&derror);
+ panel_return_val_if_fail (screen == NULL || GDK_IS_SCREEN (screen), FALSE);
+ panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- /* try to connect to the session bus */
- connection = dbus_bus_get (DBUS_BUS_SESSION, &derror);
- if (G_UNLIKELY (connection == NULL))
- {
- dbus_set_g_error (error, &derror);
- dbus_error_free (&derror);
+ /* use default screen if none is defined */
+ if (screen == NULL)
+ screen = gdk_screen_get_default ();
- return TRUE;
- }
+ /* get the proxy */
+ dbus_proxy = panel_dbus_client_get_proxy (error);
+ if (G_UNLIKELY (dbus_proxy == NULL))
+ return FALSE;
- /* check if the name is already owned */
- result = dbus_bus_name_has_owner (connection, PANEL_DBUS_SERVICE_INTERFACE, &derror);
+ /* get the display name */
+ name = gdk_screen_make_display_name (screen);
- /* handle the error is one is set */
- if (result == FALSE && dbus_error_is_set (&derror))
- {
- dbus_set_g_error (error, &derror);
- dbus_error_free (&derror);
+ /* call */
+ result = _panel_dbus_client_display_preferences_dialog (dbus_proxy, name, error);
- /* return on true on error */
- result = TRUE;
- }
+ /* cleanup */
+ g_free (name);
+ g_object_unref (G_OBJECT (dbus_proxy));
return result;
}
@@ -167,25 +99,36 @@ panel_dbus_client_check_client_running (GError **error)
gboolean
-panel_dbus_client_display_preferences_dialog (GdkScreen *screen,
- GError **error)
+panel_dbus_client_display_items_dialog (GdkScreen *screen,
+ GError **error)
{
+ gchar *name;
+ gboolean result;
+ DBusGProxy *dbus_proxy;
+
panel_return_val_if_fail (screen == NULL || GDK_IS_SCREEN (screen), FALSE);
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- return panel_dbus_client_display_dialog (screen, "DisplayPreferencesDialog", error);
-}
+ /* use default screen if none is defined */
+ if (screen == NULL)
+ screen = gdk_screen_get_default ();
+ /* get the proxy */
+ dbus_proxy = panel_dbus_client_get_proxy (error);
+ if (G_UNLIKELY (dbus_proxy == NULL))
+ return FALSE;
+ /* get the display name */
+ name = gdk_screen_make_display_name (screen);
-gboolean
-panel_dbus_client_display_items_dialog (GdkScreen *screen,
- GError **error)
-{
- panel_return_val_if_fail (screen == NULL || GDK_IS_SCREEN (screen), FALSE);
- panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ /* call */
+ result = _panel_dbus_client_display_items_dialog (dbus_proxy, name, error);
+
+ /* cleanup */
+ g_free (name);
+ g_object_unref (G_OBJECT (dbus_proxy));
- return panel_dbus_client_display_dialog (screen, "DisplayItemsDialog", error);
+ return result;
}
@@ -193,21 +136,19 @@ panel_dbus_client_display_items_dialog (GdkScreen *screen,
gboolean
panel_dbus_client_save (GError **error)
{
- DBusMessage *message;
- gboolean result;
+ DBusGProxy *dbus_proxy;
+ gboolean result;
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- /* generate the message */
- message = dbus_message_new_method_call (PANEL_DBUS_SERVICE_INTERFACE, PANEL_DBUS_SERVICE_PATH,
- PANEL_DBUS_SERVICE_INTERFACE, "Save");
- dbus_message_set_auto_start (message, FALSE);
-
- /* send the message */
- result = panel_dbus_client_send_message (message, error);
+ /* get the proxy */
+ dbus_proxy = panel_dbus_client_get_proxy (error);
+ if (G_UNLIKELY (dbus_proxy == NULL))
+ return FALSE;
- /* release the message */
- dbus_message_unref (message);
+ /* call */
+ result = _panel_dbus_client_save (dbus_proxy, error);
+ g_object_unref (G_OBJECT (dbus_proxy));
return result;
}
@@ -219,29 +160,19 @@ panel_dbus_client_add_new_item (const gchar *plugin_name,
gchar **arguments,
GError **error)
{
- DBusMessage *message;
- gboolean result;
- guint length;
+ DBusGProxy *dbus_proxy;
+ gboolean result;
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- /* arguments length */
- length = arguments ? g_strv_length (arguments) : 0;
-
- /* generate the message */
- message = dbus_message_new_method_call (PANEL_DBUS_SERVICE_INTERFACE, PANEL_DBUS_SERVICE_PATH,
- PANEL_DBUS_SERVICE_INTERFACE, "AddNewItem");
- dbus_message_set_auto_start (message, FALSE);
- dbus_message_append_args (message,
- DBUS_TYPE_STRING, &plugin_name,
- DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &arguments, length,
- DBUS_TYPE_INVALID);
+ /* get the proxy */
+ dbus_proxy = panel_dbus_client_get_proxy (error);
+ if (G_UNLIKELY (dbus_proxy == NULL))
+ return FALSE;
- /* send the message */
- result = panel_dbus_client_send_message (message, error);
-
- /* release the message */
- dbus_message_unref (message);
+ /* call */
+ result = _panel_dbus_client_add_new_item (dbus_proxy, plugin_name, (const gchar **) arguments, error);
+ g_object_unref (G_OBJECT (dbus_proxy));
return result;
}
@@ -252,22 +183,19 @@ gboolean
panel_dbus_client_terminate (gboolean restart,
GError **error)
{
- DBusMessage *message;
- gboolean result;
+ DBusGProxy *dbus_proxy;
+ gboolean result;
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- /* generate the message */
- message = dbus_message_new_method_call (PANEL_DBUS_SERVICE_INTERFACE, PANEL_DBUS_SERVICE_PATH,
- PANEL_DBUS_SERVICE_INTERFACE, "Terminate");
- dbus_message_set_auto_start (message, FALSE);
- dbus_message_append_args (message, DBUS_TYPE_BOOLEAN, &restart, DBUS_TYPE_INVALID);
-
- /* send the message */
- result = panel_dbus_client_send_message (message, error);
+ /* get the proxy */
+ dbus_proxy = panel_dbus_client_get_proxy (error);
+ if (G_UNLIKELY (dbus_proxy == NULL))
+ return FALSE;
- /* release the message */
- dbus_message_unref (message);
+ /* call */
+ result = _panel_dbus_client_terminate (dbus_proxy, restart, error);
+ g_object_unref (G_OBJECT (dbus_proxy));
return result;
}
diff --git a/panel/panel-dbus-service-infos.xml b/panel/panel-dbus-service-infos.xml
index e0a5dd3..5c08adb 100644
--- a/panel/panel-dbus-service-infos.xml
+++ b/panel/panel-dbus-service-infos.xml
@@ -24,6 +24,7 @@
<interface name="org.xfce.Panel">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="panel_dbus_service" />
+ <annotation name="org.freedesktop.DBus.GLib.ClientCSymbol" value="_panel_dbus_client" />
<!--
DisplayPreferencesDialog (display : STRING) : VOID
@@ -55,12 +56,12 @@
<!--
AddNewItem (name : STRING, args : ARRAY OF STRING) : VOID
- plugin-name : The internal name of the plugin the user wants to add.
+ plugin_name : The internal name of the plugin the user wants to add.
arguments : Optional arguments send with the command line. This
could be files or anything else.
-->
<method name="AddNewItem">
- <arg name="plugin-name" direction="in" type="s" />
+ <arg name="plugin_name" direction="in" type="s" />
<arg name="arguments" direction="in" type="as" />
</method>
@@ -73,6 +74,45 @@
<arg name="restart" direction="in" type="b" />
</method>
+ <!--
+ GetProperty (plugin-name : STRING, property : STRING, value : VARIANT) : VOID
+
+ plugin_name : Plugin id of the plugin requesting the property.
+ property : Name of the property.
+ value : GValue with the property value.
+ -->
+ <method name="GetProperty">
+ <arg name="plugin_id" direction="in" type="s" />
+ <arg name="property" direction="in" type="s" />
+ <arg name="value" direction="out" type="v" />
+ </method>
+
+ <!--
+ SetProperty (plugin-name : STRING, property : STRING, value : VARIANT) : VOID
+
+ plugin_name : Plugin id of the plugin setting the property.
+ property : Name of the property.
+ value : GValue with the property value.
+ -->
+ <method name="SetProperty">
+ <arg name="plugin_id" direction="in" type="s" />
+ <arg name="property" direction="in" type="s" />
+ <arg name="value" direction="in" type="v" />
+ </method>
+
+ <!--
+ PropertyChanged (plugin-name : STRING, property : STRING, value : VARIANT) : VOID
+
+ plugin_name : Plugin id of the plugin this signal was send to.
+ property : Name of the property that has been changed.
+ value : GValue with the property value.
+ -->
+ <signal name="PropertyChanged">
+ <arg name="plugin_id" type="s" />
+ <arg name="property" type="s" />
+ <arg name="value" type="v"/>
+ </signal>
+
</interface>
</node>
diff --git a/panel/panel-dbus-service.c b/panel/panel-dbus-service.c
index ebc0899..2ca764f 100644
--- a/panel/panel-dbus-service.c
+++ b/panel/panel-dbus-service.c
@@ -21,6 +21,10 @@
#include <config.h>
#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
@@ -32,6 +36,8 @@
#include <panel/panel-application.h>
#include <panel/panel-preferences-dialog.h>
#include <panel/panel-item-dialog.h>
+#include <panel/panel-module-factory.h>
+#include <panel/panel-marshal.h>
@@ -41,6 +47,12 @@ static void panel_dbus_service_finalize (GObject *objec
+enum
+{
+ PROPERTY_CHANGED,
+ LAST_SIGNAL
+};
+
struct _PanelDBusServiceClass
{
GObjectClass __parent__;
@@ -59,6 +71,8 @@ struct _PanelDBusService
/* shared boolean with main.c */
gboolean dbus_quit_with_restart = FALSE;
+static guint dbus_service_signals[LAST_SIGNAL];
+
G_DEFINE_TYPE (PanelDBusService, panel_dbus_service, G_TYPE_OBJECT);
@@ -74,7 +88,21 @@ panel_dbus_service_class_init (PanelDBusServiceClass *klass)
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = panel_dbus_service_finalize;
- /* install the D-BUS info for our class */
+ /**
+ * Emited when a plugin property changes
+ **/
+ dbus_service_signals[PROPERTY_CHANGED] =
+ g_signal_new (I_("property-changed"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ panel_marshal_VOID__STRING_STRING_BOXED,
+ G_TYPE_NONE, 3,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_VALUE);
+
+ /* install the d-bus info for our class */
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), &dbus_glib_panel_dbus_service_object_info);
}
@@ -232,13 +260,114 @@ panel_dbus_service_terminate (PanelDBusService *service,
-GObject *
-panel_dbus_service_new (void)
+static gboolean
+panel_dbus_service_get_property (PanelDBusService *service,
+ const gchar *plugin_id,
+ const gchar *property,
+ const GValue *value,
+ GError *error)
{
- return g_object_new (PANEL_TYPE_DBUS_SERVICE, NULL);
+ g_message ("Plugin '%s' requested property '%s'", plugin_id, property);
+
+ return TRUE;
}
+static gboolean
+panel_dbus_service_set_property (PanelDBusService *service,
+ const gchar *plugin_id,
+ const gchar *property,
+ GValue *value,
+ GError *error)
+{
+ PanelModuleFactory *factory;
+ XfcePanelPluginProvider *provider;
+
+ 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);
+
+ if (strcmp (plugin_id, "XfcePanel") == 0)
+ {
+ g_message ("Panel message: %s", property);
+ }
+ else
+ {
+ /* 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 ("Expand", property) == 0)
+ g_signal_emit_by_name (G_OBJECT (provider), "expand-changed", g_value_get_boolean (value));
+ else if (strcmp ("MoveItem", property) == 0)
+ g_signal_emit_by_name (G_OBJECT (provider), "move-item", 0);
+ else if (strcmp ("Remove", property) == 0)
+ gtk_widget_destroy (GTK_WIDGET (provider));
+ }
+
+ /* release the factory */
+ g_object_unref (G_OBJECT (factory));
+ }
+
+ return TRUE;
+}
+
+
+
+PanelDBusService *
+panel_dbus_service_get (void)
+{
+ static PanelDBusService *service = NULL;
+
+ if (G_LIKELY (service))
+ {
+ g_object_ref (G_OBJECT (service));
+ }
+ else
+ {
+ service = g_object_new (PANEL_TYPE_DBUS_SERVICE, NULL);
+ g_object_add_weak_pointer (G_OBJECT (service), (gpointer) &service);
+ }
+
+ return service;
+}
+
+
+
+void
+panel_dbus_service_set_plugin_property (const gchar *plugin_id,
+ const gchar *property,
+ const GValue *value)
+{
+ PanelDBusService *service;
+ GValue dummy_value = { 0, };
+
+ /* create dummy value */
+ if (value == NULL)
+ g_value_init (&dummy_value, G_TYPE_INT);
+
+ /* get the dbus service */
+ service = panel_dbus_service_get ();
+
+ g_message ("Set plugin '%s' property '%s'", plugin_id, property);
+
+ /* emit the signal */
+ g_signal_emit (G_OBJECT (service), dbus_service_signals[PROPERTY_CHANGED],
+ 0, plugin_id, property, value ? value : &dummy_value);
+
+ /* unset dummy value */
+ if (value == NULL)
+ g_value_unset (&dummy_value);
+
+ /* release */
+ g_object_unref (G_OBJECT (service));
+}
+
+
+
/* include the dbus glue generated by dbus-binding-tool */
#include <panel/panel-dbus-service-infos.h>
diff --git a/panel/panel-dbus-service.h b/panel/panel-dbus-service.h
index e09db1b..0e7c95b 100644
--- a/panel/panel-dbus-service.h
+++ b/panel/panel-dbus-service.h
@@ -35,9 +35,13 @@ typedef struct _PanelDBusService PanelDBusService;
#define PANEL_IS_DBUS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_DBUS_SERVICE))
#define PANEL_DBUS_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANEL_TYPE_DBUS_SERVICE, PanelDBusServiceClass))
-GType panel_dbus_service_get_type (void) G_GNUC_CONST;
+GType panel_dbus_service_get_type (void) G_GNUC_CONST;
-GObject *panel_dbus_service_new (void);
+PanelDBusService *panel_dbus_service_get (void);
+
+void panel_dbus_service_set_plugin_property (const gchar *plugin_id,
+ const gchar *property,
+ const GValue *value);
G_END_DECLS
diff --git a/panel/panel-module-factory.c b/panel/panel-module-factory.c
index 479a74f..35e372c 100644
--- a/panel/panel-module-factory.c
+++ b/panel/panel-module-factory.c
@@ -59,8 +59,11 @@ struct _PanelModuleFactory
{
GObject __parent__;
- /* table of loaded modules */
+ /* hash table of loaded modules */
GHashTable *modules;
+
+ /* table table with created panel plugins */
+ GHashTable *plugins;
/* if the factory contains the launcher plugin */
guint has_launcher : 1;
@@ -106,8 +109,9 @@ panel_module_factory_init (PanelModuleFactory *factory)
/* initialize */
factory->has_launcher = FALSE;
- /* create hash table */
+ /* create hash tables */
factory->modules = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+ factory->plugins = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
/* load all the modules */
panel_module_factory_load_modules (factory);
@@ -120,8 +124,9 @@ panel_module_factory_finalize (GObject *object)
{
PanelModuleFactory *factory = PANEL_MODULE_FACTORY (object);
- /* destroy the hash table */
+ /* destroy the hash tables */
g_hash_table_destroy (factory->modules);
+ g_hash_table_destroy (factory->plugins);
(*G_OBJECT_CLASS (panel_module_factory_parent_class)->finalize) (object);
}
@@ -345,7 +350,7 @@ panel_module_factory_get_modules (PanelModuleFactory *factory)
gboolean
-panel_module_factory_has_plugin (PanelModuleFactory *factory,
+panel_module_factory_has_module (PanelModuleFactory *factory,
const gchar *name)
{
panel_return_val_if_fail (PANEL_IS_MODULE_FACTORY (factory), FALSE);
@@ -357,13 +362,26 @@ panel_module_factory_has_plugin (PanelModuleFactory *factory,
XfcePanelPluginProvider *
+panel_module_factory_get_plugin (PanelModuleFactory *factory,
+ const gchar *id)
+{
+ panel_return_val_if_fail (PANEL_IS_MODULE_FACTORY (factory), NULL);
+ panel_return_val_if_fail (id != NULL, NULL);
+
+ return g_hash_table_lookup (factory->plugins, id);
+}
+
+
+
+XfcePanelPluginProvider *
panel_module_factory_create_plugin (PanelModuleFactory *factory,
GdkScreen *screen,
const gchar *name,
const gchar *id,
gchar **arguments)
{
- PanelModule *module;
+ PanelModule *module;
+ XfcePanelPluginProvider *provider;
panel_return_val_if_fail (PANEL_IS_MODULE_FACTORY (factory), NULL);
panel_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
@@ -381,5 +399,11 @@ panel_module_factory_create_plugin (PanelModuleFactory *factory,
}
/* create the new module */
- return panel_module_create_plugin (module, screen, name, id, arguments);
+ provider = panel_module_create_plugin (module, screen, name, id, arguments);
+
+ /* insert plugin in the hash table */
+ if (G_LIKELY (provider))
+ g_hash_table_insert (factory->plugins, g_strdup (id), provider);
+
+ return provider;
}
diff --git a/panel/panel-module-factory.h b/panel/panel-module-factory.h
index 32d93d3..4d02785 100644
--- a/panel/panel-module-factory.h
+++ b/panel/panel-module-factory.h
@@ -49,8 +49,11 @@ void panel_module_factory_emit_unique_changed (PanelModule
GList *panel_module_factory_get_modules (PanelModuleFactory *factory);
-gboolean panel_module_factory_has_plugin (PanelModuleFactory *factory,
+gboolean panel_module_factory_has_module (PanelModuleFactory *factory,
const gchar *name);
+
+XfcePanelPluginProvider *panel_module_factory_get_plugin (PanelModuleFactory *factory,
+ const gchar *id);
XfcePanelPluginProvider *panel_module_factory_create_plugin (PanelModuleFactory *factory,
GdkScreen *screen,
diff --git a/panel/panel-module.c b/panel/panel-module.c
index ee76d14..6722a2a 100644
--- a/panel/panel-module.c
+++ b/panel/panel-module.c
@@ -153,8 +153,7 @@ panel_module_finalize (GObject *object)
static gboolean
panel_module_load (GTypeModule *type_module)
{
- PanelModule *module = PANEL_MODULE (type_module);
- PluginRegisterTypesFunc register_func;
+ PanelModule *module = PANEL_MODULE (type_module);
panel_return_val_if_fail (PANEL_IS_MODULE (module), FALSE);
panel_return_val_if_fail (G_IS_TYPE_MODULE (module), FALSE);
@@ -179,10 +178,6 @@ panel_module_load (GTypeModule *type_module)
return FALSE;
}
- /* run the type register function if available */
- if (g_module_symbol (module->library, "xfce_panel_plugin_register_types", (gpointer) ®ister_func))
- (*register_func) (type_module);
-
return TRUE;
}
@@ -303,7 +298,7 @@ panel_module_new_from_desktop_file (const gchar *filename,
else if (xfce_rc_has_entry (rc, "X-XFCE-Exec"))
{
/* old external plugin, not usable anymore */
- //g_message ("The plugin from desktop file \"%s\" should be ported to an internal plugin", filename);
+ g_message ("The plugin from desktop file \"%s\" should be ported to an internal plugin", filename);
}
else
{
diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c
index 1162e99..a571917 100644
--- a/panel/panel-plugin-external.c
+++ b/panel/panel-plugin-external.c
@@ -34,6 +34,7 @@
#include <panel/panel-plugin-external.h>
#include <panel/panel-window.h>
#include <panel/panel-glue.h>
+#include <panel/panel-dbus-service.h>
@@ -43,14 +44,7 @@ static void panel_plugin_external_provider_init (XfcePanelPluginPr
static void panel_plugin_external_finalize (GObject *object);
static void panel_plugin_external_realize (GtkWidget *widget);
static void panel_plugin_external_unrealize (GtkWidget *widget);
-static gboolean panel_plugin_external_client_event (GtkWidget *widget,
- GdkEventClient *event);
static gboolean panel_plugin_external_plug_removed (GtkSocket *socket);
-static void panel_plugin_external_send_message (PanelPluginExternal *external,
- XfcePanelPluginMessage message,
- glong value);
-static void panel_plugin_external_free_queue (PanelPluginExternal *external);
-static void panel_plugin_external_flush_queue (PanelPluginExternal *external);
static const gchar *panel_plugin_external_get_name (XfcePanelPluginProvider *provider);
static const gchar *panel_plugin_external_get_id (XfcePanelPluginProvider *provider);
static void panel_plugin_external_set_size (XfcePanelPluginProvider *provider,
@@ -81,23 +75,10 @@ struct _PanelPluginExternal
/* the module */
PanelModule *module;
- /* the plug window id */
- GdkNativeWindow plug_window_id;
-
- /* message queue */
- GSList *queue;
-
/* process pid */
GPid pid;
};
-typedef struct
-{
- XfcePanelPluginMessage message;
- glong value;
-}
-QueueData;
-
static GdkAtom message_atom = GDK_NONE;
@@ -122,7 +103,6 @@ panel_plugin_external_class_init (PanelPluginExternalClass *klass)
gtkwidget_class = GTK_WIDGET_CLASS (klass);
gtkwidget_class->realize = panel_plugin_external_realize;
gtkwidget_class->unrealize = panel_plugin_external_unrealize;
- gtkwidget_class->client_event = panel_plugin_external_client_event;
gtksocket_class = GTK_SOCKET_CLASS (klass);
gtksocket_class->plug_removed = panel_plugin_external_plug_removed;
@@ -139,8 +119,6 @@ panel_plugin_external_init (PanelPluginExternal *external)
/* initialize */
external->id = NULL;
external->module = NULL;
- external->plug_window_id = 0;
- external->queue = NULL;
external->arguments = NULL;
external->pid = 0;
@@ -172,9 +150,6 @@ panel_plugin_external_finalize (GObject *object)
g_free (external->id);
g_strfreev (external->arguments);
- /* free the queue if needed */
- panel_plugin_external_free_queue (external);
-
/* release the module */
g_object_unref (G_OBJECT (external->module));
@@ -192,6 +167,7 @@ panel_plugin_external_realize (GtkWidget *widget)
gboolean succeed;
gchar *socket_id;
gint i, argc = 12;
+ GdkScreen *screen;
/* realize the socket first */
(*GTK_WIDGET_CLASS (panel_plugin_external_parent_class)->realize) (widget);
@@ -226,9 +202,12 @@ panel_plugin_external_realize (GtkWidget *widget)
/* close the argv */
argv[argc - 1] = NULL;
+
+ /* get the widget screen */
+ screen = gtk_widget_get_screen (widget);
/* spawn the proccess */
- succeed = gdk_spawn_on_screen (gdk_screen_get_default (), NULL, argv, NULL, 0, NULL, NULL, &(external->pid), &error);
+ succeed = gdk_spawn_on_screen (screen, NULL, argv, NULL, 0, NULL, NULL, &external->pid, &error);
/* cleanup */
g_free (socket_id);
@@ -250,13 +229,10 @@ panel_plugin_external_realize (GtkWidget *widget)
static void
panel_plugin_external_unrealize (GtkWidget *widget)
{
- PanelPluginExternal *external = PANEL_PLUGIN_EXTERNAL (widget);
+ //PanelPluginExternal *external = PANEL_PLUGIN_EXTERNAL (widget);
/* send message to quit the wrapper */
- panel_plugin_external_send_message (PANEL_PLUGIN_EXTERNAL (external), MESSAGE_QUIT, 0);
-
- /* don't send or queue messages */
- external->plug_window_id = -1;
+ /* TODO quit */
return (*GTK_WIDGET_CLASS (panel_plugin_external_parent_class)->unrealize) (widget);
}
@@ -264,77 +240,6 @@ panel_plugin_external_unrealize (GtkWidget *widget)
static gboolean
-panel_plugin_external_client_event (GtkWidget *widget,
- GdkEventClient *event)
-{
- PanelPluginExternal *external = PANEL_PLUGIN_EXTERNAL (widget);
- XfcePanelPluginMessage message;
- glong value;
-
- panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget), FALSE);
-
- /* check if this even is for us */
- if (G_LIKELY (event->message_type == message_atom))
- {
- /* get the event message and value */
- message = event->data.l[0];
- value = event->data.l[1];
-
- /* handle the message */
- switch (message)
- {
- case MESSAGE_EXPAND_CHANGED:
- /* emit the expand changed signal */
- g_signal_emit_by_name (G_OBJECT (external), "expand-changed", !!(value == 1));
- break;
-
- case MESSAGE_MOVE_ITEM:
- /* start a plugin dnd */
- g_signal_emit_by_name (G_OBJECT (external), "move-item", 0);
- break;
-
- case MESSAGE_ADD_NEW_ITEMS:
- /* show the add new items dialog */
- g_signal_emit_by_name (G_OBJECT (external), "add-new-items", 0);
- break;
-
- case MESSAGE_PANEL_PREFERENCES:
- /* show the panel preferences dialog */
- g_signal_emit_by_name (G_OBJECT (external), "panel-preferences", 0, gtk_widget_get_toplevel (widget));
- break;
-
- case MESSAGE_REMOVE:
- /* plugin properly removed, destroy the socket */
- gtk_widget_destroy (widget);
- break;
-
- case MESSAGE_SET_PLUG_ID:
- /* set the plug window id */
- external->plug_window_id = value;
-
- /* flush the message queue */
- panel_plugin_external_flush_queue (external);
- break;
-
- default:
- g_message ("The panel received an unkown message: %d", message);
- break;
- }
-
- /* we handled the event */
- return TRUE;
- }
-
- /* propagate event */
- if (GTK_WIDGET_CLASS (panel_plugin_external_parent_class)->client_event)
- return (*GTK_WIDGET_CLASS (panel_plugin_external_parent_class)->client_event) (widget, event);
- else
- return FALSE;
-}
-
-
-
-static gboolean
panel_plugin_external_plug_removed (GtkSocket *socket)
{
PanelPluginExternal *external = PANEL_PLUGIN_EXTERNAL (socket);
@@ -357,9 +262,6 @@ panel_plugin_external_plug_removed (GtkSocket *socket)
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
- /* don't queue messages */
- external->plug_window_id = -1;
-
/* reset the pid */
external->pid = 0;
@@ -382,9 +284,6 @@ panel_plugin_external_plug_removed (GtkSocket *socket)
/* debug check */
panel_return_val_if_fail (PANEL_IS_WINDOW (window), TRUE);
- /* queue messages again */
- external->plug_window_id = 0;
-
/* send panel information to the plugin */
panel_glue_set_provider_info (XFCE_PANEL_PLUGIN_PROVIDER (external));
@@ -423,102 +322,6 @@ panel_plugin_external_plug_removed (GtkSocket *socket)
-static void
-panel_plugin_external_send_message (PanelPluginExternal *external,
- XfcePanelPluginMessage message,
- glong value)
-{
- GdkEventClient event;
- QueueData *data;
-
- panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
-
- if (G_LIKELY (external->plug_window_id > 0))
- {
- /* setup the event */
- event.type = GDK_CLIENT_EVENT;
- event.window = GTK_WIDGET (external)->window;
- event.send_event = TRUE;
- event.message_type = message_atom;
- event.data_format = 32;
- event.data.l[0] = message;
- event.data.l[1] = value;
- event.data.l[2] = 0;
-
- /* don't crash on x errors */
- gdk_error_trap_push ();
-
- /* send the event to the wrapper */
- gdk_event_send_client_message_for_display (gdk_display_get_default (), (GdkEvent *) &event, external->plug_window_id);
-
- /* flush the x output buffer */
- gdk_flush ();
-
- /* pop the push */
- gdk_error_trap_pop ();
- }
- else if (external->plug_window_id == 0)
- {
- /* setup queue data */
- data = g_slice_new0 (QueueData);
- data->message = message;
- data->value = value;
-
- /* add the message to the list */
- external->queue = g_slist_append (external->queue, data);
- }
-}
-
-
-
-static void
-panel_plugin_external_free_queue (PanelPluginExternal *external)
-{
- GSList *li;
-
- panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
-
- if (external->queue != NULL)
- {
- /* cleanup all the queue data */
- for (li = external->queue; li != NULL; li = li->next)
- g_slice_free (QueueData, li->data);
-
- /* free the list */
- g_slist_free (external->queue);
-
- /* set to null */
- external->queue = NULL;
- }
-}
-
-
-
-static void
-panel_plugin_external_flush_queue (PanelPluginExternal *external)
-{
- GSList *li;
- QueueData *data;
-
- panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
- panel_return_if_fail (external->plug_window_id != 0);
-
- if (G_LIKELY (external->queue != NULL))
- {
- /* send all messages in the queue */
- for (li = external->queue; li != NULL; li = li->next)
- {
- data = li->data;
- panel_plugin_external_send_message (external, data->message, data->value);
- }
-
- /* free the queue */
- panel_plugin_external_free_queue (external);
- }
-}
-
-
-
static const gchar *
panel_plugin_external_get_name (XfcePanelPluginProvider *provider)
{
@@ -545,11 +348,20 @@ static void
panel_plugin_external_set_size (XfcePanelPluginProvider *provider,
gint size)
{
+ GValue value = { 0, };
+
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (provider));
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
-
- /* send the signal to the wrapper */
- panel_plugin_external_send_message (PANEL_PLUGIN_EXTERNAL (provider), MESSAGE_SET_SIZE, size);
+
+ /* set the size */
+ g_value_init (&value, G_TYPE_INT);
+ g_value_set_int (&value, size);
+
+ /* send the value */
+ panel_dbus_service_set_plugin_property (PANEL_PLUGIN_EXTERNAL (provider)->id, "Size", &value);
+
+ /* unset */
+ g_value_unset (&value);
}
@@ -558,11 +370,20 @@ static void
panel_plugin_external_set_orientation (XfcePanelPluginProvider *provider,
GtkOrientation orientation)
{
+ GValue value = { 0, };
+
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (provider));
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
- /* send the signal to the wrapper */
- panel_plugin_external_send_message (PANEL_PLUGIN_EXTERNAL (provider), MESSAGE_SET_ORIENTATION, orientation);
+ /* set the orientation */
+ g_value_init (&value, G_TYPE_UINT);
+ g_value_set_uint (&value, orientation);
+
+ /* send the value */
+ panel_dbus_service_set_plugin_property (PANEL_PLUGIN_EXTERNAL (provider)->id, "Orientation", &value);
+
+ /* unset */
+ g_value_unset (&value);
}
@@ -571,11 +392,20 @@ static void
panel_plugin_external_set_screen_position (XfcePanelPluginProvider *provider,
XfceScreenPosition screen_position)
{
+ GValue value = { 0, };
+
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (provider));
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
- /* send the signal to the wrapper */
- panel_plugin_external_send_message (PANEL_PLUGIN_EXTERNAL (provider), MESSAGE_SET_SCREEN_POSITION, screen_position);
+ /* set the orientation */
+ g_value_init (&value, G_TYPE_UINT);
+ g_value_set_uint (&value, screen_position);
+
+ /* send the value */
+ panel_dbus_service_set_plugin_property (PANEL_PLUGIN_EXTERNAL (provider)->id, "ScreenPosition", &value);
+
+ /* unset */
+ g_value_unset (&value);
}
@@ -586,8 +416,8 @@ panel_plugin_external_save (XfcePanelPluginProvider *provider)
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (provider));
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
- /* send the signal to the wrapper */
- panel_plugin_external_send_message (PANEL_PLUGIN_EXTERNAL (provider), MESSAGE_SAVE, 0);
+ /* send signal to wrapper */
+ panel_dbus_service_set_plugin_property (PANEL_PLUGIN_EXTERNAL (provider)->id, "Save", NULL);
}
@@ -595,10 +425,19 @@ panel_plugin_external_save (XfcePanelPluginProvider *provider)
static void
panel_plugin_external_set_sensitive (PanelPluginExternal *external)
{
+ GValue value = { 0, };
+
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
+
+ /* set the boolean */
+ g_value_init (&value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&value, GTK_WIDGET_IS_SENSITIVE (external));
/* send message */
- panel_plugin_external_send_message (external, MESSAGE_SET_SENSITIVE, GTK_WIDGET_IS_SENSITIVE (external) ? 1 : 0);
+ panel_dbus_service_set_plugin_property (external->id, "Sensitive", &value);
+
+ /* unset */
+ g_value_unset (&value);
}
@@ -632,11 +471,19 @@ void
panel_plugin_external_set_background_alpha (PanelPluginExternal *external,
gint percentage)
{
+ GValue value = { 0, };
+
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (external));
- /* send the signal to the wrapper */
- panel_plugin_external_send_message (external, MESSAGE_SET_BACKGROUND_ALPHA, percentage);
+ /* set the boolean */
+ g_value_init (&value, G_TYPE_INT);
+ g_value_set_int (&value, percentage);
+
+ /* send message */
+ panel_dbus_service_set_plugin_property (external->id, "BackgroundAlpha", &value);
+
+ /* unset */
+ g_value_unset (&value);
}
@@ -645,9 +492,17 @@ void
panel_plugin_external_set_active_panel (PanelPluginExternal *external,
gboolean active)
{
+ GValue value = { 0, };
+
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (external));
- /* send the signal to the wrapper */
- panel_plugin_external_send_message (external, MESSAGE_SET_ACTIVE_PANEL, active ? 1 : 0);
+ /* set the boolean */
+ g_value_init (&value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&value, active);
+
+ /* send message */
+ panel_dbus_service_set_plugin_property (external->id, "ActivePanel", &value);
+
+ /* unset */
+ g_value_unset (&value);
}
diff --git a/panel/panel-plugin-external.h b/panel/panel-plugin-external.h
index f6623ab..d9802a1 100644
--- a/panel/panel-plugin-external.h
+++ b/panel/panel-plugin-external.h
@@ -37,13 +37,18 @@ typedef struct _PanelPluginExternal PanelPluginExternal;
#define PANEL_IS_PLUGIN_EXTERNAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_PLUGIN_EXTERNAL))
#define PANEL_PLUGIN_EXTERNAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANEL_TYPE_PLUGIN_EXTERNAL, PanelPluginExternalClass))
-GType panel_plugin_external_get_type (void) G_GNUC_CONST;
+GType panel_plugin_external_get_type (void) G_GNUC_CONST;
-XfcePanelPluginProvider *panel_plugin_external_new (PanelModule *module, const gchar *name, const gchar *id, gchar **arguments);
+XfcePanelPluginProvider *panel_plugin_external_new (PanelModule *module,
+ const gchar *name,
+ const gchar *id,
+ gchar **arguments);
-void panel_plugin_external_set_background_alpha (PanelPluginExternal *external, gint percentage);
+void panel_plugin_external_set_background_alpha (PanelPluginExternal *external,
+ gint percentage);
-void panel_plugin_external_set_active_panel (PanelPluginExternal *external, gboolean active);
+void panel_plugin_external_set_active_panel (PanelPluginExternal *external,
+ gboolean active);
G_END_DECLS
diff --git a/panel/panel-window.c b/panel/panel-window.c
index e031ae9..d19cce7 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -1303,8 +1303,6 @@ panel_window_working_area (PanelWindow *window,
/* get the root monitor geometry */
gdk_screen_get_monitor_geometry (screen, monitor_num, dest);
- g_message ("%d screens and %d monitors found", gdk_display_get_n_screens (gdk_display_get_default ()), gdk_screen_get_n_monitors (screen));
-
if (window->span_monitors)
{
/* get the number of monitors */
diff --git a/plugins/clock/clock-analog.c b/plugins/clock/clock-analog.c
index fb9547c..984f7bd 100644
--- a/plugins/clock/clock-analog.c
+++ b/plugins/clock/clock-analog.c
@@ -47,6 +47,7 @@
/* prototypes */
static void xfce_clock_analog_class_init (XfceClockAnalogClass *klass);
static void xfce_clock_analog_init (XfceClockAnalog *clock);
+static void xfce_clock_analog_finalize (GObject *object);
static void xfce_clock_analog_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -56,7 +57,7 @@ static void xfce_clock_analog_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void xfce_clock_analog_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+ GtkRequisition *requisition);
static gboolean xfce_clock_analog_expose_event (GtkWidget *widget,
GdkEventExpose *event);
static void xfce_clock_analog_draw_ticks (cairo_t *cr,
@@ -94,7 +95,28 @@ struct _XfceClockAnalog
-XFCE_PANEL_DEFINE_TYPE (XfceClockAnalog, xfce_clock_analog, GTK_TYPE_IMAGE);
+static GObjectClass *xfce_clock_analog_parent_class;
+
+
+
+GType
+xfce_clock_analog_get_type (void)
+{
+ static GType type = G_TYPE_INVALID;
+
+ if (G_UNLIKELY (type == G_TYPE_INVALID))
+ {
+ type = g_type_register_static_simple (GTK_TYPE_IMAGE,
+ I_("XfceClockAnalog"),
+ sizeof (XfceClockAnalogClass),
+ (GClassInitFunc) xfce_clock_analog_class_init,
+ sizeof (XfceClockAnalog),
+ (GInstanceInitFunc) xfce_clock_analog_init,
+ 0);
+ }
+
+ return type;
+}
@@ -104,7 +126,10 @@ xfce_clock_analog_class_init (XfceClockAnalogClass *klass)
GObjectClass *gobject_class;
GtkWidgetClass *gtkwidget_class;
+ xfce_clock_analog_parent_class = g_type_class_peek_parent (klass);
+
gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = xfce_clock_analog_finalize;
gobject_class->set_property = xfce_clock_analog_set_property;
gobject_class->get_property = xfce_clock_analog_get_property;
@@ -117,11 +142,8 @@ xfce_clock_analog_class_init (XfceClockAnalogClass *klass)
**/
g_object_class_install_property (gobject_class,
PROP_SHOW_SECONDS,
- g_param_spec_boolean ("show-seconds",
- "show-seconds",
- "show-seconds",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_param_spec_boolean ("show-seconds", "show-seconds", "show-seconds",
+ FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_BLURB));
}
@@ -136,6 +158,14 @@ xfce_clock_analog_init (XfceClockAnalog *clock)
static void
+xfce_clock_analog_finalize (GObject *object)
+{
+ (*G_OBJECT_CLASS (xfce_clock_analog_parent_class)->finalize) (object);
+}
+
+
+
+static void
xfce_clock_analog_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -181,7 +211,7 @@ xfce_clock_analog_get_property (GObject *object,
static void
xfce_clock_analog_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+ GtkRequisition *requisition)
{
gint width, height;
@@ -204,7 +234,7 @@ xfce_clock_analog_expose_event (GtkWidget *widget,
cairo_t *cr;
struct tm tm;
- panel_return_val_if_fail (XFCE_IS_CLOCK_ANALOG (clock), FALSE);
+ g_return_val_if_fail (XFCE_CLOCK_IS_ANALOG (clock), FALSE);
/* get center of the widget and the radius */
xc = (widget->allocation.width / 2.0);
@@ -329,7 +359,7 @@ xfce_clock_analog_draw_pointer (cairo_t *cr,
GtkWidget *
xfce_clock_analog_new (void)
{
- return g_object_new (XFCE_TYPE_CLOCK_ANALOG, NULL);
+ return g_object_new (XFCE_CLOCK_TYPE_ANALOG, NULL);
}
diff --git a/plugins/clock/clock-analog.h b/plugins/clock/clock-analog.h
index 1e71f00..2bca95c 100644
--- a/plugins/clock/clock-analog.h
+++ b/plugins/clock/clock-analog.h
@@ -25,20 +25,18 @@ G_BEGIN_DECLS
typedef struct _XfceClockAnalogClass XfceClockAnalogClass;
typedef struct _XfceClockAnalog XfceClockAnalog;
-#define XFCE_TYPE_CLOCK_ANALOG (xfce_clock_analog_get_type ())
-#define XFCE_CLOCK_ANALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_CLOCK_ANALOG, XfceClockAnalog))
-#define XFCE_CLOCK_ANALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_CLOCK_ANALOG, XfceClockAnalogClass))
-#define XFCE_IS_CLOCK_ANALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_CLOCK_ANALOG))
-#define XFCE_IS_CLOCK_ANALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_CLOCK_ANALOG))
-#define XFCE_CLOCK_ANALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_CLOCK_ANALOG, XfceClockAnalogClass))
+#define XFCE_CLOCK_TYPE_ANALOG (xfce_clock_analog_get_type ())
+#define XFCE_CLOCK_ANALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_CLOCK_TYPE_ANALOG, XfceClockAnalog))
+#define XFCE_CLOCK_ANALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_CLOCK_TYPE_ANALOG, XfceClockAnalogClass))
+#define XFCE_CLOCK_IS_ANALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_CLOCK_TYPE_ANALOG))
+#define XFCE_CLOCK_IS_ANALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_CLOCK_TYPE_ANALOG))
+#define XFCE_CLOCK_ANALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_CLOCK_TYPE_ANALOG, XfceClockAnalogClass))
-GType xfce_clock_analog_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
+GType xfce_clock_analog_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
-void xfce_clock_analog_register_type (XfcePanelModule *panel_module) G_GNUC_INTERNAL;
+GtkWidget *xfce_clock_analog_new (void) G_GNUC_MALLOC G_GNUC_INTERNAL;
-GtkWidget *xfce_clock_analog_new (void) G_GNUC_MALLOC G_GNUC_INTERNAL;
-
-gboolean xfce_clock_analog_update (gpointer user_data) G_GNUC_INTERNAL;
+gboolean xfce_clock_analog_update (gpointer user_data) G_GNUC_INTERNAL;
G_END_DECLS
diff --git a/plugins/clock/clock-binary.c b/plugins/clock/clock-binary.c
index b2347e2..fd92abf 100644
--- a/plugins/clock/clock-binary.c
+++ b/plugins/clock/clock-binary.c
@@ -43,6 +43,7 @@
/* class functions */
static void xfce_clock_binary_class_init (XfceClockBinaryClass *klass);
static void xfce_clock_binary_init (XfceClockBinary *clock);
+static void xfce_clock_binary_finalize (GObject *object);
static void xfce_clock_binary_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -52,7 +53,7 @@ static void xfce_clock_binary_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void xfce_clock_binary_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+ GtkRequisition *requisition);
static gboolean xfce_clock_binary_expose_event (GtkWidget *widget,
GdkEventExpose *event);
@@ -82,7 +83,28 @@ struct _XfceClockBinary
-XFCE_PANEL_DEFINE_TYPE (XfceClockBinary, xfce_clock_binary, GTK_TYPE_IMAGE);
+static GObjectClass *xfce_clock_binary_parent_class;
+
+
+
+GType
+xfce_clock_binary_get_type (void)
+{
+ static GType type = G_TYPE_INVALID;
+
+ if (G_UNLIKELY (type == G_TYPE_INVALID))
+ {
+ type = g_type_register_static_simple (GTK_TYPE_IMAGE,
+ I_("XfceClockBinary"),
+ sizeof (XfceClockBinaryClass),
+ (GClassInitFunc) xfce_clock_binary_class_init,
+ sizeof (XfceClockBinary),
+ (GInstanceInitFunc) xfce_clock_binary_init,
+ 0);
+ }
+
+ return type;
+}
@@ -92,7 +114,10 @@ xfce_clock_binary_class_init (XfceClockBinaryClass *klass)
GObjectClass *gobject_class;
GtkWidgetClass *gtkwidget_class;
+ xfce_clock_binary_parent_class = g_type_class_peek_parent (klass);
+
gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = xfce_clock_binary_finalize;
gobject_class->set_property = xfce_clock_binary_set_property;
gobject_class->get_property = xfce_clock_binary_get_property;
@@ -105,22 +130,16 @@ xfce_clock_binary_class_init (XfceClockBinaryClass *klass)
**/
g_object_class_install_property (gobject_class,
PROP_SHOW_SECONDS,
- g_param_spec_boolean ("show-seconds",
- "show-seconds",
- "show-seconds",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_param_spec_boolean ("show-seconds", "show-seconds", "show-seconds",
+ FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_BLURB));
/**
* Whether this is a true binary clock
**/
g_object_class_install_property (gobject_class,
PROP_TRUE_BINARY,
- g_param_spec_boolean ("true-binary",
- "true-binary",
- "true-binary",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_param_spec_boolean ("true-binary", "true-binary", "true-binary",
+ FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_BLURB));
}
@@ -136,6 +155,14 @@ xfce_clock_binary_init (XfceClockBinary *clock)
static void
+xfce_clock_binary_finalize (GObject *object)
+{
+ (*G_OBJECT_CLASS (xfce_clock_binary_parent_class)->finalize) (object);
+}
+
+
+
+static void
xfce_clock_binary_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -189,20 +216,24 @@ xfce_clock_binary_get_property (GObject *object,
static void
xfce_clock_binary_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+ GtkRequisition *requisition)
{
- XfceClockBinary *clock = XFCE_CLOCK_BINARY (widget);
gint width, height;
gdouble ratio;
+ XfceClockBinary *clock = XFCE_CLOCK_BINARY (widget);
/* get the current widget size */
gtk_widget_get_size_request (widget, &width, &height);
/* ratio of the clock */
if (clock->true_binary)
+ {
ratio = clock->show_seconds ? 2.0 : 3.0;
+ }
else
+ {
ratio = clock->show_seconds ? 1.5 : 1.0;
+ }
/* set requisition based on the plugin orientation */
if (width == -1)
@@ -229,13 +260,13 @@ xfce_clock_binary_expose_event (GtkWidget *widget,
gdouble radius;
gdouble x, y;
gint i, j;
- gint decimal_tb[] = { 32, 16, 8, 4, 2, 1 };
- gint decimal_bcd[] = { 80, 40, 20, 10, 8, 4, 2, 1 };
+ gint decimal_tb[] = {32, 16, 8, 4, 2, 1};
+ gint decimal_bcd[] = {80, 40, 20, 10, 8, 4, 2, 1};
cairo_t *cr;
GdkColor active, inactive;
struct tm tm;
- panel_return_val_if_fail (XFCE_IS_CLOCK_BINARY (clock), FALSE);
+ g_return_val_if_fail (XFCE_CLOCK_IS_BINARY (clock), FALSE);
/* number of columns and cells */
columns = clock->show_seconds ? 3.0 : 2.0;
@@ -346,7 +377,7 @@ xfce_clock_binary_expose_event (GtkWidget *widget,
GtkWidget *
xfce_clock_binary_new (void)
{
- return g_object_new (XFCE_TYPE_CLOCK_BINARY, NULL);
+ return g_object_new (XFCE_CLOCK_TYPE_BINARY, NULL);
}
diff --git a/plugins/clock/clock-binary.h b/plugins/clock/clock-binary.h
index ec8a501..92f97bf 100644
--- a/plugins/clock/clock-binary.h
+++ b/plugins/clock/clock-binary.h
@@ -25,20 +25,18 @@ G_BEGIN_DECLS
typedef struct _XfceClockBinaryClass XfceClockBinaryClass;
typedef struct _XfceClockBinary XfceClockBinary;
-#define XFCE_TYPE_CLOCK_BINARY (xfce_clock_binary_get_type ())
-#define XFCE_CLOCK_BINARY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_CLOCK_BINARY, XfceClockBinary))
-#define XFCE_CLOCK_BINARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_CLOCK_BINARY, XfceClockBinaryClass))
-#define XFCE_IS_CLOCK_BINARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_CLOCK_BINARY))
-#define XFCE_IS_CLOCK_BINARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_CLOCK_BINARY))
-#define XFCE_CLOCK_BINARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_CLOCK_BINARY, XfceClockBinaryClass))
+#define XFCE_CLOCK_TYPE_BINARY (xfce_clock_binary_get_type ())
+#define XFCE_CLOCK_BINARY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_CLOCK_TYPE_BINARY, XfceClockBinary))
+#define XFCE_CLOCK_BINARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_CLOCK_TYPE_BINARY, XfceClockBinaryClass))
+#define XFCE_CLOCK_IS_BINARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_CLOCK_TYPE_BINARY))
+#define XFCE_CLOCK_IS_BINARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_CLOCK_TYPE_BINARY))
+#define XFCE_CLOCK_BINARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_CLOCK_TYPE_BINARY, XfceClockBinaryClass))
-GType xfce_clock_binary_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
+GType xfce_clock_binary_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
-void xfce_clock_binary_register_type (XfcePanelModule *panel_module) G_GNUC_INTERNAL;
+GtkWidget *xfce_clock_binary_new (void) G_GNUC_MALLOC G_GNUC_INTERNAL;
-GtkWidget *xfce_clock_binary_new (void) G_GNUC_MALLOC G_GNUC_INTERNAL;
-
-gboolean xfce_clock_binary_update (gpointer user_data) G_GNUC_INTERNAL;
+gboolean xfce_clock_binary_update (gpointer user_data) G_GNUC_INTERNAL;
G_END_DECLS
diff --git a/plugins/clock/clock-dialog.c b/plugins/clock/clock-dialog.c
index fece971..9c7c62b 100644
--- a/plugins/clock/clock-dialog.c
+++ b/plugins/clock/clock-dialog.c
@@ -53,25 +53,26 @@ static const gchar *digital_formats[] = {
/** prototypes **/
-void xfce_clock_dialog_options (XfceClock *clock);
+void xfce_clock_dialog_options (ClockPlugin *clock);
static void
-xfce_clock_dialog_reload_settings (XfceClock *clock)
+xfce_clock_dialog_reload_settings (ClockPlugin *clock)
{
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
if (G_LIKELY (clock->widget))
{
/* save the settings */
- xfce_clock_widget_update_properties (clock);
+ xfce_clock_widget_update_settings (clock);
/* make sure the plugin sets it's size again */
gtk_widget_queue_resize (clock->widget);
+ /* run a direct update */
+ (clock->update) (clock->widget);
+
/* reschedule the timeout */
- xfce_clock_widget_timer (clock);
+ xfce_clock_widget_sync (clock);
}
}
@@ -79,10 +80,8 @@ xfce_clock_dialog_reload_settings (XfceClock *clock)
static void
xfce_clock_dialog_mode_changed (GtkComboBox *combo,
- XfceClock *clock)
+ ClockPlugin *clock)
{
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* set the new mode */
clock->mode = gtk_combo_box_get_active (combo);
@@ -90,13 +89,13 @@ xfce_clock_dialog_mode_changed (GtkComboBox *combo,
if (G_LIKELY (clock->widget))
{
/* set the new clock mode */
- xfce_clock_widget_update_mode (clock);
+ xfce_clock_widget_set_mode (clock);
/* update the settings */
xfce_clock_dialog_reload_settings (clock);
/* update the plugin size */
- g_signal_emit_by_name (G_OBJECT (clock), "size-changed", xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (clock)));
+ xfce_clock_plugin_set_size (clock, xfce_panel_plugin_get_size (clock->plugin));
}
/* update the dialog */
@@ -107,10 +106,8 @@ xfce_clock_dialog_mode_changed (GtkComboBox *combo,
static void
xfce_clock_dialog_show_frame_toggled (GtkToggleButton *button,
- XfceClock *clock)
+ ClockPlugin *clock)
{
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* set frame mode */
clock->show_frame = gtk_toggle_button_get_active (button);
@@ -122,18 +119,16 @@ xfce_clock_dialog_show_frame_toggled (GtkToggleButton *button,
static void
xfce_clock_dialog_tooltip_format_changed (GtkComboBox *combo,
- XfceClock *clock)
+ ClockPlugin *clock)
{
gint index;
GtkWidget *entry;
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* stop running timeout */
- if (clock->tooltip_timer_id)
+ if (clock->tooltip_timeout_id)
{
- g_source_remove (clock->tooltip_timer_id);
- clock->tooltip_timer_id = 0;
+ g_source_remove (clock->tooltip_timeout_id);
+ clock->tooltip_timeout_id = 0;
}
/* get index of selected item */
@@ -155,7 +150,7 @@ xfce_clock_dialog_tooltip_format_changed (GtkComboBox *combo,
clock->tooltip_format = g_strdup (tooltip_formats[index]);
/* restart the tooltip timeout */
- xfce_clock_tooltip_timer (clock);
+ xfce_clock_tooltip_sync (clock);
}
else
{
@@ -170,11 +165,9 @@ xfce_clock_dialog_tooltip_format_changed (GtkComboBox *combo,
static void
-xfce_clock_dialog_tooltip_entry_changed (GtkEntry *entry,
- XfceClock *clock)
+xfce_clock_dialog_tooltip_entry_changed (GtkEntry *entry,
+ ClockPlugin *clock)
{
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* cleanup old format */
g_free (clock->tooltip_format);
@@ -182,17 +175,15 @@ xfce_clock_dialog_tooltip_entry_changed (GtkEntry *entry,
clock->tooltip_format = g_strdup (gtk_entry_get_text (entry));
/* restart the tooltip timeout */
- xfce_clock_tooltip_timer (clock);
+ xfce_clock_tooltip_sync (clock);
}
static void
xfce_clock_dialog_show_seconds_toggled (GtkToggleButton *button,
- XfceClock *clock)
+ ClockPlugin *clock)
{
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* whether we show seconds */
clock->show_seconds = gtk_toggle_button_get_active (button);
@@ -204,10 +195,8 @@ xfce_clock_dialog_show_seconds_toggled (GtkToggleButton *button,
static void
xfce_clock_dialog_show_military_toggled (GtkToggleButton *button,
- XfceClock *clock)
+ ClockPlugin *clock)
{
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* whether we show a 24h clock */
clock->show_military = gtk_toggle_button_get_active (button);
@@ -219,10 +208,8 @@ xfce_clock_dialog_show_military_toggled (GtkToggleButton *button,
static void
xfce_clock_dialog_show_meridiem_toggled (GtkToggleButton *button,
- XfceClock *clock)
+ ClockPlugin *clock)
{
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* whether we show am/pm */
clock->show_meridiem = gtk_toggle_button_get_active (button);
@@ -234,10 +221,8 @@ xfce_clock_dialog_show_meridiem_toggled (GtkToggleButton *button,
static void
xfce_clock_dialog_flash_separators_toggled (GtkToggleButton *button,
- XfceClock *clock)
+ ClockPlugin *clock)
{
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* whether flash the separators */
clock->flash_separators = gtk_toggle_button_get_active (button);
@@ -249,10 +234,8 @@ xfce_clock_dialog_flash_separators_toggled (GtkToggleButton *button,
static void
xfce_clock_dialog_true_binary_toggled (GtkToggleButton *button,
- XfceClock *clock)
+ ClockPlugin *clock)
{
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* whether we this is a true binary clock */
clock->true_binary = gtk_toggle_button_get_active (button);
@@ -264,13 +247,11 @@ xfce_clock_dialog_true_binary_toggled (GtkToggleButton *button,
static void
xfce_clock_dialog_digital_format_changed (GtkComboBox *combo,
- XfceClock *clock)
+ ClockPlugin *clock)
{
gint index;
GtkWidget *entry;
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* get index of selected item */
index = gtk_combo_box_get_active (combo);
@@ -305,11 +286,9 @@ xfce_clock_dialog_digital_format_changed (GtkComboBox *combo,
static void
-xfce_clock_dialog_digital_entry_changed (GtkEntry *entry,
- XfceClock *clock)
+xfce_clock_dialog_digital_entry_changed (GtkEntry *entry,
+ ClockPlugin *clock)
{
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* cleanup old format */
g_free (clock->digital_format);
@@ -394,37 +373,31 @@ xfce_clock_dialog_append_combobox_formats (GtkComboBox *combo,
static void
-xfce_clock_dialog_response (GtkWidget *dialog,
- gint response,
- XfceClock *clock)
+xfce_clock_dialog_response (GtkWidget *dialog,
+ gint response,
+ ClockPlugin *clock)
{
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* destroy the dialog */
gtk_widget_destroy (dialog);
/* remove links */
- g_object_set_data (G_OBJECT (clock), I_("configure-dialog-bin"), NULL);
+ g_object_set_data (G_OBJECT (clock->plugin), I_("configure-dialog"), NULL);
+ g_object_set_data (G_OBJECT (clock->plugin), I_("configure-dialog-bin"), NULL);
/* unblock the plugin menu */
- xfce_panel_plugin_unblock_menu (XFCE_PANEL_PLUGIN (clock));
-
- /* save the settings */
- xfce_clock_save (XFCE_PANEL_PLUGIN (clock));
+ xfce_panel_plugin_unblock_menu (clock->plugin);
}
void
-xfce_clock_dialog_options (XfceClock *clock)
+xfce_clock_dialog_options (ClockPlugin *clock)
{
GtkWidget *button, *bin, *vbox, *combo, *entry;
gboolean has_active;
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* get the frame bin */
- bin = g_object_get_data (G_OBJECT (clock), I_("configure-dialog-bin"));
+ bin = g_object_get_data (G_OBJECT (clock->plugin), I_("configure-dialog-bin"));
gtk_container_foreach (GTK_CONTAINER (bin), (GtkCallback) gtk_widget_destroy, NULL);
/* main vbox */
@@ -432,7 +405,7 @@ xfce_clock_dialog_options (XfceClock *clock)
gtk_container_add (GTK_CONTAINER (bin), vbox);
gtk_widget_show (vbox);
- if (clock->mode == XFCE_CLOCK_MODE_ANALOG || clock->mode == XFCE_CLOCK_MODE_BINARY || clock->mode == XFCE_CLOCK_MODE_LCD)
+ if (clock->mode == XFCE_CLOCK_ANALOG || clock->mode == XFCE_CLOCK_BINARY || clock->mode == XFCE_CLOCK_LCD)
{
button = gtk_check_button_new_with_mnemonic (_("Display _seconds"));
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
@@ -441,7 +414,7 @@ xfce_clock_dialog_options (XfceClock *clock)
gtk_widget_show (button);
}
- if (clock->mode == XFCE_CLOCK_MODE_LCD)
+ if (clock->mode == XFCE_CLOCK_LCD)
{
button = gtk_check_button_new_with_mnemonic (_("Use 24-_hour clock"));
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
@@ -462,7 +435,7 @@ xfce_clock_dialog_options (XfceClock *clock)
gtk_widget_show (button);
}
- if (clock->mode == XFCE_CLOCK_MODE_BINARY)
+ if (clock->mode == XFCE_CLOCK_BINARY)
{
button = gtk_check_button_new_with_mnemonic (_("True _binary clock"));
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
@@ -471,7 +444,7 @@ xfce_clock_dialog_options (XfceClock *clock)
gtk_widget_show (button);
}
- if (clock->mode == XFCE_CLOCK_MODE_DIGITAL)
+ if (clock->mode == XFCE_CLOCK_DIGITAL)
{
combo = gtk_combo_box_new_text ();
gtk_box_pack_start (GTK_BOX (vbox), combo, TRUE, TRUE, 0);
@@ -480,7 +453,8 @@ xfce_clock_dialog_options (XfceClock *clock)
g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (xfce_clock_dialog_digital_format_changed), clock);
gtk_widget_show (combo);
- entry = gtk_entry_new ();
+ entry = gtk_entry_new ();
+ gtk_entry_set_max_length (GTK_ENTRY (entry), BUFFER_SIZE - 1);
gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
g_object_set_data (G_OBJECT (combo), I_("entry"), entry);
if (!has_active)
@@ -495,32 +469,28 @@ xfce_clock_dialog_options (XfceClock *clock)
void
-xfce_clock_dialog_show (XfceClock *clock)
+xfce_clock_dialog_show (ClockPlugin *clock)
{
GtkWidget *dialog, *dialog_vbox;
GtkWidget *frame, *bin, *vbox, *combo;
GtkWidget *button, *entry;
gboolean has_active;
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
-
/* block the right-click menu */
- xfce_panel_plugin_block_menu (XFCE_PANEL_PLUGIN (clock));
+ xfce_panel_plugin_block_menu (clock->plugin);
/* create dialog */
dialog = xfce_titled_dialog_new_with_buttons (_("Clock"), NULL,
GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
- gtk_window_set_screen (GTK_WINDOW (dialog), gtk_widget_get_screen (GTK_WIDGET (clock)));
+ gtk_window_set_screen (GTK_WINDOW (dialog), gtk_widget_get_screen (GTK_WIDGET (clock->plugin)));
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-settings");
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
+ g_object_set_data (G_OBJECT (clock->plugin), I_("configure-dialog"), dialog);
g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (xfce_clock_dialog_response), clock);
- /* let the plugin take the dialg window */
- xfce_panel_plugin_take_window (XFCE_PANEL_PLUGIN (clock), GTK_WINDOW (dialog));
-
/* main vbox */
dialog_vbox = gtk_vbox_new (FALSE, 8);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), dialog_vbox, TRUE, TRUE, 0);
@@ -536,7 +506,6 @@ xfce_clock_dialog_show (XfceClock *clock)
gtk_container_add (GTK_CONTAINER (bin), vbox);
gtk_widget_show (vbox);
-
combo = gtk_combo_box_new_text ();
gtk_box_pack_start (GTK_BOX (vbox), combo, TRUE, TRUE, 0);
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Analog"));
@@ -570,6 +539,7 @@ xfce_clock_dialog_show (XfceClock *clock)
gtk_widget_show (combo);
entry = gtk_entry_new ();
+ gtk_entry_set_max_length (GTK_ENTRY (entry), BUFFER_SIZE - 1);
gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
g_object_set_data (G_OBJECT (combo), I_("entry"), entry);
if (!has_active)
@@ -582,7 +552,7 @@ xfce_clock_dialog_show (XfceClock *clock)
/* clock settings */
frame = xfce_gtk_frame_box_new (_("Clock Options"), &bin);
gtk_box_pack_start (GTK_BOX (dialog_vbox), frame, FALSE, TRUE, 0);
- g_object_set_data (G_OBJECT (clock), I_("configure-dialog-bin"), bin);
+ g_object_set_data (G_OBJECT (clock->plugin), I_("configure-dialog-bin"), bin);
gtk_widget_show (frame);
/* add the potions */
diff --git a/plugins/clock/clock-dialog.h b/plugins/clock/clock-dialog.h
index d4cd139..7545070 100644
--- a/plugins/clock/clock-dialog.h
+++ b/plugins/clock/clock-dialog.h
@@ -24,7 +24,7 @@
G_BEGIN_DECLS
-void xfce_clock_dialog_show (XfceClock *clock) G_GNUC_INTERNAL;
+void xfce_clock_dialog_show (ClockPlugin *clock) G_GNUC_INTERNAL;
G_END_DECLS
diff --git a/plugins/clock/clock-digital.c b/plugins/clock/clock-digital.c
index 657bf24..6e82017 100644
--- a/plugins/clock/clock-digital.c
+++ b/plugins/clock/clock-digital.c
@@ -68,7 +68,28 @@ struct _XfceClockDigital
-XFCE_PANEL_DEFINE_TYPE (XfceClockDigital, xfce_clock_digital, GTK_TYPE_LABEL);
+static GObjectClass *xfce_clock_digital_parent_class;
+
+
+
+GType
+xfce_clock_digital_get_type (void)
+{
+ static GType type = G_TYPE_INVALID;
+
+ if (G_UNLIKELY (type == G_TYPE_INVALID))
+ {
+ type = g_type_register_static_simple (GTK_TYPE_LABEL,
+ I_("XfceClockDigital"),
+ sizeof (XfceClockDigitalClass),
+ (GClassInitFunc) xfce_clock_digital_class_init,
+ sizeof (XfceClockDigital),
+ (GInstanceInitFunc) xfce_clock_digital_init,
+ 0);
+ }
+
+ return type;
+}
@@ -77,6 +98,8 @@ xfce_clock_digital_class_init (XfceClockDigitalClass *klass)
{
GObjectClass *gobject_class;
+ xfce_clock_digital_parent_class = g_type_class_peek_parent (klass);
+
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = xfce_clock_digital_finalize;
gobject_class->set_property = xfce_clock_digital_set_property;
@@ -87,11 +110,8 @@ xfce_clock_digital_class_init (XfceClockDigitalClass *klass)
**/
g_object_class_install_property (gobject_class,
PROP_DIGITAL_FORMAT,
- g_param_spec_string ("digital-format",
- "digital-format",
- "digital-format",
- NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_param_spec_string ("digital-format", "digital-format", "digital-format",
+ NULL, G_PARAM_READWRITE | G_PARAM_STATIC_BLURB));
}
@@ -175,7 +195,7 @@ xfce_clock_digital_get_property (GObject *object,
GtkWidget *
xfce_clock_digital_new (void)
{
- return g_object_new (XFCE_TYPE_CLOCK_DIGITAL, NULL);
+ return g_object_new (XFCE_CLOCK_TYPE_DIGITAL, NULL);
}
@@ -187,27 +207,20 @@ xfce_clock_digital_update (gpointer user_data)
gchar *string;
struct tm tm;
- panel_return_val_if_fail (XFCE_IS_CLOCK_DIGITAL (clock), FALSE);
+ g_return_val_if_fail (XFCE_CLOCK_IS_DIGITAL (clock), FALSE);
+ g_return_val_if_fail (clock->format != NULL, FALSE);
- if (clock->format != NULL)
- {
- /* get the local time */
- xfce_clock_util_get_localtime (&tm);
+ /* get the local time */
+ xfce_clock_util_get_localtime (&tm);
- /* get the string */
- string = xfce_clock_util_strdup_strftime (clock->format, &tm);
+ /* get the string */
+ string = xfce_clock_util_strdup_strftime (clock->format, &tm);
- /* set the new label */
- gtk_label_set_markup (GTK_LABEL (clock), string);
+ /* set the new label */
+ gtk_label_set_markup (GTK_LABEL (clock), string);
- /* cleanup */
- g_free (string);
- }
- else
- {
- /* clear label */
- gtk_label_set_text (GTK_LABEL (clock), NULL);
- }
+ /* cleanup */
+ g_free (string);
return TRUE;
}
diff --git a/plugins/clock/clock-digital.h b/plugins/clock/clock-digital.h
index 62d5b06..94b2b25 100644
--- a/plugins/clock/clock-digital.h
+++ b/plugins/clock/clock-digital.h
@@ -25,20 +25,18 @@ G_BEGIN_DECLS
typedef struct _XfceClockDigitalClass XfceClockDigitalClass;
typedef struct _XfceClockDigital XfceClockDigital;
-#define XFCE_TYPE_CLOCK_DIGITAL (xfce_clock_digital_get_type ())
-#define XFCE_CLOCK_DIGITAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_CLOCK_DIGITAL, XfceClockDigital))
-#define XFCE_CLOCK_DIGITAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_CLOCK_DIGITAL, XfceClockDigitalClass))
-#define XFCE_IS_CLOCK_DIGITAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_CLOCK_DIGITAL))
-#define XFCE_IS_CLOCK_DIGITAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_CLOCK_DIGITAL))
-#define XFCE_CLOCK_DIGITAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_CLOCK_DIGITAL, XfceClockDigitalClass))
+#define XFCE_CLOCK_TYPE_DIGITAL (xfce_clock_digital_get_type ())
+#define XFCE_CLOCK_DIGITAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_CLOCK_TYPE_DIGITAL, XfceClockDigital))
+#define XFCE_CLOCK_DIGITAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_CLOCK_TYPE_DIGITAL, XfceClockDigitalClass))
+#define XFCE_CLOCK_IS_DIGITAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_CLOCK_TYPE_DIGITAL))
+#define XFCE_CLOCK_IS_DIGITAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_CLOCK_TYPE_DIGITAL))
+#define XFCE_CLOCK_DIGITAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_CLOCK_TYPE_DIGITAL, XfceClockDigitalClass))
-GType xfce_clock_digital_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
+GType xfce_clock_digital_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
-void xfce_clock_digital_register_type (XfcePanelModule *panel_module) G_GNUC_INTERNAL;
+GtkWidget *xfce_clock_digital_new (void) G_GNUC_MALLOC G_GNUC_INTERNAL;
-GtkWidget *xfce_clock_digital_new (void) G_GNUC_MALLOC G_GNUC_INTERNAL;
-
-gboolean xfce_clock_digital_update (gpointer user_data) G_GNUC_INTERNAL;
+gboolean xfce_clock_digital_update (gpointer user_data) G_GNUC_INTERNAL;
G_END_DECLS
diff --git a/plugins/clock/clock-lcd.c b/plugins/clock/clock-lcd.c
index 8af986d..d164933 100644
--- a/plugins/clock/clock-lcd.c
+++ b/plugins/clock/clock-lcd.c
@@ -36,6 +36,7 @@
/* prototypes */
static void xfce_clock_lcd_class_init (XfceClockLcdClass *klass);
static void xfce_clock_lcd_init (XfceClockLcd *clock);
+static void xfce_clock_lcd_finalize (GObject *object);
static void xfce_clock_lcd_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -94,7 +95,28 @@ struct _XfceClockLcd
-XFCE_PANEL_DEFINE_TYPE (XfceClockLcd, xfce_clock_lcd, GTK_TYPE_IMAGE);
+static GObjectClass *xfce_clock_lcd_parent_class;
+
+
+
+GType
+xfce_clock_lcd_get_type (void)
+{
+ static GType type = G_TYPE_INVALID;
+
+ if (G_UNLIKELY (type == G_TYPE_INVALID))
+ {
+ type = g_type_register_static_simple (GTK_TYPE_IMAGE,
+ I_("XfceClockLcd"),
+ sizeof (XfceClockLcdClass),
+ (GClassInitFunc) xfce_clock_lcd_class_init,
+ sizeof (XfceClockLcd),
+ (GInstanceInitFunc) xfce_clock_lcd_init,
+ 0);
+ }
+
+ return type;
+}
@@ -104,7 +126,10 @@ xfce_clock_lcd_class_init (XfceClockLcdClass *klass)
GObjectClass *gobject_class;
GtkWidgetClass *gtkwidget_class;
+ xfce_clock_lcd_parent_class = g_type_class_peek_parent (klass);
+
gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = xfce_clock_lcd_finalize;
gobject_class->set_property = xfce_clock_lcd_set_property;
gobject_class->get_property = xfce_clock_lcd_get_property;
@@ -117,44 +142,36 @@ xfce_clock_lcd_class_init (XfceClockLcdClass *klass)
**/
g_object_class_install_property (gobject_class,
PROP_SHOW_SECONDS,
- g_param_spec_boolean ("show-seconds",
- "show-seconds",
- "show-seconds",
+ g_param_spec_boolean ("show-seconds", "show-seconds", "show-seconds",
FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ G_PARAM_READWRITE | G_PARAM_STATIC_BLURB));
/**
* Whether we show a 24h clock
**/
g_object_class_install_property (gobject_class,
PROP_SHOW_MILITARY,
- g_param_spec_boolean ("show-military",
- "show-military",
- "show-military",
+ g_param_spec_boolean ("show-military", "show-military", "show-military",
FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ G_PARAM_READWRITE | G_PARAM_STATIC_BLURB));
/**
* Whether we show am or pm
**/
g_object_class_install_property (gobject_class,
PROP_SHOW_MERIDIEM,
- g_param_spec_boolean ("show-meridiem",
- "show-meridiem",
- "show-meridiem",
+ g_param_spec_boolean ("show-meridiem", "show-meridiem", "show-meridiem",
TRUE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ G_PARAM_READWRITE | G_PARAM_STATIC_BLURB));
/**
* Whether to flash the time separators
**/
g_object_class_install_property (gobject_class,
PROP_FLASH_SEPARATORS,
- g_param_spec_boolean ("flash-separators",
- "flash-separators",
- "flash-separators",
+ g_param_spec_boolean ("flash-separators", "flash-separators", "flash-separators",
FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ G_PARAM_READWRITE | G_PARAM_STATIC_BLURB));
}
@@ -172,6 +189,14 @@ xfce_clock_lcd_init (XfceClockLcd *clock)
static void
+xfce_clock_lcd_finalize (GObject *object)
+{
+ (*G_OBJECT_CLASS (xfce_clock_lcd_parent_class)->finalize) (object);
+}
+
+
+
+static void
xfce_clock_lcd_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -266,6 +291,9 @@ xfce_clock_lcd_size_request (GtkWidget *widget,
requisition->height = height;
requisition->width = height * ratio;
}
+
+ /* increase the width with 1 px for rounding errors */
+ requisition->width++;
}
@@ -282,7 +310,7 @@ xfce_clock_lcd_expose_event (GtkWidget *widget,
gdouble ratio;
struct tm tm;
- panel_return_val_if_fail (XFCE_IS_CLOCK_LCD (clock), FALSE);
+ g_return_val_if_fail (XFCE_CLOCK_IS_LCD (clock), FALSE);
/* size of a digit should be a fraction of 10 */
size = widget->allocation.height - widget->allocation.height % 10;
@@ -315,7 +343,7 @@ xfce_clock_lcd_expose_event (GtkWidget *widget,
if (ticks >= 10)
{
- /* draw the number and increase the offset*/
+ /* draw the number and increase the offset */
offset_x = xfce_clock_lcd_draw_digit (cr, ticks >= 20 ? 2 : 1, size, offset_x, offset_y);
}
@@ -435,7 +463,7 @@ xfce_clock_lcd_draw_digit (cairo_t *cr,
gint segment;
gdouble x, y;
- panel_return_val_if_fail (number >= 0 || number <= 11, offset_x);
+ g_return_val_if_fail (number >= 0 || number <= 11, offset_x);
/* coordicates to draw for each segment */
gdouble segments_x[][6] = { { 0.02, 0.48, 0.38, 0.12, -1.0, 0.00 },
@@ -508,7 +536,7 @@ xfce_clock_lcd_draw_digit (cairo_t *cr,
GtkWidget *
xfce_clock_lcd_new (void)
{
- return g_object_new (XFCE_TYPE_CLOCK_LCD, NULL);
+ return g_object_new (XFCE_CLOCK_TYPE_LCD, NULL);
}
diff --git a/plugins/clock/clock-lcd.h b/plugins/clock/clock-lcd.h
index 7d078d2..2329628 100644
--- a/plugins/clock/clock-lcd.h
+++ b/plugins/clock/clock-lcd.h
@@ -25,20 +25,18 @@ G_BEGIN_DECLS
typedef struct _XfceClockLcdClass XfceClockLcdClass;
typedef struct _XfceClockLcd XfceClockLcd;
-#define XFCE_TYPE_CLOCK_LCD (xfce_clock_lcd_get_type ())
-#define XFCE_CLOCK_LCD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_CLOCK_LCD, XfceClockLcd))
-#define XFCE_CLOCK_LCD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_CLOCK_LCD, XfceClockLcdClass))
-#define XFCE_IS_CLOCK_LCD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_CLOCK_LCD))
-#define XFCE_IS_CLOCK_LCD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_CLOCK_LCD))
-#define XFCE_CLOCK_LCD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_CLOCK_LCD, XfceClockLcdClass))
+#define XFCE_CLOCK_TYPE_LCD (xfce_clock_lcd_get_type ())
+#define XFCE_CLOCK_LCD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_CLOCK_TYPE_LCD, XfceClockLcd))
+#define XFCE_CLOCK_LCD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_CLOCK_TYPE_LCD, XfceClockLcdClass))
+#define XFCE_CLOCK_IS_LCD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_CLOCK_TYPE_LCD))
+#define XFCE_CLOCK_IS_LCD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_CLOCK_TYPE_LCD))
+#define XFCE_CLOCK_LCD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_CLOCK_TYPE_LCD, XfceClockLcdClass))
-GType xfce_clock_lcd_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
+GType xfce_clock_lcd_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
-void xfce_clock_lcd_register_type (XfcePanelModule *panel_module) G_GNUC_INTERNAL;
+GtkWidget *xfce_clock_lcd_new (void) G_GNUC_MALLOC G_GNUC_INTERNAL;
-GtkWidget *xfce_clock_lcd_new (void) G_GNUC_MALLOC G_GNUC_INTERNAL;
-
-gboolean xfce_clock_lcd_update (gpointer user_data) G_GNUC_INTERNAL;
+gboolean xfce_clock_lcd_update (gpointer user_data) G_GNUC_INTERNAL;
G_END_DECLS
diff --git a/plugins/clock/clock.c b/plugins/clock/clock.c
index feb7a10..601ed41 100644
--- a/plugins/clock/clock.c
+++ b/plugins/clock/clock.c
@@ -1,6 +1,6 @@
/* $Id: clock.c 26625 2008-02-18 07:59:29Z nick $ */
/*
- * Copyright (c) 2007-2008 Nick Schermer <nick at xfce.org>
+ * Copyright (c) 2007 Nick Schermer <nick at xfce.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -38,248 +38,45 @@
/** prototypes **/
-static void xfce_clock_class_init (XfceClockClass *klass);
-static void xfce_clock_init (XfceClock *clock);
-static void xfce_clock_finalize (GObject *object);
-static void xfce_clock_size_changed (XfcePanelPlugin *plugin,
- gint size);
-static void xfce_clock_configure_plugin (XfcePanelPlugin *plugin);
-static void xfce_clock_load (XfceClock *clock);
-static guint xfce_clock_util_interval_from_format (const gchar *format);
-static guint xfce_clock_util_sync_interval (guint timeout_interval);
-static gboolean xfce_clock_tooltip_timer_update (gpointer user_data);
-static gboolean xfce_clock_tooltip_timer_sync (gpointer user_data);
-static gboolean xfce_clock_widget_timer_sync (gpointer user_data);
-
-
-
-#if !GTK_CHECK_VERSION (2,12,0)
-static GtkTooltips *shared_tooltips = NULL;
-#endif
-
-
-
-XFCE_PANEL_DEFINE_TYPE (XfceClock, xfce_clock, XFCE_TYPE_PANEL_PLUGIN);
-
-
-
-static void
-xfce_clock_class_init (XfceClockClass *klass)
-{
- GObjectClass *gobject_class;
- XfcePanelPluginClass *plugin_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = xfce_clock_finalize;
-
- plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass);
- plugin_class->save = xfce_clock_save;
- plugin_class->size_changed = xfce_clock_size_changed;
- plugin_class->configure_plugin = xfce_clock_configure_plugin;
-
-#if !GTK_CHECK_VERSION (2,12,0)
- /* allocate share tooltip */
- shared_tooltips = gtk_tooltips_new ();
+#if USE_DEBUG_TIME
+static void xfce_clock_util_get_debug_localtime (struct tm *tm);
#endif
-}
+static guint xfce_clock_util_interval_from_format (const gchar *format);
+static guint xfce_clock_util_next_interval (guint timeout_interval);
+static gboolean xfce_clock_tooltip_update (gpointer user_data);
+static gboolean xfce_clock_tooltip_sync_timeout (gpointer user_data);
+static gboolean xfce_clock_widget_sync_timeout (gpointer user_data);
+static ClockPlugin *xfce_clock_plugin_init (XfcePanelPlugin *plugin);
+static void xfce_clock_plugin_read (ClockPlugin *clock);
+static void xfce_clock_plugin_write (ClockPlugin *clock);
+static void xfce_clock_plugin_free (ClockPlugin *clock);
+static void xfce_clock_plugin_construct (XfcePanelPlugin *plugin);
-static void
-xfce_clock_init (XfceClock *clock)
-{
- /* initialize the default values */
- clock->widget_timer_id = 0;
- clock->tooltip_timer_id = 0;
- clock->widget = NULL;
- clock->mode = XFCE_CLOCK_MODE_DIGITAL;
- clock->tooltip_format = NULL;
- clock->digital_format = NULL;
-
- /* read the user settings */
- xfce_clock_load (clock);
-
- /* build widgets */
- clock->frame = gtk_frame_new (NULL);
- gtk_container_add (GTK_CONTAINER (clock), clock->frame);
- gtk_frame_set_shadow_type (GTK_FRAME (clock->frame), clock->show_frame ? GTK_SHADOW_IN : GTK_SHADOW_NONE);
- gtk_widget_show (clock->frame);
-
- /* set the clock mode (create clock widget) */
- xfce_clock_widget_update_mode (clock);
-
- /* set the clock settings */
- xfce_clock_widget_update_properties (clock);
-
- /* start the widget timer */
- xfce_clock_widget_timer (clock);
-
- /* start the tooltip timer */
- xfce_clock_tooltip_timer (clock);
-
- /* show the properties dialog */
- xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (clock));
-}
-
-
-
-static void
-xfce_clock_finalize (GObject *object)
-{
- XfceClock *clock = XFCE_CLOCK (object);
-
- /* stop running timeouts */
- if (G_LIKELY (clock->widget_timer_id != 0))
- g_source_remove (clock->widget_timer_id);
-
- if (G_LIKELY (clock->tooltip_timer_id != 0))
- g_source_remove (clock->tooltip_timer_id);
-
- /* cleanup */
- g_free (clock->tooltip_format);
- g_free (clock->digital_format);
-
- (*G_OBJECT_CLASS (xfce_clock_parent_class)->finalize) (object);
-}
+/** register the plugin **/
+XFCE_PANEL_PLUGIN_REGISTER (xfce_clock_plugin_construct);
+/** utilities **/
void
-xfce_clock_save (XfcePanelPlugin *plugin)
-{
- XfceClock *clock = XFCE_CLOCK (plugin);
- gchar *filename;
- XfceRc *rc;
-
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (clock));
-
- /* config filename */
- filename = xfce_panel_plugin_save_location (plugin, TRUE);
- if (G_LIKELY (filename))
- {
- /* open rc file */
- rc = xfce_rc_simple_open (filename, FALSE);
-
- /* cleanup */
- g_free (filename);
-
- if (G_LIKELY (rc))
- {
- /* write settings */
- if (G_LIKELY (clock->digital_format && *clock->digital_format != '\0'))
- xfce_rc_write_entry (rc, "DigitalFormat", clock->digital_format);
-
- if (G_LIKELY (clock->tooltip_format && *clock->tooltip_format != '\0'))
- xfce_rc_write_entry (rc, "TooltipFormat", clock->tooltip_format);
-
- xfce_rc_write_int_entry (rc, "ClockType", clock->mode);
- xfce_rc_write_bool_entry (rc, "ShowFrame", clock->show_frame);
- xfce_rc_write_bool_entry (rc, "ShowSeconds", clock->show_seconds);
- xfce_rc_write_bool_entry (rc, "ShowMilitary", clock->show_military);
- xfce_rc_write_bool_entry (rc, "ShowMeridiem", clock->show_meridiem);
- xfce_rc_write_bool_entry (rc, "TrueBinary", clock->true_binary);
- xfce_rc_write_bool_entry (rc, "FlashSeparators", clock->flash_separators);
-
- /* close the rc file */
- xfce_rc_close (rc);
- }
- }
-}
-
-
-
-static void
-xfce_clock_size_changed (XfcePanelPlugin *plugin,
- gint size)
-{
- XfceClock *clock = XFCE_CLOCK (plugin);
- GtkOrientation orientation;
-
- /* set the frame border */
- gtk_container_set_border_width (GTK_CONTAINER (clock->frame), size > 26 ? 1 : 0);
-
- /* get the clock size */
- size -= size > 26 ? 6 : 4;
-
- /* get plugin orientation */
- orientation = xfce_panel_plugin_get_orientation (plugin);
-
- /* set the clock size */
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_widget_set_size_request (clock->widget, -1, size);
- else
- gtk_widget_set_size_request (clock->widget, size, -1);
-}
-
-
-
-static void
-xfce_clock_configure_plugin (XfcePanelPlugin *plugin)
-{
- /* show the dialog */
- xfce_clock_dialog_show (XFCE_CLOCK (plugin));
-}
-
-
-
-static void
-xfce_clock_load (XfceClock *clock)
+xfce_clock_util_get_localtime (struct tm *tm)
{
- gchar *filename;
- const gchar *value;
- XfceRc *rc;
- gboolean succeed = FALSE;
+ time_t now = time (0);
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (clock));
-
- /* config filename */
- filename = xfce_panel_plugin_lookup_rc_file (XFCE_PANEL_PLUGIN (clock));
-
- if (G_LIKELY (filename))
- {
- /* open rc file (readonly) */
- rc = xfce_rc_simple_open (filename, TRUE);
-
- /* cleanup */
- g_free (filename);
+#ifndef HAVE_LOCALTIME_R
+ struct tm *tmbuf;
- if (G_LIKELY (rc))
- {
- /* read strings */
- value = xfce_rc_read_entry (rc, "DigitalFormat", DEFAULT_DIGITAL_FORMAT);
- if (G_LIKELY (value != NULL && *value != '\0'))
- clock->digital_format = g_strdup (value);
-
- value = xfce_rc_read_entry (rc, "TooltipFormat", DEFAULT_TOOLTIP_FORMAT);
- if (G_LIKELY (value != NULL && *value != '\0'))
- clock->tooltip_format = g_strdup (value);
-
- /* read clock type */
- clock->mode = xfce_rc_read_int_entry (rc, "ClockType", XFCE_CLOCK_MODE_DIGITAL);
-
- /* read boolean settings */
- clock->show_frame = xfce_rc_read_bool_entry (rc, "ShowFrame", TRUE);
- clock->show_seconds = xfce_rc_read_bool_entry (rc, "ShowSeconds", FALSE);
- clock->show_military = xfce_rc_read_bool_entry (rc, "ShowMilitary", TRUE);
- clock->show_meridiem = xfce_rc_read_bool_entry (rc, "ShowMeridiem", FALSE);
- clock->true_binary = xfce_rc_read_bool_entry (rc, "TrueBinary", FALSE);
- clock->flash_separators = xfce_rc_read_bool_entry (rc, "FlashSeparators", FALSE);
-
- /* close the rc file */
- xfce_rc_close (rc);
-
- /* loading succeeded */
- succeed = TRUE;
- }
- }
+ tmbuf = localtime (&now);
+ *tm = *tmbuf;
+#else
+ localtime_r (&now, tm);
+#endif
- if (succeed == FALSE)
- {
- /* fallback to defaults */
- clock->digital_format = g_strdup (DEFAULT_DIGITAL_FORMAT);
- clock->tooltip_format = g_strdup (DEFAULT_TOOLTIP_FORMAT);
- }
+#if USE_DEBUG_TIME
+ xfce_clock_util_get_debug_localtime (tm);
+#endif
}
@@ -288,133 +85,110 @@ xfce_clock_load (XfceClock *clock)
static void
xfce_clock_util_get_debug_localtime (struct tm *tm)
{
- static gint hour = 23;
- static gint min = 59;
- static gint sec = 45;
+ static gint hour = 23;
+ static gint min = 59;
+ static gint sec = 45;
- /* add 1 seconds */
- sec++;
+ /* add 1 seconds */
+ sec++;
- /* update times */
- if (sec > 59)
+ /* update times */
+ if (sec > 59)
{
- sec = 0;
- min++;
+ sec = 0;
+ min++;
}
- if (min > 59)
+ if (min > 59)
{
- min = 0;
- hour++;
+ min = 0;
+ hour++;
}
- if (hour > 23)
+ if (hour > 23)
{
- hour = 0;
+ hour = 0;
}
- /* set time structure */
- tm->tm_sec = sec;
- tm->tm_min = min;
- tm->tm_hour = hour;
+ /* set time structure */
+ tm->tm_sec = sec;
+ tm->tm_min = min;
+ tm->tm_hour = hour;
}
#endif
-void
-xfce_clock_util_get_localtime (struct tm *tm)
-{
- time_t now = time (0);
-
-#ifndef HAVE_LOCALTIME_R
- struct tm *tmbuf;
-
- tmbuf = localtime (&now);
- *tm = *tmbuf;
-#else
- localtime_r (&now, tm);
-#endif
-
-#if USE_DEBUG_TIME
- xfce_clock_util_get_debug_localtime (tm);
-#endif
-}
-
-
-
static guint
xfce_clock_util_interval_from_format (const gchar *format)
{
- const gchar *p;
- guint interval = CLOCK_INTERVAL_HOUR;
+ const gchar *p;
+ guint interval = CLOCK_INTERVAL_HOUR;
- /* no format, update once an hour */
- if (G_UNLIKELY (format == NULL))
- return CLOCK_INTERVAL_HOUR;
+ if (G_UNLIKELY (format == NULL))
+ return CLOCK_INTERVAL_HOUR;
- /* walk the format to find the smallest update time */
- for (p = format; *p != '\0'; ++p)
+ for (p = format; *p != '\0'; ++p)
{
- if (p[0] == '%' && p[1] != '\0')
+ if (p[0] == '%' && p[1] != '\0')
{
- switch (*++p)
+ switch (*++p)
{
- case 'c':
- case 'N':
- case 'r':
- case 's':
- case 'S':
- case 'T':
- case 'X':
- return CLOCK_INTERVAL_SECOND;
-
- case 'M':
- case 'R':
- interval = CLOCK_INTERVAL_MINUTE;
- break;
+ case 'c':
+ case 'N':
+ case 'r':
+ case 's':
+ case 'S':
+ case 'T':
+ case 'X':
+ return CLOCK_INTERVAL_SECOND;
+
+ case 'M':
+ case 'R':
+ interval = CLOCK_INTERVAL_MINUTE;
+ break;
}
}
}
- return interval;
+ return interval;
}
static guint
-xfce_clock_util_sync_interval (guint timeout_interval)
+xfce_clock_util_next_interval (guint timeout_interval)
{
- struct tm tm;
- GTimeVal timeval;
- guint interval;
+ struct tm tm;
+ GTimeVal timeval;
+ guint interval;
- /* get the precise time */
- g_get_current_time (&timeval);
+ /* get the precise time */
+ g_get_current_time (&timeval);
- /* ms to next second */
- interval = 1000 - (timeval.tv_usec / 1000);
+ /* ms to next second */
+ interval = 1000 - (timeval.tv_usec / 1000);
- /* get current time */
- xfce_clock_util_get_localtime (&tm);
+ /* get current time */
+ xfce_clock_util_get_localtime (&tm);
- /* add the interval time to the next update */
- switch (timeout_interval)
+ /* add the interval time to the next update */
+ switch (timeout_interval)
{
- case CLOCK_INTERVAL_HOUR:
- /* ms to next hour */
- interval += (60 - tm.tm_min) * CLOCK_INTERVAL_MINUTE;
+ case CLOCK_INTERVAL_HOUR:
+ /* ms to next hour */
+ interval += (60 - tm.tm_min) * CLOCK_INTERVAL_MINUTE;
- /* fall-through to add the minutes */
+ /* fall-through to add the minutes */
- case CLOCK_INTERVAL_MINUTE:
- /* ms to next minute */
- interval += (60 - tm.tm_sec) * CLOCK_INTERVAL_SECOND;
- break;
+ case CLOCK_INTERVAL_MINUTE:
+ /* ms to next minute */
+ interval += (60 - tm.tm_sec) * CLOCK_INTERVAL_SECOND;
+ break;
- default:
- break;
+ default:
+ break;
}
- return interval;
+ return interval;
}
@@ -423,322 +197,466 @@ gchar *
xfce_clock_util_strdup_strftime (const gchar *format,
const struct tm *tm)
{
- gchar *converted, *result;
- gsize length;
- gchar buffer[BUFFER_SIZE];
-
- /* return null */
- if (G_UNLIKELY (format == NULL))
- return NULL;
+ gchar *converted, *result;
+ gsize length;
+ gchar buffer[BUFFER_SIZE];
- /* convert to locale, because that's what strftime uses */
- converted = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
- if (G_UNLIKELY (converted == NULL))
- return NULL;
+ /* convert to locale, because that's what strftime uses */
+ converted = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
+ if (G_UNLIKELY (converted == NULL))
+ return NULL;
- /* parse the time string */
- length = strftime (buffer, sizeof (buffer), converted, tm);
- if (G_UNLIKELY (length == 0))
- buffer[0] = '\0';
+ /* parse the time string */
+ length = strftime (buffer, sizeof (buffer), converted, tm);
+ if (G_UNLIKELY (length == 0))
+ buffer[0] = '\0';
- /* convert the string back to utf-8 */
- result = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
+ /* convert the string back to utf-8 */
+ result = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
- /* cleanup */
- g_free (converted);
+ /* cleanup */
+ g_free (converted);
- return result;
+ return result;
}
+/** tooltip functions **/
static gboolean
-xfce_clock_tooltip_timer_update (gpointer user_data)
+xfce_clock_tooltip_update (gpointer user_data)
{
- XfceClock *clock = XFCE_CLOCK (user_data);
- gchar *string;
- struct tm tm;
+ ClockPlugin *clock = (ClockPlugin *) user_data;
+ gchar *string;
+ struct tm tm;
- /* stop running this timeout */
- if (clock->tooltip_format == NULL)
- return FALSE;
+ if (G_UNLIKELY (clock->tooltip_format == NULL))
+ return TRUE;
- /* get the local time */
- xfce_clock_util_get_localtime (&tm);
+ /* get the local time */
+ xfce_clock_util_get_localtime (&tm);
- /* get the string */
- string = xfce_clock_util_strdup_strftime (clock->tooltip_format, &tm);
+ /* get the string */
+ string = xfce_clock_util_strdup_strftime (clock->tooltip_format, &tm);
-#if GTK_CHECK_VERSION (2,12,0)
- /* set the tooltip */
- gtk_widget_set_tooltip_text (GTK_WIDGET (clock), string);
-#else
- /* set the tooltip */
- if (G_LIKELY (shared_tooltips))
- gtk_tooltips_set_tip (shared_tooltips, GTK_WIDGET (clock), string, NULL);
-#endif
+ /* set the tooltip */
+ gtk_widget_set_tooltip_text (clock->ebox, string);
- /* cleanup */
- g_free (string);
+ /* cleanup */
+ g_free (string);
- return TRUE;
+ return TRUE;
}
static gboolean
-xfce_clock_tooltip_timer_sync (gpointer user_data)
+xfce_clock_tooltip_sync_timeout (gpointer user_data)
{
- XfceClock *clock = XFCE_CLOCK (user_data);
+ ClockPlugin *clock = (ClockPlugin *) user_data;
- /* start the tooltip update interval */
- clock->tooltip_timer_id = clock_timeout_add (clock->tooltip_interval, xfce_clock_tooltip_timer_update, clock);
+ /* start the tooltip update interval */
+ clock->clock_timeout_id = g_timeout_add (clock->tooltip_interval, xfce_clock_tooltip_update, clock);
- /* manual update for this interval */
- xfce_clock_tooltip_timer_update (XFCE_CLOCK (user_data));
+ /* manual update for this timeout */
+ xfce_clock_tooltip_update (clock);
- /* stop the sync timeout */
- return FALSE;
+ /* stop the sync timeout */
+ return FALSE;
}
void
-xfce_clock_tooltip_timer (XfceClock *clock)
+xfce_clock_tooltip_sync (ClockPlugin *clock)
{
- guint interval;
-
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
+ guint interval;
- /* stop a running timeout */
- if (clock->tooltip_timer_id != 0)
+ if (clock->tooltip_timeout_id)
{
- g_source_remove (clock->tooltip_timer_id);
- clock->tooltip_timer_id = 0;
+ /* stop old and reset timeout */
+ g_source_remove (clock->tooltip_timeout_id);
+ clock->tooltip_timeout_id = 0;
}
- /* start a new timeout if there is a format string */
- if (clock->tooltip_format != NULL)
- {
- /* detect the tooltip interval from the string */
- clock->tooltip_interval = xfce_clock_util_interval_from_format (clock->tooltip_format);
+ /* detect the tooltip interval from the string */
+ clock->tooltip_interval = xfce_clock_util_interval_from_format (clock->tooltip_format);
- /* get the interval to the next update */
- interval = xfce_clock_util_sync_interval (clock->tooltip_interval);
+ /* get the interval to the next update */
+ interval = xfce_clock_util_next_interval (clock->tooltip_interval);
- /* start the sync timeout (loosy timer) */
- clock->tooltip_timer_id = clock_timeout_add (interval, xfce_clock_tooltip_timer_sync, clock);
+ /* start the sync timeout */
+ clock->tooltip_timeout_id = g_timeout_add (interval, xfce_clock_tooltip_sync_timeout, clock);
- /* update the tooltip (if reasonable) */
- if (interval >= CLOCK_INTERVAL_SECOND)
- xfce_clock_tooltip_timer_update (clock);
- }
- else
- {
-#if GTK_CHECK_VERSION (2,12,0)
- /* unset the tooltip */
- gtk_widget_set_tooltip_text (GTK_WIDGET (clock), NULL);
-#else
- /* unset the tooltip */
- if (G_LIKELY (shared_tooltips))
- gtk_tooltips_set_tip (shared_tooltips, GTK_WIDGET (clock), NULL, NULL);
-#endif
- }
+ /* update the tooltip */
+ xfce_clock_tooltip_update (clock);
}
+/** clock widget functions **/
static gboolean
-xfce_clock_widget_timer_sync (gpointer user_data)
+xfce_clock_widget_sync_timeout (gpointer user_data)
{
- XfceClock *clock = XFCE_CLOCK (user_data);
+ ClockPlugin *clock = (ClockPlugin *) user_data;
- if (G_LIKELY (clock->widget
- && clock->update_func != NULL
- && clock->widget_interval > 0))
+ if (G_LIKELY (clock->widget))
{
- /* start the clock update timeout */
- clock->widget_timer_id = clock_timeout_add (clock->widget_interval, clock->update_func, clock->widget);
+ /* start the clock update timeout */
+ clock->clock_timeout_id = g_timeout_add (clock->interval, clock->update, clock->widget);
- /* manual update for this interval */
- (*clock->update_func) (GTK_WIDGET (clock->widget));
+ /* manual update for this interval */
+ (clock->update) (clock->widget);
}
- else
+ else
{
- /* remove timer id */
- clock->widget_timer_id = 0;
+ /* remove timer id */
+ clock->clock_timeout_id = 0;
}
- /* stop the sync timeout */
- return FALSE;
+ /* stop the sync timeout */
+ return FALSE;
}
void
-xfce_clock_widget_timer (XfceClock *clock)
+xfce_clock_widget_sync (ClockPlugin *clock)
{
- guint interval;
-
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
+ guint interval;
- /* stop a running timeout */
- if (clock->widget_timer_id != 0)
+ if (clock->clock_timeout_id)
{
- g_source_remove (clock->widget_timer_id);
- clock->widget_timer_id = 0;
+ /* stop old and reset timeout */
+ g_source_remove (clock->clock_timeout_id);
+ clock->clock_timeout_id = 0;
}
- if (G_LIKELY (clock->widget))
+ if (G_LIKELY (clock->widget))
{
- /* get the interval to the next update */
- interval = xfce_clock_util_sync_interval (clock->widget_interval);
+ /* get the interval to the next update */
+ interval = xfce_clock_util_next_interval (clock->interval);
- /* start the sync timeout (use precision timer) */
- clock->widget_timer_id = g_timeout_add (interval, xfce_clock_widget_timer_sync, clock);
-
- /* manual update if reasonable */
- if (interval >= CLOCK_INTERVAL_SECOND)
- (*clock->update_func) (GTK_WIDGET (clock->widget));
+ /* start the sync timeout */
+ clock->clock_timeout_id = g_timeout_add (interval, xfce_clock_widget_sync_timeout, clock);
}
}
void
-xfce_clock_widget_update_properties (XfceClock *clock)
+xfce_clock_widget_update_settings (ClockPlugin *clock)
{
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
- panel_return_if_fail (clock->widget != NULL);
-
- /* leave when there is no widget */
- if (clock->widget == NULL)
- return;
+ g_return_if_fail (clock->widget != NULL);
- /* send the settings based on the clock mode */
- switch (clock->mode)
+ /* send the settings based on the clock mode */
+ switch (clock->mode)
{
- case XFCE_CLOCK_MODE_ANALOG:
- /* set settings */
- g_object_set (G_OBJECT (clock->widget),
- "show-seconds", clock->show_seconds, NULL);
- break;
-
- case XFCE_CLOCK_MODE_BINARY:
- /* set settings */
- g_object_set (G_OBJECT (clock->widget),
- "show-seconds", clock->show_seconds,
- "true-binary", clock->true_binary, NULL);
- break;
-
- case XFCE_CLOCK_MODE_DIGITAL:
- /* set settings */
- g_object_set (G_OBJECT (clock->widget),
- "digital-format", clock->digital_format, NULL);
- break;
-
- case XFCE_CLOCK_MODE_LCD:
- /* set settings */
- g_object_set (G_OBJECT (clock->widget),
- "show-seconds", clock->show_seconds,
- "show-military", clock->show_military,
- "show-meridiem", clock->show_meridiem,
- "flash-separators", clock->flash_separators, NULL);
- break;
+ case XFCE_CLOCK_ANALOG:
+ /* set settings */
+ g_object_set (G_OBJECT (clock->widget),
+ "show-seconds", clock->show_seconds, NULL);
+ break;
+
+ case XFCE_CLOCK_BINARY:
+ /* set settings */
+ g_object_set (G_OBJECT (clock->widget),
+ "show-seconds", clock->show_seconds,
+ "true-binary", clock->true_binary, NULL);
+ break;
+
+ case XFCE_CLOCK_DIGITAL:
+ /* set settings */
+ g_object_set (G_OBJECT (clock->widget),
+ "digital-format", clock->digital_format, NULL);
+ break;
+
+ case XFCE_CLOCK_LCD:
+ /* set settings */
+ g_object_set (G_OBJECT (clock->widget),
+ "show-seconds", clock->show_seconds,
+ "show-military", clock->show_military,
+ "show-meridiem", clock->show_meridiem,
+ "flash-separators", clock->flash_separators, NULL);
+ break;
}
- /* get update interval */
- if (clock->mode == XFCE_CLOCK_MODE_DIGITAL)
+ /* get update interval */
+ if (clock->mode == XFCE_CLOCK_DIGITAL)
{
- /* get interval from string */
- clock->widget_interval = xfce_clock_util_interval_from_format (clock->digital_format);
+ /* get interval from string */
+ clock->interval = xfce_clock_util_interval_from_format (clock->digital_format);
}
- else
+ else
{
- /* interval from setting */
- if (clock->mode == XFCE_CLOCK_MODE_LCD)
- clock->widget_interval = (clock->show_seconds || clock->flash_separators) ? CLOCK_INTERVAL_SECOND : CLOCK_INTERVAL_MINUTE;
- else
- clock->widget_interval = clock->show_seconds ? CLOCK_INTERVAL_SECOND : CLOCK_INTERVAL_MINUTE;
+ /* interval from setting */
+ if (clock->mode == XFCE_CLOCK_LCD)
+ clock->interval = (clock->show_seconds || clock->flash_separators) ? CLOCK_INTERVAL_SECOND : CLOCK_INTERVAL_MINUTE;
+ else
+ clock->interval = clock->show_seconds ? CLOCK_INTERVAL_SECOND : CLOCK_INTERVAL_MINUTE;
}
}
void
-xfce_clock_widget_update_mode (XfceClock *clock)
+xfce_clock_widget_set_mode (ClockPlugin *clock)
{
- GtkWidget *widget = NULL;
+ GtkWidget *widget;
- panel_return_if_fail (XFCE_IS_CLOCK (clock));
+ /* stop runing timeout */
+ if (clock->clock_timeout_id)
+ {
+ g_source_remove (clock->clock_timeout_id);
+ clock->clock_timeout_id = 0;
+ }
- /* stop runing timeout */
- if (clock->widget_timer_id)
+ /* destroy the old widget */
+ if (clock->widget)
{
- g_source_remove (clock->widget_timer_id);
- clock->widget_timer_id = 0;
+ gtk_widget_destroy (clock->widget);
+ clock->widget = NULL;
}
- /* destroy the old widget */
- if (clock->widget)
+ switch (clock->mode)
{
- gtk_widget_destroy (clock->widget);
- clock->widget = NULL;
+ case XFCE_CLOCK_ANALOG:
+ widget = xfce_clock_analog_new ();
+ clock->update = xfce_clock_analog_update;
+ break;
+
+ case XFCE_CLOCK_BINARY:
+ widget = xfce_clock_binary_new ();
+ clock->update = xfce_clock_binary_update;
+ break;
+
+ case XFCE_CLOCK_DIGITAL:
+ widget = xfce_clock_digital_new ();
+ clock->update = xfce_clock_digital_update;
+ break;
+
+ case XFCE_CLOCK_LCD:
+ widget = xfce_clock_lcd_new ();
+ clock->update = xfce_clock_lcd_update;
+ break;
+
+ default:
+ g_error ("Unknown clock type");
+ return;
}
- /* create a new widget and set the update function */
- switch (clock->mode)
+ /* set the clock */
+ clock->widget = widget;
+
+ /* add and show the clock */
+ gtk_container_add (GTK_CONTAINER (clock->frame), widget);
+ gtk_widget_show (widget);
+}
+
+
+
+/** plugin functions **/
+static ClockPlugin *
+xfce_clock_plugin_init (XfcePanelPlugin *plugin)
+{
+ ClockPlugin *clock;
+
+ /* create structure */
+ clock = g_slice_new0 (ClockPlugin);
+
+ /* set plugin */
+ clock->plugin = plugin;
+
+ /* initialize */
+ clock->clock_timeout_id = 0;
+ clock->tooltip_timeout_id = 0;
+ clock->widget = NULL;
+ clock->tooltip_format = NULL;
+ clock->digital_format = NULL;
+
+ /* read the user settings */
+ xfce_clock_plugin_read (clock);
+
+ /* build widgets */
+ clock->ebox = gtk_event_box_new ();
+ gtk_container_add (GTK_CONTAINER (plugin), clock->ebox);
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (clock->ebox), FALSE);
+ gtk_widget_show (clock->ebox);
+
+ clock->frame = gtk_frame_new (NULL);
+ gtk_container_add (GTK_CONTAINER (clock->ebox), clock->frame);
+ gtk_frame_set_shadow_type (GTK_FRAME (clock->frame), clock->show_frame ? GTK_SHADOW_IN : GTK_SHADOW_NONE);
+ gtk_widget_show (clock->frame);
+
+ /* set the clock */
+ xfce_clock_widget_set_mode (clock);
+
+ /* set the clock settings */
+ xfce_clock_widget_update_settings (clock);
+
+ /* start the timeout */
+ xfce_clock_widget_sync (clock);
+
+ /* start the tooltip sync */
+ xfce_clock_tooltip_sync (clock);
+
+ return clock;
+}
+
+
+
+gboolean
+xfce_clock_plugin_set_size (ClockPlugin *clock,
+ guint size)
+{
+ GtkOrientation orientation;
+
+ /* set the frame border */
+ gtk_container_set_border_width (GTK_CONTAINER (clock->frame), size > 26 ? 1 : 0);
+
+ /* get the clock size */
+ size -= size > 26 ? 6 : 4;
+
+ /* get plugin orientation */
+ orientation = xfce_panel_plugin_get_orientation (clock->plugin);
+
+ /* set the clock size */
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ gtk_widget_set_size_request (clock->widget, -1, size);
+ else
+ gtk_widget_set_size_request (clock->widget, size, -1);
+
+ return TRUE;
+}
+
+
+
+static void
+xfce_clock_plugin_read (ClockPlugin *clock)
+{
+ gchar *filename;
+ const gchar *value;
+ XfceRc *rc;
+
+ /* config filename */
+ filename = xfce_panel_plugin_lookup_rc_file (clock->plugin);
+
+ if (G_LIKELY (filename))
{
- case XFCE_CLOCK_MODE_ANALOG:
- widget = xfce_clock_analog_new ();
- clock->update_func = xfce_clock_analog_update;
- break;
-
- case XFCE_CLOCK_MODE_BINARY:
- widget = xfce_clock_binary_new ();
- clock->update_func = xfce_clock_binary_update;
- break;
-
- case XFCE_CLOCK_MODE_DIGITAL:
- widget = xfce_clock_digital_new ();
- clock->update_func = xfce_clock_digital_update;
- break;
-
- case XFCE_CLOCK_MODE_LCD:
- widget = xfce_clock_lcd_new ();
- clock->update_func = xfce_clock_lcd_update;
- break;
-
- default:
- panel_assert_not_reached ();
- return;
+ /* open rc file (readonly) and cleanup */
+ rc = xfce_rc_simple_open (filename, TRUE);
+ g_free (filename);
+
+ if (G_LIKELY (rc))
+ {
+ /* read strings */
+ value = xfce_rc_read_entry (rc, "DigitalFormat", DEFAULT_DIGITAL_FORMAT);
+ if (G_LIKELY (value != NULL && *value != '\0'))
+ clock->digital_format = g_strdup (value);
+
+ value = xfce_rc_read_entry (rc, "TooltipFormat", DEFAULT_TOOLTIP_FORMAT);
+ if (G_LIKELY (value != NULL && *value != '\0'))
+ clock->tooltip_format = g_strdup (value);
+
+ /* read clock type */
+ clock->mode = xfce_rc_read_int_entry (rc, "ClockType", XFCE_CLOCK_DIGITAL);
+
+ /* read boolean settings */
+ clock->show_frame = xfce_rc_read_bool_entry (rc, "ShowFrame", TRUE);
+ clock->show_seconds = xfce_rc_read_bool_entry (rc, "ShowSeconds", FALSE);
+ clock->show_military = xfce_rc_read_bool_entry (rc, "ShowMilitary", TRUE);
+ clock->show_meridiem = xfce_rc_read_bool_entry (rc, "ShowMeridiem", FALSE);
+ clock->true_binary = xfce_rc_read_bool_entry (rc, "TrueBinary", FALSE);
+ clock->flash_separators = xfce_rc_read_bool_entry (rc, "FlashSeparators", FALSE);
+
+ /* close the rc file */
+ xfce_rc_close (rc);
+ }
}
+}
+
+
+
+static void
+xfce_clock_plugin_write (ClockPlugin *clock)
+{
+ gchar *filename;
+ XfceRc *rc;
- /* set the new widget */
- if (G_LIKELY (widget))
+ /* config filename */
+ filename = xfce_panel_plugin_save_location (clock->plugin, TRUE);
+
+ if (G_LIKELY (filename))
{
- clock->widget = widget;
- gtk_container_add (GTK_CONTAINER (clock->frame), widget);
- gtk_widget_show (widget);
+ /* open rc file and cleanup */
+ rc = xfce_rc_simple_open (filename, FALSE);
+ g_free (filename);
+
+ if (G_LIKELY (rc))
+ {
+ /* write settings */
+ if (G_LIKELY (clock->digital_format && *clock->digital_format != '\0'))
+ xfce_rc_write_entry (rc, "DigitalFormat", clock->digital_format);
+
+ if (G_LIKELY (clock->tooltip_format && *clock->tooltip_format != '\0'))
+ xfce_rc_write_entry (rc, "TooltipFormat", clock->tooltip_format);
+
+ xfce_rc_write_int_entry (rc, "ClockType", clock->mode);
+ xfce_rc_write_bool_entry (rc, "ShowFrame", clock->show_frame);
+ xfce_rc_write_bool_entry (rc, "ShowSeconds", clock->show_seconds);
+ xfce_rc_write_bool_entry (rc, "ShowMilitary", clock->show_military);
+ xfce_rc_write_bool_entry (rc, "ShowMeridiem", clock->show_meridiem);
+ xfce_rc_write_bool_entry (rc, "TrueBinary", clock->true_binary);
+ xfce_rc_write_bool_entry (rc, "FlashSeparators", clock->flash_separators);
+
+ /* close the rc file */
+ xfce_rc_close (rc);
+ }
}
}
-G_MODULE_EXPORT void
-xfce_panel_plugin_register_types (XfcePanelModule *panel_module)
+static void
+xfce_clock_plugin_free (ClockPlugin *clock)
{
- panel_return_if_fail (G_IS_TYPE_MODULE (panel_module));
+ GtkWidget *dialog;
- /* register the types */
- xfce_clock_register_type (panel_module);
- xfce_clock_analog_register_type (panel_module);
- xfce_clock_binary_register_type (panel_module);
- xfce_clock_digital_register_type (panel_module);
- xfce_clock_lcd_register_type (panel_module);
+ /* stop timeouts */
+ if (G_LIKELY (clock->clock_timeout_id))
+ g_source_remove (clock->clock_timeout_id);
- //g_message ("Clock types registered");
+ if (G_LIKELY (clock->tooltip_timeout_id))
+ g_source_remove (clock->tooltip_timeout_id);
+
+ /* destroy the configure dialog if it's still open */
+ dialog = g_object_get_data (G_OBJECT (clock->plugin), I_("configure-dialog"));
+ if (G_UNLIKELY (dialog != NULL))
+ gtk_widget_destroy (dialog);
+
+ /* cleanup */
+ g_free (clock->tooltip_format);
+ g_free (clock->digital_format);
+
+ /* free structure */
+ g_slice_free (ClockPlugin, clock);
}
-XFCE_PANEL_PLUGIN_REGISTER_OBJECT (XFCE_TYPE_CLOCK)
+
+static void
+xfce_clock_plugin_construct (XfcePanelPlugin *plugin)
+{
+ ClockPlugin *clock = xfce_clock_plugin_init (plugin);
+
+ /* plugin settings */
+ xfce_panel_plugin_add_action_widget (plugin, clock->ebox);
+ xfce_panel_plugin_menu_show_configure (plugin);
+
+ /* connect signals */
+ g_signal_connect_swapped (G_OBJECT (plugin), "size-changed", G_CALLBACK (xfce_clock_plugin_set_size), clock);
+ g_signal_connect_swapped (G_OBJECT (plugin), "save", G_CALLBACK (xfce_clock_plugin_write), clock);
+ g_signal_connect_swapped (G_OBJECT (plugin), "free-data", G_CALLBACK (xfce_clock_plugin_free), clock);
+ g_signal_connect_swapped (G_OBJECT (plugin), "configure-plugin", G_CALLBACK (xfce_clock_dialog_show), clock);
+}
+
diff --git a/plugins/clock/clock.h b/plugins/clock/clock.h
index bc84188..ebba7fe 100644
--- a/plugins/clock/clock.h
+++ b/plugins/clock/clock.h
@@ -1,6 +1,6 @@
/* $Id$ */
/*
- * Copyright (c) 2007-2008 Nick Schermer <nick at xfce.org>
+ * Copyright (c) 2007 Nick Schermer <nick at xfce.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -26,100 +26,79 @@
G_BEGIN_DECLS
-/* clock intervals in ms */
#define CLOCK_INTERVAL_SECOND (1000)
-#define CLOCK_INTERVAL_MINUTE (60 * CLOCK_INTERVAL_SECOND)
-#define CLOCK_INTERVAL_HOUR (60 * CLOCK_INTERVAL_MINUTE)
+#define CLOCK_INTERVAL_MINUTE (60 * 1000)
+#define CLOCK_INTERVAL_HOUR (3600 * 1000)
-/* default values */
#define BUFFER_SIZE 256
#define DEFAULT_TOOLTIP_FORMAT "%A %d %B %Y"
#define DEFAULT_DIGITAL_FORMAT "%R"
-/* allow timer grouping to save resources */
-#if GLIB_CHECK_VERSION (2,14,0)
-#define clock_timeout_add(interval, function, data) \
- g_timeout_add_seconds ((interval) / 1000, function, data)
-#else
-#define clock_timeout_add(interval, function, data) \
- g_timeout_add (interval, function, data)
-#endif
-typedef struct _XfceClockClass XfceClockClass;
-typedef struct _XfceClock XfceClock;
-typedef enum _XfceClockMode XfceClockMode;
+typedef struct _ClockPlugin ClockPlugin;
+typedef enum _ClockPluginMode ClockPluginMode;
-#define XFCE_TYPE_CLOCK (xfce_clock_get_type ())
-#define XFCE_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_CLOCK, XfceClock))
-#define XFCE_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_CLOCK, XfceClockClass))
-#define XFCE_IS_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_CLOCK))
-#define XFCE_IS_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_CLOCK))
-#define XFCE_CLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_CLOCK, XfceClockClass))
-
-enum _XfceClockMode
-{
- XFCE_CLOCK_MODE_ANALOG = 0,
- XFCE_CLOCK_MODE_BINARY,
- XFCE_CLOCK_MODE_DIGITAL,
- XFCE_CLOCK_MODE_LCD
-};
-
-struct _XfceClockClass
+enum _ClockPluginMode
{
- XfcePanelPluginClass __parent__;
+ XFCE_CLOCK_ANALOG = 0,
+ XFCE_CLOCK_BINARY,
+ XFCE_CLOCK_DIGITAL,
+ XFCE_CLOCK_LCD
};
-struct _XfceClock
+struct _ClockPlugin
{
- XfcePanelPlugin __parent__;
-
- GtkWidget *frame;
- GtkWidget *widget;
-
- /* active clock */
- XfceClockMode mode;
-
- /* widget timer update */
- GSourceFunc update_func;
- guint widget_interval;
- guint widget_timer_id;
-
- /* tooltip timer update */
- guint tooltip_interval;
- guint tooltip_timer_id;
-
- /* settings */
- gchar *tooltip_format;
- gchar *digital_format;
- guint show_frame : 1;
- guint show_seconds : 1;
- guint show_military : 1;
- guint show_meridiem : 1;
- guint true_binary : 1;
- guint flash_separators : 1;
+ /* plugin */
+ XfcePanelPlugin *plugin;
+
+ /* widgets */
+ GtkWidget *ebox;
+ GtkWidget *frame;
+ GtkWidget *widget;
+
+ /* clock update function and timeout */
+ GSourceFunc update;
+ guint interval;
+
+ /* tooltip interval */
+ guint tooltip_interval;
+
+ /* clock type */
+ ClockPluginMode mode;
+
+ /* timeouts */
+ guint clock_timeout_id;
+ guint tooltip_timeout_id;
+
+ /* settings */
+ gchar *tooltip_format;
+ gchar *digital_format;
+ guint show_frame : 1;
+ guint show_seconds : 1;
+ guint show_military : 1;
+ guint show_meridiem : 1;
+ guint true_binary : 1;
+ guint flash_separators : 1;
};
-GType xfce_clock_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
-
-void xfce_clock_register_type (XfcePanelModule *panel_module) G_GNUC_INTERNAL;
-
-void xfce_clock_save (XfcePanelPlugin *plugin);
+void xfce_clock_util_get_localtime (struct tm *tm) G_GNUC_INTERNAL;
-void xfce_clock_util_get_localtime (struct tm *tm) G_GNUC_INTERNAL;
+gchar *xfce_clock_util_strdup_strftime (const gchar *format,
+ const struct tm *tm) G_GNUC_MALLOC G_GNUC_INTERNAL;
-gchar *xfce_clock_util_strdup_strftime (const gchar *format,
- const struct tm *tm) G_GNUC_MALLOC G_GNUC_INTERNAL;
+void xfce_clock_tooltip_sync (ClockPlugin *clock) G_GNUC_INTERNAL;
-void xfce_clock_tooltip_timer (XfceClock *clock) G_GNUC_INTERNAL;
+void xfce_clock_widget_sync (ClockPlugin *clock) G_GNUC_INTERNAL;
-void xfce_clock_widget_timer (XfceClock *clock) G_GNUC_INTERNAL;
+void xfce_clock_widget_update_settings (ClockPlugin *clock) G_GNUC_INTERNAL;
-void xfce_clock_widget_update_properties (XfceClock *clock) G_GNUC_INTERNAL;
+void xfce_clock_widget_set_mode (ClockPlugin *clock) G_GNUC_INTERNAL;
-void xfce_clock_widget_update_mode (XfceClock *clock) G_GNUC_INTERNAL;
+gboolean xfce_clock_plugin_set_size (ClockPlugin *clock,
+ guint size) G_GNUC_INTERNAL;
G_END_DECLS
diff --git a/plugins/systray/systray.desktop.in.in b/plugins/systray/systray.desktop.in.in
index 32b7dc4..e4cdc7d 100644
--- a/plugins/systray/systray.desktop.in.in
+++ b/plugins/systray/systray.desktop.in.in
@@ -6,4 +6,4 @@ _Comment=Area where notification icons appear
Icon=applications-system
X-XFCE-Module=systray
X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins
-X-XFCE-External=TRUE
+X-XFCE-External=FALSE
diff --git a/plugins/systray/xfce-tray-manager.c b/plugins/systray/xfce-tray-manager.c
index ca3ae36..41ad944 100644
--- a/plugins/systray/xfce-tray-manager.c
+++ b/plugins/systray/xfce-tray-manager.c
@@ -692,32 +692,6 @@ xfce_tray_manager_handle_cancel_message (XfceTrayManager *manager,
}
#endif
-void
-_set_source_rgba (cairo_t *cr,
- GdkColor *color,
- gdouble alpha)
-{
- panel_return_if_fail (alpha >= 0.00 && alpha <= 1.00);
-
- if (alpha == 1.00)
- {
- /* set normal source color */
- cairo_set_source_rgb (cr,
- color->red / 65535.00,
- color->green / 65535.00,
- color->blue / 65535.00);
- }
- else
- {
- /* set source color with alpha */
- cairo_set_source_rgba (cr,
- color->red / 65535.00,
- color->green / 65535.00,
- color->blue / 65535.00,
- alpha);
- }
-}
-
static void
@@ -736,7 +710,6 @@ xfce_tray_manager_handle_dock_request (XfceTrayManager *manager,
/* allow applications to draw on this widget */
gtk_widget_set_app_paintable (socket, TRUE);
- gtk_widget_set_double_buffered (socket, FALSE);
/* allocate and set the xwindow */
xwindow = g_new (Window, 1);
diff --git a/wrapper/Makefile.am b/wrapper/Makefile.am
index 7a06536..a0ecf87 100644
--- a/wrapper/Makefile.am
+++ b/wrapper/Makefile.am
@@ -14,15 +14,20 @@ INCLUDES = \
libexec_PROGRAMS = \
xfce4-panel-wrapper
+xfce4_panel_wrapper_built_sources = \
+ wrapper-dbus-client-infos.h \
+ wrapper-marshal.h \
+ wrapper-marshal.c
+
xfce4_panel_wrapper_SOURCES = \
+ $(xfce4_panel_wrapper_built_sources) \
main.c \
- wrapper-module.c \
- wrapper-module.h \
wrapper-plug.c \
wrapper-plug.h
xfce4_panel_wrapper_CFLAGS = \
$(GTK_CFLAGS) \
+ $(DBUS_CFLAGS) \
$(GMODULE_CFLAGS) \
$(GTHREAD_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS) \
@@ -35,6 +40,7 @@ xfce4_panel_wrapper_LDFLAGS = \
xfce4_panel_wrapper_LDADD = \
$(top_builddir)/libxfce4panel/libxfce4panel.la \
$(GTK_LIBS) \
+ $(DBUS_LIBS) \
$(GMODULE_LIBS) \
$(GTHREAD_LIBS) \
$(LIBXFCE4UTIL_LIBS)
@@ -42,4 +48,22 @@ xfce4_panel_wrapper_LDADD = \
xfce4_panel_wrapper_DEPENDENCIES = \
$(top_builddir)/libxfce4panel/libxfce4panel.la
+if MAINTAINER_MODE
+wrapper-dbus-client-infos.h: $(top_builddir)/panel/panel-dbus-service-infos.xml Makefile
+ dbus-binding-tool --mode=glib-client $< \
+ | sed -e 's/_panel_dbus_client/wrapper_dbus_client/g' > $@
+
+wrapper-marshal.h: $(top_builddir)/panel/panel-marshal.list Makefile
+ glib-genmarshal --header --prefix=wrapper_marshal $< > $@
+
+wrapper-marshal.c: $(top_builddir)/panel/panel-marshal.list Makefile
+ glib-genmarshal --body --prefix=wrapper_marshal $< > $@
+
+BUILT_SOURCES = \
+ $(xfce4_panel_wrapper_built_sources)
+
+DISTCLEANFILES = \
+ $(xfce4_panel_wrapper_built_sources)
+endif
+
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/wrapper/main.c b/wrapper/main.c
index 7cc48d7..6e7c5e8 100644
--- a/wrapper/main.c
+++ b/wrapper/main.c
@@ -27,23 +27,29 @@
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
#include <gtk/gtk.h>
+#include <dbus/dbus-glib.h>
#include <libxfce4util/libxfce4util.h>
#include <libxfce4panel/libxfce4panel.h>
#include <libxfce4panel/xfce-panel-plugin-provider.h>
-#include <wrapper/wrapper-module.h>
#include <wrapper/wrapper-plug.h>
+#include <wrapper/wrapper-marshal.h>
+#include <wrapper/wrapper-dbus-client-infos.h>
-static gchar *opt_name = NULL;
-static gchar *opt_display_name = NULL;
-static gchar *opt_id = NULL;
-static gchar *opt_filename = NULL;
-static gint opt_socket_id = 0;
-static gchar **opt_arguments = NULL;
+static gchar *opt_name = NULL;
+static gchar *opt_display_name = NULL;
+static gchar *opt_id = NULL;
+static gchar *opt_filename = NULL;
+static gint opt_socket_id = 0;
+static gchar **opt_arguments = NULL;
+static GQuark plug_quark = 0;
@@ -60,14 +66,157 @@ static GOptionEntry option_entries[] =
+static void
+dbus_proxy_provider_property_changed (DBusGProxy *dbus_proxy,
+ const gchar *plugin_id,
+ const gchar *property,
+ const GValue *value,
+ XfcePanelPluginProvider *provider)
+{
+ WrapperPlug *plug;
+
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+ /* check if the signal is for this panel */
+ if (strcmp (plugin_id, xfce_panel_plugin_provider_get_id (provider)) != 0)
+ return;
+
+ g_message ("Wrapper %s received property %s", plugin_id, property);
+
+ /* handle the property */
+ if (G_UNLIKELY (property == NULL))
+ g_message ("External plugin '%s' received null property", plugin_id);
+ else if (strcmp (property, "Size") == 0)
+ xfce_panel_plugin_provider_set_size (provider, g_value_get_int (value));
+ else if (strcmp (property, "Orientation") == 0)
+ xfce_panel_plugin_provider_set_orientation (provider, g_value_get_uint (value));
+ else if (strcmp (property, "ScreenPosition") == 0)
+ xfce_panel_plugin_provider_set_screen_position (provider, g_value_get_uint (value));
+ else if (strcmp (property, "Save") == 0)
+ xfce_panel_plugin_provider_save (provider);
+ else if (strcmp (property, "Quit") == 0)
+ gtk_main_quit ();
+ else if (strcmp (property, "Sensitive") == 0)
+ gtk_widget_set_sensitive (GTK_WIDGET (provider), g_value_get_boolean (value));
+ else
+ {
+ /* get the plug */
+ plug = g_object_get_qdata (G_OBJECT (provider), plug_quark);
+
+ if (strcmp (property, "BackgroundAlpha") == 0)
+ wrapper_plug_set_background_alpha (plug, g_value_get_int (value) / 100.00);
+ else if (strcmp (property, "ActivePanel") == 0)
+ wrapper_plug_set_selected (plug, g_value_get_boolean (value));
+ else
+ g_message ("External plugin '%s' received unknown property '%s'", plugin_id, property);
+ }
+}
+
+
+
+static void
+dbus_proxy_provider_expand_changed (XfcePanelPluginProvider *provider,
+ gboolean expand,
+ DBusGProxy *dbus_proxy)
+{
+ GValue value = { 0, };
+
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+ /* init the value */
+ g_value_init (&value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&value, expand);
+
+ /* call */
+ wrapper_dbus_client_set_property (dbus_proxy,
+ xfce_panel_plugin_provider_get_id (provider),
+ "Expand", &value, NULL);
+
+ /* unset */
+ g_value_unset (&value);
+}
+
+
+
+static void
+dbus_proxy_provider_move_item (XfcePanelPluginProvider *provider,
+ DBusGProxy *dbus_proxy)
+{
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+ /* call */
+ wrapper_dbus_client_set_property (dbus_proxy,
+ xfce_panel_plugin_provider_get_id (provider),
+ "MoveItem", NULL, NULL);
+}
+
+
+
+static void
+dbus_proxy_provider_add_new_items (XfcePanelPluginProvider *provider,
+ DBusGProxy *dbus_proxy)
+{
+ gchar *name;
+
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+ /* create a screen name */
+ name = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (provider)));
+
+ /* call */
+ wrapper_dbus_client_display_items_dialog (dbus_proxy, name, NULL);
+
+ /* cleanup */
+ g_free (name);
+}
+
+
+
+static void
+dbus_proxy_provider_panel_preferences (XfcePanelPluginProvider *provider,
+ DBusGProxy *dbus_proxy)
+{
+ gchar *name;
+
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+ /* create a screen name */
+ name = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (provider)));
+
+ /* call */
+ wrapper_dbus_client_display_preferences_dialog (dbus_proxy, name, NULL);
+
+ /* cleanup */
+ g_free (name);
+}
+
+
+
+static void
+dbus_proxy_provider_remove (XfcePanelPluginProvider *provider,
+ DBusGProxy *dbus_proxy)
+{
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+ /* call */
+ wrapper_dbus_client_set_property (dbus_proxy,
+ xfce_panel_plugin_provider_get_id (provider),
+ "Remove", NULL, NULL);
+}
+
+
+
gint
main (gint argc, gchar **argv)
{
GError *error = NULL;
XfcePanelPluginProvider *provider;
- GtkWidget *plug;
- WrapperModule *module;
- gboolean succeed = FALSE;
+ GModule *module;
+ PluginConstructFunc construct_func;
+ DBusGConnection *dbus_connection;
+ DBusGProxy *dbus_proxy;
+ WrapperPlug *plug;
+ GValue value = { 0, };
/* set translation domain */
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
@@ -95,48 +244,146 @@ main (gint argc, gchar **argv)
return EXIT_FAILURE;
}
- /* check arguments */
- if (opt_filename == NULL || opt_socket_id == 0 || opt_name == NULL || opt_id == NULL || opt_display_name == NULL)
+ /* check if the module exists */
+ if (opt_filename == NULL || *opt_filename == '\0'
+ || g_file_test (opt_filename, G_FILE_TEST_EXISTS) == FALSE)
{
/* print error */
- g_critical ("One of the required arguments for the wrapper is missing");
+ g_critical ("Unable to find plugin module '%s'.", opt_filename);
/* leave */
return EXIT_FAILURE;
}
- /* try to create a wrapper module */
- module = wrapper_module_new (opt_filename, opt_name);
- if (G_LIKELY (module != NULL))
+ /* check if all the other arguments are defined */
+ if (opt_socket_id == 0
+ || opt_name == NULL || *opt_name == '\0'
+ || opt_id == NULL || *opt_id == '\0'
+ || opt_display_name == NULL || *opt_display_name == '\0')
{
- /* try to create the panel plugin */
- provider = wrapper_module_create_plugin (module, opt_name, opt_id, opt_display_name, opt_arguments);
- if (G_LIKELY (provider != NULL))
- {
- /* create the plug */
- plug = wrapper_plug_new (opt_socket_id, provider);
- gtk_container_add (GTK_CONTAINER (plug), GTK_WIDGET (provider));
- gtk_widget_show (plug);
+ /* print error */
+ g_critical ("One of the required arguments is missing.");
- /* realize the plugin */
- gtk_widget_show (GTK_WIDGET (provider));
+ /* leave */
+ return EXIT_FAILURE;
+ }
- /* everything worked fine */
- succeed = TRUE;
+ /* try to connect to dbus */
+ dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (G_UNLIKELY (dbus_connection == NULL))
+ {
+ /* print error */
+ g_critical ("Failed to connect to dbus: %s", error->message);
- /* enter the mainloop */
- gtk_main ();
+ /* cleanup */
+ g_error_free (error);
- /* destroy the plug (and provider) */
- gtk_widget_destroy (plug);
+ /* leave */
+ return EXIT_FAILURE;
+ }
+
+ /* get the dbus proxy */
+ dbus_proxy = dbus_g_proxy_new_for_name (dbus_connection, "org.xfce.Panel", "/org/xfce/Panel", "org.xfce.Panel");
+ if (G_UNLIKELY (dbus_proxy == NULL))
+ {
+ /* print error */
+ g_critical ("Failed to create the dbus proxy: %s", error->message);
+
+ /* cleanup */
+ g_object_unref (G_OBJECT (dbus_connection));
+ g_error_free (error);
- /* decrease the module use count */
- g_type_module_unuse (G_TYPE_MODULE (module));
+ /* leave */
+ return EXIT_FAILURE;
+ }
+
+ /* setup signal for property changes */
+ dbus_g_object_register_marshaller (wrapper_marshal_VOID__STRING_STRING_BOXED, G_TYPE_NONE,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (dbus_proxy, "PropertyChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
+
+ /* load the module and link the function */
+ module = g_module_open (opt_filename, 0);
+ if (G_LIKELY (module))
+ {
+ /* get the contruct symbol */
+ if (!g_module_symbol (module, "xfce_panel_plugin_construct", (gpointer) &construct_func))
+ {
+ /* print error */
+ g_critical ("Plugin '%s' lacks a required symbol: %s.", opt_name, g_module_error ());
+
+ /* close the module */
+ g_module_close (module);
+
+ /* leave */
+ return EXIT_FAILURE;
}
+ }
+ else
+ {
+ /* print error */
+ g_critical ("Unable to load the plugin module '%s': %s.", opt_name, g_module_error ());
+
+ /* leave */
+ return EXIT_FAILURE;
+ }
+
+ /* contruct the panel plugin */
+ provider = (*construct_func) (opt_name, opt_id, opt_display_name, opt_arguments, gdk_screen_get_default ());
+ if (G_LIKELY (provider))
+ {
+ /* create quark */
+ plug_quark = g_quark_from_static_string ("plug-quark");
- /* g_object_unref for the module doesn't work,
- * so we don't do that... */
+ /* create the wrapper plug (a gtk plug with transparency capabilities) */
+ plug = wrapper_plug_new (opt_socket_id);
+ gtk_container_add (GTK_CONTAINER (plug), GTK_WIDGET (provider));
+ g_object_set_qdata (G_OBJECT (provider), plug_quark, plug);
+
+ /* connect provider signals */
+ g_signal_connect (G_OBJECT (provider), "expand-changed", G_CALLBACK (dbus_proxy_provider_expand_changed), dbus_proxy);
+ g_signal_connect (G_OBJECT (provider), "move-item", G_CALLBACK (dbus_proxy_provider_move_item), dbus_proxy);
+ g_signal_connect (G_OBJECT (provider), "add-new-items", G_CALLBACK (dbus_proxy_provider_add_new_items), dbus_proxy);
+ g_signal_connect (G_OBJECT (provider), "panel-preferences", G_CALLBACK (dbus_proxy_provider_panel_preferences), dbus_proxy);
+ g_signal_connect (G_OBJECT (provider), "destroy", G_CALLBACK (dbus_proxy_provider_remove), dbus_proxy);
+
+ /* connect dbus property change signal */
+ dbus_g_proxy_connect_signal (dbus_proxy, "PropertyChanged", G_CALLBACK (dbus_proxy_provider_property_changed), provider, NULL);
+
+ /* show the plugin */
+ gtk_widget_show (GTK_WIDGET (plug));
+ gtk_widget_show (GTK_WIDGET (provider));
+
+ /* register the plugin */
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_static_string (&value, opt_id);
+ wrapper_dbus_client_set_property (dbus_proxy, "XfcePanel", "RegisterPlugin", &value, NULL);
+ g_value_unset (&value);
+
+ /* enter the main loop */
+ gtk_main ();
+
+ /* unregister the plugin */
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_static_string (&value, opt_id);
+ wrapper_dbus_client_set_property (dbus_proxy, "XfcePanel", "UnregisterPlugin", &value, NULL);
+ g_value_unset (&value);
+
+ /* destroy the plug and provider */
+ gtk_widget_destroy (GTK_WIDGET (plug));
+ }
+ else
+ {
+ /* print error */
+ g_critical ("Failed to contruct the plugin '%s'.", opt_name);
}
- return succeed ? EXIT_SUCCESS : EXIT_FAILURE;
+ /* close the module */
+ g_module_close (module);
+
+ /* release dbus */
+ g_object_unref (G_OBJECT (dbus_proxy));
+ g_object_unref (G_OBJECT (dbus_connection));
+
+ return EXIT_SUCCESS;
}
diff --git a/wrapper/wrapper-module.c b/wrapper/wrapper-module.c
deleted file mode 100644
index a3789c1..0000000
--- a/wrapper/wrapper-module.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* $Id$ */
-/*
- * Copyright (C) 2008 Nick Schermer <nick at xfce.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gdk/gdk.h>
-#include <gmodule.h>
-#include <libxfce4util/libxfce4util.h>
-#include <libxfce4panel/libxfce4panel.h>
-#include <libxfce4panel/xfce-panel-plugin-provider.h>
-
-#include <wrapper/wrapper-module.h>
-
-
-
-static void wrapper_module_class_init (WrapperModuleClass *klass);
-static void wrapper_module_init (WrapperModule *module);
-static gboolean wrapper_module_load (GTypeModule *type_module);
-static void wrapper_module_unload (GTypeModule *type_module);
-
-
-
-struct _WrapperModuleClass
-{
- GTypeModuleClass __parent__;
-};
-
-struct _WrapperModule
-{
- GTypeModule __parent__;
-
- /* plugin library */
- GModule *library;
-
- /* plugin init function */
- PluginConstructFunc construct_func;
-
- /* the library location */
- const gchar *filename;
-};
-
-
-
-G_DEFINE_TYPE (WrapperModule, wrapper_module, G_TYPE_TYPE_MODULE);
-
-
-
-static void
-wrapper_module_class_init (WrapperModuleClass *klass)
-{
- GTypeModuleClass *gtype_module_class;
-
- gtype_module_class = G_TYPE_MODULE_CLASS (klass);
- gtype_module_class->load = wrapper_module_load;
- gtype_module_class->unload = wrapper_module_unload;
-}
-
-
-
-static void
-wrapper_module_init (WrapperModule *module)
-{
- /* initialize */
- module->library = NULL;
- module->construct_func = NULL;
- module->filename = NULL;
-}
-
-
-
-static gboolean
-wrapper_module_load (GTypeModule *type_module)
-{
- WrapperModule *module = WRAPPER_MODULE (type_module);
- PluginRegisterTypesFunc register_func;
-
- panel_return_val_if_fail (WRAPPER_IS_MODULE (module), FALSE);
- panel_return_val_if_fail (G_IS_TYPE_MODULE (module), FALSE);
-
- /* load the module */
- module->library = g_module_open (module->filename, G_MODULE_BIND_LOCAL);
- if (G_UNLIKELY (module->library == NULL))
- {
- g_critical ("Failed to load plugin '%s': %s", type_module->name, g_module_error ());
-
- return FALSE;
- }
-
- /* link the required construct function */
- if (!g_module_symbol (module->library, "xfce_panel_plugin_construct", (gpointer) &module->construct_func))
- {
- g_critical ("Plugin '%s' lacks required symbol: %s", type_module->name, g_module_error ());
-
- /* unload */
- wrapper_module_unload (type_module);
-
- return FALSE;
- }
-
- /* run the type register function if available */
- if (g_module_symbol (module->library, "xfce_panel_plugin_register_types", (gpointer) ®ister_func))
- (*register_func) (type_module);
-
- return TRUE;
-}
-
-
-
-static void
-wrapper_module_unload (GTypeModule *type_module)
-{
- WrapperModule *module = WRAPPER_MODULE (type_module);
-
- panel_return_if_fail (WRAPPER_IS_MODULE (module));
- panel_return_if_fail (G_IS_TYPE_MODULE (module));
-
- /* unload the library */
- g_module_close (module->library);
-
- /* reset plugin state */
- module->library = NULL;
- module->construct_func = NULL;
-}
-
-
-
-WrapperModule *
-wrapper_module_new (const gchar *filename,
- const gchar *name)
-{
- WrapperModule *module = NULL;
-
- panel_return_val_if_fail (filename != NULL && *filename != '\0', NULL);
-
- /* test if the library exists */
- if (G_LIKELY (g_file_test (filename, G_FILE_TEST_EXISTS)))
- {
- /* create new module */
- module = g_object_new (WRAPPER_TYPE_MODULE, NULL);
-
- /* set the module name */
- g_type_module_set_name (G_TYPE_MODULE (module), name);
-
- /* set library location */
- module->filename = filename;
- }
-
- return module;
-}
-
-
-
-XfcePanelPluginProvider *
-wrapper_module_create_plugin (WrapperModule *module,
- const gchar *name,
- const gchar *id,
- const gchar *display_name,
- gchar **arguments)
-{
- XfcePanelPluginProvider *provider = NULL;
-
- panel_return_val_if_fail (WRAPPER_IS_MODULE (module), NULL);
- panel_return_val_if_fail (name != NULL && *name != '\0', NULL);
- panel_return_val_if_fail (id != NULL && *id != '\0', NULL);
-
- /* increase the module use count */
- g_type_module_use (G_TYPE_MODULE (module));
-
- if (G_LIKELY (module->library))
- {
- /* debug check */
- panel_return_val_if_fail (module->construct_func != NULL, NULL);
-
- /* create a new panel plugin */
- provider = (*module->construct_func) (name, id, display_name, arguments, gdk_screen_get_default ());
- }
- else
- {
- /* decrease the module use count */
- g_type_module_unuse (G_TYPE_MODULE (module));
-
- /* this should never happen */
- panel_assert_not_reached ();
- }
-
- return provider;
-}
diff --git a/wrapper/wrapper-module.h b/wrapper/wrapper-module.h
deleted file mode 100644
index a30620a..0000000
--- a/wrapper/wrapper-module.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* $Id$ */
-/*
- * Copyright (C) 2008 Nick Schermer <nick at xfce.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __WRAPPER_MODULE_H__
-#define __WRAPPER_MODULE_H__
-
-#include <gtk/gtk.h>
-#include <libxfce4panel/libxfce4panel.h>
-#include <libxfce4panel/xfce-panel-plugin-provider.h>
-
-G_BEGIN_DECLS
-
-typedef struct _WrapperModuleClass WrapperModuleClass;
-typedef struct _WrapperModule WrapperModule;
-
-#define WRAPPER_TYPE_MODULE (wrapper_module_get_type ())
-#define WRAPPER_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WRAPPER_TYPE_MODULE, WrapperModule))
-#define WRAPPER_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WRAPPER_TYPE_MODULE, WrapperModuleClass))
-#define WRAPPER_IS_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WRAPPER_TYPE_MODULE))
-#define WRAPPER_IS_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WRAPPER_TYPE_MODULE))
-#define WRAPPER_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WRAPPER_TYPE_MODULE, WrapperModuleClass))
-
-GType wrapper_module_get_type (void) G_GNUC_CONST;
-
-WrapperModule *wrapper_module_new (const gchar *filename,
- const gchar *name);
-
-XfcePanelPluginProvider *wrapper_module_create_plugin (WrapperModule *module,
- const gchar *name,
- const gchar *id,
- const gchar *display_name,
- gchar **arguments);
-
-G_END_DECLS
-
-#endif /* !__WRAPPER_MODULE_H__ */
diff --git a/wrapper/wrapper-plug.c b/wrapper/wrapper-plug.c
index bdd1240..3a33dd2 100644
--- a/wrapper/wrapper-plug.c
+++ b/wrapper/wrapper-plug.c
@@ -21,11 +21,6 @@
#include <config.h>
#endif
-#include <gdk/gdk.h>
-#include <libxfce4util/libxfce4util.h>
-#include <libxfce4panel/libxfce4panel.h>
-#include <libxfce4panel/xfce-panel-plugin-provider.h>
-
#include <wrapper/wrapper-plug.h>
@@ -34,23 +29,7 @@ static void wrapper_plug_class_init (WrapperPlugClass
static void wrapper_plug_init (WrapperPlug *plug);
static gboolean wrapper_plug_expose_event (GtkWidget *widget,
GdkEventExpose *event);
-static gboolean wrapper_plug_client_event (GtkWidget *widget,
- GdkEventClient *event);
static void wrapper_plug_set_colormap (WrapperPlug *plug);
-static void wrapper_plug_send_message (WrapperPlug *plug,
- XfcePanelPluginMessage message,
- glong value);
-static void wrapper_plug_message_expand_changed (XfcePanelPluginProvider *provider,
- gboolean expand,
- WrapperPlug *plug);
-static void wrapper_plug_message_move_item (XfcePanelPluginProvider *provider,
- WrapperPlug *plug);
-static void wrapper_plug_message_add_new_items (XfcePanelPluginProvider *provider,
- WrapperPlug *plug);
-static void wrapper_plug_message_panel_preferences (XfcePanelPluginProvider *provider,
- WrapperPlug *plug);
-static void wrapper_plug_message_remove (XfcePanelPluginProvider *provider,
- WrapperPlug *plug);
@@ -63,23 +42,14 @@ struct _WrapperPlug
{
GtkPlug __parent__;
- /* the panel plugin */
- XfcePanelPluginProvider *provider;
-
- /* socket id of panel window */
- GdkNativeWindow socket_id;
-
- /* the message atom */
- GdkAtom atom;
-
/* background alpha */
- gdouble background_alpha;
+ gdouble background_alpha;
- /* if this plugin is on an active panel */
- guint is_active_panel : 1;
+ /* if the plugin background should be the selection color */
+ guint is_selected : 1;
/* whether the wrapper has a rgba colormap */
- guint is_composited : 1;
+ guint is_composited : 1;
};
@@ -94,7 +64,6 @@ wrapper_plug_class_init (WrapperPlugClass *klass)
GtkWidgetClass *gtkwidget_class;
gtkwidget_class = GTK_WIDGET_CLASS (klass);
- gtkwidget_class->client_event = wrapper_plug_client_event;
gtkwidget_class->expose_event = wrapper_plug_expose_event;
}
@@ -104,10 +73,8 @@ static void
wrapper_plug_init (WrapperPlug *plug)
{
/* init vars */
- plug->socket_id = 0;
- plug->atom = gdk_atom_intern_static_string ("XFCE_PANEL_PLUGIN");
plug->background_alpha = 1.00;
- plug->is_active_panel = FALSE;
+ plug->is_selected = FALSE;
plug->is_composited = FALSE;
/* allow painting, else compositing won't work */
@@ -133,13 +100,13 @@ wrapper_plug_expose_event (GtkWidget *widget,
gdouble alpha = plug->is_composited ? plug->background_alpha : 1.00;
if (GTK_WIDGET_DRAWABLE (widget) &&
- (alpha < 1.00 || plug->is_active_panel))
+ (alpha < 1.00 || plug->is_selected))
{
/* create the cairo context */
cr = gdk_cairo_create (widget->window);
/* change the state is this plugin is on an active panel */
- if (G_UNLIKELY (plug->is_active_panel))
+ if (G_UNLIKELY (plug->is_selected))
state = GTK_STATE_SELECTED;
/* get the background gdk color */
@@ -167,90 +134,6 @@ wrapper_plug_expose_event (GtkWidget *widget,
-static gboolean
-wrapper_plug_client_event (GtkWidget *widget,
- GdkEventClient *event)
-{
- WrapperPlug *plug = WRAPPER_PLUG (widget);
- XfcePanelPluginMessage message;
- glong value;
-
- /* check if this is a panel client event */
- if (G_LIKELY (event->message_type == plug->atom))
- {
- /* get message and value */
- message = event->data.l[0];
- value = event->data.l[1];
-
- switch (message)
- {
- case MESSAGE_SET_SENSITIVE:
- /* set the sensitivity of the plug */
- gtk_widget_set_sensitive (widget, !!(value == 1));
- break;
-
- case MESSAGE_SET_SIZE:
- /* set the new plugin size */
- xfce_panel_plugin_provider_set_size (plug->provider, value);
- break;
-
- case MESSAGE_SET_ORIENTATION:
- /* set the plugin orientation */
- xfce_panel_plugin_provider_set_orientation (plug->provider, value);
- break;
-
- case MESSAGE_SET_SCREEN_POSITION:
- /* set the plugin screen position */
- xfce_panel_plugin_provider_set_screen_position (plug->provider, value);
- break;
-
- case MESSAGE_SET_BACKGROUND_ALPHA:
- /* set the background alpha */
- plug->background_alpha = CLAMP (value, 0, 100) / 100.00;
-
- /* redraw the window */
- gtk_widget_queue_draw (widget);
- break;
-
- case MESSAGE_SET_ACTIVE_PANEL:
- /* set if this plugin is on an active panel */
- plug->is_active_panel = !!(value == 1);
-
- /* redraw the window */
- gtk_widget_queue_draw (widget);
- break;
-
- case MESSAGE_SAVE:
- /* save the plugin */
- xfce_panel_plugin_provider_save (plug->provider);
- break;
-
- case MESSAGE_QUIT:
- /* don't send messages */
- plug->socket_id = 0;
-
- /* quit the main loop (destroy plugin) */
- gtk_main_quit ();
- break;
-
- default:
- g_message ("The wrapper received an unknown message: %d", message);
- break;
- }
-
- /* we handled the event */
- return TRUE;
- }
-
- /* propagate event */
- if (GTK_WIDGET_CLASS (wrapper_plug_parent_class)->client_event)
- return (*GTK_WIDGET_CLASS (wrapper_plug_parent_class)->client_event) (widget, event);
- else
- return FALSE;
-}
-
-
-
static void
wrapper_plug_set_colormap (WrapperPlug *plug)
{
@@ -313,140 +196,49 @@ wrapper_plug_set_colormap (WrapperPlug *plug)
-static void
-wrapper_plug_send_message (WrapperPlug *plug,
- XfcePanelPluginMessage message,
- glong value)
+WrapperPlug *
+wrapper_plug_new (GdkNativeWindow socket_id)
{
- GdkEventClient event;
-
- panel_return_if_fail (WRAPPER_IS_PLUG (plug));
-
- if (G_LIKELY (plug->socket_id > 0))
- {
- /* setup the event */
- event.type = GDK_CLIENT_EVENT;
- event.window = GTK_WIDGET (plug)->window;
- event.send_event = TRUE;
- event.message_type = plug->atom;
- event.data_format = 32;
- event.data.l[0] = message;
- event.data.l[1] = value;
- event.data.l[2] = 0;
-
- /* don't crash on x errors */
- gdk_error_trap_push ();
-
- /* send the event to the wrapper */
- gdk_event_send_client_message_for_display (gdk_display_get_default (), (GdkEvent *) &event, plug->socket_id);
-
- /* flush the x output buffer */
- gdk_flush ();
-
- /* pop the push */
- gdk_error_trap_pop ();
- }
-}
-
-
-
-static void
-wrapper_plug_message_expand_changed (XfcePanelPluginProvider *provider,
- gboolean expand,
- WrapperPlug *plug)
-{
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
- panel_return_if_fail (WRAPPER_IS_PLUG (plug));
-
- /* send signal */
- wrapper_plug_send_message (plug, MESSAGE_EXPAND_CHANGED, expand ? 1 : 0);
-}
-
-
-
-static void
-wrapper_plug_message_move_item (XfcePanelPluginProvider *provider,
- WrapperPlug *plug)
-{
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
- panel_return_if_fail (WRAPPER_IS_PLUG (plug));
-
- /* send signal */
- wrapper_plug_send_message (plug, MESSAGE_MOVE_ITEM, 0);
-}
-
+ WrapperPlug *plug;
+ /* create new object */
+ plug = g_object_new (WRAPPER_TYPE_PLUG, NULL);
-static void
-wrapper_plug_message_add_new_items (XfcePanelPluginProvider *provider,
- WrapperPlug *plug)
-{
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
- panel_return_if_fail (WRAPPER_IS_PLUG (plug));
+ /* contruct the plug */
+ gtk_plug_construct (GTK_PLUG (plug), socket_id);
- /* send signal */
- wrapper_plug_send_message (plug, MESSAGE_ADD_NEW_ITEMS, 0);
+ return plug;
}
-static void
-wrapper_plug_message_panel_preferences (XfcePanelPluginProvider *provider,
- WrapperPlug *plug)
+void
+wrapper_plug_set_background_alpha (WrapperPlug *plug,
+ gdouble alpha)
{
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
panel_return_if_fail (WRAPPER_IS_PLUG (plug));
-
- /* send signal */
- wrapper_plug_send_message (plug, MESSAGE_PANEL_PREFERENCES, 0);
+ panel_return_if_fail (GTK_IS_WIDGET (plug));
+
+ /* set the alpha */
+ plug->background_alpha = CLAMP (alpha, 0.00, 1.00);
+
+ /* redraw */
+ if (plug->is_composited)
+ gtk_widget_queue_draw (GTK_WIDGET (plug));
}
-static void
-wrapper_plug_message_remove (XfcePanelPluginProvider *provider,
- WrapperPlug *plug)
+void
+wrapper_plug_set_selected (WrapperPlug *plug,
+ gboolean selected)
{
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
panel_return_if_fail (WRAPPER_IS_PLUG (plug));
-
- if (plug->socket_id > 0)
- {
- /* send signal */
- wrapper_plug_send_message (plug, MESSAGE_REMOVE, 0);
-
- /* quit the wrapper */
- gtk_main_quit ();
- }
-}
-
-
-
-GtkWidget *
-wrapper_plug_new (GdkNativeWindow socket_id,
- XfcePanelPluginProvider *provider)
-{
- WrapperPlug *plug;
-
- /* create new object */
- plug = g_object_new (WRAPPER_TYPE_PLUG, NULL);
-
- /* store info */
- plug->socket_id = socket_id;
- plug->provider = provider;
-
- /* monitor changes in the provider */
- g_signal_connect (G_OBJECT (provider), "expand-changed", G_CALLBACK (wrapper_plug_message_expand_changed), plug);
- g_signal_connect (G_OBJECT (provider), "move-item", G_CALLBACK (wrapper_plug_message_move_item), plug);
- g_signal_connect (G_OBJECT (provider), "add-new-items", G_CALLBACK (wrapper_plug_message_add_new_items), plug);
- g_signal_connect (G_OBJECT (provider), "panel-preferences", G_CALLBACK (wrapper_plug_message_panel_preferences), plug);
- g_signal_connect (G_OBJECT (provider), "destroy", G_CALLBACK (wrapper_plug_message_remove), plug);
-
- /* contruct the plug */
- gtk_plug_construct (GTK_PLUG (plug), socket_id);
-
- /* send the plug id back to the panel */
- wrapper_plug_send_message (plug, MESSAGE_SET_PLUG_ID, gtk_plug_get_id (GTK_PLUG (plug)));
-
- return GTK_WIDGET (plug);
+ panel_return_if_fail (GTK_IS_WIDGET (plug));
+
+ /* set value */
+ plug->is_selected = !!selected;
+
+ /* redraw */
+ gtk_widget_queue_draw (GTK_WIDGET (plug));
}
diff --git a/wrapper/wrapper-plug.h b/wrapper/wrapper-plug.h
index 748f93d..de69e29 100644
--- a/wrapper/wrapper-plug.h
+++ b/wrapper/wrapper-plug.h
@@ -36,10 +36,15 @@ typedef struct _WrapperPlug WrapperPlug;
#define WRAPPER_IS_PLUG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WRAPPER_TYPE_PLUG))
#define WRAPPER_PLUG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WRAPPER_TYPE_PLUG, WrapperPlugClass))
-GType wrapper_plug_get_type (void) G_GNUC_CONST;
+GType wrapper_plug_get_type (void) G_GNUC_CONST;
-GtkWidget *wrapper_plug_new (GdkNativeWindow socket_id,
- XfcePanelPluginProvider *provider);
+WrapperPlug *wrapper_plug_new (GdkNativeWindow socket_id);
+
+void wrapper_plug_set_background_alpha (WrapperPlug *plug,
+ gdouble alpha);
+
+void wrapper_plug_set_selected (WrapperPlug *plug,
+ gboolean selected);
G_END_DECLS
More information about the Xfce4-commits
mailing list