[Xfce4-commits] <xfce4-clipman-plugin:master> Make the code GSEAL-proof

Mike Massonnet noreply at xfce.org
Mon Dec 7 19:04:01 CET 2009


Updating branch refs/heads/master
         to 3f35d6444792bcbda2bc7a9880e1e576cf7293be (commit)
       from b945efc54dd5b737c901ec8dbf5d24a58dd8e6df (commit)

commit 3f35d6444792bcbda2bc7a9880e1e576cf7293be
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Mon Dec 7 18:34:05 2009 +0100

    Make the code GSEAL-proof

 daemon/Makefile.am                 |    1 +
 daemon/gsd-clipboard-manager.c     |   15 ++++++++-------
 panel-plugin/Makefile.am           |    1 +
 panel-plugin/main-panel-plugin.c   |   16 +++++++++-------
 panel-plugin/plugin.c              |    2 +-
 panel-plugin/xfce4-popup-clipman.c |    2 +-
 6 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 2d1a10a..5f87b7e 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -1,6 +1,7 @@
 NULL = 
 
 INCLUDES =								\
+	-DGSEAL_ENABLE							\
 	-I${top_srcdir}							\
 	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"				\
 	$(NULL)
diff --git a/daemon/gsd-clipboard-manager.c b/daemon/gsd-clipboard-manager.c
index 016e031..0e96741 100644
--- a/daemon/gsd-clipboard-manager.c
+++ b/daemon/gsd-clipboard-manager.c
@@ -123,7 +123,8 @@ default_clipboard_get_func (GtkClipboard *clipboard,
         list = manager->priv->default_cache;
         for (; list->next != NULL; list = list->next) {
                 selection_data_cache = list->data;
-                if (selection_data->target == selection_data_cache->target) {
+                if (gtk_selection_data_get_target (selection_data) ==
+                    gtk_selection_data_get_target (selection_data_cache)) {
                         break;
                 }
                 selection_data_cache = NULL;
@@ -131,10 +132,8 @@ default_clipboard_get_func (GtkClipboard *clipboard,
         if (selection_data_cache == NULL) {
                 return;
         }
-        gtk_selection_data_set (selection_data, selection_data->target,
-                                selection_data_cache->format,
-                                selection_data_cache->data,
-                                selection_data_cache->length);
+        gtk_selection_data_free (selection_data);
+        selection_data = gtk_selection_data_copy (selection_data_cache);
 }
 
 static void
@@ -158,7 +157,9 @@ default_clipboard_restore (GsdClipboardManager *manager)
         list = manager->priv->default_cache;
         for (; list->next != NULL; list = list->next) {
                 sdata = list->data;
-                gtk_target_list_add (target_list, sdata->target, 0, 0);
+                gtk_target_list_add (target_list,
+                                     gtk_selection_data_get_target (sdata),
+                                     0, 0);
         }
         targets = gtk_target_table_new_from_list (target_list, &n_targets);
 
@@ -249,7 +250,7 @@ start_clipboard_idle_cb (GsdClipboardManager *manager)
         manager->priv->window = gtk_invisible_new ();
         gtk_widget_realize (manager->priv->window);
 
-        window = GDK_WINDOW_XID (manager->priv->window->window);
+        window = GDK_WINDOW_XID (gtk_widget_get_window (manager->priv->window));
         timestamp = GDK_CURRENT_TIME;
 
         XSelectInput (display, window, PropertyChangeMask);
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index c0d9d9f..d7bde8f 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -1,6 +1,7 @@
 NULL = 
 
 INCLUDES =								\
+	-DGSEAL_ENABLE							\
 	-I${top_srcdir}							\
 	-DSYSCONFDIR=\"$(sysconfdir)\"					\
 	-DDATAROOTDIR=\"$(datarootdir)\"				\
diff --git a/panel-plugin/main-panel-plugin.c b/panel-plugin/main-panel-plugin.c
index 6ca334a..2777400 100644
--- a/panel-plugin/main-panel-plugin.c
+++ b/panel-plugin/main-panel-plugin.c
@@ -110,8 +110,8 @@ panel_plugin_set_size (MyPlugin *plugin,
 
   gtk_widget_set_size_request (plugin->button, size, size);
 
-  size -= 2 + 2 * MAX (plugin->button->style->xthickness,
-                       plugin->button->style->ythickness);
+  size -= 2 + 2 * MAX (gtk_widget_get_style (plugin->button)->xthickness,
+                       gtk_widget_get_style (plugin->button)->ythickness);
   pixbuf = xfce_themed_icon_load (GTK_STOCK_PASTE, size);
   gtk_image_set_from_pixbuf (GTK_IMAGE (plugin->image), pixbuf);
   g_object_unref (G_OBJECT (pixbuf));
@@ -148,23 +148,25 @@ my_plugin_position_menu (GtkMenu *menu,
                          MyPlugin *plugin)
 {
   GtkWidget *button;
+  gint button_width, button_height;
   GtkRequisition requisition;
   GtkOrientation orientation;
 
   button = plugin->button;
   orientation = xfce_panel_plugin_get_orientation (plugin->panel_plugin);
+  gtk_widget_get_size_request (button, &button_width, &button_height);
   gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
-  gdk_window_get_origin (GTK_WIDGET (plugin->panel_plugin)->window, x, y);
+  gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (plugin->panel_plugin)), x, y);
 
   switch (orientation)
     {
     case GTK_ORIENTATION_HORIZONTAL:
-      if (*y + button->allocation.height + requisition.height > gdk_screen_height ())
+      if (*y + button_height + requisition.height > gdk_screen_height ())
         /* Show menu above */
         *y -= requisition.height;
       else
         /* Show menu below */
-        *y += button->allocation.height;
+        *y += button_height;
 
       if (*x + requisition.width > gdk_screen_width ())
         /* Adjust horizontal position */
@@ -172,12 +174,12 @@ my_plugin_position_menu (GtkMenu *menu,
       break;
 
     case GTK_ORIENTATION_VERTICAL:
-      if (*x + button->allocation.width + requisition.width > gdk_screen_width ())
+      if (*x + button_width + requisition.width > gdk_screen_width ())
         /* Show menu on the right */
         *x -= requisition.width;
       else
         /* Show menu on the left */
-        *x += button->allocation.width;
+        *x += button_width;
 
       if (*y + requisition.height > gdk_screen_height ())
         /* Adjust vertical position */
diff --git a/panel-plugin/plugin.c b/panel-plugin/plugin.c
index de70a6b..c5a11b2 100644
--- a/panel-plugin/plugin.c
+++ b/panel-plugin/plugin.c
@@ -372,7 +372,7 @@ my_plugin_set_popup_selection (MyPlugin *plugin)
 
   win = gtk_invisible_new ();
   gtk_widget_realize (win);
-  id = GDK_WINDOW_XID (win->window);
+  id = GDK_WINDOW_XID (gtk_widget_get_window (win));
 
   gscreen = gtk_widget_get_screen (win);
   selection_name = g_strdup_printf (XFCE_CLIPMAN_SELECTION"%d",
diff --git a/panel-plugin/xfce4-popup-clipman.c b/panel-plugin/xfce4-popup-clipman.c
index e8ca7d5..f548d81 100644
--- a/panel-plugin/xfce4-popup-clipman.c
+++ b/panel-plugin/xfce4-popup-clipman.c
@@ -61,7 +61,7 @@ main (gint argc, gchar *argv[])
   gtk_widget_realize (win);
 
   gev.type              = GDK_CLIENT_EVENT;
-  gev.window            = win->window;
+  gev.window            = gtk_widget_get_window (win);
   gev.send_event        = TRUE;
   gev.message_type      = gdk_atom_intern ("STRING", FALSE);
   gev.data_format       = 8;



More information about the Xfce4-commits mailing list