Bug 537591 – Don't hardcode minimum width of menuitems
2008-07-02 Michael Natterer <mitch@imendio.com> Bug 537591 – Don't hardcode minimum width of menuitems * gtk/gtkmenuitem.c: applied patch from Christian Dywan which introduces a "width-chars" style property which replaces the hardcoded minimum width of menuitems with submenu. Patch extracted from Maemo-GTK+. svn path=/trunk/; revision=20733
This commit is contained in:

committed by
Michael Natterer

parent
1b291602bd
commit
a82c180023
@ -1,3 +1,12 @@
|
|||||||
|
2008-07-02 Michael Natterer <mitch@imendio.com>
|
||||||
|
|
||||||
|
Bug 537591 – Don't hardcode minimum width of menuitems
|
||||||
|
|
||||||
|
* gtk/gtkmenuitem.c: applied patch from Christian Dywan which
|
||||||
|
introduces a "width-chars" style property which replaces the
|
||||||
|
hardcoded minimum width of menuitems with submenu. Patch
|
||||||
|
extracted from Maemo-GTK+.
|
||||||
|
|
||||||
2008-07-02 Michael Natterer <mitch@imendio.com>
|
2008-07-02 Michael Natterer <mitch@imendio.com>
|
||||||
|
|
||||||
* gtk/gtkfilechooserdefault.c: remove some of the million includes.
|
* gtk/gtkfilechooserdefault.c: remove some of the million includes.
|
||||||
|
@ -280,6 +280,20 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
|
|||||||
P_("Amount of space used up by arrow, relative to the menu item's font size"),
|
P_("Amount of space used up by arrow, relative to the menu item's font size"),
|
||||||
0.0, 2.0, 0.8,
|
0.0, 2.0, 0.8,
|
||||||
GTK_PARAM_READABLE));
|
GTK_PARAM_READABLE));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GtkMenuItem:width-chars:
|
||||||
|
*
|
||||||
|
* The minimum desired width of the menu item in characters.
|
||||||
|
*
|
||||||
|
* Since: 2.14
|
||||||
|
**/
|
||||||
|
gtk_widget_class_install_style_property (widget_class,
|
||||||
|
g_param_spec_int ("width-chars",
|
||||||
|
P_("Width in Characters"),
|
||||||
|
P_("The minimum desired width of the menu item in characters"),
|
||||||
|
0, G_MAXINT, 12,
|
||||||
|
GTK_PARAM_READABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -597,19 +611,21 @@ get_minimum_width (GtkWidget *widget)
|
|||||||
{
|
{
|
||||||
PangoContext *context;
|
PangoContext *context;
|
||||||
PangoFontMetrics *metrics;
|
PangoFontMetrics *metrics;
|
||||||
gint height;
|
gint width;
|
||||||
|
gint width_chars;
|
||||||
|
|
||||||
context = gtk_widget_get_pango_context (widget);
|
context = gtk_widget_get_pango_context (widget);
|
||||||
metrics = pango_context_get_metrics (context,
|
metrics = pango_context_get_metrics (context,
|
||||||
widget->style->font_desc,
|
widget->style->font_desc,
|
||||||
pango_context_get_language (context));
|
pango_context_get_language (context));
|
||||||
|
|
||||||
height = pango_font_metrics_get_ascent (metrics) +
|
width = pango_font_metrics_get_approximate_char_width (metrics);
|
||||||
pango_font_metrics_get_descent (metrics);
|
|
||||||
|
|
||||||
pango_font_metrics_unref (metrics);
|
pango_font_metrics_unref (metrics);
|
||||||
|
|
||||||
return PANGO_PIXELS (7 * height);
|
gtk_widget_style_get (widget, "width-chars", &width_chars, NULL);
|
||||||
|
|
||||||
|
return PANGO_PIXELS (width_chars * width);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user