summaryrefslogtreecommitdiff
path: root/libwnck
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2002-09-27 16:34:19 +0000
committerHavoc Pennington <hp@src.gnome.org>2002-09-27 16:34:19 +0000
commit59721714c292828ffb951057480f3cc3ebeba0fe (patch)
tree79e0972262584d9b8a559322c22d01ec7d0add39 /libwnck
parent774591c9bb8d44824e76d564c3c79f49d41659d4 (diff)
downloadlibwnck-59721714c292828ffb951057480f3cc3ebeba0fe.tar.gz
use stock icons, and reorder menu to match metacity
2002-09-27 Havoc Pennington <hp@redhat.com> * libwnck/window-action-menu.c (wnck_create_window_action_menu): use stock icons, and reorder menu to match metacity * libwnck/xutils.c (_wnck_stock_icons_init): new function * libwnck/Makefile.am: add stock icons
Diffstat (limited to 'libwnck')
-rw-r--r--libwnck/Makefile.am7
-rw-r--r--libwnck/stock_delete.pngbin0 -> 216 bytes
-rw-r--r--libwnck/stock_maximize.pngbin0 -> 166 bytes
-rw-r--r--libwnck/stock_minimize.pngbin0 -> 145 bytes
-rw-r--r--libwnck/window-action-menu.c65
-rw-r--r--libwnck/xutils.c48
-rw-r--r--libwnck/xutils.h6
7 files changed, 114 insertions, 12 deletions
diff --git a/libwnck/Makefile.am b/libwnck/Makefile.am
index 01170bb..ad36230 100644
--- a/libwnck/Makefile.am
+++ b/libwnck/Makefile.am
@@ -95,8 +95,11 @@ regenerate-built-sources:
&& echo "#include <libwnck/libwnck.h>" > wnck-marshal.c \
&& @GLIB_GENMARSHAL@ --prefix=_wnck_marshal wnck-marshal.list --body >> wnck-marshal.c
-IMAGES=default_icon.png
-VARIABLES=default_icon_data $(srcdir)/default_icon.png
+IMAGES=default_icon.png stock_delete.png stock_maximize.png stock_minimize.png
+VARIABLES=default_icon_data $(srcdir)/default_icon.png \
+ stock_delete_data $(srcdir)/stock_delete.png \
+ stock_maximize_data $(srcdir)/stock_maximize.png \
+ stock_minimize_data $(srcdir)/stock_minimize.png
noinst_DATA = inlinepixbufs.h
CLEANFILES += $(noinst_DATA)
diff --git a/libwnck/stock_delete.png b/libwnck/stock_delete.png
new file mode 100644
index 0000000..4f57e0e
--- /dev/null
+++ b/libwnck/stock_delete.png
Binary files differ
diff --git a/libwnck/stock_maximize.png b/libwnck/stock_maximize.png
new file mode 100644
index 0000000..6f10840
--- /dev/null
+++ b/libwnck/stock_maximize.png
Binary files differ
diff --git a/libwnck/stock_minimize.png b/libwnck/stock_minimize.png
new file mode 100644
index 0000000..a22e3c4
--- /dev/null
+++ b/libwnck/stock_minimize.png
Binary files differ
diff --git a/libwnck/window-action-menu.c b/libwnck/window-action-menu.c
index 750f975..9c14fb1 100644
--- a/libwnck/window-action-menu.c
+++ b/libwnck/window-action-menu.c
@@ -141,6 +141,34 @@ set_item_text (GtkWidget *mi,
gtk_label_set_use_underline (GTK_LABEL (GTK_BIN (mi)->child), TRUE);
}
+static void
+set_item_stock (GtkWidget *mi,
+ const char *stock_id)
+{
+ GtkWidget *image;
+
+ image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (mi));
+
+ if (stock_id == NULL)
+ {
+ if (image != NULL)
+ gtk_widget_destroy (image);
+ return;
+ }
+
+ if (image == NULL)
+ {
+ image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image);
+ }
+ else
+ {
+ gtk_image_set_from_stock (GTK_IMAGE (image), stock_id,
+ GTK_ICON_SIZE_MENU);
+ }
+}
+
static gboolean
update_menu_state (ActionMenuData *amd)
{
@@ -153,12 +181,14 @@ update_menu_state (ActionMenuData *amd)
if (wnck_window_is_minimized (amd->window))
{
set_item_text (amd->minimize_item, _("Un_minimize"));
+ set_item_stock (amd->minimize_item, NULL);
gtk_widget_set_sensitive (amd->minimize_item,
(actions & WNCK_WINDOW_ACTION_UNMINIMIZE) != 0);
}
else
{
set_item_text (amd->minimize_item, _("_Minimize"));
+ set_item_stock (amd->minimize_item, WNCK_STOCK_MINIMIZE);
gtk_widget_set_sensitive (amd->minimize_item,
(actions & WNCK_WINDOW_ACTION_MINIMIZE) != 0);
}
@@ -166,12 +196,14 @@ update_menu_state (ActionMenuData *amd)
if (wnck_window_is_maximized (amd->window))
{
set_item_text (amd->maximize_item, _("_Unmaximize"));
+ set_item_stock (amd->maximize_item, NULL);
gtk_widget_set_sensitive (amd->maximize_item,
(actions & WNCK_WINDOW_ACTION_UNMAXIMIZE) != 0);
}
else
{
set_item_text (amd->maximize_item, _("Ma_ximize"));
+ set_item_stock (amd->maximize_item, WNCK_STOCK_MAXIMIZE);
gtk_widget_set_sensitive (amd->maximize_item,
(actions & WNCK_WINDOW_ACTION_MAXIMIZE) != 0);
}
@@ -179,12 +211,14 @@ update_menu_state (ActionMenuData *amd)
if (wnck_window_is_shaded (amd->window))
{
set_item_text (amd->shade_item, _("_Unroll"));
+ set_item_stock (amd->shade_item, NULL);
gtk_widget_set_sensitive (amd->shade_item,
(actions & WNCK_WINDOW_ACTION_UNSHADE) != 0);
}
else
{
set_item_text (amd->shade_item, _("Roll _Up"));
+ set_item_stock (amd->shade_item, NULL);
gtk_widget_set_sensitive (amd->shade_item,
(actions & WNCK_WINDOW_ACTION_SHADE) != 0);
}
@@ -242,8 +276,8 @@ make_menu_item (ActionMenuData *amd,
{
GtkWidget *mi;
- mi = gtk_menu_item_new_with_label ("");
-
+ mi = gtk_image_menu_item_new_with_label ("");
+
set_data (G_OBJECT (mi), amd);
g_signal_connect (G_OBJECT (mi), "activate",
@@ -277,7 +311,10 @@ wnck_create_window_action_menu (WnckWindow *window)
{
GtkWidget *menu;
ActionMenuData *amd;
-
+ GtkWidget *separator;
+
+ _wnck_stock_icons_init ();
+
amd = g_new0 (ActionMenuData, 1);
amd->window = window;
@@ -290,13 +327,6 @@ wnck_create_window_action_menu (WnckWindow *window)
g_object_weak_ref (G_OBJECT (window), window_weak_notify, menu);
g_object_weak_ref (G_OBJECT (menu), object_weak_notify, window);
- amd->close_item = make_menu_item (amd, CLOSE);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu),
- amd->close_item);
-
- set_item_text (amd->close_item, _("_Close"));
-
amd->minimize_item = make_menu_item (amd, MINIMIZE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu),
@@ -317,12 +347,27 @@ wnck_create_window_action_menu (WnckWindow *window)
amd->move_item);
set_item_text (amd->move_item, _("Mo_ve"));
+ set_item_stock (amd->move_item, NULL);
amd->resize_item = make_menu_item (amd, RESIZE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu),
amd->resize_item);
set_item_text (amd->resize_item, _("_Resize"));
+ set_item_stock (amd->move_item, NULL);
+
+ amd->close_item = make_menu_item (amd, CLOSE);
+
+ separator = gtk_separator_menu_item_new ();
+ gtk_widget_show (separator);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu),
+ separator);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu),
+ amd->close_item);
+
+ set_item_text (amd->close_item, _("_Close"));
+ set_item_stock (amd->close_item, WNCK_STOCK_DELETE);
g_signal_connect_object (G_OBJECT (amd->window),
"state_changed",
diff --git a/libwnck/xutils.c b/libwnck/xutils.c
index e644988..8431dab 100644
--- a/libwnck/xutils.c
+++ b/libwnck/xutils.c
@@ -2440,3 +2440,51 @@ _wnck_desktop_layout_manager_process_event (XEvent *xev)
return FALSE;
}
+
+/* stock icon code Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org> */
+typedef struct
+{
+ char *stock_id;
+ const guint8 *icon_data;
+} StockIcon;
+
+void
+_wnck_stock_icons_init (void)
+{
+ GtkIconFactory *factory;
+ int i;
+ static gboolean done = FALSE;
+
+ if (done)
+ return;
+
+ done = TRUE;
+
+ StockIcon items[] =
+ {
+ { WNCK_STOCK_DELETE, stock_delete_data },
+ { WNCK_STOCK_MINIMIZE, stock_minimize_data },
+ { WNCK_STOCK_MAXIMIZE, stock_maximize_data }
+ };
+
+ factory = gtk_icon_factory_new ();
+ gtk_icon_factory_add_default (factory);
+
+ for (i = 0; i < (gint) G_N_ELEMENTS (items); i++)
+ {
+ GtkIconSet *icon_set;
+ GdkPixbuf *pixbuf;
+
+ pixbuf = gdk_pixbuf_new_from_inline (-1, items[i].icon_data,
+ FALSE,
+ NULL);
+
+ icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
+ gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
+ gtk_icon_set_unref (icon_set);
+
+ g_object_unref (G_OBJECT (pixbuf));
+ }
+
+ g_object_unref (G_OBJECT (factory));
+}
diff --git a/libwnck/xutils.h b/libwnck/xutils.h
index 4f3c409..d6831f8 100644
--- a/libwnck/xutils.h
+++ b/libwnck/xutils.h
@@ -30,6 +30,10 @@
G_BEGIN_DECLS
+#define WNCK_STOCK_DELETE "wnck-stock-delete"
+#define WNCK_STOCK_MAXIMIZE "wnck-stock-maximize"
+#define WNCK_STOCK_MINIMIZE "wnck-stock-minimize"
+
#define WNCK_APP_WINDOW_EVENT_MASK (PropertyChangeMask | StructureNotifyMask)
gboolean _wnck_get_cardinal (Window xwindow,
@@ -182,6 +186,8 @@ void _wnck_release_desktop_layout_manager (Screen *xscreen,
int current_token);
gboolean _wnck_desktop_layout_manager_process_event (XEvent *xev);
+void _wnck_stock_icons_init (void);
+
G_END_DECLS
#endif /* WNCK_XUTILS_H */