[libwnck/wip/muktupavels/wnck-image-menu-item] avoid deprecated GtkImageMenuItem



commit f0ef0c5d81ede8725647e927bfe2f39bfb7c9802
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Nov 12 02:29:35 2016 +0200

    avoid deprecated GtkImageMenuItem

 libwnck/Makefile.am                    |    2 +
 libwnck/private.h                      |    3 +
 libwnck/selector.c                     |  141 ++++----------------
 libwnck/tasklist.c                     |   22 ++--
 libwnck/wnck-image-menu-item-private.h |   46 +++++++
 libwnck/wnck-image-menu-item.c         |  224 ++++++++++++++++++++++++++++++++
 6 files changed, 312 insertions(+), 126 deletions(-)
---
diff --git a/libwnck/Makefile.am b/libwnck/Makefile.am
index 4a105e6..4bbe863 100644
--- a/libwnck/Makefile.am
+++ b/libwnck/Makefile.am
@@ -82,6 +82,8 @@ libwnck_3_la_SOURCES =                \
        private.h               \
        xutils.c                \
        xutils.h                \
+       wnck-image-menu-item.c \
+       wnck-image-menu-item-private.h \
        $(wnck_accessibility_files)
 
 $(libwnck_3_la_OBJECTS): $(wnck_built_headers)
