summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJorn Baayen <jorn@nl.linux.org>2002-08-10 16:47:43 +0000
committerHavoc Pennington <hp@src.gnome.org>2002-08-10 16:47:43 +0000
commit7179d77d0c6644f7c55d39e66495a94eb5b066db (patch)
tree196ca4642ae48a07cc74d5a7fcd61c5467714b88 /src
parent4c3a20c3f2ebf5b709ed43098cfedce3171fc381 (diff)
downloadmetacity-7179d77d0c6644f7c55d39e66495a94eb5b066db.tar.gz
metacity-7179d77d0c6644f7c55d39e66495a94eb5b066db.tar.bz2
Register window menu icons with the Gtk stock system, instead of using the
2002-08-10 Jorn Baayen <jorn@nl.linux.org> 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
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am7
-rw-r--r--src/menu.c85
-rw-r--r--src/menu.h5
-rw-r--r--src/stock_delete.pngbin0 -> 216 bytes
-rw-r--r--src/stock_maximize.pngbin0 -> 166 bytes
-rw-r--r--src/stock_minimize.pngbin0 -> 145 bytes
-rw-r--r--src/ui.c49
7 files changed, 63 insertions, 83 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index af558b3..c04d480 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 a5429fe..367c5e9 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 7fb5dee..39902fd 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -25,6 +25,11 @@
#include <gtk/gtk.h>
#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 0000000..4f57e0e
--- /dev/null
+++ b/src/stock_delete.png
Binary files differ
diff --git a/src/stock_maximize.png b/src/stock_maximize.png
new file mode 100644
index 0000000..6f10840
--- /dev/null
+++ b/src/stock_maximize.png
Binary files differ
diff --git a/src/stock_minimize.png b/src/stock_minimize.png
new file mode 100644
index 0000000..a22e3c4
--- /dev/null
+++ b/src/stock_minimize.png
Binary files differ
diff --git a/src/ui.c b/src/ui.c
index 3e3e619..d242ffb 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -1,7 +1,8 @@
/* Metacity interface for talking to GTK+ UI module */
/*
- * Copyright (C) 2001 Havoc Pennington
+ * Copyright (C) 2002 Havoc Pennington
+ * stock icon code Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org>
*
* 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 <string.h>
+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 <jorn@nl.linux.org> */
+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));
+}