Browse Source

Partly fix background alpha in remote plugins.

upstream/xfce4-panel-4.10.1
Nick Schermer 13 years ago
parent
commit
4b33cc07ce
  1. 11
      libxfce4panel/xfce-panel-plugin-provider.c
  2. 17
      libxfce4panel/xfce-panel-plugin-provider.h
  3. 14
      libxfce4panel/xfce-panel-plugin.c
  4. 12
      panel/panel-application.c
  5. 80
      panel/panel-plugin-external.c
  6. 2
      panel/panel-plugin-external.h
  7. 25
      panel/panel-window.c
  8. 2
      plugins/clock/clock.desktop.in.in
  9. 2
      plugins/systray/systray.desktop.in.in
  10. 2
      plugins/tasklist/tasklist.desktop.in.in
  11. 2
      wrapper/main.c
  12. 211
      wrapper/wrapper-plug.c

11
libxfce4panel/xfce-panel-plugin-provider.c

@ -175,17 +175,6 @@ xfce_panel_plugin_provider_set_screen_position (XfcePanelPluginProvider *provide
void
xfce_panel_plugin_provider_set_opacity (XfcePanelPluginProvider *provider,
gdouble opacity)
{
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
(*XFCE_PANEL_PLUGIN_PROVIDER_GET_IFACE (provider)->set_opacity) (provider, opacity);
}
void
xfce_panel_plugin_provider_save (XfcePanelPluginProvider *provider)
{

17
libxfce4panel/xfce-panel-plugin-provider.h

@ -35,11 +35,6 @@ typedef XfcePanelPluginProvider *(*PluginConstructFunc) (const gchar *name,
typedef void (*PluginRegisterTypesFunc) (XfcePanelModule *module);
#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))
#define XFCE_IS_PANEL_PLUGIN_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_PANEL_PLUGIN_PROVIDER))
#define XFCE_PANEL_PLUGIN_PROVIDER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XFCE_TYPE_PANEL_PLUGIN_PROVIDER, XfcePanelPluginProviderIface))
enum _XfcePanelPluginMessage
{
MESSAGE_EXPAND_CHANGED,
@ -51,10 +46,17 @@ enum _XfcePanelPluginMessage
MESSAGE_SET_SCREEN_POSITION,
MESSAGE_SET_PLUG_ID,
MESSAGE_SET_SENSITIVE,
MESSAGE_SET_BACKGROUND_ALPHA,
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))
#define XFCE_IS_PANEL_PLUGIN_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_PANEL_PLUGIN_PROVIDER))
#define XFCE_PANEL_PLUGIN_PROVIDER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XFCE_TYPE_PANEL_PLUGIN_PROVIDER, XfcePanelPluginProviderIface))
struct _XfcePanelPluginProviderIface
{
/*< private >*/
@ -69,8 +71,6 @@ struct _XfcePanelPluginProviderIface
GtkOrientation orientation);
void (*set_screen_position) (XfcePanelPluginProvider *provider,
XfceScreenPosition screen_position);
void (*set_opacity) (XfcePanelPluginProvider *provider,
gdouble opacity);
void (*save) (XfcePanelPluginProvider *provider);
};
@ -89,9 +89,6 @@ void xfce_panel_plugin_provider_set_orientation (XfcePanelPluginProv
void xfce_panel_plugin_provider_set_screen_position (XfcePanelPluginProvider *provider,
XfceScreenPosition screen_position);
void xfce_panel_plugin_provider_set_opacity (XfcePanelPluginProvider *provider,
gdouble opacity);
void xfce_panel_plugin_provider_save (XfcePanelPluginProvider *provider);
G_END_DECLS

14
libxfce4panel/xfce-panel-plugin.c

@ -63,8 +63,6 @@ static void xfce_panel_plugin_set_orientation (XfcePanelPluginProvi
GtkOrientation orientation);
static void xfce_panel_plugin_set_screen_position (XfcePanelPluginProvider *provider,
XfceScreenPosition screen_position);
static void xfce_panel_plugin_set_opacity (XfcePanelPluginProvider *provider,
gdouble opacity);
static void xfce_panel_plugin_save (XfcePanelPluginProvider *provider);
static void xfce_panel_plugin_take_window_notify (gpointer data,
GObject *where_the_object_was);
@ -373,7 +371,6 @@ xfce_panel_plugin_provider_init (XfcePanelPluginProviderIface *iface)
iface->set_size = xfce_panel_plugin_set_size;
iface->set_orientation = xfce_panel_plugin_set_orientation;
iface->set_screen_position = xfce_panel_plugin_set_screen_position;
iface->set_opacity = xfce_panel_plugin_set_opacity;
iface->save = xfce_panel_plugin_save;
}
@ -922,17 +919,6 @@ xfce_panel_plugin_set_screen_position (XfcePanelPluginProvider *provider,
static void
xfce_panel_plugin_set_opacity (XfcePanelPluginProvider *provider,
gdouble opacity)
{
//XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
//panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
}
static void
xfce_panel_plugin_save (XfcePanelPluginProvider *provider)
{

12
panel/panel-application.c

@ -40,6 +40,7 @@
#include <panel/panel-item-dialog.h>
#include <panel/panel-dialogs.h>
#include <panel/panel-glue.h>
#include <panel/panel-plugin-external.h>
#define PANEL_CONFIG_PATH "xfce4" G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "panels.new.xml"
#define AUTOSAVE_INTERVAL (10 * 60)
@ -337,7 +338,7 @@ expand_handle (GtkWidget *plugin,
{
GtkWidget *itembar;
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin));
panel_return_if_fail (PANEL_IS_WINDOW (window));
/* get the itembar */
@ -439,13 +440,18 @@ panel_application_insert_plugin (PanelApplication *application,
/* add the item to the panel */
panel_itembar_insert (PANEL_ITEMBAR (itembar), GTK_WIDGET (provider), position);
/* show the plugin */
gtk_widget_show (GTK_WIDGET (provider));
/* set the background alpha if the plugin is external */
if (PANEL_IS_PLUGIN_EXTERNAL (provider))
panel_plugin_external_set_background_alpha (PANEL_PLUGIN_EXTERNAL (provider), panel_window_get_background_alpha (window));
/* send plugin information */
xfce_panel_plugin_provider_set_orientation (provider, panel_window_get_orientation (window));
xfce_panel_plugin_provider_set_screen_position (provider, panel_glue_get_screen_position (window));
xfce_panel_plugin_provider_set_size (provider, panel_window_get_size (window));
/* show the plugin */
gtk_widget_show (GTK_WIDGET (provider));
/* we've succeeded */
succeed = TRUE;
}

80
panel/panel-plugin-external.c

@ -44,6 +44,7 @@ static gboolean panel_plugin_external_plug_removed (GtkSocket
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);
@ -53,6 +54,7 @@ static void panel_plugin_external_set_orientation (XfcePanelPluginPr
GtkOrientation orientation);
static void panel_plugin_external_set_screen_position (XfcePanelPluginProvider *provider,
XfceScreenPosition screen_position);
static void panel_plugin_external_save (XfcePanelPluginProvider *provider);
static void panel_plugin_external_set_sensitive (PanelPluginExternal *external);
@ -145,6 +147,7 @@ panel_plugin_external_provider_init (XfcePanelPluginProviderIface *iface)
iface->set_size = panel_plugin_external_set_size;
iface->set_orientation = panel_plugin_external_set_orientation;
iface->set_screen_position = panel_plugin_external_set_screen_position;
iface->save = panel_plugin_external_save;
}
@ -154,12 +157,13 @@ panel_plugin_external_finalize (GObject *object)
{
PanelPluginExternal *external = PANEL_PLUGIN_EXTERNAL (object);
panel_return_if_fail (external->queue == NULL);
/* cleanup */
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));
@ -382,6 +386,29 @@ panel_plugin_external_send_message (PanelPluginExternal *external,
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)
{
@ -391,25 +418,17 @@ panel_plugin_external_flush_queue (PanelPluginExternal *external)
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
panel_return_if_fail (external->plug_window_id != 0);
if (external->queue != NULL)
if (G_LIKELY (external->queue != NULL))
{
/* free all message */
/* send all messages in the queue */
for (li = external->queue; li != NULL; li = li->next)
{
data = li->data;
/* send message */
panel_plugin_external_send_message (external, data->message, data->value);
/* cleanup */
g_slice_free (QueueData, data);
}
/* cleanup */
g_slist_free (external->queue);
/* set to null */
external->queue = NULL;
/* free the queue */
panel_plugin_external_free_queue (external);
}
}
@ -441,6 +460,9 @@ static void
panel_plugin_external_set_size (XfcePanelPluginProvider *provider,
gint size)
{
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);
}
@ -451,6 +473,9 @@ static void
panel_plugin_external_set_orientation (XfcePanelPluginProvider *provider,
GtkOrientation orientation)
{
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);
}
@ -461,12 +486,27 @@ static void
panel_plugin_external_set_screen_position (XfcePanelPluginProvider *provider,
XfceScreenPosition screen_position)
{
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);
}
static void
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);
}
static void
panel_plugin_external_set_sensitive (PanelPluginExternal *external)
{
@ -501,3 +541,15 @@ panel_plugin_external_new (PanelModule *module,
return XFCE_PANEL_PLUGIN_PROVIDER (external);
}
void
panel_plugin_external_set_background_alpha (PanelPluginExternal *external,
gint percentage)
{
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 (PANEL_PLUGIN_EXTERNAL (external), MESSAGE_SET_BACKGROUND_ALPHA, percentage);
}

2
panel/panel-plugin-external.h

@ -39,6 +39,8 @@ 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);
void panel_plugin_external_set_background_alpha (PanelPluginExternal *external, gint percentage);
G_END_DECLS
#endif /* !__PANEL_PLUGIN_EXTERNAL_H__ */

