Applied modified patch from maemo-gtk which makes separators more

2006-03-03  Michael Natterer  <mitch@imendio.com>

	Applied modified patch from maemo-gtk which makes separators more
	themeable. Fixes bug #332022.

	* gtk/gtkwidget.c: added style properties "wide-separators",
	"separator-width" and "separator-height".

	* gtk/gtkhseparator.c
	* gtk/gtkvseparator.c
	* gtk/gtkmenuitem.c
	* gtk/gtktoolbar.c: honor the new settings and paint separators
	using gtk_paint_box() if wide-separators is true.
This commit is contained in:
Michael Natterer
2006-03-03 12:38:42 +00:00
committed by Michael Natterer
parent d168e186aa
commit 43cb6010cc
7 changed files with 237 additions and 46 deletions

View File

@ -1,3 +1,17 @@
2006-03-03 Michael Natterer <mitch@imendio.com>
Applied modified patch from maemo-gtk which makes separators more
themeable. Fixes bug #332022.
* gtk/gtkwidget.c: added style properties "wide-separators",
"separator-width" and "separator-height".
* gtk/gtkhseparator.c
* gtk/gtkvseparator.c
* gtk/gtkmenuitem.c
* gtk/gtktoolbar.c: honor the new settings and paint separators
using gtk_paint_box() if wide-separators is true.
2006-03-02 Dom Lachowicz <cinamod@hotmail.com> 2006-03-02 Dom Lachowicz <cinamod@hotmail.com>
* modules/engines/ms-windows/msw_style.c: Fix combobox theming * modules/engines/ms-windows/msw_style.c: Fix combobox theming

View File

@ -1,3 +1,17 @@
2006-03-03 Michael Natterer <mitch@imendio.com>
Applied modified patch from maemo-gtk which makes separators more
themeable. Fixes bug #332022.
* gtk/gtkwidget.c: added style properties "wide-separators",
"separator-width" and "separator-height".
* gtk/gtkhseparator.c
* gtk/gtkvseparator.c
* gtk/gtkmenuitem.c
* gtk/gtktoolbar.c: honor the new settings and paint separators
using gtk_paint_box() if wide-separators is true.
2006-03-02 Dom Lachowicz <cinamod@hotmail.com> 2006-03-02 Dom Lachowicz <cinamod@hotmail.com>
* modules/engines/ms-windows/msw_style.c: Fix combobox theming * modules/engines/ms-windows/msw_style.c: Fix combobox theming

View File

@ -30,10 +30,12 @@
#include "gtkalias.h" #include "gtkalias.h"
static void gtk_hseparator_class_init (GtkHSeparatorClass *klass); static void gtk_hseparator_class_init (GtkHSeparatorClass *klass);
static void gtk_hseparator_init (GtkHSeparator *hseparator); static void gtk_hseparator_init (GtkHSeparator *hseparator);
static gint gtk_hseparator_expose (GtkWidget *widget, static void gtk_hseparator_size_request (GtkWidget *widget,
GdkEventExpose *event); GtkRequisition *requisition);
static gint gtk_hseparator_expose (GtkWidget *widget,
GdkEventExpose *event);
GType GType
@ -71,6 +73,7 @@ gtk_hseparator_class_init (GtkHSeparatorClass *class)
widget_class = (GtkWidgetClass*) class; widget_class = (GtkWidgetClass*) class;
widget_class->size_request = gtk_hseparator_size_request;
widget_class->expose_event = gtk_hseparator_expose; widget_class->expose_event = gtk_hseparator_expose;
} }
@ -87,18 +90,56 @@ gtk_hseparator_new (void)
return g_object_new (GTK_TYPE_HSEPARATOR, NULL); return g_object_new (GTK_TYPE_HSEPARATOR, NULL);
} }
static void
gtk_hseparator_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
gboolean wide_separators;
gint separator_height;
gtk_widget_style_get (widget,
"wide-separators", &wide_separators,
"separator-height", &separator_height,
NULL);
if (wide_separators)
requisition->height = separator_height;
else
requisition->height = widget->style->ythickness;
}
static gint static gint
gtk_hseparator_expose (GtkWidget *widget, gtk_hseparator_expose (GtkWidget *widget,
GdkEventExpose *event) GdkEventExpose *event)
{ {
if (GTK_WIDGET_DRAWABLE (widget)) if (GTK_WIDGET_DRAWABLE (widget))
gtk_paint_hline (widget->style, widget->window, GTK_WIDGET_STATE (widget), {
&event->area, widget, "hseparator", gboolean wide_separators;
widget->allocation.x, gint separator_height;
widget->allocation.x + widget->allocation.width - 1,
widget->allocation.y + (widget->allocation.height - gtk_widget_style_get (widget,
widget->style->ythickness) / 2); "wide-separators", &wide_separators,
"separator-height", &separator_height,
NULL);
if (wide_separators)
gtk_paint_box (widget->style, widget->window,
GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
&event->area, widget, "hseparator",
widget->allocation.x,
widget->allocation.y + (widget->allocation.height -
separator_height) / 2,
widget->allocation.width,
separator_height);
else
gtk_paint_hline (widget->style, widget->window,
GTK_WIDGET_STATE (widget),
&event->area, widget, "hseparator",
widget->allocation.x,
widget->allocation.x + widget->allocation.width - 1,
widget->allocation.y + (widget->allocation.height -
widget->style->ythickness) / 2);
}
return FALSE; return FALSE;
} }

