diff options
Diffstat (limited to 'widgets/misc/e-combo-button.c')
-rw-r--r-- | widgets/misc/e-combo-button.c | 69 |
1 files changed, 23 insertions, 46 deletions
diff --git a/widgets/misc/e-combo-button.c b/widgets/misc/e-combo-button.c index 802a776942..5dafec034e 100644 --- a/widgets/misc/e-combo-button.c +++ b/widgets/misc/e-combo-button.c @@ -25,13 +25,13 @@ #endif #include "e-combo-button.h" -#include "art/empty.xpm" +#include <e-util/e-icon-factory.h> #include <gtk/gtkarrow.h> #include <gtk/gtkhbox.h> #include <gtk/gtklabel.h> #include <gtk/gtkmain.h> -#include <gtk/gtkpixmap.h> +#include <gtk/gtkimage.h> #include <gtk/gtksignal.h> #include <gal/util/e-util.h> @@ -40,9 +40,9 @@ struct _EComboButtonPrivate { GdkPixbuf *icon; - GtkWidget *icon_pixmap; + GtkWidget *icon_image; GtkWidget *label; - GtkWidget *arrow_pixmap; + GtkWidget *arrow_image; GtkWidget *hbox; GtkMenu *menu; @@ -68,35 +68,18 @@ static guint signals[LAST_SIGNAL] = { 0 }; /* Utility functions. */ static GtkWidget * -create_pixmap_widget_from_pixbuf (GdkPixbuf *pixbuf) +create_empty_image_widget (void) { - GtkWidget *pixmap_widget; - GdkPixmap *pixmap; - GdkBitmap *mask; - - gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 128); - - pixmap_widget = gtk_pixmap_new (pixmap, mask); - - gdk_pixmap_unref (pixmap); - g_object_unref (mask); - - return pixmap_widget; -} - -static GtkWidget * -create_empty_pixmap_widget (void) -{ - GtkWidget *pixmap_widget; + GtkWidget *image_widget; GdkPixbuf *pixbuf; - pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)empty_xpm); + pixbuf = e_icon_factory_get_icon (NULL, 16); - pixmap_widget = create_pixmap_widget_from_pixbuf (pixbuf); + image_widget = gtk_image_new_from_pixbuf (pixbuf); g_object_unref (pixbuf); - return pixmap_widget; + return image_widget; } static void @@ -104,8 +87,6 @@ set_icon (EComboButton *combo_button, GdkPixbuf *pixbuf) { EComboButtonPrivate *priv; - GdkPixmap *pixmap; - GdkBitmap *mask; priv = combo_button->priv; @@ -114,19 +95,15 @@ set_icon (EComboButton *combo_button, if (pixbuf == NULL) { priv->icon = NULL; - gtk_widget_hide (priv->icon_pixmap); + gtk_widget_hide (priv->icon_image); return; } priv->icon = g_object_ref (pixbuf); - gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 128); - gtk_pixmap_set (GTK_PIXMAP (priv->icon_pixmap), pixmap, mask); - - gtk_widget_show (priv->icon_pixmap); + gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon_image), priv->icon); - gdk_pixmap_unref (pixmap); - gdk_pixmap_unref (mask); + gtk_widget_show (priv->icon_image); } @@ -156,7 +133,7 @@ paint (EComboButton *combo_button, separator_x = (priv->label->allocation.width + priv->label->allocation.x - + priv->arrow_pixmap->allocation.x) / 2; + + priv->arrow_image->allocation.x) / 2; gtk_widget_style_get (GTK_WIDGET (widget), "focus-line-width", &focus_width, @@ -278,9 +255,9 @@ impl_destroy (GtkObject *object) priv = combo_button->priv; if (priv) { - if (priv->arrow_pixmap != NULL) { - gtk_widget_destroy (priv->arrow_pixmap); - priv->arrow_pixmap = NULL; + if (priv->arrow_image != NULL) { + gtk_widget_destroy (priv->arrow_image); + priv->arrow_image = NULL; } if (priv->icon != NULL) { @@ -313,7 +290,7 @@ impl_button_press_event (GtkWidget *widget, GTK_BUTTON (widget)->button_down = TRUE; if (event->button == 3 || - event->x >= priv->arrow_pixmap->allocation.x) { + event->x >= priv->arrow_image->allocation.x) { /* User clicked on the right side: pop up the menu. */ gtk_button_pressed (GTK_BUTTON (widget)); @@ -452,19 +429,19 @@ init (EComboButton *combo_button) gtk_container_add (GTK_CONTAINER (combo_button), priv->hbox); gtk_widget_show (priv->hbox); - priv->icon_pixmap = create_empty_pixmap_widget (); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->icon_pixmap, TRUE, TRUE, 0); - gtk_widget_show (priv->icon_pixmap); + priv->icon_image = create_empty_image_widget (); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->icon_image, TRUE, TRUE, 0); + gtk_widget_show (priv->icon_image); priv->label = gtk_label_new (""); gtk_box_pack_start (GTK_BOX (priv->hbox), priv->label, TRUE, TRUE, 2 * GTK_WIDGET (combo_button)->style->xthickness); gtk_widget_show (priv->label); - priv->arrow_pixmap = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->arrow_pixmap, TRUE, TRUE, + priv->arrow_image = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->arrow_image, TRUE, TRUE, GTK_WIDGET (combo_button)->style->xthickness); - gtk_widget_show (priv->arrow_pixmap); + gtk_widget_show (priv->arrow_image); priv->icon = NULL; priv->menu = NULL; |