From 7179d77d0c6644f7c55d39e66495a94eb5b066db Mon Sep 17 00:00:00 2001 From: Jorn Baayen Date: Sat, 10 Aug 2002 16:47:43 +0000 Subject: [PATCH] Register window menu icons with the Gtk stock system, instead of using the 2002-08-10 Jorn Baayen Register window menu icons with the Gtk stock system, instead of using the ones from the Metacity theme (which looked very bad with some themes). * src/Makefile.am: * src/main.c: * src/menu.c: * src/stock_delete.png: added these files * src/stock_minimize.png: * src/stock_maximize.png: * src/ui.c --- ChangeLog | 14 +++++++ src/Makefile.am | 7 +++- src/menu.c | 85 +++-------------------------------------- src/menu.h | 5 +++ src/stock_delete.png | Bin 0 -> 216 bytes src/stock_maximize.png | Bin 0 -> 166 bytes src/stock_minimize.png | Bin 0 -> 145 bytes src/ui.c | 49 +++++++++++++++++++++++- 8 files changed, 77 insertions(+), 83 deletions(-) create mode 100644 src/stock_delete.png create mode 100644 src/stock_maximize.png create mode 100644 src/stock_minimize.png diff --git a/ChangeLog b/ChangeLog index 1cfaa68fe..ddb31daab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2002-08-10 Jorn Baayen + + Register window menu icons with the Gtk stock system, instead + of using the ones from the Metacity theme (which looked very bad with + some themes). + + * src/Makefile.am: + * src/main.c: + * src/menu.c: + * src/stock_delete.png: added these files + * src/stock_minimize.png: + * src/stock_maximize.png: + * src/ui.c + 2002-08-10 Havoc Pennington * src/keybindings.c (meta_display_process_key_event): filter out diff --git a/src/Makefile.am b/src/Makefile.am index af558b339..c04d4807c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -114,8 +114,11 @@ schema_DATA = $(schema_in_files:.schemas.in=.schemas) install-data-local: GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$(schema_DATA) -IMAGES=default_icon.png -VARIABLES=default_icon_data $(srcdir)/default_icon.png +IMAGES=default_icon.png stock_maximize.png stock_minimize.png stock_delete.png +VARIABLES=default_icon_data $(srcdir)/default_icon.png \ + stock_maximize_data $(srcdir)/stock_maximize.png \ + stock_minimize_data $(srcdir)/stock_minimize.png \ + stock_delete_data $(srcdir)/stock_delete.png BUILT_SOURCES = inlinepixbufs.h CLEANFILES = inlinepixbufs.h diff --git a/src/menu.c b/src/menu.c index a5429fe7f..367c5e95b 100644 --- a/src/menu.c +++ b/src/menu.c @@ -27,6 +27,7 @@ #include "util.h" #include "core.h" #include "themewidget.h" +#include "stock-icons.h" typedef struct _MenuItem MenuItem; typedef struct _MenuData MenuData; @@ -48,9 +49,9 @@ struct _MenuData static void activate_cb (GtkWidget *menuitem, gpointer data); static MenuItem menuitems[] = { - { META_MENU_OP_DELETE, NULL, N_("_Close") }, - { META_MENU_OP_MINIMIZE, NULL, N_("_Minimize") }, - { META_MENU_OP_MAXIMIZE, NULL, N_("Ma_ximize") }, + { META_MENU_OP_DELETE, METACITY_STOCK_DELETE, N_("_Close") }, + { META_MENU_OP_MINIMIZE, METACITY_STOCK_MINIMIZE, N_("_Minimize") }, + { META_MENU_OP_MAXIMIZE, METACITY_STOCK_MAXIMIZE, N_("Ma_ximize") }, { META_MENU_OP_UNMAXIMIZE, NULL, N_("Unma_ximize") }, { META_MENU_OP_SHADE, NULL, N_("_Shade") }, { META_MENU_OP_UNSHADE, NULL, N_("Un_shade") }, @@ -120,40 +121,6 @@ activate_cb (GtkWidget *menuitem, gpointer data) /* menu may now be freed */ } -static void -menu_icon_size_func (MetaArea *area, - int *width, - int *height, - void *user_data) -{ - gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, - width, height); -} - -static void -menu_icon_expose_func (MetaArea *area, - GdkEventExpose *event, - int x_offset, - int y_offset, - void *user_data) -{ - int width, height; - MetaMenuIconType type; - - type = GPOINTER_TO_INT (user_data); - - gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, - &width, &height); - - meta_theme_draw_menu_icon (meta_theme_get_current (), - GTK_WIDGET (area), - GTK_WIDGET (area)->window, - &event->area, - x_offset, y_offset, - width, height, - type); -} - /* * Given a Display and an index, get the workspace name and add any * accelerators. At the moment this means adding a _ if the name is of @@ -262,49 +229,7 @@ meta_window_menu_new (MetaFrames *frames, image = NULL; - switch (menuitems[i].op) - { - case META_MENU_OP_MAXIMIZE: - image = meta_area_new (); - meta_area_setup (META_AREA (image), - menu_icon_size_func, - menu_icon_expose_func, - GINT_TO_POINTER (META_MENU_ICON_TYPE_MAXIMIZE), - NULL); - break; - - case META_MENU_OP_UNMAXIMIZE: - image = meta_area_new (); - meta_area_setup (META_AREA (image), - menu_icon_size_func, - menu_icon_expose_func, - GINT_TO_POINTER (META_MENU_ICON_TYPE_UNMAXIMIZE), - NULL); - break; - - case META_MENU_OP_MINIMIZE: - image = meta_area_new (); - meta_area_setup (META_AREA (image), - menu_icon_size_func, - menu_icon_expose_func, - GINT_TO_POINTER (META_MENU_ICON_TYPE_MINIMIZE), - NULL); - break; - - case META_MENU_OP_DELETE: - image = meta_area_new (); - meta_area_setup (META_AREA (image), - menu_icon_size_func, - menu_icon_expose_func, - GINT_TO_POINTER (META_MENU_ICON_TYPE_CLOSE), - NULL); - break; - default: - break; - } - - if (image == NULL && - menuitems[i].stock_id) + if (menuitems[i].stock_id) { image = gtk_image_new_from_stock (menuitems[i].stock_id, GTK_ICON_SIZE_MENU); diff --git a/src/menu.h b/src/menu.h index 7fb5deef5..39902fd4c 100644 --- a/src/menu.h +++ b/src/menu.h @@ -25,6 +25,11 @@ #include #include "frames.h" +/* Stock icons */ +#define METACITY_STOCK_DELETE "metacity-delete" +#define METACITY_STOCK_MINIMIZE "metacity-minimize" +#define METACITY_STOCK_MAXIMIZE "metacity-maximize" + struct _MetaWindowMenu { MetaFrames *frames; diff --git a/src/stock_delete.png b/src/stock_delete.png new file mode 100644 index 0000000000000000000000000000000000000000..4f57e0e0ce26653e25d7465d10fcef878d18bb93 GIT binary patch literal 216 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G^tAk28_ZrvZCAbW|YuPgf{R(U>FzQZrIOMybEo-U3d6?2jkBtA6=_Wu8WadGvF zBn<~YznAu#?9@_Dy7#{`bP|1Vr6-S3c$ZR4Tf*g@s|-194=$ZK00d2^cb;f_z%9N; zPl5G;3B$7-C&uop3?=rDjad#e#4xs<7U&YbWWc~Mz0P6BsZVOlffh1&y85}Sb4q9e E0P#CZ&;S4c literal 0 HcmV?d00001 diff --git a/src/stock_maximize.png b/src/stock_maximize.png new file mode 100644 index 0000000000000000000000000000000000000000..6f1084058e214f21884b4e307f0b7b0e52bb6ce3 GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G^tAk28_ZrvZCAbW|YuPgf{R(U=)*_iBAoJz5nNj)cQ=> z)sVy-ae-CNc31m5T@eNKlSHhw>3V9@ZW#e|1}LHItKXd7FSE>Jszr>mdKI;Vst E0OCI|fdBvi literal 0 HcmV?d00001 diff --git a/src/stock_minimize.png b/src/stock_minimize.png new file mode 100644 index 0000000000000000000000000000000000000000..a22e3c45b0fa870ce093aff2726a7ab9f97360b9 GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G^tAk28_ZrvZCAbW|YuPgf{R(U=)?iuTPEP+CDo-U3d6?2jkBv= * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -35,6 +36,8 @@ #include +static void meta_stock_icons_init (void); + struct _MetaUI { Display *xdisplay; @@ -69,6 +72,8 @@ meta_ui_init (int *argc, char ***argv) pango_font_description_free (font_desc); g_object_unref (G_OBJECT (context)); } + + meta_stock_icons_init (); } Display* @@ -681,3 +686,45 @@ meta_ui_window_is_widget (MetaUI *ui, else return FALSE; } + +/* stock icon code Copyright (C) 2002 Jorn Baayen */ +typedef struct +{ + char *stock_id; + const guint8 *icon_data; +} MetaStockIcon; + +static void +meta_stock_icons_init (void) +{ + GtkIconFactory *factory; + int i; + + MetaStockIcon items[] = + { + { METACITY_STOCK_DELETE, stock_delete_data }, + { METACITY_STOCK_MINIMIZE, stock_minimize_data }, + { METACITY_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)); +}