View File

@ -559,10 +559,20 @@ gtk_menu_item_size_request (GtkWidget *widget,
requisition->width = MAX (requisition->width, get_minimum_width (widget)); requisition->width = MAX (requisition->width, get_minimum_width (widget));
} }
} }
else else /* separator item */
{ {
/* separator item */ gboolean wide_separators;
requisition->height += 4; gint separator_height;
gtk_widget_style_get (widget,
"wide-separators", &wide_separators,
"separator-height", &separator_height,
NULL);
if (wide_separators)
requisition->height += separator_height + widget->style->ythickness;
else
requisition->height += widget->style->ythickness * 2;
} }
accel_width = 0; accel_width = 0;
@ -824,18 +834,34 @@ gtk_menu_item_paint (GtkWidget *widget,
} }
else if (!GTK_BIN (menu_item)->child) else if (!GTK_BIN (menu_item)->child)
{ {
guint horizontal_padding; gboolean wide_separators;
gint separator_height;
guint horizontal_padding;
gtk_widget_style_get (widget, gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding, "wide-separators", &wide_separators,
NULL); "separator-height", &separator_height,
"horizontal-padding", &horizontal_padding,
gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL, NULL);
area, widget, "menuitem",
widget->allocation.x + horizontal_padding + widget->style->xthickness, if (wide_separators)
widget->allocation.x + widget->allocation.width - horizontal_padding - widget->style->xthickness - 1, gtk_paint_box (widget->style, widget->window,
widget->allocation.y + (widget->allocation.height - GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
widget->style->ythickness) / 2); area, widget, "hseparator",
widget->allocation.x + horizontal_padding + widget->style->xthickness,
widget->allocation.y + (widget->allocation.height -
separator_height -
widget->style->ythickness) / 2,
widget->allocation.width -
2 * (horizontal_padding + widget->style->xthickness),
separator_height);
else
gtk_paint_hline (widget->style, widget->window,
GTK_STATE_NORMAL, area, widget, "menuitem",
widget->allocation.x + horizontal_padding + widget->style->xthickness,
widget->allocation.x + widget->allocation.width - horizontal_padding - widget->style->xthickness - 1,
widget->allocation.y + (widget->allocation.height -
widget->style->ythickness) / 2);
} }
} }
} }

View File

@ -4852,21 +4852,55 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget,
if (orientation == GTK_ORIENTATION_HORIZONTAL) if (orientation == GTK_ORIENTATION_HORIZONTAL)
{ {
gtk_paint_vline (widget->style, widget->window, gboolean wide_separators;
GTK_WIDGET_STATE (widget), area, widget, gint separator_width;
"toolbar",
allocation->y + allocation->height * start_fraction, gtk_widget_style_get (widget,
allocation->y + allocation->height * end_fraction, "wide-separators", &wide_separators,
allocation->x + (allocation->width - widget->style->xthickness) / 2); "separator-width", &separator_width,
NULL);
if (wide_separators)
gtk_paint_box (widget->style, widget->window,
GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
area, widget, "vseparator",
allocation->x + (allocation->width - separator_width) / 2,
allocation->y + allocation->height * start_fraction,
separator_width,
allocation->height * (end_fraction - start_fraction));
else
gtk_paint_vline (widget->style, widget->window,
GTK_WIDGET_STATE (widget), area, widget,
"toolbar",
allocation->y + allocation->height * start_fraction,
allocation->y + allocation->height * end_fraction,
allocation->x + (allocation->width - widget->style->xthickness) / 2);
} }
else else
{ {
gtk_paint_hline (widget->style, widget->window, gboolean wide_separators;
GTK_WIDGET_STATE (widget), area, widget, gint separator_height;
"toolbar",
allocation->x + allocation->width * start_fraction, gtk_widget_style_get (widget,
allocation->x + allocation->width * end_fraction, "wide-separators", &wide_separators,
allocation->y + (allocation->height - widget->style->ythickness) / 2); "separator-height", &separator_height,
NULL);
if (wide_separators)
gtk_paint_box (widget->style, widget->window,
GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
area, widget, "hseparator",
allocation->x + allocation->width * start_fraction,
allocation->y + (allocation->height - separator_height) / 2,
allocation->width * (end_fraction - start_fraction),
separator_height);
else
gtk_paint_hline (widget->style, widget->window,
GTK_WIDGET_STATE (widget), area, widget,
"toolbar",
allocation->x + allocation->width * start_fraction,
allocation->x + allocation->width * end_fraction,
allocation->y + (allocation->height - widget->style->ythickness) / 2);
} }
} }

