use MetaMenuIconType not button type for the size of the menu ops array

2002-08-04  Havoc Pennington  <hp@redhat.com>

	* src/theme.c (free_menu_ops): use MetaMenuIconType not button
	type for the size of the menu ops array
	(meta_theme_define_int_constant): return TRUE on success (how the
	heck did this ever work?)
	(meta_theme_define_float_constant): return TRUE on success
	(meta_frame_style_validate): allow the "positional" buttons to
	be omitted for now.

	* src/testgradient.c (render_multi): don't define N_COLORS twice

	* src/theme-viewer.c (run_theme_benchmark): don't define
	ITERATIONS twice

	* src/theme.c (button_rect): handle new button types
	(meta_button_type_to_string): update
	(meta_button_type_from_string): update

	* src/theme.h (enum): add button types for the 6 possible button
	positions. No way to reposition buttons still but this will allow
	themes to go ahead and support doing so.
This commit is contained in:
Havoc Pennington 2002-08-04 20:02:45 +00:00 committed by Havoc Pennington
parent ae148bc89f
commit 583596178f
8 changed files with 123 additions and 27 deletions

View File

@ -1,13 +1,36 @@
2002-08-04 Havoc Pennington <hp@redhat.com>
* src/theme.c (free_menu_ops): use MetaMenuIconType not button
type for the size of the menu ops array
(meta_theme_define_int_constant): return TRUE on success (how the
heck did this ever work?)
(meta_theme_define_float_constant): return TRUE on success
(meta_frame_style_validate): allow the "positional" buttons to
be omitted for now.
* src/testgradient.c (render_multi): don't define N_COLORS twice
* src/theme-viewer.c (run_theme_benchmark): don't define
ITERATIONS twice
* src/theme.c (button_rect): handle new button types
(meta_button_type_to_string): update
(meta_button_type_from_string): update
* src/theme.h (enum): add button types for the 6 possible button
positions. No way to reposition buttons still but this will allow
themes to go ahead and support doing so.
2002-08-03 Craig Black <blackc@speakeasy.net> 2002-08-03 Craig Black <blackc@speakeasy.net>
* src/keybindings.c: (meta_display_process_key_event), * src/keybindings.c: (meta_display_process_key_event),
(process_tab_grab), (do_choose_window): change alt+tab (process_tab_grab), (do_choose_window): change alt+tab to a
to a windowless grab, fixes #83499 windowless grab, fixes #83499
2002-08-03 Craig Black <blackc@speakeasy.net> 2002-08-03 Craig Black <blackc@speakeasy.net>
* src/display.c: (event_callback): Have ButtonPress and UnmapNotify * src/display.c: (event_callback): Have ButtonPress and
events account for a null grab window, fixes #87896 UnmapNotify events account for a null grab window, fixes #87896
2002-08-03 Gaute Lindkvist <lindkvis@linpro.no> 2002-08-03 Gaute Lindkvist <lindkvis@linpro.no>

View File

@ -12,6 +12,14 @@ FILE=src/display.c
DIE=0 DIE=0
AUTOMAKE=automake-1.4
ACLOCAL=aclocal-1.4
($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
AUTOMAKE=automake
ACLOCAL=aclocal
}
(autoconf --version) < /dev/null > /dev/null 2>&1 || { (autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo echo
echo "You must have autoconf installed to compile $PROJECT." echo "You must have autoconf installed to compile $PROJECT."
@ -20,7 +28,7 @@ DIE=0
DIE=1 DIE=1
} }
(automake --version) < /dev/null > /dev/null 2>&1 || { ($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
echo echo
echo "You must have automake installed to compile $PROJECT." echo "You must have automake installed to compile $PROJECT."
echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.4.tar.gz" echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.4.tar.gz"
@ -104,14 +112,14 @@ do
echo "Running libtoolize..." echo "Running libtoolize..."
libtoolize --force --copy libtoolize --force --copy
fi fi
echo "Running aclocal $aclocalinclude ..." echo "Running $ACLOCAL $aclocalinclude ..."
aclocal $aclocalinclude $ACLOCAL $aclocalinclude
if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then
echo "Running autoheader..." echo "Running autoheader..."
autoheader autoheader
fi fi
echo "Running automake --gnu $am_opt ..." echo "Running $AUTOMAKE --gnu $am_opt ..."
automake --add-missing --gnu $am_opt $AUTOMAKE --add-missing --gnu $am_opt
echo "Running autoconf ..." echo "Running autoconf ..."
autoconf autoconf
) )

