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

@ -1021,7 +1021,10 @@ event_callback (XEvent *event,
if (window &&
window->frame &&
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)
{

View File

@ -201,6 +201,7 @@ render_multi (GdkDrawable *drawable,
0, 0);
g_object_unref (G_OBJECT (pixbuf));
#undef N_COLORS
}
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 (pixmap));
gtk_widget_destroy (widget);
#undef ITERATIONS
}
typedef struct

View File

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

View File

@ -396,6 +396,13 @@ 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_MAXIMIZE,
META_BUTTON_TYPE_MINIMIZE,