[Xfce4-commits] <xfce4-panel:devel> Rename XfceScaledImage to XfcePanelImage.
Nick Schermer
nick at xfce.org
Tue Aug 11 20:35:12 CEST 2009
Updating branch refs/heads/devel
to 466377925e1e222598d4ce077a229939d1af1ce8 (commit)
from 4780229d86229e15c20a6192ecb674481c4a9f75 (commit)
commit 466377925e1e222598d4ce077a229939d1af1ce8
Author: Nick Schermer <nick at xfce.org>
Date: Wed Jun 24 20:27:42 2009 +0200
Rename XfceScaledImage to XfcePanelImage.
This to avoid conflicts between panel and libxfcegui4.
Also changed the calls to the function. You can now set a
filename or icon-name through _set_source() function, the
object will figure out what the source is. This to reduce
code dupplication for loading files or (weird) icon names.
libxfce4panel/Makefile.am | 4 +-
libxfce4panel/libxfce4panel.h | 2 +-
libxfce4panel/xfce-panel-image.c | 547 ++++++++++++++++++++++++++++++++++++
libxfce4panel/xfce-panel-image.h | 80 ++++++
libxfce4panel/xfce-scaled-image.c | 435 ----------------------------
libxfce4panel/xfce-scaled-image.h | 63 ----
plugins/actions/actions.c | 12 +-
plugins/launcher/launcher.c | 26 +-
plugins/showdesktop/showdesktop.c | 2 +-
plugins/tasklist/tasklist-widget.c | 6 +-
plugins/windowmenu/windowmenu.c | 18 +-
11 files changed, 660 insertions(+), 535 deletions(-)
diff --git a/libxfce4panel/Makefile.am b/libxfce4panel/Makefile.am
index 04c3442..ff46839 100644
--- a/libxfce4panel/Makefile.am
+++ b/libxfce4panel/Makefile.am
@@ -22,7 +22,7 @@ libxfce4panel_headers = \
xfce-panel-enums.h \
xfce-panel-macros.h \
xfce-panel-plugin.h \
- xfce-scaled-image.h
+ xfce-panel-image.h
libxfce4panel_includedir = \
$(includedir)/xfce4/libxfce4panel
@@ -39,7 +39,7 @@ libxfce4panel_la_SOURCES = \
xfce-panel-plugin.c \
xfce-panel-plugin-provider.c \
xfce-panel-plugin-provider.h \
- xfce-scaled-image.c
+ xfce-panel-image.c
libxfce4panel_la_CFLAGS = \
$(GTK_CFLAGS) \
diff --git a/libxfce4panel/libxfce4panel.h b/libxfce4panel/libxfce4panel.h
index 54fae77..b16d10a 100644
--- a/libxfce4panel/libxfce4panel.h
+++ b/libxfce4panel/libxfce4panel.h
@@ -30,7 +30,7 @@ G_BEGIN_DECLS
#include <libxfce4panel/xfce-panel-convenience.h>
#include <libxfce4panel/xfce-panel-enums.h>
#include <libxfce4panel/xfce-panel-plugin.h>
-#include <libxfce4panel/xfce-scaled-image.h>
+#include <libxfce4panel/xfce-panel-image.h>
#undef LIBXFCE4PANEL_INSIDE_LIBXFCE4PANEL_H
diff --git a/libxfce4panel/xfce-panel-image.c b/libxfce4panel/xfce-panel-image.c
new file mode 100644
index 0000000..ca7f325
--- /dev/null
+++ b/libxfce4panel/xfce-panel-image.c
@@ -0,0 +1,547 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2009 Nick Schermer <nick at xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+
+#include <gtk/gtk.h>
+
+#include <common/panel-private.h>
+#include <libxfce4panel/libxfce4panel.h>
+
+
+/* design limit for the panel, to reduce the uncached pixbuf size */
+#define MAX_PIXBUF_SIZE (128)
+
+#define XFCE_PANEL_IMAGE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
+ XFCE_TYPE_PANEL_IMAGE, \
+ XfcePanelImagePrivate))
+
+
+
+struct _XfcePanelImagePrivate
+{
+ /* pixbuf set by the user */
+ GdkPixbuf *pixbuf;
+
+ /* internal cached pixbuf (resized) */
+ GdkPixbuf *cache;
+
+ /* source name */
+ gchar *source;
+
+ /* fixed size */
+ gint size;
+
+ /* whether we round to fixed icon sizes */
+ guint force_icon_sizes : 1;
+
+ /* cached width and height */
+ gint width;
+ gint height;
+};
+
+enum
+{
+ PROP_0,
+ PROP_SOURCE,
+ PROP_PIXBUF,
+ PROP_SIZE
+};
+
+
+
+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 GdkPixbuf *xfce_panel_image_scale_pixbuf (GdkPixbuf *source,
+ gint dest_width,
+ gint dest_height);
+
+
+
+G_DEFINE_TYPE (XfcePanelImage, xfce_panel_image, GTK_TYPE_WIDGET)
+
+
+
+static void
+xfce_panel_image_class_init (XfcePanelImageClass *klass)
+{
+ GObjectClass *gobject_class;
+ GtkWidgetClass *gtkwidget_class;
+
+ /* add private data */
+ 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->finalize = xfce_panel_image_finalize;
+
+ gtkwidget_class = GTK_WIDGET_CLASS (klass);
+ gtkwidget_class->size_request = xfce_panel_image_size_request;
+ gtkwidget_class->size_allocate = xfce_panel_image_size_allocate;
+ gtkwidget_class->expose_event = xfce_panel_image_expose_event;
+ gtkwidget_class->style_set = xfce_panel_image_style_set;
+
+ g_object_class_install_property (gobject_class,
+ PROP_SOURCE,
+ g_param_spec_string ("source",
+ "Source",
+ "Icon or filename",
+ NULL,
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class,
+ PROP_PIXBUF,
+ g_param_spec_object ("pixbuf",
+ "Pixbuf",
+ "Pixbuf image",
+ GDK_TYPE_PIXBUF,
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class,
+ PROP_SIZE,
+ g_param_spec_int ("size",
+ "Size",
+ "Pixel size of the image",
+ -1, MAX_PIXBUF_SIZE, -1,
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS));
+
+ gtk_widget_class_install_style_property (gtkwidget_class,
+ g_param_spec_boolean ("force-gtk-icon-sizes",
+ NULL,
+ "Force the image to fix to GtkIconSizes",
+ FALSE,
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS));
+}
+
+
+
+static void
+xfce_panel_image_init (XfcePanelImage *image)
+{
+ GTK_WIDGET_SET_FLAGS (image, GTK_NO_WINDOW);
+
+ /* set private pointer */
+ image->priv = XFCE_PANEL_IMAGE_GET_PRIVATE (image);
+
+ /* initialize */
+ image->priv->pixbuf = NULL;
+ image->priv->cache = NULL;
+ image->priv->source = NULL;
+ image->priv->size = -1;
+ image->priv->width = -1;
+ image->priv->height = -1;
+ image->priv->force_icon_sizes = FALSE;
+}
+
+
+
+static void
+xfce_panel_image_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_SOURCE:
+ g_value_set_string (value, priv->source);
+ break;
+
+ case PROP_PIXBUF:
+ g_value_set_object (value, priv->pixbuf);
+ break;
+
+ case PROP_SIZE:
+ g_value_set_int (value, priv->size);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+static void
+xfce_panel_image_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ XfcePanelImagePrivate *priv;
+ gint size;
+
+ switch (prop_id)
+ {
+ case PROP_SOURCE:
+ xfce_panel_image_set_from_source (XFCE_PANEL_IMAGE (object),
+ g_value_get_string (value));
+ break;
+
+ case PROP_PIXBUF:
+ xfce_panel_image_set_from_pixbuf (XFCE_PANEL_IMAGE (object),
+ g_value_get_object (value));
+ break;
+
+ case PROP_SIZE:
+ priv = XFCE_PANEL_IMAGE (object)->priv;
+ size = g_value_get_int (value);
+ if (G_LIKELY (priv->size != size))
+ {
+ priv->size = size;
+ gtk_widget_queue_resize (GTK_WIDGET (object));
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+static void
+xfce_panel_image_finalize (GObject *object)
+{
+ /* cleanup */
+ xfce_panel_image_clear (XFCE_PANEL_IMAGE (object));
+
+ (*G_OBJECT_CLASS (xfce_panel_image_parent_class)->finalize) (object);
+}
+
+
+
+static void
+xfce_panel_image_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
+
+ if (priv->size > 0)
+ {
+ requisition->width = priv->size;
+ requisition->height = priv->size;
+ }
+ else if (priv->pixbuf != NULL)
+ {
+ requisition->width = gdk_pixbuf_get_width (priv->pixbuf);
+ requisition->height = gdk_pixbuf_get_height (priv->pixbuf);
+ }
+ else
+ {
+ requisition->width = widget->allocation.width;
+ requisition->height = widget->allocation.height;
+ }
+}
+
+
+
+static void
+xfce_panel_image_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
+ GdkPixbuf *pixbuf = NULL;
+ GdkScreen *screen;
+ GError *error = NULL;
+
+ widget->allocation = *allocation;
+
+ /* check if the available size changed */
+ if ((priv->pixbuf != NULL || priv->source != NULL)
+ && allocation->width > 0
+ && allocation->height > 0
+ && (allocation->width != priv->width
+ || allocation->height != priv->height))
+ {
+ /* store the new size */
+ priv->width = allocation->width;
+ priv->height = allocation->height;
+
+ /* free cache */
+ if (G_LIKELY (priv->cache != NULL))
+ g_object_unref (G_OBJECT (priv->cache));
+ priv->cache = NULL;
+
+ if (priv->pixbuf != NULL)
+ {
+ /* use the pixbuf set by the user */
+ pixbuf = g_object_ref (G_OBJECT (priv->pixbuf));
+ }
+ else if (g_path_is_absolute (priv->source))
+ {
+ pixbuf = gdk_pixbuf_new_from_file (priv->source, &error);
+ if (G_UNLIKELY (pixbuf == NULL))
+ {
+ g_critical ("Failed to loading image \"%s\": %s",
+ priv->source, error->message);
+ g_error_free (error);
+ return;
+ }
+ }
+ else
+ {
+ /* get the screen */
+ screen = gtk_widget_get_screen (widget);
+
+ /* get a pixbuf from the icon name */
+ pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_for_screen (screen),
+ priv->source,
+ MIN (priv->width, priv->height),
+ 0, NULL);
+
+ /* TODO more loading modes: try without extension and lower case */
+ }
+
+ if (G_LIKELY (pixbuf != NULL))
+ {
+ /* scale the icon to the correct size */
+ priv->cache = xfce_panel_image_scale_pixbuf (pixbuf, priv->width,
+ priv->height);
+
+ /* release the pixbuf */
+ g_object_unref (G_OBJECT (pixbuf));
+ }
+ }
+}
+
+
+
+static gboolean
+xfce_panel_image_expose_event (GtkWidget *widget,
+ GdkEventExpose *event)
+{
+ XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
+ gint source_width, source_height;
+ gint dest_x, dest_y;
+
+ if (G_LIKELY (priv->cache != NULL))
+ {
+ /* get the size of the cache pixbuf */
+ source_width = gdk_pixbuf_get_width (priv->cache);
+ source_height = gdk_pixbuf_get_height (priv->cache);
+
+ /* position */
+ dest_x = widget->allocation.x + (priv->width - source_width) / 2;
+ dest_y = widget->allocation.y + (priv->height - source_height) / 2;
+
+ /* draw the pixbuf */
+ gdk_draw_pixbuf (widget->window,
+ widget->style->black_gc,
+ priv->cache,
+ 0, 0,
+ dest_x, dest_y,
+ source_width, source_height,
+ GDK_RGB_DITHER_NORMAL, 0, 0);
+ }
+
+ return FALSE;
+}
+
+
+
+static void
+xfce_panel_image_style_set (GtkWidget *widget,
+ GtkStyle *previous_style)
+{
+ XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (widget)->priv;
+ gboolean force;
+
+ /* let gtk update the widget style */
+ (*GTK_WIDGET_CLASS (xfce_panel_image_parent_class)->style_set) (widget, previous_style);
+
+ /* get style property */
+ gtk_widget_style_get (widget, "force-gtk-icon-sizes", &force, NULL);
+
+ /* update if needed */
+ if (priv->force_icon_sizes != force)
+ {
+ priv->force_icon_sizes = force;
+ if (priv->size > 0)
+ gtk_widget_queue_resize (widget);
+ }
+}
+
+
+
+static GdkPixbuf *
+xfce_panel_image_scale_pixbuf (GdkPixbuf *source,
+ gint dest_width,
+ gint dest_height)
+{
+ gdouble wratio;
+ gdouble hratio;
+ gint source_width;
+ gint source_height;
+
+ panel_return_val_if_fail (GDK_IS_PIXBUF (source), NULL);
+ panel_return_val_if_fail (dest_width > 0, NULL);
+ panel_return_val_if_fail (dest_height > 0, NULL);
+
+ source_width = gdk_pixbuf_get_width (source);
+ source_height = gdk_pixbuf_get_height (source);
+
+ /* check if we need to scale */
+ if (source_width <= dest_width && source_height <= dest_height)
+ return g_object_ref (G_OBJECT (source));
+
+ /* calculate the new dimensions */
+ wratio = (gdouble) source_width / (gdouble) dest_width;
+ hratio = (gdouble) source_height / (gdouble) dest_height;
+
+ if (hratio > wratio)
+ dest_width = rint (source_width / hratio);
+ else
+ dest_height = rint (source_height / wratio);
+
+ return gdk_pixbuf_scale_simple (source, MAX (dest_width, 1),
+ MAX (dest_height, 1),
+ GDK_INTERP_BILINEAR);
+}
+
+
+
+PANEL_SYMBOL_EXPORT GtkWidget *
+xfce_panel_image_new (void)
+{
+ return g_object_new (XFCE_TYPE_PANEL_IMAGE, NULL);
+}
+
+
+
+PANEL_SYMBOL_EXPORT GtkWidget *
+xfce_panel_image_new_from_pixbuf (GdkPixbuf *pixbuf)
+{
+ g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
+
+ return g_object_new (XFCE_TYPE_PANEL_IMAGE,
+ "pixbuf", pixbuf, NULL);
+}
+
+
+
+PANEL_SYMBOL_EXPORT GtkWidget *
+xfce_panel_image_new_from_source (const gchar *source)
+{
+ g_return_val_if_fail (IS_STRING (source), NULL);
+
+ return g_object_new (XFCE_TYPE_PANEL_IMAGE,
+ "source", source, NULL);
+}
+
+
+
+PANEL_SYMBOL_EXPORT void
+xfce_panel_image_set_from_pixbuf (XfcePanelImage *image,
+ GdkPixbuf *pixbuf)
+{
+ g_return_if_fail (XFCE_IS_PANEL_IMAGE (image));
+ g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
+
+ /* cleanup */
+ xfce_panel_image_clear (image);
+
+ /* set the new pixbuf, scale it to the maximum size if needed */
+ image->priv->pixbuf = xfce_panel_image_scale_pixbuf (pixbuf,
+ MAX_PIXBUF_SIZE, MAX_PIXBUF_SIZE);
+
+ /* queue a resize */
+ gtk_widget_queue_resize (GTK_WIDGET (image));
+}
+
+
+
+PANEL_SYMBOL_EXPORT void
+xfce_panel_image_set_from_source (XfcePanelImage *image,
+ const gchar *source)
+{
+ g_return_if_fail (XFCE_IS_PANEL_IMAGE (image));
+ g_return_if_fail (IS_STRING (source));
+
+ /* cleanup */
+ xfce_panel_image_clear (image);
+
+ /* set new value */
+ image->priv->source = g_strdup (source);
+
+ /* queue a resize */
+ gtk_widget_queue_resize (GTK_WIDGET (image));
+}
+
+
+
+void
+xfce_panel_image_clear (XfcePanelImage *image)
+{
+ XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (image)->priv;
+
+ g_return_if_fail (XFCE_IS_PANEL_IMAGE (image));
+
+ if (priv->source != NULL)
+ {
+ g_free (priv->source);
+ priv->source = NULL;
+ }
+
+ if (priv->pixbuf != NULL)
+ {
+ g_object_unref (G_OBJECT (priv->pixbuf));
+ priv->pixbuf = NULL;
+ }
+
+ if (priv->cache != NULL)
+ {
+ g_object_unref (G_OBJECT (priv->cache));
+ priv->cache = NULL;
+ }
+
+ /* reset values */
+ priv->width = -1;
+ priv->height = -1;
+}
diff --git a/libxfce4panel/xfce-panel-image.h b/libxfce4panel/xfce-panel-image.h
new file mode 100644
index 0000000..64dd823
--- /dev/null
+++ b/libxfce4panel/xfce-panel-image.h
@@ -0,0 +1,80 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2009 Nick Schermer <nick at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#if !defined(LIBXFCE4PANEL_INSIDE_LIBXFCE4PANEL_H) && !defined(LIBXFCE4PANEL_COMPILATION)
+#error "Only <libxfce4panel/libxfce4panel.h> can be included directly, this file may disappear or change contents"
+#endif
+
+#ifndef __XFCE_PANEL_IMAGE_H__
+#define __XFCE_PANEL_IMAGE_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _XfcePanelImageClass XfcePanelImageClass;
+typedef struct _XfcePanelImage XfcePanelImage;
+typedef struct _XfcePanelImagePrivate XfcePanelImagePrivate;
+
+struct _XfcePanelImageClass
+{
+ /*< private >*/
+ GtkWidgetClass __parent__;
+
+ /*< private >*/
+ void (*reserved1) (void);
+ void (*reserved2) (void);
+};
+
+struct _XfcePanelImage
+{
+ /*< private >*/
+ GtkWidget __parent__;
+
+ /*< private >*/
+ XfcePanelImagePrivate *priv;
+};
+
+#define XFCE_TYPE_PANEL_IMAGE (xfce_panel_image_get_type ())
+#define XFCE_PANEL_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_PANEL_IMAGE, XfcePanelImage))
+#define XFCE_PANEL_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_PANEL_IMAGE, XfcePanelImageClass))
+#define XFCE_IS_PANEL_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_PANEL_IMAGE))
+#define XFCE_IS_PANEL_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_PANEL_IMAGE))
+#define XFCE_PANEL_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_PANEL_IMAGE, XfcePanelImageClass))
+
+PANEL_SYMBOL_EXPORT
+GType xfce_panel_image_get_type (void) G_GNUC_CONST;
+
+GtkWidget *xfce_panel_image_new (void) G_GNUC_MALLOC;
+
+GtkWidget *xfce_panel_image_new_from_pixbuf (GdkPixbuf *pixbuf) G_GNUC_MALLOC;
+
+GtkWidget *xfce_panel_image_new_from_source (const gchar *source) G_GNUC_MALLOC;
+
+void xfce_panel_image_set_from_pixbuf (XfcePanelImage *image,
+ GdkPixbuf *pixbuf);
+
+void xfce_panel_image_set_from_source (XfcePanelImage *image,
+ const gchar *source);
+
+void xfce_panel_image_clear (XfcePanelImage *image);
+
+G_END_DECLS
+
+#endif /* !__XFCE_PANEL_IMAGE_H__ */
diff --git a/libxfce4panel/xfce-scaled-image.c b/libxfce4panel/xfce-scaled-image.c
deleted file mode 100644
index 7e34b21..0000000
--- a/libxfce4panel/xfce-scaled-image.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/* $Id$ */
-/*
- * Copyright (C) 2008-2009 Nick Schermer <nick at xfce.org>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_MATH_H
-#include <math.h>
-#endif
-
-#include <gtk/gtk.h>
-
-#include <common/panel-private.h>
-#include <libxfce4panel/libxfce4panel.h>
-
-
-/* design limit for the panel, to reduce the uncached pixbuf size */
-#define MAX_PIXBUF_SIZE (128)
-
-
-
-struct _XfceScaledImageClass
-{
- GtkWidgetClass __parent__;
-};
-
-struct _XfceScaledImage
-{
- GtkWidget __parent__;
-
- /* pixbuf set by the user */
- GdkPixbuf *pixbuf;
-
- /* internal cached pixbuf (resized) */
- GdkPixbuf *cache;
-
- /* icon name */
- gchar *icon_name;
-
- /* cached width and height */
- gint width;
- gint height;
-};
-
-
-
-static void xfce_scaled_image_finalize (GObject *object);
-static void xfce_scaled_image_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void xfce_scaled_image_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gboolean xfce_scaled_image_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-static GdkPixbuf *xfce_scaled_image_scale_pixbuf (GdkPixbuf *source,
- gint dest_width,
- gint dest_height);
-static void xfce_scaled_image_cleanup (XfceScaledImage *image);
-
-
-
-G_DEFINE_TYPE (XfceScaledImage, xfce_scaled_image, GTK_TYPE_WIDGET);
-
-
-
-static void
-xfce_scaled_image_class_init (XfceScaledImageClass *klass)
-{
- GObjectClass *gobject_class;
- GtkWidgetClass *gtkwidget_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = xfce_scaled_image_finalize;
-
- gtkwidget_class = GTK_WIDGET_CLASS (klass);
- gtkwidget_class->size_request = xfce_scaled_image_size_request;
- gtkwidget_class->size_allocate = xfce_scaled_image_size_allocate;
- gtkwidget_class->expose_event = xfce_scaled_image_expose_event;
-}
-
-
-
-static void
-xfce_scaled_image_init (XfceScaledImage *image)
-{
- GTK_WIDGET_SET_FLAGS (image, GTK_NO_WINDOW);
-
- image->pixbuf = NULL;
- image->cache = NULL;
- image->icon_name = NULL;
- image->width = -1;
- image->height = -1;
-}
-
-
-
-static void
-xfce_scaled_image_finalize (GObject *object)
-{
- XfceScaledImage *image = XFCE_SCALED_IMAGE (object);
-
- /* cleanup */
- xfce_scaled_image_cleanup (image);
-
- (*G_OBJECT_CLASS (xfce_scaled_image_parent_class)->finalize) (object);
-}
-
-
-
-static void
-xfce_scaled_image_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- XfceScaledImage *image = XFCE_SCALED_IMAGE (widget);
-
- if (image->pixbuf)
- {
- requisition->width = gdk_pixbuf_get_width (image->pixbuf);
- requisition->height = gdk_pixbuf_get_height (image->pixbuf);
- }
- else
- {
- requisition->width = widget->allocation.width;
- requisition->height = widget->allocation.height;
- }
-}
-
-
-
-static void
-xfce_scaled_image_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- XfceScaledImage *image = XFCE_SCALED_IMAGE (widget);
- GdkPixbuf *pixbuf = NULL;
- GdkScreen *screen;
-
- widget->allocation = *allocation;
-
- /* check if the available size changed */
- if ((image->pixbuf != NULL || image->icon_name != NULL)
- && allocation->width > 0
- && allocation->height > 0
- && (allocation->width != image->width
- || allocation->height != image->height))
- {
- /* store the new size */
- image->width = allocation->width;
- image->height = allocation->height;
-
- /* free cache */
- if (image->cache != NULL)
- g_object_unref (G_OBJECT (image->cache));
- image->cache = NULL;
-
- if (image->pixbuf != NULL)
- {
- /* use the pixbuf set by the user */
- pixbuf = g_object_ref (G_OBJECT (image->pixbuf));
- }
- else if (image->icon_name != NULL)
- {
- /* get the screen */
- screen = gtk_widget_get_screen (GTK_WIDGET (image));
-
- /* get a pixbuf from the icon name */
- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_for_screen (screen),
- image->icon_name,
- MIN (image->width, image->height),
- 0, NULL);
- }
-
- if (G_LIKELY (pixbuf != NULL))
- {
- /* scale the icon to the correct size */
- image->cache = xfce_scaled_image_scale_pixbuf (pixbuf, image->width,
- image->height);
-
- /* release the pixbuf */
- g_object_unref (G_OBJECT (pixbuf));
- }
- }
-}
-
-
-
-static gboolean
-xfce_scaled_image_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
-{
- XfceScaledImage *image = XFCE_SCALED_IMAGE (widget);
- gint source_width, source_height;
- gint dest_x, dest_y;
-
- if (G_LIKELY (image->cache != NULL))
- {
- /* get the size of the cache pixbuf */
- source_width = gdk_pixbuf_get_width (image->cache);
- source_height = gdk_pixbuf_get_height (image->cache);
-
- /* position */
- dest_x = widget->allocation.x + (image->width - source_width) / 2;
- dest_y = widget->allocation.y + (image->height - source_height) / 2;
-
- /* draw the pixbuf */
- gdk_draw_pixbuf (widget->window,
- widget->style->black_gc,
- image->cache,
- 0, 0,
- dest_x, dest_y,
- source_width, source_height,
- GDK_RGB_DITHER_NORMAL, 0, 0);
- }
-
- return FALSE;
-}
-
-
-
-static GdkPixbuf *
-xfce_scaled_image_scale_pixbuf (GdkPixbuf *source,
- gint dest_width,
- gint dest_height)
-{
- gdouble wratio;
- gdouble hratio;
- gint source_width;
- gint source_height;
-
- panel_return_val_if_fail (GDK_IS_PIXBUF (source), NULL);
- panel_return_val_if_fail (dest_width > 0, NULL);
- panel_return_val_if_fail (dest_height > 0, NULL);
-
- source_width = gdk_pixbuf_get_width (source);
- source_height = gdk_pixbuf_get_height (source);
-
- /* check if we need to scale */
- if (source_width <= dest_width && source_height <= dest_height)
- return g_object_ref (G_OBJECT (source));
-
- /* calculate the new dimensions */
- wratio = (gdouble) source_width / (gdouble) dest_width;
- hratio = (gdouble) source_height / (gdouble) dest_height;
-
- if (hratio > wratio)
- dest_width = rint (source_width / hratio);
- else
- dest_height = rint (source_height / wratio);
-
- return gdk_pixbuf_scale_simple (source, MAX (dest_width, 1), MAX (dest_height, 1), GDK_INTERP_BILINEAR);
-}
-
-
-
-static void
-xfce_scaled_image_cleanup (XfceScaledImage *image)
-{
- /* release the pixbuf reference */
- if (G_LIKELY (image->pixbuf))
- g_object_unref (G_OBJECT (image->pixbuf));
-
- /* free the icon name */
- g_free (image->icon_name);
-
- /* clear the image */
- if (G_LIKELY (image->cache != NULL))
- g_object_unref (G_OBJECT (image->cache));
- image->cache = NULL;
-
- /* reset varaibles */
- image->pixbuf = NULL;
- image->icon_name = NULL;
- image->width = -1;
- image->height = -1;
-}
-
-
-
-PANEL_SYMBOL_EXPORT GtkWidget *
-xfce_scaled_image_new (void)
-{
- return g_object_new (XFCE_TYPE_SCALED_IMAGE, NULL);
-}
-
-
-
-PANEL_SYMBOL_EXPORT GtkWidget *
-xfce_scaled_image_new_from_pixbuf (GdkPixbuf *pixbuf)
-{
- GtkWidget *image;
-
- g_return_val_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf), NULL);
-
- /* create a scaled image */
- image = xfce_scaled_image_new ();
-
- /* set the pixbuf */
- xfce_scaled_image_set_from_pixbuf (XFCE_SCALED_IMAGE (image), pixbuf);
-
- return image;
-}
-
-
-
-PANEL_SYMBOL_EXPORT GtkWidget *
-xfce_scaled_image_new_from_icon_name (const gchar *icon_name)
-{
- GtkWidget *image;
-
- /* create a scaled image */
- image = xfce_scaled_image_new ();
-
- /* set the icon name */
- xfce_scaled_image_set_from_icon_name (XFCE_SCALED_IMAGE (image), icon_name);
-
- return image;
-}
-
-
-
-PANEL_SYMBOL_EXPORT GtkWidget *
-xfce_scaled_image_new_from_file (const gchar *filename)
-{
- GtkWidget *image;
-
- /* create a scaled image */
- image = xfce_scaled_image_new ();
-
- /* set the filename */
- xfce_scaled_image_set_from_file (XFCE_SCALED_IMAGE (image), filename);
-
- return image;
-}
-
-
-
-PANEL_SYMBOL_EXPORT void
-xfce_scaled_image_set_from_pixbuf (XfceScaledImage *image,
- GdkPixbuf *pixbuf)
-{
- gint source_width;
- gint source_height;
-
- g_return_if_fail (XFCE_IS_SCALED_IMAGE (image));
- g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
-
- /* cleanup */
- xfce_scaled_image_cleanup (image);
-
- /* get the new pixbuf sizes */
- source_width = gdk_pixbuf_get_width (pixbuf);
- source_height = gdk_pixbuf_get_height (pixbuf);
-
- /* set the new pixbuf, scale it to the maximum size if needed */
- image->pixbuf = xfce_scaled_image_scale_pixbuf (pixbuf,
- MAX_PIXBUF_SIZE, MAX_PIXBUF_SIZE);
-
- /* queue a resize */
- gtk_widget_queue_resize (GTK_WIDGET (image));
-}
-
-
-
-PANEL_SYMBOL_EXPORT void
-xfce_scaled_image_set_from_icon_name (XfceScaledImage *image,
- const gchar *icon_name)
-{
- g_return_if_fail (XFCE_IS_SCALED_IMAGE (image));
- panel_return_if_fail (icon_name == NULL || !g_path_is_absolute (icon_name));
-
- /* cleanup */
- xfce_scaled_image_cleanup (image);
-
- /* set the new icon name */
- if (G_LIKELY (IS_STRING (icon_name)))
- image->icon_name = g_strdup (icon_name);
-
- /* queue a resize */
- gtk_widget_queue_resize (GTK_WIDGET (image));
-}
-
-
-
-PANEL_SYMBOL_EXPORT void
-xfce_scaled_image_set_from_file (XfceScaledImage *image,
- const gchar *filename)
-{
- GError *error = NULL;
- GdkPixbuf *pixbuf;
-
- g_return_if_fail (XFCE_IS_SCALED_IMAGE (image));
- panel_return_if_fail (filename == NULL || g_path_is_absolute (filename));
-
- /* cleanup */
- xfce_scaled_image_cleanup (image);
-
- if (G_LIKELY (IS_STRING (filename)))
- {
- /* try to load the image from the file */
- pixbuf = gdk_pixbuf_new_from_file (filename, &error);
-
- if (G_LIKELY (pixbuf))
- {
- /* set the new pixbuf */
- xfce_scaled_image_set_from_pixbuf (image, pixbuf);
-
- /* release the pixbuf */
- g_object_unref (G_OBJECT (pixbuf));
- }
- else
- {
- /* print a warning what went wrong */
- g_critical ("Failed to loading image from filename: %s", error->message);
-
- /* cleanup */
- g_error_free (error);
- }
- }
-}
diff --git a/libxfce4panel/xfce-scaled-image.h b/libxfce4panel/xfce-scaled-image.h
deleted file mode 100644
index 372ca0f..0000000
--- a/libxfce4panel/xfce-scaled-image.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* $Id$ */
-/*
- * Copyright (C) 2008-2009 Nick Schermer <nick at xfce.org>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#if !defined(LIBXFCE4PANEL_INSIDE_LIBXFCE4PANEL_H) && !defined(LIBXFCE4PANEL_COMPILATION)
-#error "Only <libxfce4panel/libxfce4panel.h> can be included directly, this file may disappear or change contents"
-#endif
-
-#ifndef __XFCE_SCALED_IMAGE_H__
-#define __XFCE_SCALED_IMAGE_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-typedef struct _XfceScaledImageClass XfceScaledImageClass;
-typedef struct _XfceScaledImage XfceScaledImage;
-
-#define XFCE_TYPE_SCALED_IMAGE (xfce_scaled_image_get_type ())
-#define XFCE_SCALED_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_SCALED_IMAGE, XfceScaledImage))
-#define XFCE_SCALED_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_SCALED_IMAGE, XfceScaledImageClass))
-#define XFCE_IS_SCALED_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_SCALED_IMAGE))
-#define XFCE_IS_SCALED_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_SCALED_IMAGE))
-#define XFCE_SCALED_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_SCALED_IMAGE, XfceScaledImageClass))
-
-PANEL_SYMBOL_EXPORT
-GType xfce_scaled_image_get_type (void) G_GNUC_CONST;
-
-GtkWidget *xfce_scaled_image_new (void) G_GNUC_MALLOC;
-
-GtkWidget *xfce_scaled_image_new_from_pixbuf (GdkPixbuf *pixbuf) G_GNUC_MALLOC;
-
-GtkWidget *xfce_scaled_image_new_from_icon_name (const gchar *icon_name) G_GNUC_MALLOC;
-
-GtkWidget *xfce_scaled_image_new_from_file (const gchar *filename) G_GNUC_MALLOC;
-
-void xfce_scaled_image_set_from_pixbuf (XfceScaledImage *image,
- GdkPixbuf *pixbuf);
-
-void xfce_scaled_image_set_from_icon_name (XfceScaledImage *image,
- const gchar *icon_name);
-
-void xfce_scaled_image_set_from_file (XfceScaledImage *image,
- const gchar *filename);
-
-G_END_DECLS
-
-#endif /* !__XFCE_SCALED_IMAGE_H__ */
diff --git a/plugins/actions/actions.c b/plugins/actions/actions.c
index fd215be..6bdf007 100644
--- a/plugins/actions/actions.c
+++ b/plugins/actions/actions.c
@@ -190,7 +190,7 @@ actions_plugin_init (ActionsPlugin *plugin)
xfce_panel_plugin_add_action_widget (XFCE_PANEL_PLUGIN (plugin), widget);
gtk_widget_show (widget);
- plugin->first_image = xfce_scaled_image_new_from_icon_name (entry->icon_name);
+ plugin->first_image = xfce_panel_image_new_from_source (entry->icon_name);
gtk_container_add (GTK_CONTAINER (widget), plugin->first_image);
gtk_widget_show (plugin->first_image);
@@ -200,7 +200,7 @@ actions_plugin_init (ActionsPlugin *plugin)
G_CALLBACK (actions_plugin_button_clicked), plugin);
xfce_panel_plugin_add_action_widget (XFCE_PANEL_PLUGIN (plugin), widget);
- plugin->second_image = xfce_scaled_image_new ();
+ plugin->second_image = xfce_panel_image_new ();
gtk_container_add (GTK_CONTAINER (widget), plugin->second_image);
gtk_widget_show (plugin->second_image);
}
@@ -249,8 +249,8 @@ actions_plugin_set_property (GObject *object,
action = plugin->first_action = g_value_get_uint (value) + 1;
gtk_widget_set_tooltip_text (plugin->first_button,
_(action_entries[action].title));
- xfce_scaled_image_set_from_icon_name (
- XFCE_SCALED_IMAGE (plugin->first_image),
+ xfce_panel_image_set_from_source (
+ XFCE_PANEL_IMAGE (plugin->first_image),
action_entries[action].icon_name);
break;
@@ -268,8 +268,8 @@ actions_plugin_set_property (GObject *object,
gtk_widget_show (plugin->second_button);
gtk_widget_set_tooltip_text (plugin->second_button,
_(action_entries[action].title));
- xfce_scaled_image_set_from_icon_name (
- XFCE_SCALED_IMAGE (plugin->second_image),
+ xfce_panel_image_set_from_source (
+ XFCE_PANEL_IMAGE (plugin->second_image),
action_entries[action].icon_name);
}
diff --git a/plugins/launcher/launcher.c b/plugins/launcher/launcher.c
index b93dcdb..88a08b1 100644
--- a/plugins/launcher/launcher.c
+++ b/plugins/launcher/launcher.c
@@ -279,7 +279,7 @@ launcher_plugin_init (LauncherPlugin *plugin)
g_signal_connect_after (G_OBJECT (plugin->button), "expose-event",
G_CALLBACK (launcher_plugin_button_expose_event), plugin);
- plugin->child = xfce_scaled_image_new ();
+ plugin->child = xfce_panel_image_new ();
gtk_container_add (GTK_CONTAINER (plugin->button), plugin->child);
plugin->arrow = xfce_arrow_button_new (GTK_ARROW_UP);
@@ -463,7 +463,7 @@ launcher_plugin_set_property (GObject *object,
if (G_UNLIKELY (plugin->show_label))
plugin->child = gtk_label_new (NULL);
else
- plugin->child = xfce_scaled_image_new ();
+ plugin->child = xfce_panel_image_new ();
gtk_container_add (GTK_CONTAINER (plugin->button), plugin->child);
gtk_widget_show (plugin->child);
@@ -1041,26 +1041,22 @@ launcher_plugin_button_update (LauncherPlugin *plugin)
}
else if (G_LIKELY (item != NULL))
{
- panel_return_if_fail (XFCE_IS_SCALED_IMAGE (plugin->child));
+ panel_return_if_fail (XFCE_IS_PANEL_IMAGE (plugin->child));
icon_name = xfce_menu_item_get_icon_name (item);
if (!IS_STRING (icon_name))
- goto fallback_image;
-
- if (g_path_is_absolute (icon_name))
- xfce_scaled_image_set_from_file (XFCE_SCALED_IMAGE (plugin->child),
- icon_name);
- else
- xfce_scaled_image_set_from_icon_name (XFCE_SCALED_IMAGE (plugin->child),
- icon_name);
+ {
+fallback_image:
+ icon_name = GTK_STOCK_MISSING_IMAGE;
+ }
+ xfce_panel_image_set_from_source (XFCE_PANEL_IMAGE (plugin->child),
+ icon_name);
}
else
{
-fallback_image:
/* set missing image icon */
- panel_return_if_fail (XFCE_IS_SCALED_IMAGE (plugin->child));
- xfce_scaled_image_set_from_icon_name (XFCE_SCALED_IMAGE (plugin->child),
- GTK_STOCK_MISSING_IMAGE);
+ panel_return_if_fail (XFCE_IS_PANEL_IMAGE (plugin->child));
+ goto fallback_image;
}
}
diff --git a/plugins/showdesktop/showdesktop.c b/plugins/showdesktop/showdesktop.c
index 4fd284e..0f3180e 100644
--- a/plugins/showdesktop/showdesktop.c
+++ b/plugins/showdesktop/showdesktop.c
@@ -97,7 +97,7 @@ show_desktop_plugin_init (ShowDesktopPlugin *plugin)
gtk_widget_show (button);
/* add an icon */
- image = xfce_scaled_image_new_from_icon_name ("user-desktop");
+ image = xfce_panel_image_new_from_source ("user-desktop");
gtk_container_add (GTK_CONTAINER (button), image);
gtk_widget_show (image);
}
diff --git a/plugins/tasklist/tasklist-widget.c b/plugins/tasklist/tasklist-widget.c
index 858e864..55e53c8 100644
--- a/plugins/tasklist/tasklist-widget.c
+++ b/plugins/tasklist/tasklist-widget.c
@@ -1259,7 +1259,7 @@ tasklist_button_icon_changed (WnckWindow *window,
if (G_LIKELY (lucent != NULL))
{
/* set the button icon */
- xfce_scaled_image_set_from_pixbuf (XFCE_SCALED_IMAGE (child->icon), lucent);
+ xfce_panel_image_set_from_pixbuf (XFCE_PANEL_IMAGE (child->icon), lucent);
/* release the pixbuf */
g_object_unref (G_OBJECT (lucent));
@@ -1268,7 +1268,7 @@ tasklist_button_icon_changed (WnckWindow *window,
else
{
/* set the button icon */
- xfce_scaled_image_set_from_pixbuf (XFCE_SCALED_IMAGE (child->icon), pixbuf);
+ xfce_panel_image_set_from_pixbuf (XFCE_PANEL_IMAGE (child->icon), pixbuf);
}
}
@@ -1499,7 +1499,7 @@ xfce_tasklist_button_new (XfceTasklistChild *child)
gtk_container_add (GTK_CONTAINER (child->button), child->box);
gtk_widget_show (child->box);
- child->icon = xfce_scaled_image_new ();
+ child->icon = xfce_panel_image_new ();
if (child->tasklist->show_labels)
gtk_box_pack_start (GTK_BOX (child->box), child->icon, FALSE, TRUE, 0);
else
diff --git a/plugins/windowmenu/windowmenu.c b/plugins/windowmenu/windowmenu.c
index d9446d3..29895f9 100644
--- a/plugins/windowmenu/windowmenu.c
+++ b/plugins/windowmenu/windowmenu.c
@@ -209,7 +209,7 @@ window_menu_plugin_init (WindowMenuPlugin *plugin)
g_signal_connect (G_OBJECT (plugin->button), "button-press-event",
G_CALLBACK (window_menu_plugin_button_press_event), plugin);
- plugin->icon = xfce_scaled_image_new_from_icon_name ("user-desktop");
+ plugin->icon = xfce_panel_image_new_from_source ("user-desktop");
gtk_container_add (GTK_CONTAINER (plugin->button), plugin->icon);
}
@@ -534,13 +534,13 @@ window_menu_plugin_active_window_changed (WnckScreen *screen,
WnckWindow *previous_window,
WindowMenuPlugin *plugin)
{
- WnckWindow *window;
- GdkPixbuf *pixbuf;
- XfceScaledImage *icon = XFCE_SCALED_IMAGE (plugin->icon);
- WnckWindowType type;
+ WnckWindow *window;
+ GdkPixbuf *pixbuf;
+ XfcePanelImage *icon = XFCE_PANEL_IMAGE (plugin->icon);
+ WnckWindowType type;
panel_return_if_fail (XFCE_IS_WINDOW_MENU_PLUGIN (plugin));
- panel_return_if_fail (XFCE_IS_SCALED_IMAGE (icon));
+ panel_return_if_fail (XFCE_IS_PANEL_IMAGE (icon));
panel_return_if_fail (WNCK_IS_SCREEN (screen));
panel_return_if_fail (plugin->screen == screen);
@@ -561,16 +561,16 @@ window_menu_plugin_active_window_changed (WnckScreen *screen,
wnck_window_get_name (window));
if (G_LIKELY (pixbuf != NULL))
- xfce_scaled_image_set_from_pixbuf (icon, pixbuf);
+ xfce_panel_image_set_from_pixbuf (icon, pixbuf);
else
- xfce_scaled_image_set_from_icon_name (icon, GTK_STOCK_MISSING_IMAGE);
+ xfce_panel_image_set_from_source (icon, GTK_STOCK_MISSING_IMAGE);
}
else
{
show_desktop_icon:
/* desktop is shown right now */
- xfce_scaled_image_set_from_icon_name (icon, "user-desktop");
+ xfce_panel_image_set_from_source (icon, "user-desktop");
gtk_widget_set_tooltip_text (GTK_WIDGET (icon), _("Desktop"));
}
}
More information about the Xfce4-commits
mailing list