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
This commit is contained in:
parent
4c3a20c3f2
commit
7179d77d0c
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
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
|
||||
|
||||
2002-08-10 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* src/keybindings.c (meta_display_process_key_event): filter out
|
||||
|
@ -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
|
||||
|
85
src/menu.c
85
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);
|
||||
|
@ -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;
|
||||
|
BIN
src/stock_delete.png
Normal file
BIN
src/stock_delete.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 216 B |
BIN
src/stock_maximize.png
Normal file
BIN
src/stock_maximize.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 166 B |
BIN
src/stock_minimize.png
Normal file
BIN
src/stock_minimize.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 145 B |
49
src/ui.c
49
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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user