diff --git a/libwnck/private.h b/libwnck/private.h
index 72cb545..3398d38 100644
--- a/libwnck/private.h
+++ b/libwnck/private.h
@@ -144,6 +144,9 @@ void           _wnck_pager_get_workspace_rect   (WnckPager     *pager,
 void           _make_gtk_label_bold   (GtkLabel *label);
 void           _make_gtk_label_normal (GtkLabel *label);
 
+void           _wnck_selector_set_window_icon   (GtkWidget     *image,
+                                                 WnckWindow    *window);
+
 G_END_DECLS
 
 #endif /* WNCK_PRIVATE_H */
diff --git a/libwnck/selector.c b/libwnck/selector.c
index 066d3e8..d90f2ec 100644
--- a/libwnck/selector.c
+++ b/libwnck/selector.c
@@ -34,6 +34,7 @@
 #include "inlinepixbufs.h"
 #include "libwnck.h"
 #include "screen.h"
+#include "wnck-image-menu-item-private.h"
 #include "private.h"
 
 /**
@@ -51,12 +52,6 @@
  * represent windows of this screen only.
  */
 
-typedef struct
-{
-  GtkWidget *item;
-  GtkWidget *label;
-} window_hash_item;
-
 struct _WnckSelectorPrivate {
   GtkWidget  *image;
   WnckWindow *icon_window;
@@ -178,10 +173,9 @@ wnck_selector_dimm_icon (GdkPixbuf *pixbuf)
   return dimmed;
 }
 
-static void
-wnck_selector_set_window_icon (WnckSelector *selector,
-                               GtkWidget *image,
-                               WnckWindow *window)
+void
+_wnck_selector_set_window_icon (GtkWidget  *image,
+                                WnckWindow *window)
 {
   GdkPixbuf *pixbuf, *freeme, *freeme2;
   int width, height;
@@ -231,7 +225,7 @@ wnck_selector_set_window_icon (WnckSelector *selector,
 static void
 wnck_selector_set_active_window (WnckSelector *selector, WnckWindow *window)
 {
-  wnck_selector_set_window_icon (selector, selector->priv->image, window);
+  _wnck_selector_set_window_icon (selector->priv->image, window);
   selector->priv->icon_window = window;
 }
 
@@ -335,25 +329,19 @@ static void
 wnck_selector_window_icon_changed (WnckWindow *window,
                                    WnckSelector *selector)
 {
-  window_hash_item *item;
-  GtkWidget *image;
+  GtkWidget *item;
 
   if (selector->priv->icon_window == window)
     wnck_selector_set_active_window (selector, window);
 
-  item = NULL;
-
   if (!selector->priv->window_hash)
          return;
 
   item = g_hash_table_lookup (selector->priv->window_hash, window);
   if (item != NULL)
     {
-      image = gtk_image_new ();
-      wnck_selector_set_window_icon (selector, image, window);
-      gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item->item),
-                                     GTK_WIDGET (image));
-      gtk_widget_show (image);
+      wnck_image_menu_item_set_image_from_window (WNCK_IMAGE_MENU_ITEM (item),
+                                                  window);
     }
 }
 
@@ -361,12 +349,9 @@ static void
 wnck_selector_window_name_changed (WnckWindow *window,
                                    WnckSelector *selector)
 {
-  window_hash_item *item;
+  GtkWidget *item;
   char *window_name;
 
-  item = NULL;
-  window_name = NULL;
-
   if (!selector->priv->window_hash)
          return;
 
@@ -374,7 +359,7 @@ wnck_selector_window_name_changed (WnckWindow *window,
   if (item != NULL)
     {
       window_name = _wnck_window_get_name_for_display (window, FALSE, TRUE);
-      gtk_label_set_text (GTK_LABEL (item->label), window_name);
+      gtk_menu_item_set_label (GTK_MENU_ITEM (item), window_name);
       g_free (window_name);
     }
 }
@@ -385,7 +370,7 @@ wnck_selector_window_state_changed (WnckWindow *window,
                                     WnckWindowState new_state,
                                     WnckSelector *selector)
 {
-  window_hash_item *item;
+  GtkWidget *item;
   char *window_name;
 
   if (!
@@ -396,9 +381,6 @@ wnck_selector_window_state_changed (WnckWindow *window,
         WNCK_WINDOW_STATE_URGENT)))
     return;
 
-  item = NULL;
-  window_name = NULL;
-
   if (!selector->priv->window_hash)
          return;
 
@@ -409,9 +391,9 @@ wnck_selector_window_state_changed (WnckWindow *window,
   if (changed_mask & WNCK_WINDOW_STATE_SKIP_TASKLIST)
     {
       if (wnck_window_is_skip_tasklist (window))
-        gtk_widget_hide (item->item);
+        gtk_widget_hide (item);
       else
-        gtk_widget_show (item->item);
+        gtk_widget_show (item);
 
       wnck_selector_make_menu_consistent (selector);
 
@@ -422,28 +404,25 @@ wnck_selector_window_state_changed (WnckWindow *window,
       (WNCK_WINDOW_STATE_DEMANDS_ATTENTION | WNCK_WINDOW_STATE_URGENT))
     {
       if (wnck_window_or_transient_needs_attention (window))
-       _make_gtk_label_bold (GTK_LABEL (item->label));
+        wnck_image_menu_item_make_label_bold (WNCK_IMAGE_MENU_ITEM (item));
       else
-       _make_gtk_label_normal (GTK_LABEL (item->label));
+        wnck_image_menu_item_make_label_normal (WNCK_IMAGE_MENU_ITEM (item));
     }
 
   if (changed_mask &
       (WNCK_WINDOW_STATE_MINIMIZED | WNCK_WINDOW_STATE_SHADED))
     {
       window_name = _wnck_window_get_name_for_display (window, FALSE, TRUE);
-      gtk_label_set_text (GTK_LABEL (item->label), window_name);
+      gtk_menu_item_set_label (GTK_MENU_ITEM (item), window_name);
       g_free (window_name);
     }
 }
 
-
 static void
 wnck_selector_window_workspace_changed (WnckWindow   *window,
                                         WnckSelector *selector)
 {
-  window_hash_item *item;
-
-  item = NULL;
+  GtkWidget *item;
 
   if (!selector->priv->menu || !gtk_widget_get_visible (selector->priv->menu))
     return;
@@ -456,7 +435,7 @@ wnck_selector_window_workspace_changed (WnckWindow   *window,
     return;
 
   /* destroy the item and recreate one so it's at the right position */
-  gtk_widget_destroy (item->item);
+  gtk_widget_destroy (item);
   g_hash_table_remove (selector->priv->window_hash, window);
 
   wnck_selector_insert_window (selector, window);
@@ -498,46 +477,6 @@ wnck_selector_activate_window (WnckWindow *window)
   wnck_window_activate (window, timestamp);
 }
 
-#define SELECTOR_MAX_WIDTH 50   /* maximum width in characters */
-
-static gint
-wnck_selector_get_width (GtkWidget *widget, const char *text)
-{
-  GtkStyleContext *style_context;
-  GtkStateFlags state;
-  PangoContext *context;
-  PangoFontMetrics *metrics;
-  PangoFontDescription *description;
-  gint char_width;
-  PangoLayout *layout;
-  PangoRectangle natural;
-  gint max_width;
-  gint screen_width;
-  gint width;
-
-  style_context = gtk_widget_get_style_context (widget);
-  state = gtk_style_context_get_state (style_context);
-  gtk_style_context_get (style_context, state, GTK_STYLE_PROPERTY_FONT, &description, NULL);
-
-  context = gtk_widget_get_pango_context (widget);
-  metrics = pango_context_get_metrics (context, description,
-                                       pango_context_get_language (context));
-  char_width = pango_font_metrics_get_approximate_char_width (metrics);
-  pango_font_metrics_unref (metrics);
-  max_width = PANGO_PIXELS (SELECTOR_MAX_WIDTH * char_width);
-
-  layout = gtk_widget_create_pango_layout (widget, text);
-  pango_layout_get_pixel_extents (layout, NULL, &natural);
-  g_object_unref (G_OBJECT (layout));
-
-  screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget));
-
-  width = MIN (natural.width, max_width);
-  width = MIN (width, 3 * (screen_width / 4));
-
-  return width;
-}
-
 static void
 wnck_selector_drag_begin (GtkWidget          *widget,
                          GdkDragContext     *context,
@@ -579,40 +518,21 @@ wnck_selector_item_new (WnckSelector *selector,
                         const gchar *label, WnckWindow *window)
 {
   GtkWidget *item;
-  GtkWidget *ellipsizing_label;
-  window_hash_item *hash_item;
   static const GtkTargetEntry targets[] = {
     { "application/x-wnck-window-id", 0, 0 }
   };
 
-  item = gtk_image_menu_item_new ();
-  gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
-
-  ellipsizing_label = gtk_label_new (label);
-  gtk_label_set_xalign (GTK_LABEL (ellipsizing_label), 0.0);
-  gtk_label_set_ellipsize (GTK_LABEL (ellipsizing_label),
-                           PANGO_ELLIPSIZE_END);
+  item = wnck_image_menu_item_new_with_label (label);
 
   if (window != NULL)
     {
       /* if window demands attention, bold the label */
       if (wnck_window_or_transient_needs_attention (window))
-       _make_gtk_label_bold (GTK_LABEL (ellipsizing_label));
+        wnck_image_menu_item_make_label_bold (WNCK_IMAGE_MENU_ITEM (item));
 
-      hash_item = g_new0 (window_hash_item, 1);
-      hash_item->item = item;
-      hash_item->label = ellipsizing_label;
-      g_hash_table_insert (selector->priv->window_hash, window, hash_item);
+      g_hash_table_insert (selector->priv->window_hash, window, item);
     }
 
-  gtk_container_add (GTK_CONTAINER (item), ellipsizing_label);
-
-  gtk_widget_show (ellipsizing_label);
-
-  gtk_widget_set_size_request (ellipsizing_label,
-                               wnck_selector_get_width (GTK_WIDGET (selector),
-                                                        label), -1);
-
   if (window != NULL)
     {
       gtk_drag_source_set (item,
@@ -707,22 +627,15 @@ static GtkWidget *
 wnck_selector_create_window (WnckSelector *selector, WnckWindow *window)
 {
   GtkWidget *item;
-  GtkWidget *image;
   char *name;
 
   name = _wnck_window_get_name_for_display (window, FALSE, TRUE);
 
   item = wnck_selector_item_new (selector, name, window);
-
   g_free (name);
 
-  image = gtk_image_new ();
-
-  wnck_selector_set_window_icon (selector, image, window);
-
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
-                                 GTK_WIDGET (image));
-  gtk_widget_show (image);
+  wnck_image_menu_item_set_image_from_window (WNCK_IMAGE_MENU_ITEM (item),
+                                              window);
 
   g_signal_connect_swapped (item, "activate",
                             G_CALLBACK (wnck_selector_activate_window),
@@ -836,7 +749,7 @@ static void
 wnck_selector_window_closed (WnckScreen *screen,
                              WnckWindow *window, WnckSelector *selector)
 {
-  window_hash_item *item;
+  GtkWidget *item;
 
   if (window == selector->priv->icon_window)
     wnck_selector_set_active_window (selector, NULL);
@@ -851,9 +764,9 @@ wnck_selector_window_closed (WnckScreen *screen,
   if (!item)
     return;
 
-  g_object_set_data (G_OBJECT (item->item), "wnck-selector-window", NULL);
+  g_object_set_data (G_OBJECT (item), "wnck-selector-window", NULL);
 
-  gtk_widget_hide (item->item);
+  gtk_widget_hide (item);
   wnck_selector_make_menu_consistent (selector);
 
   gtk_menu_reposition (GTK_MENU (selector->priv->menu));
@@ -1124,7 +1037,7 @@ wnck_selector_on_show (GtkWidget *widget, WnckSelector *selector)
     g_hash_table_destroy (selector->priv->window_hash);
   selector->priv->window_hash = g_hash_table_new_full (g_direct_hash,
                                                  g_direct_equal,
-                                                 NULL, g_free);
+                                                 NULL, NULL);
 
   screen = wnck_selector_get_screen (selector);
 
diff --git a/libwnck/tasklist.c b/libwnck/tasklist.c
index c464a0d..ec4185d 100644
--- a/libwnck/tasklist.c
+++ b/libwnck/tasklist.c
@@ -31,6 +31,7 @@
 #include "window.h"
 #include "class-group.h"
 #include "window-action-menu.h"
+#include "wnck-image-menu-item-private.h"
 #include "workspace.h"
 #include "xutils.h"
 #include "private.h"
@@ -2882,7 +2883,6 @@ wnck_task_popup_menu (WnckTask *task,
   char *text;
   GdkPixbuf *pixbuf;
   GtkWidget *menu_item;
-  GtkWidget *image;
   GList *l, *list;
 
   g_return_if_fail (task->type == WNCK_TASK_CLASS_GROUP);
@@ -2915,12 +2915,9 @@ wnck_task_popup_menu (WnckTask *task,
       win_task = WNCK_TASK (l->data);
 
       text = wnck_task_get_text (win_task, TRUE, TRUE);
-      menu_item = gtk_image_menu_item_new_with_label (text);
+      menu_item = wnck_image_menu_item_new_with_label (text);
       g_free (text);
 
-      gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menu_item),
-                                                 TRUE);
-
       if (wnck_task_get_needs_attention (win_task))
         _make_gtk_label_bold (GTK_LABEL (gtk_bin_get_child (GTK_BIN (menu_item))));
 
@@ -2930,13 +2927,14 @@ wnck_task_popup_menu (WnckTask *task,
 
       pixbuf = wnck_task_get_icon (win_task);
       if (pixbuf)
-       {
-         image = gtk_image_new_from_pixbuf (pixbuf);
-         gtk_widget_show (image);
-         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
-                                        image);
-         g_object_unref (pixbuf);
-       }
+        {
+          WnckImageMenuItem *item;
+
+          item = WNCK_IMAGE_MENU_ITEM (menu_item);
+
+          wnck_image_menu_item_set_image_from_icon_pixbuf (item, pixbuf);
+          g_object_unref (pixbuf);
+        }
 
       gtk_widget_show (menu_item);
 
diff --git a/libwnck/wnck-image-menu-item-private.h b/libwnck/wnck-image-menu-item-private.h
new file mode 100644
index 0000000..265289d
--- /dev/null
+++ b/libwnck/wnck-image-menu-item-private.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2016 Alberts Muktupāvels
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef WNCK_IMAGE_MENU_ITEM_PRIVATE_H
+#define WNCK_IMAGE_MENU_ITEM_PRIVATE_H
+
+#include <gtk/gtk.h>
+#include "window.h"
+
+G_BEGIN_DECLS
+
+#define WNCK_TYPE_IMAGE_MENU_ITEM wnck_image_menu_item_get_type ()
+G_DECLARE_FINAL_TYPE (WnckImageMenuItem, wnck_image_menu_item,
+                      WNCK, IMAGE_MENU_ITEM, GtkMenuItem)
+
+GtkWidget *wnck_image_menu_item_new                        (void);
+
+GtkWidget *wnck_image_menu_item_new_with_label             (const gchar       *label);
+
+void       wnck_image_menu_item_set_image_from_icon_pixbuf (WnckImageMenuItem *item,
+                                                            GdkPixbuf         *pixbuf);
+
+void       wnck_image_menu_item_set_image_from_window      (WnckImageMenuItem *item,
+                                                            WnckWindow        *window);
+
+void       wnck_image_menu_item_make_label_bold            (WnckImageMenuItem *item);
+
+void       wnck_image_menu_item_make_label_normal          (WnckImageMenuItem *item);
+
+G_END_DECLS
+
+#endif
diff --git a/libwnck/wnck-image-menu-item.c b/libwnck/wnck-image-menu-item.c
new file mode 100644
index 0000000..b1d4c26
--- /dev/null
+++ b/libwnck/wnck-image-menu-item.c
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2016 Alberts Muktupāvels
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "wnck-image-menu-item-private.h"
+#include "private.h"
+
+#define SPACING 6
+
+struct _WnckImageMenuItem
+{
+  GtkMenuItem  parent;
+
+  GtkWidget   *box;
+  GtkWidget   *image;
+  GtkWidget   *accel_label;
+
+  gchar       *label;
+};
+
+G_DEFINE_TYPE (WnckImageMenuItem, wnck_image_menu_item, GTK_TYPE_MENU_ITEM)
+
+static void
+wnck_image_menu_item_get_preferred_width (GtkWidget *widget,
+                                          gint      *minimum,
+                                          gint      *natural)
+{
+  GtkWidgetClass *widget_class;
+  WnckImageMenuItem *item;
+  GtkRequisition image_requisition;
+
+  widget_class = GTK_WIDGET_CLASS (wnck_image_menu_item_parent_class);
+  item = WNCK_IMAGE_MENU_ITEM (widget);
+
+  widget_class->get_preferred_width (widget, minimum, natural);
+
+  if (!gtk_widget_get_visible (item->image))
+    return;
+
+  gtk_widget_get_preferred_size (item->image, &image_requisition, NULL);
+
+  if (image_requisition.width > 0)
+    {
+      *minimum -= image_requisition.width + SPACING;
+      *natural -= image_requisition.width + SPACING;
+    }
+}
+
+static void
+wnck_image_menu_item_size_allocate (GtkWidget     *widget,
+                                    GtkAllocation *allocation)
+{
+  GtkWidgetClass *widget_class;
+  WnckImageMenuItem *item;
+  GtkRequisition image_requisition;
+  GtkAllocation box_allocation;
+
+  widget_class = GTK_WIDGET_CLASS (wnck_image_menu_item_parent_class);
+  item = WNCK_IMAGE_MENU_ITEM (widget);
+
+  widget_class->size_allocate (widget, allocation);
+
+  if (!gtk_widget_get_visible (item->image))
+    return;
+
+  gtk_widget_get_preferred_size (item->image, &image_requisition, NULL);
+  gtk_widget_get_allocation (item->box, &box_allocation);
+
+  if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+    {
+      if (image_requisition.width > 0)
+        box_allocation.x -= image_requisition.width + SPACING;
+    }
+  else
+    {
+      if (image_requisition.width > 0)
+        box_allocation.x += image_requisition.width + SPACING;
+    }
+
+  gtk_widget_size_allocate (item->box, &box_allocation);
+}
+
+static const gchar *
+wnck_image_menu_item_get_label (GtkMenuItem *menu_item)
+{
+  WnckImageMenuItem *item;
+
+  item = WNCK_IMAGE_MENU_ITEM (menu_item);
+
+  return item->label;
+}
+
+static void
+wnck_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
+                                          gint        *requisition)
+{
+  WnckImageMenuItem *item;
+  GtkRequisition image_requisition;
+
+  item = WNCK_IMAGE_MENU_ITEM (menu_item);
+
+  *requisition = 0;
+
+  if (!gtk_widget_get_visible (item->image))
+    return;
+
+  gtk_widget_get_preferred_size (item->image, &image_requisition, NULL);
+
+  if (image_requisition.width > 0)
+    *requisition = image_requisition.width + SPACING;
+}
+
+static void
+wnck_image_menu_item_set_label (GtkMenuItem *menu_item,
+                                const gchar *label)
+{
+  WnckImageMenuItem *item;
+
+  item = WNCK_IMAGE_MENU_ITEM (menu_item);
+
+  if (g_strcmp0 (item->label, label) != 0)
+    {
+      g_free (item->label);
+      item->label = g_strdup (label);
+
+      gtk_label_set_text_with_mnemonic (GTK_LABEL (item->accel_label), label);
+      g_object_notify (G_OBJECT (menu_item), "label");
+    }
+}
+
+static void
+wnck_image_menu_item_class_init (WnckImageMenuItemClass *item_class)
+{
+  GtkWidgetClass *widget_class;
+  GtkMenuItemClass *menu_item_class;
+
+  widget_class = GTK_WIDGET_CLASS (item_class);
+  menu_item_class = GTK_MENU_ITEM_CLASS (item_class);
+
+  widget_class->get_preferred_width = wnck_image_menu_item_get_preferred_width;
+  widget_class->size_allocate = wnck_image_menu_item_size_allocate;
+
+  menu_item_class->get_label = wnck_image_menu_item_get_label;
+  menu_item_class->toggle_size_request = wnck_image_menu_item_toggle_size_request;
+  menu_item_class->set_label = wnck_image_menu_item_set_label;
+}
+
+static void
+wnck_image_menu_item_init (WnckImageMenuItem *item)
+{
+  GtkAccelLabel *accel_label;
+
+  item->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, SPACING);
+  gtk_container_add (GTK_CONTAINER (item), item->box);
+  gtk_widget_show (item->box);
+
+  item->image = gtk_image_new ();
+  gtk_box_pack_start (GTK_BOX (item->box), item->image, FALSE, FALSE, 0);
+
+  item->accel_label = gtk_accel_label_new ("");
+  gtk_box_pack_end (GTK_BOX (item->box), item->accel_label, TRUE, TRUE, 0);
+  gtk_label_set_xalign (GTK_LABEL (item->accel_label), 0.0);
+  gtk_widget_show (item->accel_label);
+
+  accel_label = GTK_ACCEL_LABEL (item->accel_label);
+  gtk_accel_label_set_accel_widget (accel_label, GTK_WIDGET (item));
+  gtk_label_set_ellipsize (GTK_LABEL (accel_label), PANGO_ELLIPSIZE_END);
+  gtk_label_set_use_underline (GTK_LABEL (accel_label), TRUE);
+}
+
+GtkWidget *
+wnck_image_menu_item_new (void)
+{
+  return g_object_new (WNCK_TYPE_IMAGE_MENU_ITEM, NULL);
+}
+
+GtkWidget *
+wnck_image_menu_item_new_with_label (const gchar *label)
+{
+  return g_object_new (WNCK_TYPE_IMAGE_MENU_ITEM, "label", label, NULL);
+}
+
+void
+wnck_image_menu_item_set_image_from_icon_pixbuf (WnckImageMenuItem *item,
+                                                 GdkPixbuf         *pixbuf)
+{
+  gtk_image_set_from_pixbuf (GTK_IMAGE (item->image), pixbuf);
+  gtk_widget_show (item->image);
+}
+
+void
+wnck_image_menu_item_set_image_from_window (WnckImageMenuItem *item,
+                                            WnckWindow        *window)
+{
+  _wnck_selector_set_window_icon (item->image, window);
+  gtk_widget_show (item->image);
+}
+
+void
+wnck_image_menu_item_make_label_bold (WnckImageMenuItem *item)
+{
+  _make_gtk_label_bold (GTK_LABEL (item->accel_label));
+}
+
+void
+wnck_image_menu_item_make_label_normal (WnckImageMenuItem *item)
+{
+  _make_gtk_label_normal (GTK_LABEL (item->accel_label));
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]