View File

@ -30,10 +30,12 @@
#include "gtkalias.h" #include "gtkalias.h"
static void gtk_vseparator_class_init (GtkVSeparatorClass *klass); static void gtk_vseparator_class_init (GtkVSeparatorClass *klass);
static void gtk_vseparator_init (GtkVSeparator *vseparator); static void gtk_vseparator_init (GtkVSeparator *vseparator);
static gint gtk_vseparator_expose (GtkWidget *widget, static void gtk_vseparator_size_request (GtkWidget *widget,
GdkEventExpose *event); GtkRequisition *requisition);
static gint gtk_vseparator_expose (GtkWidget *widget,
GdkEventExpose *event);
GType GType
@ -71,6 +73,7 @@ gtk_vseparator_class_init (GtkVSeparatorClass *klass)
widget_class = (GtkWidgetClass*) klass; widget_class = (GtkWidgetClass*) klass;
widget_class->size_request = gtk_vseparator_size_request;
widget_class->expose_event = gtk_vseparator_expose; widget_class->expose_event = gtk_vseparator_expose;
} }
@ -87,18 +90,56 @@ gtk_vseparator_new (void)
return g_object_new (GTK_TYPE_VSEPARATOR, NULL); return g_object_new (GTK_TYPE_VSEPARATOR, NULL);
} }
static void
gtk_vseparator_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
gboolean wide_separators;
gint separator_width;
gtk_widget_style_get (widget,
"wide-separators", &wide_separators,
"separator-width", &separator_width,
NULL);
if (wide_separators)
requisition->height = separator_width;
else
requisition->height = widget->style->xthickness;
}
static gint static gint
gtk_vseparator_expose (GtkWidget *widget, gtk_vseparator_expose (GtkWidget *widget,
GdkEventExpose *event) GdkEventExpose *event)
{ {
if (GTK_WIDGET_DRAWABLE (widget)) if (GTK_WIDGET_DRAWABLE (widget))
gtk_paint_vline (widget->style, widget->window, GTK_WIDGET_STATE (widget), {
&event->area, widget, "vseparator", gboolean wide_separators;
widget->allocation.y, gint separator_width;
widget->allocation.y + widget->allocation.height - 1,
widget->allocation.x + (widget->allocation.width - gtk_widget_style_get (widget,
widget->style->xthickness) / 2); "wide-separators", &wide_separators,
"separator-width", &separator_width,
NULL);
if (wide_separators)
gtk_paint_box (widget->style, widget->window,
GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
&event->area, widget, "vseparator",
widget->allocation.x + (widget->allocation.width -
separator_width) / 2,
widget->allocation.y,
separator_width,
widget->allocation.height);
else
gtk_paint_vline (widget->style, widget->window,
GTK_WIDGET_STATE (widget),
&event->area, widget, "vseparator",
widget->allocation.y,
widget->allocation.y + widget->allocation.height - 1,
widget->allocation.x + (widget->allocation.width -
widget->style->xthickness) / 2);
}
return FALSE; return FALSE;
} }

View File

@ -1515,7 +1515,28 @@ gtk_widget_class_init (GtkWidgetClass *klass)
P_("Visited Link Color"), P_("Visited Link Color"),
P_("Color of visited links"), P_("Color of visited links"),
GDK_TYPE_COLOR, GDK_TYPE_COLOR,
GTK_PARAM_READABLE)); GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (klass,
g_param_spec_boolean ("wide-separators",
P_("Wide Separators"),
P_("Whether separators have configurable width and should be drawn using a box instead of a line"),
FALSE,
GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (klass,
g_param_spec_int ("separator-width",
P_("Separator Width"),
P_("The width of separators if wide-separators is TRUE"),
0, 64, 0,
GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (klass,
g_param_spec_int ("separator-height",
P_("Separator Height"),
P_("The height of separators if wide-separators is TRUE"),
0, 64, 0,
GTK_PARAM_READABLE));
} }
static void static void