summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter de Ridder <peter@xfce.org>2013-04-07 23:08:37 +0200
committerPeter de Ridder <peter@xfce.org>2013-04-07 23:14:59 +0200
commit1b51c7af53d9a8831c23c9daaa10e3af87c17482 (patch)
tree27cbf1dc3d4e4906044d56d27c70f8b88826c942
parent55f09b17a823fa1c5828f43e321311ca7f5ba891 (diff)
Added GTK+-3 version of libxfce4panel.
-rw-r--r--configure.ac.in10
-rw-r--r--libxfce4panel/Makefile.am45
-rw-r--r--libxfce4panel/xfce-arrow-button.c209
-rw-r--r--libxfce4panel/xfce-panel-convenience.c6
-rw-r--r--libxfce4panel/xfce-panel-image.c185
-rw-r--r--libxfce4panel/xfce-panel-macros-46.h6
-rw-r--r--libxfce4panel/xfce-panel-plugin.c30
7 files changed, 420 insertions, 71 deletions
diff --git a/configure.ac.in b/configure.ac.in
index 80d909e3..654eab23 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -139,6 +139,14 @@ XDT_CHECK_PACKAGE([DBUS], [dbus-glib-1], [0.73])
XDT_CHECK_PACKAGE([CAIRO], [cairo], [1.0.0])
XDT_CHECK_PACKAGE([LIBWNCK], [libwnck-1.0], [2.30])
+dnl ***********************************************************
+dnl *** Optional support for a GTK+3 version of the library ***
+dnl ***********************************************************
+XDT_CHECK_OPTIONAL_PACKAGE([GTK3],
+ [gtk+-3.0], [3.2.0], [gtk3],
+ [GTK+ 3 support])
+AM_CONDITIONAL([ENABLE_GTK3_LIBRARY], [test "x$GTK3_FOUND" = "xyes"])
+
dnl **********************************
dnl *** Optional GIO UNIX features ***
dnl **********************************
@@ -228,6 +236,7 @@ icons/48x48/Makefile
icons/scalable/Makefile
libxfce4panel/Makefile
libxfce4panel/libxfce4panel-1.0.pc
+libxfce4panel/libxfce4panel-2.0.pc
libxfce4panel/libxfce4panel-config.h
migrate/Makefile
migrate/default.xml
@@ -256,4 +265,5 @@ echo "Build Configuration:"
echo
echo "* Debug Support: $enable_debug"
echo "* GNU Visibility: $have_gnuc_visibility"
+echo "* GTK+ 3 Support: $GTK3_FOUND"
echo
diff --git a/libxfce4panel/Makefile.am b/libxfce4panel/Makefile.am
index cba5083f..384d15ff 100644
--- a/libxfce4panel/Makefile.am
+++ b/libxfce4panel/Makefile.am
@@ -75,6 +75,51 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libxfce4panel-$(LIBXFCE4PANEL_VERSION_API).pc
#
+# GTK+ 3 support library
+#
+if ENABLE_GTK3_LIBRARY
+
+lib_LTLIBRARIES += libxfce4panel-2.0.la
+
+libxfce4panel2_includedir = \
+ $(includedir)/xfce4/libxfce4panel-2.0/libxfce4panel
+
+libxfce4panel2_include_HEADERS = \
+ $(libxfce4panel_public_built_sources) \
+ $(libxfce4panel_headers)
+
+libxfce4panel_2_0_la_SOURCES = \
+ $(libxfce4panel_built_sources) \
+ $(libxfce4panel_headers) \
+ libxfce4panel-config.c \
+ xfce-arrow-button.c \
+ xfce-panel-convenience.c \
+ xfce-panel-plugin.c \
+ xfce-panel-plugin-provider.c \
+ xfce-panel-image.c
+
+libxfce4panel_2_0_la_CFLAGS = \
+ $(GTK_CFLAGS) \
+ $(LIBXFCE4UTIL_CFLAGS) \
+ $(PLATFORM_CFLAGS)
+
+libxfce4panel_2_0_la_LDFLAGS = \
+ -no-undefined \
+ -export-dynamic \
+ -version-info $(LIBXFCE4PANEL_VERINFO) \
+ -export-symbols-regex '^[^_].*' \
+ $(PLATFORM_LDFLAGS)
+
+libxfce4panel_2_0_la_LIBADD = \
+ $(GTK_LIBS) \
+ $(LIBXFCE4UTIL_LIBS) \
+ -lm
+
+pkgconfig_DATA += libxfce4panel-2.0.pc
+
+endif
+
+#
# Build sources
#
if MAINTAINER_MODE
diff --git a/libxfce4panel/xfce-arrow-button.c b/libxfce4panel/xfce-arrow-button.c
index 01eb2d25..bbf23694 100644
--- a/libxfce4panel/xfce-arrow-button.c
+++ b/libxfce4panel/xfce-arrow-button.c
@@ -66,21 +66,32 @@ enum
PROP_ARROW_TYPE
};
-static void xfce_arrow_button_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void xfce_arrow_button_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void xfce_arrow_button_finalize (GObject *object);
-static gboolean xfce_arrow_button_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-static void xfce_arrow_button_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void xfce_arrow_button_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
+static void xfce_arrow_button_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void xfce_arrow_button_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void xfce_arrow_button_finalize (GObject *object);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean xfce_arrow_button_draw (GtkWidget *widget,
+ cairo_t *cr);
+static void xfce_arrow_button_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width);
+static void xfce_arrow_button_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height);
+#else
+static gboolean xfce_arrow_button_expose_event (GtkWidget *widget,
+ GdkEventExpose *event);
+static void xfce_arrow_button_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
+#endif
+static void xfce_arrow_button_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
@@ -124,8 +135,14 @@ xfce_arrow_button_class_init (XfceArrowButtonClass * klass)
gobject_class->finalize = xfce_arrow_button_finalize;
gtkwidget_class = GTK_WIDGET_CLASS (klass);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtkwidget_class->draw = xfce_arrow_button_draw;
+ gtkwidget_class->get_preferred_width = xfce_arrow_button_get_preferred_width;
+ gtkwidget_class->get_preferred_height = xfce_arrow_button_get_preferred_height;
+#else
gtkwidget_class->expose_event = xfce_arrow_button_expose_event;
gtkwidget_class->size_request = xfce_arrow_button_size_request;
+#endif
gtkwidget_class->size_allocate = xfce_arrow_button_size_allocate;
/**
@@ -176,8 +193,9 @@ xfce_arrow_button_init (XfceArrowButton *button)
button->priv->last_relief = GTK_RELIEF_NORMAL;
/* set some widget properties */
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (button), GTK_NO_WINDOW);
- GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_DEFAULT | GTK_CAN_FOCUS);
+ gtk_widget_set_has_window (GTK_WIDGET (button), FALSE);
+ gtk_widget_set_can_default (GTK_WIDGET (button), FALSE);
+ gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE);
gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
}
@@ -240,6 +258,147 @@ xfce_arrow_button_finalize (GObject *object)
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean
+xfce_arrow_button_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ XfceArrowButton *button = XFCE_ARROW_BUTTON (widget);
+ GtkWidget *child;
+ gint x, y, width;
+ GtkAllocation alloc;
+ gdouble angle;
+ GtkStyleContext *context;
+
+ /* draw the button */
+ (*GTK_WIDGET_CLASS (xfce_arrow_button_parent_class)->draw) (widget, cr);
+
+ if (button->priv->arrow_type != GTK_ARROW_NONE
+ && gtk_widget_is_drawable (widget))
+ {
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child != NULL
+ && gtk_widget_get_visible (child))
+ {
+ gtk_widget_get_allocation (widget, &alloc);
+
+ if (button->priv->arrow_type == GTK_ARROW_UP
+ || button->priv->arrow_type == GTK_ARROW_DOWN)
+ {
+ width = ARROW_WIDTH;
+ x = alloc.x + 1 /* widget->style->xthickness */;
+ y = alloc.y + (alloc.height - width) / 2;
+ }
+ else
+ {
+ width = ARROW_WIDTH;
+ x = alloc.x + (alloc.width - width) / 2;
+ y = alloc.y + 1 /* widget->style->ythickness */;
+ }
+ }
+ else
+ {
+ width = MIN (alloc.height - 2 * 1 /* widget->style->ythickness */,
+ alloc.width - 2 * 1 /* widget->style->xthickness */);
+ width = CLAMP (width, 1, ARROW_WIDTH);
+
+ x = alloc.x + (alloc.width - width) / 2;
+ y = alloc.y + (alloc.height - width) / 2;
+ }
+
+ switch (button->priv->arrow_type)
+ {
+ case GTK_ARROW_DOWN: angle = G_PI;
+ case GTK_ARROW_LEFT: angle = G_PI / 2.0 + G_PI;
+ case GTK_ARROW_RIGHT: angle = G_PI / 2.0;
+ default: angle = 0;
+ }
+
+ context = gtk_widget_get_style_context (widget);
+ gtk_render_arrow (context, cr, angle, x, y, ARROW_WIDTH);
+ }
+
+ return TRUE;
+}
+
+
+
+static void
+xfce_arrow_button_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ XfceArrowButton *button = XFCE_ARROW_BUTTON (widget);
+ GtkWidget *child;
+
+ /* use gtk for the widget size */
+ (*GTK_WIDGET_CLASS (xfce_arrow_button_parent_class)->get_preferred_width) (widget, minimal_width, natural_width);
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child != NULL
+ && gtk_widget_get_visible (child))
+ {
+ /* reserve space for the arrow */
+ switch (button->priv->arrow_type)
+ {
+ case GTK_ARROW_UP:
+ case GTK_ARROW_DOWN:
+ *minimal_width += ARROW_WIDTH;
+ *natural_width += ARROW_WIDTH;
+ break;
+
+ default:
+ break;
+ }
+ }
+ else if (button->priv->arrow_type != GTK_ARROW_NONE)
+ {
+ *minimal_width += ARROW_WIDTH;
+ *natural_width += ARROW_WIDTH;
+ }
+}
+
+
+
+static void
+xfce_arrow_button_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ XfceArrowButton *button = XFCE_ARROW_BUTTON (widget);
+ GtkWidget *child;
+
+ /* use gtk for the widget size */
+ (*GTK_WIDGET_CLASS (xfce_arrow_button_parent_class)->get_preferred_height) (widget, minimal_height, natural_height);
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child != NULL
+ && gtk_widget_get_visible (child))
+ {
+ /* reserve space for the arrow */
+ switch (button->priv->arrow_type)
+ {
+ case GTK_ARROW_UP:
+ case GTK_ARROW_DOWN:
+ *minimal_height += ARROW_WIDTH;
+ *natural_height += ARROW_WIDTH;
+ break;
+
+ default:
+ break;
+ }
+ }
+ else if (button->priv->arrow_type != GTK_ARROW_NONE)
+ {
+ *minimal_height += ARROW_WIDTH;
+ *natural_height += ARROW_WIDTH;
+ }
+}
+#endif
+
+
+
+#if !GTK_CHECK_VERSION (3, 0, 0)
static gboolean
xfce_arrow_button_expose_event (GtkWidget *widget,
GdkEventExpose *event)
@@ -329,6 +488,7 @@ xfce_arrow_button_size_request (GtkWidget *widget,
requisition->width = ARROW_WIDTH + 2 * widget->style->ythickness;
}
}
+#endif
@@ -346,10 +506,11 @@ xfce_arrow_button_size_allocate (GtkWidget *widget,
if (button->priv->arrow_type != GTK_ARROW_NONE)
{
child = gtk_bin_get_child (GTK_BIN (widget));
- if (child != NULL && GTK_WIDGET_VISIBLE (child))
+ if (child != NULL
+ && gtk_widget_get_visible (child))
{
/* copy the child allocation */
- child_allocation = child->allocation;
+ gtk_widget_get_allocation (child, &child_allocation);
/* update the allocation to make space for the arrow */
switch (button->priv->arrow_type)
@@ -381,8 +542,6 @@ xfce_arrow_button_blinking_timeout (gpointer user_data)
GtkStyle *style;
GtkRcStyle *rc;
- GDK_THREADS_ENTER ();
-
rc = gtk_widget_get_modifier_style (GTK_WIDGET (button));
if(PANEL_HAS_FLAG (rc->color_flags[GTK_STATE_NORMAL], GTK_RC_BG)
|| button->priv->blinking_timeout_id == 0)
@@ -400,8 +559,6 @@ xfce_arrow_button_blinking_timeout (gpointer user_data)
gtk_widget_modify_style(GTK_WIDGET (button), rc);
}
- GDK_THREADS_LEAVE ();
-
return (button->priv->blinking_counter++ < MAX_BLINKING_COUNT);
}
@@ -531,9 +688,9 @@ xfce_arrow_button_set_blinking (XfceArrowButton *button,
{
/* start blinking timeout */
button->priv->blinking_timeout_id =
- g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 500,
- xfce_arrow_button_blinking_timeout, button,
- xfce_arrow_button_blinking_timeout_destroyed);
+ gdk_threads_add_timeout_full (G_PRIORITY_DEFAULT_IDLE, 500,
+ xfce_arrow_button_blinking_timeout, button,
+ xfce_arrow_button_blinking_timeout_destroyed);
}
}
else if (button->priv->blinking_timeout_id != 0)
diff --git a/libxfce4panel/xfce-panel-convenience.c b/libxfce4panel/xfce-panel-convenience.c
index 79023608..43a3c08c 100644
--- a/libxfce4panel/xfce-panel-convenience.c
+++ b/libxfce4panel/xfce-panel-convenience.c
@@ -57,7 +57,8 @@ xfce_panel_create_button (void)
{
GtkWidget *button = gtk_button_new ();
- 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 +81,8 @@ 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_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-image.c b/libxfce4panel/xfce-panel-image.c
index f8dfab30..2c5ba5b1 100644
--- a/libxfce4panel/xfce-panel-image.c
+++ b/libxfce4panel/xfce-panel-image.c
@@ -105,28 +105,42 @@ enum
-static void xfce_panel_image_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void xfce_panel_image_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void xfce_panel_image_finalize (GObject *object);
-static void xfce_panel_image_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void xfce_panel_image_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gboolean xfce_panel_image_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-static void xfce_panel_image_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
-static gboolean xfce_panel_image_load (gpointer data);
-static void xfce_panel_image_load_destroy (gpointer data);
-static GdkPixbuf *xfce_panel_image_scale_pixbuf (GdkPixbuf *source,
- gint dest_width,
- gint dest_height);
+static void xfce_panel_image_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void xfce_panel_image_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void xfce_panel_image_finalize (GObject *object);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void xfce_panel_image_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width);
+static void xfce_panel_image_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height);
+#else
+static void xfce_panel_image_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
+#endif
+static void xfce_panel_image_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean xfce_panel_image_draw (GtkWidget *widget,
+ cairo_t *cr);
+#else
+static gboolean xfce_panel_image_expose_event (GtkWidget *widget,
+ GdkEventExpose *event);
+#endif
+static void xfce_panel_image_style_set (GtkWidget *widget,
+ GtkStyle *previous_style);
+static gboolean xfce_panel_image_load (gpointer data);
+static void xfce_panel_image_load_destroy (gpointer data);
+static GdkPixbuf *xfce_panel_image_scale_pixbuf (GdkPixbuf *source,
+ gint dest_width,
+ gint dest_height);
@@ -143,14 +157,23 @@ xfce_panel_image_class_init (XfcePanelImageClass *klass)
g_type_class_add_private (klass, sizeof (XfcePanelImagePrivate));
gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->get_property = xfce_panel_image_get_property;
gobject_class->set_property = xfce_panel_image_set_property;
+ gobject_class->get_property = xfce_panel_image_get_property;
gobject_class->finalize = xfce_panel_image_finalize;
gtkwidget_class = GTK_WIDGET_CLASS (klass);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtkwidget_class->get_preferred_width = xfce_panel_image_get_preferred_width;
+ gtkwidget_class->get_preferred_height = xfce_panel_image_get_preferred_height;
+#else
gtkwidget_class->size_request = xfce_panel_image_size_request;
+#endif
gtkwidget_class->size_allocate = xfce_panel_image_size_allocate;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtkwidget_class->draw = xfce_panel_image_draw;
+#else
gtkwidget_class->expose_event = xfce_panel_image_expose_event;
+#endif
gtkwidget_class->style_set = xfce_panel_image_style_set;
g_object_class_install_property (gobject_class,
@@ -194,7 +217,7 @@ xfce_panel_image_class_init (XfcePanelImageClass *klass)
static void
xfce_panel_image_init (XfcePanelImage *image)
{
- GTK_WIDGET_SET_FLAGS (image, GTK_NO_WINDOW);
+ gtk_widget_set_has_window (GTK_WIDGET (image), FALSE);
image->priv = G_TYPE_INSTANCE_GET_PRIVATE (image, XFCE_TYPE_PANEL_IMAGE, XfcePanelImagePrivate);
@@ -280,6 +303,55 @@ xfce_panel_image_finalize (GObject *object)
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+xfce_panel_image_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
+ GtkAllocation alloc;
+
+ if (priv->size > 0)
+ *minimal_width = priv->size;
+ else if (priv->pixbuf != NULL)
+ *minimal_width = gdk_pixbuf_get_width (priv->pixbuf);
+ else
+ {
+ gtk_widget_get_allocation (widget, &alloc);
+ *minimal_width = alloc.width;
+ }
+
+ *natural_width = *minimal_width;
+}
+
+
+
+static void
+xfce_panel_image_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
+ GtkAllocation alloc;
+
+ if (priv->size > 0)
+ *minimal_height = priv->size;
+ else if (priv->pixbuf != NULL)
+ *minimal_height = gdk_pixbuf_get_height (priv->pixbuf);
+ else
+ {
+ gtk_widget_get_allocation (widget, &alloc);
+ *minimal_height = alloc.height;
+ }
+
+ *natural_height = *minimal_height;
+}
+#endif
+
+
+
+#if !GTK_CHECK_VERSION (3, 0, 0)
static void
xfce_panel_image_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -302,6 +374,7 @@ xfce_panel_image_size_request (GtkWidget *widget,
requisition->height = widget->allocation.height;
}
}
+#endif
@@ -311,8 +384,7 @@ xfce_panel_image_size_allocate (GtkWidget *widget,
{
XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
-
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
/* check if the available size changed */
if ((priv->pixbuf != NULL || priv->source != NULL)
@@ -331,8 +403,8 @@ xfce_panel_image_size_allocate (GtkWidget *widget,
if (priv->pixbuf == NULL)
{
/* delay icon loading */
- priv->idle_load_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, xfce_panel_image_load,
- widget, xfce_panel_image_load_destroy);
+ priv->idle_load_id = gdk_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE, xfce_panel_image_load,
+ widget, xfce_panel_image_load_destroy);
}
else
{
@@ -344,6 +416,58 @@ xfce_panel_image_size_allocate (GtkWidget *widget,
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean
+xfce_panel_image_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
+ gint source_width, source_height;
+ gint dest_x, dest_y;
+ GtkIconSource *source;
+ GdkPixbuf *rendered = NULL;
+ GdkPixbuf *pixbuf = priv->cache;
+ GtkStyleContext *context;
+ GtkAllocation alloc;
+
+ if (G_LIKELY (pixbuf != NULL))
+ {
+ /* get the size of the cache pixbuf */
+ source_width = gdk_pixbuf_get_width (pixbuf);
+ source_height = gdk_pixbuf_get_height (pixbuf);
+
+ /* position */
+ gtk_widget_get_allocation (widget, &alloc);
+ dest_x = alloc.x + (priv->width - source_width) / 2;
+ dest_y = alloc.y + (priv->height - source_height) / 2;
+
+ context = gtk_widget_get_style_context (widget);
+
+ if (!gtk_widget_is_sensitive (widget))
+ {
+ source = gtk_icon_source_new ();
+ gtk_icon_source_set_pixbuf (source, pixbuf);
+ rendered = gtk_render_icon_pixbuf (context, source, -1);
+ gtk_icon_source_free (source);
+
+ if (G_LIKELY (rendered != NULL))
+ pixbuf = rendered;
+ }
+
+ /* draw the icon */
+ gtk_render_icon (context, cr, pixbuf, dest_x, dest_y);
+
+ if (rendered != NULL)
+ g_object_unref (G_OBJECT (rendered));
+ }
+
+ return FALSE;
+}
+#endif
+
+
+
+#if !GTK_CHECK_VERSION (3, 0, 0)
static gboolean
xfce_panel_image_expose_event (GtkWidget *widget,
GdkEventExpose *event)
@@ -397,6 +521,7 @@ xfce_panel_image_expose_event (GtkWidget *widget,
return FALSE;
}
+#endif
@@ -442,8 +567,6 @@ xfce_panel_image_load (gpointer data)
GtkIconTheme *icon_theme = NULL;
gint dest_w, dest_h;
- GDK_THREADS_ENTER ();
-
dest_w = priv->width;
dest_h = priv->height;
@@ -487,8 +610,6 @@ xfce_panel_image_load (gpointer data)
if (G_LIKELY (priv->cache != NULL))
gtk_widget_queue_draw (GTK_WIDGET (data));
- GDK_THREADS_LEAVE ();
-
return FALSE;
}
diff --git a/libxfce4panel/xfce-panel-macros-46.h b/libxfce4panel/xfce-panel-macros-46.h
index 19f2153b..6b472e3d 100644
--- a/libxfce4panel/xfce-panel-macros-46.h
+++ b/libxfce4panel/xfce-panel-macros-46.h
@@ -393,9 +393,9 @@ G_BEGIN_DECLS
\
g_return_if_fail (GTK_IS_PLUG (plug)); \
g_return_if_fail (XFCE_IS_PANEL_PLUGIN (xpp)); \
- g_return_if_fail (GTK_WIDGET_REALIZED (plug)); \
+ g_return_if_fail (gtk_widget_get_realized (plug)); \
g_return_if_fail (_xpp_atom != GDK_NONE); \
- g_return_if_fail (GTK_WIDGET_REALIZED (xpp)); \
+ g_return_if_fail (gtk_widget_get_realized (xpp)); \
\
if (_xpp_debug) \
g_printerr ("xfce4-panel(%s): send provider signal %d\n", \
@@ -428,7 +428,7 @@ G_BEGIN_DECLS
\
g_return_if_fail (XFCE_IS_PANEL_PLUGIN (xpp)); \
g_return_if_fail (GTK_IS_PLUG (plug)); \
- g_return_if_fail (GTK_WIDGET_REALIZED (plug)); \
+ g_return_if_fail (gtk_widget_get_realized (plug)); \
\
if (_xpp_debug) \
g_printerr ("xfce4-panel(%s): calling plugin construct function\n", \
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index d43d4e9c..cd67eaac 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -28,6 +28,9 @@
#endif
#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <gtk/gtkx.h>
+#endif
#include <glib.h>
#include <libxfce4util/libxfce4util.h>
@@ -2409,6 +2412,7 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
GTimeVal now_t, end_t;
GtkWidget *toplevel, *plug;
gint px, py;
+ GtkAllocation alloc;
g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
g_return_if_fail (GTK_IS_WIDGET (menu_widget));
@@ -2420,15 +2424,19 @@ 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 */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (menu_widget, &requisition, NULL);
+#else
gtk_widget_size_request (menu_widget, &requisition);
+#endif
/* get the root position of the attach widget */
toplevel = gtk_widget_get_toplevel (attach_widget);
@@ -2438,8 +2446,13 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
plug = gtk_widget_get_ancestor (attach_widget, GTK_TYPE_PLUG);
if (plug != NULL)
{
+#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;
@@ -2458,7 +2471,7 @@ 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 (gtk_widget_get_window (attach_widget), x, y);
/* don't try longer then 1/2 a second */
g_get_current_time (&now_t);
@@ -2470,8 +2483,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, &alloc);
+ *x += alloc.x;
+ *y += alloc.y;
switch (xfce_panel_plugin_arrow_type (plugin))
{
@@ -2480,7 +2494,7 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
break;
case GTK_ARROW_DOWN:
- *y += attach_widget->allocation.height;
+ *y += alloc.height;
break;
case GTK_ARROW_LEFT:
@@ -2488,13 +2502,13 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
break;
default: /* GTK_ARROW_RIGHT and GTK_ARROW_NONE */
- *x += attach_widget->allocation.width;
+ *x += alloc.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 */