Browse Source

Wrapper communication through DBus and drop GOBject plugins.

The GObject plugin support gives a lot of problems. Will add some
better once I get to it.
Also a bunch of cleanups through the code.
upstream/xfce4-panel-4.10.1
Nick Schermer 13 years ago
parent
commit
8dc355e70f
  1. 117
      libxfce4panel/libxfce4panel.h
  2. 9
      libxfce4panel/xfce-panel-plugin-provider.c
  3. 19
      libxfce4panel/xfce-panel-plugin-provider.h
  4. 693
      libxfce4panel/xfce-panel-plugin.c
  5. 24
      panel/Makefile.am
  6. 6
      panel/main.c
  7. 18
      panel/panel-application.c
  8. 250
      panel/panel-dbus-client.c
  9. 44
      panel/panel-dbus-service-infos.xml
  10. 137
      panel/panel-dbus-service.c
  11. 8
      panel/panel-dbus-service.h
  12. 36
      panel/panel-module-factory.c
  13. 5
      panel/panel-module-factory.h
  14. 9
      panel/panel-module.c
  15. 297
      panel/panel-plugin-external.c
  16. 13
      panel/panel-plugin-external.h
  17. 2
      panel/panel-window.c
  18. 50
      plugins/clock/clock-analog.c
  19. 20
      plugins/clock/clock-analog.h
  20. 67
      plugins/clock/clock-binary.c
  21. 20
      plugins/clock/clock-binary.h
  22. 124
      plugins/clock/clock-dialog.c
  23. 2
      plugins/clock/clock-dialog.h
  24. 61
      plugins/clock/clock-digital.c
  25. 20
      plugins/clock/clock-digital.h
  26. 70
      plugins/clock/clock-lcd.c
  27. 20
      plugins/clock/clock-lcd.h
  28. 972
      plugins/clock/clock.c
  29. 123
      plugins/clock/clock.h
  30. 2
      plugins/systray/systray.desktop.in.in
  31. 27
      plugins/systray/xfce-tray-manager.c
  32. 28
      wrapper/Makefile.am
  33. 321
      wrapper/main.c
  34. 205
      wrapper/wrapper-module.c
  35. 52
      wrapper/wrapper-module.h
  36. 280
      wrapper/wrapper-plug.c
  37. 11
      wrapper/wrapper-plug.h

117
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; \
}

9
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;

19
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))

693
libxfce4panel/xfce-panel-plugin.c

File diff suppressed because it is too large

24
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:

6
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);

18
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)

250
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;
}

44
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>

137
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>

8
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

36
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);
@ -356,6 +361,18 @@ 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,
@ -363,7 +380,8 @@ panel_module_factory_create_plugin (PanelModuleFactory *factory,
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;
}

5
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,

9
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) &register_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
{

297
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,90 +229,16 @@ 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);
}
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)
{
@ -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);
}