[Xfce4-commits] <xfce4-embed-plugin:master> Use the plug window's expose_event handler to color our socket.

David Schneider noreply at xfce.org
Fri Sep 21 08:52:02 CEST 2012


Updating branch refs/heads/master
         to 796a028bd16c8ce17fbe423a74fda1d633b7f67b (commit)
       from 6d1fbee7879bd8cf4a68ee3c3f1cdaece031a4af (commit)

commit 796a028bd16c8ce17fbe423a74fda1d633b7f67b
Author: David Schneider <dnschneid at gmail.com>
Date:   Thu Sep 20 23:48:28 2012 -0700

    Use the plug window's expose_event handler to color our socket.

 panel-plugin/embed.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/panel-plugin/embed.c b/panel-plugin/embed.c
index f37fa7a..e719c90 100644
--- a/panel-plugin/embed.c
+++ b/panel-plugin/embed.c
@@ -831,6 +831,23 @@ embed_size_allocate (GtkSocket *socket, GdkRectangle *allocation,
 
 
 
+/* Callback used when the socket (or fake socket) needs to be painted.
+ * HACK: Let the parent plugin wrapper do the heavy lifting by convincing it to
+ * draw on our window for us.
+ */
+static gint
+embed_expose (GtkWidget *widget, GdkEvent *event, EmbedPlugin *embed)
+{
+  GtkWidget *plugwidget = gtk_widget_get_parent (GTK_WIDGET (embed->plugin));
+  GdkWindow *plugwindow = plugwidget->window;
+  plugwidget->window = widget->window;
+  gtk_widget_send_expose (plugwidget, event);
+  plugwidget->window = plugwindow;
+  return TRUE;
+}
+
+
+
 /* Callback for when the gtksocket is realized.
  * Set the window settings and then start a search.
  */
@@ -874,8 +891,11 @@ embed_add_socket (EmbedPlugin *embed, gboolean update_size)
                     G_CALLBACK (embed_plug_removed), embed);
   g_signal_connect (G_OBJECT (embed->socket), "realize",
                     G_CALLBACK (embed_socket_realize), embed);
+  g_signal_connect (G_OBJECT (embed->socket), "expose-event",
+                    G_CALLBACK (embed_expose), embed);
 
   xfce_panel_plugin_add_action_widget (embed->plugin, embed->socket);
+  gtk_widget_set_app_paintable (embed->socket, TRUE);
 
   /* Add it to the plugin hvbox */
   gtk_widget_show (embed->socket);
@@ -903,8 +923,11 @@ embed_add_fake_socket (EmbedPlugin *embed)
   /* We use the size-allocate signal to keep the size of the plug up-to-date. */
   g_signal_connect (G_OBJECT (embed->socket), "size-allocate",
                     G_CALLBACK (embed_size_allocate), embed);
+  g_signal_connect (G_OBJECT (embed->socket), "expose-event",
+                    G_CALLBACK (embed_expose), embed);
 
   xfce_panel_plugin_add_action_widget (embed->plugin, embed->socket);
+  gtk_widget_set_app_paintable (embed->socket, TRUE);
 
   /* Add it to the plugin hvbox */
   gtk_widget_show (embed->socket);


More information about the Xfce4-commits mailing list