[Xfce4-commits] <xfce4-panel:andrzejr/gtk3> Quick hack for compiling libxfce4-panel and wrapper w/gtk3

Andrzej noreply at xfce.org
Tue Apr 16 00:32:04 CEST 2013


Updating branch refs/heads/andrzejr/gtk3
         to 0622d8f3a0d4af2a4fe3679a0546e0ec55a76345 (commit)
       from 83a29466cd47dfae0f75778d5dff1222939f1207 (commit)

commit 0622d8f3a0d4af2a4fe3679a0546e0ec55a76345
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Thu Mar 14 02:46:42 2013 +0000

    Quick hack for compiling libxfce4-panel and wrapper w/gtk3

 Makefile.am                            |    6 +++-
 libxfce4panel/Makefile.am              |    5 +---
 libxfce4panel/xfce-panel-convenience.c |    8 ++++-
 libxfce4panel/xfce-panel-plugin.c      |   27 +++++++++++++------
 wrapper/main.c                         |    4 +++
 wrapper/wrapper-plug.c                 |   43 +++++++++++++++++++++++++++++---
 wrapper/wrapper-plug.h                 |    6 ++++
 7 files changed, 78 insertions(+), 21 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 0ad0780..9a5063a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,14 +2,16 @@
 SUBDIRS = \
 	libxfce4panel \
 	common \
-	panel \
-	plugins \
 	wrapper \
 	migrate \
 	docs \
 	icons \
 	po
 
+#	panel \
+#	plugins \
+#
+
 distclean-local:
 	rm -rf *.spec *.cache *~
 
diff --git a/libxfce4panel/Makefile.am b/libxfce4panel/Makefile.am
index cba5083..f65e85c 100644
--- a/libxfce4panel/Makefile.am
+++ b/libxfce4panel/Makefile.am
@@ -24,7 +24,6 @@ libxfce4panel_headers = \
 	libxfce4panel.h \
 	libxfce4panel-config.h \
 	libxfce4panel-enums.h \
-	xfce-arrow-button.h \
 	xfce-hvbox.h \
 	xfce-panel-convenience.h \
 	xfce-panel-macros.h \
@@ -44,12 +43,10 @@ libxfce4panel_1_0_la_SOURCES = \
 	$(libxfce4panel_built_sources) \
 	$(libxfce4panel_headers) \
 	libxfce4panel-config.c \
-	xfce-arrow-button.c \
 	xfce-hvbox.c \
 	xfce-panel-convenience.c \
 	xfce-panel-plugin.c \
-	xfce-panel-plugin-provider.c \
-	xfce-panel-image.c
+	xfce-panel-plugin-provider.c
 
 libxfce4panel_1_0_la_CFLAGS =	 \
 	$(GTK_CFLAGS) \
diff --git a/libxfce4panel/xfce-panel-convenience.c b/libxfce4panel/xfce-panel-convenience.c
index a3f3be1..34e21f3 100644
--- a/libxfce4panel/xfce-panel-convenience.c
+++ b/libxfce4panel/xfce-panel-convenience.c
@@ -57,7 +57,9 @@ xfce_panel_create_button (void)
 {
   GtkWidget *button = gtk_button_new ();
 
-  GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_DEFAULT | GTK_CAN_FOCUS);
+  //GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_DEFAULT | GTK_CAN_FOCUS);
+  gtk_widget_set_can_default (GTK_WIDGET (button), FALSE);
+  gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE);
   gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
   gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
   gtk_widget_set_name (button, "xfce-panel-button");
@@ -80,7 +82,9 @@ xfce_panel_create_toggle_button (void)
 {
   GtkWidget *button = gtk_toggle_button_new ();
 
-  GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_DEFAULT | GTK_CAN_FOCUS);
+  //GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_DEFAULT | GTK_CAN_FOCUS);
+  gtk_widget_set_can_default (GTK_WIDGET (button), FALSE);
+  gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE);
   gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
   gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
   gtk_widget_set_name (button, "xfce-panel-toggle-button");
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 8126922..e649ff3 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -28,6 +28,7 @@
 #endif
 
 #include <gtk/gtk.h>
+#include <gtk/gtkx.h>
 #include <glib.h>
 #include <libxfce4util/libxfce4util.h>
 