25
panel/panel-window.c

@ -30,6 +30,7 @@
#include <panel/panel-window.h>
#include <panel/panel-glue.h>
#include <panel/panel-application.h>
#include <panel/panel-plugin-external.h>
#define HANDLE_SIZE (8)
#define HANDLE_SPACING (2)
@ -1880,12 +1881,26 @@ panel_window_get_background_alpha (PanelWindow *window)
}
static void
panel_window_set_plugin_background_alpha (GtkWidget *widget,
gpointer user_data)
{
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget));
panel_return_if_fail (PANEL_IS_WINDOW (user_data));
/* we only have to send the alpha to external plugins */
if (PANEL_IS_PLUGIN_EXTERNAL (widget))
panel_plugin_external_set_background_alpha (PANEL_PLUGIN_EXTERNAL (widget), panel_window_get_background_alpha (PANEL_WINDOW (user_data)));
}
void
panel_window_set_background_alpha (PanelWindow *window,
gint alpha)
{
gdouble value;
gdouble value;
GtkWidget *itembar;
panel_return_if_fail (PANEL_IS_WINDOW (window));
panel_return_if_fail (alpha >= 0 && alpha <= 100);
@ -1897,8 +1912,14 @@ panel_window_set_background_alpha (PanelWindow *window,
/* set new alpha value */
window->background_alpha = value;
/* redraw */
/* redraw the window */
gtk_widget_queue_draw (GTK_WIDGET (window));
/* get the itembar */
itembar = gtk_bin_get_child (GTK_BIN (window));
/* walk the plugins */
gtk_container_foreach (GTK_CONTAINER (itembar), panel_window_set_plugin_background_alpha, window);
}
}