View File

@ -1021,7 +1021,10 @@ event_callback (XEvent *event,
if (window && if (window &&
window->frame && window->frame &&
modified == window->frame->xwindow) modified == window->frame->xwindow)
frame_was_receiver = TRUE; {
frame_was_receiver = TRUE;
meta_topic (META_DEBUG_EVENTS, "Frame was receiver of event\n");
}
switch (event->type) switch (event->type)
{ {

View File

@ -201,6 +201,7 @@ render_multi (GdkDrawable *drawable,
0, 0); 0, 0);
g_object_unref (G_OBJECT (pixbuf)); g_object_unref (G_OBJECT (pixbuf));
#undef N_COLORS
} }
static void static void

View File

@ -744,6 +744,8 @@ run_theme_benchmark (int client_width,
g_object_unref (G_OBJECT (layout)); g_object_unref (G_OBJECT (layout));
g_object_unref (G_OBJECT (pixmap)); g_object_unref (G_OBJECT (pixmap));
gtk_widget_destroy (widget); gtk_widget_destroy (widget);
#undef ITERATIONS
} }
typedef struct typedef struct

View File

@ -3556,20 +3556,24 @@ meta_frame_style_validate (MetaFrameStyle *style,
i = 0; i = 0;
while (i < META_BUTTON_TYPE_LAST) while (i < META_BUTTON_TYPE_LAST)
{ {
j = 0; /* for now the "positional" buttons are optional */
while (j < META_BUTTON_STATE_LAST) if (i >= META_BUTTON_TYPE_CLOSE)
{ {
if (get_button (style, i, j) == NULL) j = 0;
while (j < META_BUTTON_STATE_LAST)
{ {
g_set_error (error, META_THEME_ERROR, if (get_button (style, i, j) == NULL)
META_THEME_ERROR_FAILED, {
_("<button function=\"%s\" state=\"%s\" draw_ops=\"whatever\"/> must be specified for this frame style"), g_set_error (error, META_THEME_ERROR,
meta_button_type_to_string (i), META_THEME_ERROR_FAILED,
meta_button_state_to_string (j)); _("<button function=\"%s\" state=\"%s\" draw_ops=\"whatever\"/> must be specified for this frame style"),
return FALSE; meta_button_type_to_string (i),
meta_button_state_to_string (j));
return FALSE;
}
++j;
} }
++j;
} }
++i; ++i;
@ -3585,22 +3589,34 @@ button_rect (MetaButtonType type,
{ {
switch (type) switch (type)
{ {
case META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND:
case META_BUTTON_TYPE_CLOSE: case META_BUTTON_TYPE_CLOSE:
*rect = fgeom->close_rect; *rect = fgeom->close_rect;
break; break;
case META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND:
case META_BUTTON_TYPE_MAXIMIZE: case META_BUTTON_TYPE_MAXIMIZE:
*rect = fgeom->max_rect; *rect = fgeom->max_rect;
break; break;
case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND:
case META_BUTTON_TYPE_MINIMIZE: case META_BUTTON_TYPE_MINIMIZE:
*rect = fgeom->min_rect; *rect = fgeom->min_rect;
break; break;
case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND:
case META_BUTTON_TYPE_MENU: case META_BUTTON_TYPE_MENU:
*rect = fgeom->menu_rect; *rect = fgeom->menu_rect;
break; break;
case META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND:
case META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND:
rect->x = 0;
rect->y = 0;
rect->width = 0;
rect->height = 0;
break;
case META_BUTTON_TYPE_LAST: case META_BUTTON_TYPE_LAST:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
@ -4113,12 +4129,12 @@ meta_theme_new (void)
static void static void
free_menu_ops (MetaDrawOpList *op_lists[META_BUTTON_TYPE_LAST][N_GTK_STATES]) free_menu_ops (MetaDrawOpList *op_lists[META_MENU_ICON_TYPE_LAST][N_GTK_STATES])
{ {
int i, j; int i, j;
i = 0; i = 0;
while (i < META_BUTTON_TYPE_LAST) while (i < META_MENU_ICON_TYPE_LAST)
{ {
j = 0; j = 0;
while (j < N_GTK_STATES) while (j < N_GTK_STATES)
@ -4662,6 +4678,8 @@ meta_theme_define_int_constant (MetaTheme *theme,
g_hash_table_insert (theme->integer_constants, g_hash_table_insert (theme->integer_constants,
g_strdup (name), g_strdup (name),
GINT_TO_POINTER (value)); GINT_TO_POINTER (value));
return TRUE;
} }
gboolean gboolean
@ -4723,7 +4741,9 @@ meta_theme_define_float_constant (MetaTheme *theme,
*d = value; *d = value;
g_hash_table_insert (theme->float_constants, g_hash_table_insert (theme->float_constants,
g_strdup (name), d); g_strdup (name), d);
return TRUE;
} }
gboolean gboolean
@ -4883,6 +4903,18 @@ meta_button_type_from_string (const char *str)
return META_BUTTON_TYPE_MINIMIZE; return META_BUTTON_TYPE_MINIMIZE;
else if (strcmp ("menu", str) == 0) else if (strcmp ("menu", str) == 0)
return META_BUTTON_TYPE_MENU; return META_BUTTON_TYPE_MENU;
else if (strcmp ("left_left_background", str) == 0)
return META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND;
else if (strcmp ("left_middle_background", str) == 0)
return META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND;
else if (strcmp ("left_right_background", str) == 0)
return META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND;
else if (strcmp ("right_left_background", str) == 0)
return META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND;
else if (strcmp ("right_middle_background", str) == 0)
return META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND;
else if (strcmp ("right_right_background", str) == 0)
return META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND;
else else
return META_BUTTON_TYPE_LAST; return META_BUTTON_TYPE_LAST;
} }
@ -4900,6 +4932,18 @@ meta_button_type_to_string (MetaButtonType type)
return "minimize"; return "minimize";
case META_BUTTON_TYPE_MENU: case META_BUTTON_TYPE_MENU:
return "menu"; return "menu";
case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND:
return "left_left_background";
case META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND:
return "left_middle_background";
case META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND:
return "left_right_background";
case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND:
return "right_left_background";
case META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND:
return "right_middle_background";
case META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND:
return "right_right_background";
case META_BUTTON_TYPE_LAST: case META_BUTTON_TYPE_LAST:
break; break;
} }

View File

@ -396,6 +396,13 @@ typedef enum
typedef enum typedef enum
{ {
/* Ordered so that background is drawn first */
META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND,
META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND,
META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND,
META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND,
META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND,
META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND,
META_BUTTON_TYPE_CLOSE, META_BUTTON_TYPE_CLOSE,
META_BUTTON_TYPE_MAXIMIZE, META_BUTTON_TYPE_MAXIMIZE,
META_BUTTON_TYPE_MINIMIZE, META_BUTTON_TYPE_MINIMIZE,

View File

@ -173,9 +173,17 @@ Themes are in a simple XML-subset format.
<!-- For buttons, drawing methods have to be provided for <!-- For buttons, drawing methods have to be provided for
each of three states: each of three states:
normal, pressed, prelight normal, pressed, prelight
and the button name must be provided: and the button function or position must be provided:
close, maximize, minimize, menu close, maximize, minimize, menu,
left_left_background, left_middle_background,
left_right_background, right_left_background,
right_middle_background, right_right_background
So a working theme needs 3*4 = 12 button declarations So a working theme needs 3*4 = 12 button declarations
and a theme may have up to 3*10 = 30 button declarations
in order to handle button-rearrangement preferences.
(The name "function" for the attribute is from before the
background values existed.)
--> -->
<button function="close" state="normal" draw_ops="previously_named"/> <button function="close" state="normal" draw_ops="previously_named"/>