@@ -2411,6 +2412,7 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
                                    gint            *y)
 {
   GtkRequisition  requisition;
+  GtkAllocation   allocation;
   GdkScreen      *screen;
   GdkRectangle    monitor;
   gint            monitor_num;
@@ -2428,11 +2430,11 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
     attach_widget = GTK_WIDGET (plugin);
 
   /* make sure the menu is realized to get valid rectangle sizes */
-  if (!GTK_WIDGET_REALIZED (menu_widget))
+  if (!gtk_widget_get_realized (menu_widget))
     gtk_widget_realize (menu_widget);
 
   /* make sure the attach widget is realized for the gdkwindow */
-  if (!GTK_WIDGET_REALIZED (attach_widget))
+  if (!gtk_widget_get_realized (attach_widget))
     gtk_widget_realize (attach_widget);
 
   /* get the menu/widget size request */
@@ -2446,8 +2448,13 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
   plug = gtk_widget_get_ancestor (attach_widget, GTK_TYPE_PLUG);
   if (plug != NULL)
     {
-       gdk_window_get_geometry (gtk_plug_get_socket_window (GTK_PLUG (plug)),
+#if GTK_CHECK_VERSION(3,0,0)
+      gdk_window_get_geometry (gtk_plug_get_socket_window (GTK_PLUG (plug)),
+                                &px, &py, NULL, NULL);
+#else
+      gdk_window_get_geometry (gtk_plug_get_socket_window (GTK_PLUG (plug)),
                                 &px, &py, NULL, NULL, NULL);
+#endif
 
        *x += px;
        *y += py;
@@ -2466,7 +2473,8 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
           while (gtk_events_pending ())
             gtk_main_iteration ();
 
-          gdk_window_get_position (GDK_WINDOW (attach_widget->window), x, y);
+          gdk_window_get_position
+            (GDK_WINDOW (gtk_widget_get_window (attach_widget)), x, y);
 
           /* don't try longer then 1/2 a second */
           g_get_current_time (&now_t);
@@ -2478,8 +2486,9 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
     }
 
   /* add the widgets allocation */
-  *x += attach_widget->allocation.x;
-  *y += attach_widget->allocation.y;
+  gtk_widget_get_allocation (attach_widget, &allocation);
+  *x += allocation.x;
+  *y += allocation.y;
 
   switch (xfce_panel_plugin_arrow_type (plugin))
     {
@@ -2488,7 +2497,7 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
       break;
 
     case GTK_ARROW_DOWN:
-      *y += attach_widget->allocation.height;
+      *y += allocation.height;
       break;
 
     case GTK_ARROW_LEFT:
@@ -2496,13 +2505,13 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
       break;
 
     default: /* GTK_ARROW_RIGHT and GTK_ARROW_NONE */
-      *x += attach_widget->allocation.width;
+      *x += allocation.width;
       break;
     }
 
   /* get the monitor geometry */
   screen = gtk_widget_get_screen (attach_widget);
-  monitor_num = gdk_screen_get_monitor_at_window (screen, attach_widget->window);
+  monitor_num = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (attach_widget));
   gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
 
   /* keep the menu inside the screen */
diff --git a/wrapper/main.c b/wrapper/main.c
index 2420d79..d42ec7d 100644
--- a/wrapper/main.c
+++ b/wrapper/main.c
@@ -271,7 +271,11 @@ main (gint argc, gchar **argv)
   GError                  *error = NULL;
   const gchar             *filename;
   gint                     unique_id;
+#if GTK_CHECK_VERSION(3,0,0)
+  Window                   socket_id;
+#else
   GdkNativeWindow          socket_id;
+#endif
   const gchar             *name;
   const gchar             *display_name;
   const gchar             *comment;
diff --git a/wrapper/wrapper-plug.c b/wrapper/wrapper-plug.c
index 29cced3..119ddbd 100644
--- a/wrapper/wrapper-plug.c
+++ b/wrapper/wrapper-plug.c
@@ -30,8 +30,13 @@
 
 
 static void     wrapper_plug_finalize         (GObject        *object);
+#if GTK_CHECK_VERSION(3,0,0)
+static gboolean wrapper_plug_draw             (GtkWidget      *widget,
+                                               cairo_t        *cr);
+#else
 static gboolean wrapper_plug_expose_event     (GtkWidget      *widget,
                                                GdkEventExpose *event);
+#endif
 static void     wrapper_plug_background_reset (WrapperPlug    *plug);
 
 
@@ -73,7 +78,12 @@ wrapper_plug_class_init (WrapperPlugClass *klass)
   gobject_class->finalize = wrapper_plug_finalize;
 
   gtkwidget_class = GTK_WIDGET_CLASS (klass);
+
+#if GTK_CHECK_VERSION(3,0,0)
+  gtkwidget_class->draw = wrapper_plug_draw;
+#else
   gtkwidget_class->expose_event = wrapper_plug_expose_event;
+#endif
 }
 
 