2
plugins/clock/clock.desktop.in.in

@ -6,4 +6,4 @@ _Comment=What time is it?
Icon=x-office-calendar
X-XFCE-Module=clock
X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins
X-XFCE-External=FALSE
X-XFCE-External=TRUE

2
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=FALSE
X-XFCE-External=TRUE

2
plugins/tasklist/tasklist.desktop.in.in

@ -6,4 +6,4 @@ _Comment=Show all running applications
Icon=xfwm4
X-XFCE-Module=tasklist
X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins
X-XFCE-External=FALSE
X-XFCE-External=TRUE

2
wrapper/main.c

@ -114,7 +114,7 @@ main (gint argc, gchar **argv)
gtk_container_add (GTK_CONTAINER (plug), GTK_WIDGET (provider));
gtk_widget_show (plug);
/* show the plugin */
/* realize the plugin */
gtk_widget_show (GTK_WIDGET (provider));
/* everything worked fine */

211
wrapper/wrapper-plug.c

@ -20,6 +20,7 @@
#endif
#include <gdk/gdk.h>
#include <panel/panel-private.c>
#include <libxfce4util/libxfce4util.h>
#include <libxfce4panel/libxfce4panel.h>
#include <libxfce4panel/xfce-panel-plugin-provider.h>
@ -43,52 +44,80 @@ struct _WrapperPlugClass
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;
};
G_DEFINE_TYPE (WrapperPlug, wrapper_plug, GTK_TYPE_PLUG);
//~ static gboolean
//~ wrapper_plug_expose_event (GtkWidget *widget,
//~ GdkEventExpose *event)
//~ {
//~ cairo_t *cr;
//~ GtkStyle *style;
//~ double r,g,b;
//~
//~ cr = gdk_cairo_create (widget->window);
//~
//~ cairo_rectangle (cr, event->area.x,
//~ event->area.y,
//~ event->area.width,
//~ event->area.height);
//~ cairo_clip (cr);
//~
//~ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
//~
//~ /* fully transparent */
//~ style = gtk_widget_get_style (widget);
//~ r = (double) style->bg[widget->state].red / (double) 65535;
//~ g = (double) style->bg[widget->state].green / (double) 65535;
//~ b = (double) style->bg[widget->state].blue / (double) 65535;
//~ cairo_set_source_rgba (cr, r, g, b, 0.50);
//~ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
//~ cairo_paint (cr);
//~
//~ cairo_destroy (cr);
//~ return GTK_WIDGET_CLASS(wrapper_plug_parent_class)->expose_event(widget, event);
//~ }
static gboolean
wrapper_plug_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
WrapperPlug *plug = WRAPPER_PLUG (widget);
cairo_t *cr;
GdkColor *color;
if (GTK_WIDGET_DRAWABLE (widget) && plug->background_alpha < 1.00)
{
/* create the cairo context */
cr = gdk_cairo_create (widget->window);
/* get the background gdk color */
color = &(widget->style->bg[GTK_STATE_NORMAL]);
/* set the cairo source color */
_set_source_rgba (cr, color, plug->background_alpha);
/* create retangle */
cairo_rectangle (cr, event->area.x, event->area.y,
event->area.width, event->area.height);
/* draw on source */
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
/* paint rectangle */
cairo_fill (cr);
/* destroy cairo context */
cairo_destroy (cr);
}
//~ cairo_rectangle (cr, event->area.x,
//~ event->area.y,
//~ event->area.width,
//~ event->area.height);
//~ cairo_clip (cr);
//~
//~ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
//~
//~ style = gtk_widget_get_style (widget);
//~ r = (double) style->bg[widget->state].red / (double) 65535;
//~ g = (double) style->bg[widget->state].green / (double) 65535;
//~ b = (double) style->bg[widget->state].blue / (double) 65535;
//~ cairo_set_source_rgba (cr, r, g, b, 0.50);
//~ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
//~ cairo_paint (cr);
//~
//~ cairo_destroy (cr);
return GTK_WIDGET_CLASS(wrapper_plug_parent_class)->expose_event(widget, event);
}
@ -100,10 +129,10 @@ wrapper_plug_class_init (WrapperPlugClass *klass)
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = wrapper_plug_finalize;
gtkwidget_class = GTK_WIDGET_CLASS (klass);
gtkwidget_class->client_event = wrapper_plug_client_event;
//gtkwidget_class->expose_event = wrapper_plug_expose_event;
gtkwidget_class->expose_event = wrapper_plug_expose_event;
}
@ -113,26 +142,27 @@ wrapper_plug_init (WrapperPlug *plug)
{
plug->socket_id = 0;
plug->atom = panel_atom_intern ("XFCE_PANEL_PLUGIN");
//~ GdkScreen *screen;
//~ GdkColormap *colormap;
//~ GtkWidget *widget = GTK_WIDGET (plug);
//~
//~ /* try to set the rgba colormap */
//~ screen = gtk_window_get_screen (GTK_WINDOW (plug));
//~ if (gdk_screen_is_composited (screen))
//~ {
//~ /* try to get the rgba colormap */
//~ colormap = gdk_screen_get_rgba_colormap (screen);
//~
//~ if (G_LIKELY (colormap))
//~ {
//~ /* set the colormap */
//~ gtk_widget_set_colormap (widget, colormap);
//~ }
//~ }
//gtk_widget_set_app_paintable (GTK_WIDGET (plug), TRUE);
plug->background_alpha = 1.00;
GdkScreen *screen;
GdkColormap *colormap;
GtkWidget *widget = GTK_WIDGET (plug);
/* try to set the rgba colormap */
screen = gtk_window_get_screen (GTK_WINDOW (plug));
if (gdk_screen_is_composited (screen))
{
/* try to get the rgba colormap */
colormap = gdk_screen_get_rgba_colormap (screen);
if (G_LIKELY (colormap))
{
/* set the colormap */
gtk_widget_set_colormap (widget, colormap);
}
}
gtk_widget_set_app_paintable (GTK_WIDGET (plug), TRUE);
}
@ -147,56 +177,69 @@ wrapper_plug_finalize (GObject *object)
static gboolean
wrapper_plug_client_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_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;
}
@ -216,9 +259,9 @@ wrapper_plug_send_message (WrapperPlug *plug,
glong value)
{
GdkEventClient event;
panel_return_if_fail (WRAPPER_IS_PLUG (plug));
if (G_LIKELY (plug->socket_id > 0))
{
/* setup the event */
@ -230,16 +273,16 @@ wrapper_plug_send_message (WrapperPlug *plug,
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 ();
}
@ -254,7 +297,7 @@ wrapper_plug_message_expand_changed (XfcePanelPluginProvider *provider,
{
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);
}
@ -267,7 +310,7 @@ wrapper_plug_message_move_item (XfcePanelPluginProvider *provider,
{
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);
}
@ -280,7 +323,7 @@ wrapper_plug_message_add_new_items (XfcePanelPluginProvider *provider,
{
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_ADD_NEW_ITEMS, 0);
}
@ -293,7 +336,7 @@ wrapper_plug_message_customize_panel (XfcePanelPluginProvider *provider,
{
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_CUSTOMIZE_PANEL, 0);
}
@ -311,7 +354,7 @@ wrapper_plug_message_remove (XfcePanelPluginProvider *provider,
{
/* send signal */
wrapper_plug_send_message (plug, MESSAGE_REMOVE, 0);
/* quit the wrapper */
gtk_main_quit ();
}
@ -324,26 +367,26 @@ 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), "customize-panel", G_CALLBACK (wrapper_plug_message_customize_panel), 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);
}

Loading…
Cancel
Save