@@ -81,8 +91,10 @@ wrapper_plug_class_init (WrapperPlugClass *klass)
 static void
 wrapper_plug_init (WrapperPlug *plug)
 {
+#if !GTK_CHECK_VERSION(3,0,0)
   GdkColormap *colormap = NULL;
   GdkScreen   *screen;
+#endif
 
   plug->background_alpha = 1.00;
   plug->background_color = NULL;
@@ -101,11 +113,13 @@ wrapper_plug_init (WrapperPlug *plug)
       && strcmp (wrapper_name, "systray") == 0)
     return;
 
+#if !GTK_CHECK_VERSION(3,0,0)
   /* set the colormap */
   screen = gtk_window_get_screen (GTK_WINDOW (plug));
   colormap = gdk_screen_get_rgba_colormap (screen);
   if (colormap != NULL)
     gtk_widget_set_colormap (GTK_WIDGET (plug), colormap);
+#endif
 }
 
 
@@ -120,25 +134,35 @@ wrapper_plug_finalize (GObject *object)
 
 
 
+#if GTK_CHECK_VERSION(3,0,0)
+static gboolean
+wrapper_plug_draw (GtkWidget *widget,
+                   cairo_t   *cr)
+#else
 static gboolean
 wrapper_plug_expose_event (GtkWidget      *widget,
                            GdkEventExpose *event)
+#endif
 {
   WrapperPlug    *plug = WRAPPER_PLUG (widget);
+#if !GTK_CHECK_VERSION(3,0,0)
   cairo_t        *cr;
+#endif
   const GdkColor *color;
   gdouble         alpha;
   GdkPixbuf      *pixbuf;
   GError         *error = NULL;
 
-  if (GTK_WIDGET_DRAWABLE (widget))
+  if (gtk_widget_is_drawable (widget))
     {
       if (G_UNLIKELY (plug->background_image != NULL))
         {
-          cr = gdk_cairo_create (widget->window);
+          cr = gdk_cairo_create (gtk_widget_get_window (widget));
           cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+#if !GTK_CHECK_VERSION(3,0,0)
           gdk_cairo_rectangle (cr, &event->area);
           cairo_clip (cr);
+#endif
 
           if (G_LIKELY (plug->background_image_cache != NULL))
             {
@@ -184,20 +208,26 @@ wrapper_plug_expose_event (GtkWidget      *widget,
               if (plug->background_color != NULL)
                 color = plug->background_color;
               else
-                color = &(widget->style->bg[GTK_STATE_NORMAL]);
+                color = &(gtk_widget_get_style (widget)->bg[GTK_STATE_NORMAL]);
 
               /* draw the background color */
-              cr = gdk_cairo_create (widget->window);
+              cr = gdk_cairo_create (gtk_widget_get_window (widget));
               cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
               cairo_set_source_rgba (cr, PANEL_GDKCOLOR_TO_DOUBLE (color), alpha);
+#if !GTK_CHECK_VERSION(3,0,0)
               gdk_cairo_rectangle (cr, &event->area);
+#endif
               cairo_fill (cr);
               cairo_destroy (cr);
             }
         }
     }
 
+#if GTK_CHECK_VERSION(3,0,0)
+  return GTK_WIDGET_CLASS (wrapper_plug_parent_class)->draw (widget, cr);
+#else
   return GTK_WIDGET_CLASS (wrapper_plug_parent_class)->expose_event (widget, event);
+#endif
 }
 
 
@@ -221,8 +251,13 @@ wrapper_plug_background_reset (WrapperPlug *plug)
 
 
 
+#if GTK_CHECK_VERSION(3,0,0)
+WrapperPlug *
+wrapper_plug_new (Window socket_id)
+#else
 WrapperPlug *
 wrapper_plug_new (GdkNativeWindow socket_id)
+#endif
 {
   WrapperPlug *plug;
 
diff --git a/wrapper/wrapper-plug.h b/wrapper/wrapper-plug.h
index 05853d0..984949f 100644
--- a/wrapper/wrapper-plug.h
+++ b/wrapper/wrapper-plug.h
@@ -20,6 +20,8 @@
 #define __WRAPPER_PLUG_H__
 
 #include <gtk/gtk.h>
+#include <gtk/gtkx.h>
+
 #include <libxfce4panel/libxfce4panel.h>
 #include <libxfce4panel/xfce-panel-plugin-provider.h>
 
@@ -39,7 +41,11 @@ extern gchar *wrapper_name;
 
 GType         wrapper_plug_get_type             (void) G_GNUC_CONST;
 
+#if GTK_CHECK_VERSION(3,0,0)
+WrapperPlug  *wrapper_plug_new                  (Window           socket_id);
+#else
 WrapperPlug  *wrapper_plug_new                  (GdkNativeWindow  socket_id);
+#endif
 
 void          wrapper_plug_set_background_alpha (WrapperPlug     *plug,
                                                  gdouble          alpha);


More information about the Xfce4-commits mailing list