mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
Only treat buttons as homogeneous when they are narrower than 13 time the
Fri Aug 29 20:32:07 2003 Soeren Sandmann <sandmann@daimi.au.dk> * gtk/gtktoolbar.c: Only treat buttons as homogeneous when they are narrower than 13 time the estimated character width of the font. (#107781, David Bordoley) * gtk/gtktoggletoolbutton.c (gtk_toggle_tool_button_init): Check here if the GtkToggleButton is active. This may be the case if it is a radio button. * gtk/gtktoolbar.c: Clarify documentation wrt. GtkSignalFunc vs. void (*) (GtkWidget, gpointer). (#107495, Mariano Suarez-Alvarez). * gtk/gtkcheckmenuitem.[ch]: new "draw_as_radio" property. (#111207, David Bordoley). * gtk/gtktoggletoolbutton.c (gtk_toggle_tool_button_create_menu_proxy): use new "draw_as_radio" property on the menu item when the item is a radio tool button * gtk/gtktoolbutton.c (gtk_tool_button_create_menu_proxy): Fixes to only pay attention to the "use_underline" property when the button label comes from the "label" property.
This commit is contained in:
parent
4ec7006f28
commit
545b40a1b3
26
ChangeLog
26
ChangeLog
@ -1,3 +1,29 @@
|
|||||||
|
Fri Aug 29 20:32:07 2003 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
|
* gtk/gtktoolbar.c: Only treat buttons as homogeneous when they
|
||||||
|
are narrower than 13 time the estimated character width of the
|
||||||
|
font. (#107781, David Bordoley)
|
||||||
|
|
||||||
|
* gtk/gtktoggletoolbutton.c (gtk_toggle_tool_button_init): Check
|
||||||
|
here if the GtkToggleButton is active. This may be the case if it
|
||||||
|
is a radio button.
|
||||||
|
|
||||||
|
* gtk/gtktoolbar.c: Clarify documentation wrt. GtkSignalFunc
|
||||||
|
vs. void (*) (GtkWidget, gpointer). (#107495, Mariano
|
||||||
|
Suarez-Alvarez).
|
||||||
|
|
||||||
|
* gtk/gtkcheckmenuitem.[ch]: new "draw_as_radio"
|
||||||
|
property. (#111207, David Bordoley).
|
||||||
|
|
||||||
|
* gtk/gtktoggletoolbutton.c
|
||||||
|
(gtk_toggle_tool_button_create_menu_proxy): use new
|
||||||
|
"draw_as_radio" property on the menu item when the item is a radio
|
||||||
|
tool button
|
||||||
|
|
||||||
|
* gtk/gtktoolbutton.c (gtk_tool_button_create_menu_proxy): Fixes
|
||||||
|
to only pay attention to the "use_underline" property when the
|
||||||
|
button label comes from the "label" property.
|
||||||
|
|
||||||
2003-08-29 Laurent Dhima <laurenti@alblinux.net>
|
2003-08-29 Laurent Dhima <laurenti@alblinux.net>
|
||||||
|
|
||||||
* configure.in: Added "sq" to ALL_LINGUAS.
|
* configure.in: Added "sq" to ALL_LINGUAS.
|
||||||
|
@ -1,3 +1,29 @@
|
|||||||
|
Fri Aug 29 20:32:07 2003 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
|
* gtk/gtktoolbar.c: Only treat buttons as homogeneous when they
|
||||||
|
are narrower than 13 time the estimated character width of the
|
||||||
|
font. (#107781, David Bordoley)
|
||||||
|
|
||||||
|
* gtk/gtktoggletoolbutton.c (gtk_toggle_tool_button_init): Check
|
||||||
|
here if the GtkToggleButton is active. This may be the case if it
|
||||||
|
is a radio button.
|
||||||
|
|
||||||
|
* gtk/gtktoolbar.c: Clarify documentation wrt. GtkSignalFunc
|
||||||
|
vs. void (*) (GtkWidget, gpointer). (#107495, Mariano
|
||||||
|
Suarez-Alvarez).
|
||||||
|
|
||||||
|
* gtk/gtkcheckmenuitem.[ch]: new "draw_as_radio"
|
||||||
|
property. (#111207, David Bordoley).
|
||||||
|
|
||||||
|
* gtk/gtktoggletoolbutton.c
|
||||||
|
(gtk_toggle_tool_button_create_menu_proxy): use new
|
||||||
|
"draw_as_radio" property on the menu item when the item is a radio
|
||||||
|
tool button
|
||||||
|
|
||||||
|
* gtk/gtktoolbutton.c (gtk_tool_button_create_menu_proxy): Fixes
|
||||||
|
to only pay attention to the "use_underline" property when the
|
||||||
|
button label comes from the "label" property.
|
||||||
|
|
||||||
2003-08-29 Laurent Dhima <laurenti@alblinux.net>
|
2003-08-29 Laurent Dhima <laurenti@alblinux.net>
|
||||||
|
|
||||||
* configure.in: Added "sq" to ALL_LINGUAS.
|
* configure.in: Added "sq" to ALL_LINGUAS.
|
||||||
|
@ -1,3 +1,29 @@
|
|||||||
|
Fri Aug 29 20:32:07 2003 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
|
* gtk/gtktoolbar.c: Only treat buttons as homogeneous when they
|
||||||
|
are narrower than 13 time the estimated character width of the
|
||||||
|
font. (#107781, David Bordoley)
|
||||||
|
|
||||||
|
* gtk/gtktoggletoolbutton.c (gtk_toggle_tool_button_init): Check
|
||||||
|
here if the GtkToggleButton is active. This may be the case if it
|
||||||
|
is a radio button.
|
||||||
|
|
||||||
|
* gtk/gtktoolbar.c: Clarify documentation wrt. GtkSignalFunc
|
||||||
|
vs. void (*) (GtkWidget, gpointer). (#107495, Mariano
|
||||||
|
Suarez-Alvarez).
|
||||||
|
|
||||||
|
* gtk/gtkcheckmenuitem.[ch]: new "draw_as_radio"
|
||||||
|
property. (#111207, David Bordoley).
|
||||||
|
|
||||||
|
* gtk/gtktoggletoolbutton.c
|
||||||
|
(gtk_toggle_tool_button_create_menu_proxy): use new
|
||||||
|
"draw_as_radio" property on the menu item when the item is a radio
|
||||||
|
tool button
|
||||||
|
|
||||||
|
* gtk/gtktoolbutton.c (gtk_tool_button_create_menu_proxy): Fixes
|
||||||
|
to only pay attention to the "use_underline" property when the
|
||||||
|
button label comes from the "label" property.
|
||||||
|
|
||||||
2003-08-29 Laurent Dhima <laurenti@alblinux.net>
|
2003-08-29 Laurent Dhima <laurenti@alblinux.net>
|
||||||
|
|
||||||
* configure.in: Added "sq" to ALL_LINGUAS.
|
* configure.in: Added "sq" to ALL_LINGUAS.
|
||||||
|
@ -1,3 +1,29 @@
|
|||||||
|
Fri Aug 29 20:32:07 2003 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
|
* gtk/gtktoolbar.c: Only treat buttons as homogeneous when they
|
||||||
|
are narrower than 13 time the estimated character width of the
|
||||||
|
font. (#107781, David Bordoley)
|
||||||
|
|
||||||
|
* gtk/gtktoggletoolbutton.c (gtk_toggle_tool_button_init): Check
|
||||||
|
here if the GtkToggleButton is active. This may be the case if it
|
||||||
|
is a radio button.
|
||||||
|
|
||||||
|
* gtk/gtktoolbar.c: Clarify documentation wrt. GtkSignalFunc
|
||||||
|
vs. void (*) (GtkWidget, gpointer). (#107495, Mariano
|
||||||
|
Suarez-Alvarez).
|
||||||
|
|
||||||
|
* gtk/gtkcheckmenuitem.[ch]: new "draw_as_radio"
|
||||||
|
property. (#111207, David Bordoley).
|
||||||
|
|
||||||
|
* gtk/gtktoggletoolbutton.c
|
||||||
|
(gtk_toggle_tool_button_create_menu_proxy): use new
|
||||||
|
"draw_as_radio" property on the menu item when the item is a radio
|
||||||
|
tool button
|
||||||
|
|
||||||
|
* gtk/gtktoolbutton.c (gtk_tool_button_create_menu_proxy): Fixes
|
||||||
|
to only pay attention to the "use_underline" property when the
|
||||||
|
button label comes from the "label" property.
|
||||||
|
|
||||||
2003-08-29 Laurent Dhima <laurenti@alblinux.net>
|
2003-08-29 Laurent Dhima <laurenti@alblinux.net>
|
||||||
|
|
||||||
* configure.in: Added "sq" to ALL_LINGUAS.
|
* configure.in: Added "sq" to ALL_LINGUAS.
|
||||||
|
@ -1,3 +1,29 @@
|
|||||||
|
Fri Aug 29 20:32:07 2003 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
|
* gtk/gtktoolbar.c: Only treat buttons as homogeneous when they
|
||||||
|
are narrower than 13 time the estimated character width of the
|
||||||
|
font. (#107781, David Bordoley)
|
||||||
|
|
||||||
|
* gtk/gtktoggletoolbutton.c (gtk_toggle_tool_button_init): Check
|
||||||
|
here if the GtkToggleButton is active. This may be the case if it
|
||||||
|
is a radio button.
|
||||||
|
|
||||||
|
* gtk/gtktoolbar.c: Clarify documentation wrt. GtkSignalFunc
|
||||||
|
vs. void (*) (GtkWidget, gpointer). (#107495, Mariano
|
||||||
|
Suarez-Alvarez).
|
||||||
|
|
||||||
|
* gtk/gtkcheckmenuitem.[ch]: new "draw_as_radio"
|
||||||
|
property. (#111207, David Bordoley).
|
||||||
|
|
||||||
|
* gtk/gtktoggletoolbutton.c
|
||||||
|
(gtk_toggle_tool_button_create_menu_proxy): use new
|
||||||
|
"draw_as_radio" property on the menu item when the item is a radio
|
||||||
|
tool button
|
||||||
|
|
||||||
|
* gtk/gtktoolbutton.c (gtk_tool_button_create_menu_proxy): Fixes
|
||||||
|
to only pay attention to the "use_underline" property when the
|
||||||
|
button label comes from the "label" property.
|
||||||
|
|
||||||
2003-08-29 Laurent Dhima <laurenti@alblinux.net>
|
2003-08-29 Laurent Dhima <laurenti@alblinux.net>
|
||||||
|
|
||||||
* configure.in: Added "sq" to ALL_LINGUAS.
|
* configure.in: Added "sq" to ALL_LINGUAS.
|
||||||
|
@ -39,7 +39,8 @@ enum {
|
|||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_ACTIVE,
|
PROP_ACTIVE,
|
||||||
PROP_INCONSISTENT
|
PROP_INCONSISTENT,
|
||||||
|
PROP_DRAW_AS_RADIO
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass);
|
static void gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass);
|
||||||
@ -127,6 +128,14 @@ gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass)
|
|||||||
FALSE,
|
FALSE,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_INCONSISTENT,
|
||||||
|
g_param_spec_boolean ("draw_as_radio",
|
||||||
|
_("Draw as radio menu item"),
|
||||||
|
_("Whether the menu item looks like a radio menu item"),
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
widget_class->expose_event = gtk_check_menu_item_expose;
|
widget_class->expose_event = gtk_check_menu_item_expose;
|
||||||
|
|
||||||
menu_item_class->activate = gtk_check_menu_item_activate;
|
menu_item_class->activate = gtk_check_menu_item_activate;
|
||||||
@ -306,6 +315,48 @@ gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item)
|
|||||||
return check_menu_item->inconsistent;
|
return check_menu_item->inconsistent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_check_menu_item_set_draw_as_radio:
|
||||||
|
* @check_menu_item: a #GtkCheckMenuItem
|
||||||
|
* @draw_as_radio: whether @check_menu_item is drawn like a #GtkRadioMenuItem
|
||||||
|
*
|
||||||
|
* Sets whether @check_menu_item is drawn like a #GtkRadioMenuItem
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gtk_check_menu_item_set_draw_as_radio (GtkCheckMenuItem *check_menu_item,
|
||||||
|
gboolean draw_as_radio)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item));
|
||||||
|
|
||||||
|
draw_as_radio = draw_as_radio != FALSE;
|
||||||
|
|
||||||
|
if (draw_as_radio != check_menu_item->draw_as_radio)
|
||||||
|
{
|
||||||
|
check_menu_item->draw_as_radio = draw_as_radio;
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (GTK_WIDGET (check_menu_item));
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (check_menu_item), "draw_as_radio");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_check_menu_item_get_draw_as_radio:
|
||||||
|
* @check_menu_item: a #GtkCheckMenuItem
|
||||||
|
*
|
||||||
|
* Returns whether @check_menu_item looks like a #GtkRadioMenuItem
|
||||||
|
*
|
||||||
|
* Return value: Whether @check_menu_item looks like a #GtkRadioMenuItem
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
gtk_check_menu_item_get_draw_as_radio (GtkCheckMenuItem *check_menu_item)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item), FALSE);
|
||||||
|
|
||||||
|
return check_menu_item->draw_as_radio;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item)
|
gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item)
|
||||||
{
|
{
|
||||||
@ -398,36 +449,32 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
|
|||||||
{
|
{
|
||||||
state_type = GTK_WIDGET_STATE (widget);
|
state_type = GTK_WIDGET_STATE (widget);
|
||||||
|
|
||||||
if (check_menu_item->always_show_toggle)
|
|
||||||
{
|
|
||||||
shadow_type = GTK_SHADOW_OUT;
|
|
||||||
if (check_menu_item->active)
|
|
||||||
shadow_type = GTK_SHADOW_IN;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shadow_type = GTK_SHADOW_IN;
|
|
||||||
if (check_menu_item->active &&
|
|
||||||
(state_type == GTK_STATE_PRELIGHT))
|
|
||||||
shadow_type = GTK_SHADOW_OUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (check_menu_item->inconsistent)
|
if (check_menu_item->inconsistent)
|
||||||
{
|
|
||||||
shadow_type = GTK_SHADOW_ETCHED_IN;
|
shadow_type = GTK_SHADOW_ETCHED_IN;
|
||||||
if (state_type == GTK_STATE_ACTIVE)
|
else if (check_menu_item->active)
|
||||||
state_type = GTK_STATE_NORMAL;
|
shadow_type = GTK_SHADOW_IN;
|
||||||
}
|
else
|
||||||
|
shadow_type = GTK_SHADOW_OUT;
|
||||||
|
|
||||||
if (!GTK_WIDGET_IS_SENSITIVE (widget))
|
if (!GTK_WIDGET_IS_SENSITIVE (widget))
|
||||||
state_type = GTK_STATE_INSENSITIVE;
|
state_type = GTK_STATE_INSENSITIVE;
|
||||||
|
|
||||||
|
if (check_menu_item->draw_as_radio)
|
||||||
|
{
|
||||||
|
gtk_paint_option (widget->style, widget->window,
|
||||||
|
state_type, shadow_type,
|
||||||
|
area, widget, "option",
|
||||||
|
x, y, width, height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
gtk_paint_check (widget->style, widget->window,
|
gtk_paint_check (widget->style, widget->window,
|
||||||
state_type, shadow_type,
|
state_type, shadow_type,
|
||||||
area, widget, "check",
|
area, widget, "check",
|
||||||
x, y, width, height);
|
x, y, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ struct _GtkCheckMenuItem
|
|||||||
guint active : 1;
|
guint active : 1;
|
||||||
guint always_show_toggle : 1;
|
guint always_show_toggle : 1;
|
||||||
guint inconsistent : 1;
|
guint inconsistent : 1;
|
||||||
|
guint draw_as_radio : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GtkCheckMenuItemClass
|
struct _GtkCheckMenuItemClass
|
||||||
@ -74,6 +75,7 @@ struct _GtkCheckMenuItemClass
|
|||||||
|
|
||||||
|
|
||||||
GType gtk_check_menu_item_get_type (void) G_GNUC_CONST;
|
GType gtk_check_menu_item_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkWidget* gtk_check_menu_item_new (void);
|
GtkWidget* gtk_check_menu_item_new (void);
|
||||||
GtkWidget* gtk_check_menu_item_new_with_label (const gchar *label);
|
GtkWidget* gtk_check_menu_item_new_with_label (const gchar *label);
|
||||||
GtkWidget* gtk_check_menu_item_new_with_mnemonic (const gchar *label);
|
GtkWidget* gtk_check_menu_item_new_with_mnemonic (const gchar *label);
|
||||||
@ -84,6 +86,9 @@ void gtk_check_menu_item_toggled (GtkCheckMenuItem *check_menu_i
|
|||||||
void gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item,
|
void gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item,
|
||||||
gboolean setting);
|
gboolean setting);
|
||||||
gboolean gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item);
|
gboolean gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item);
|
||||||
|
void gtk_check_menu_item_set_draw_as_radio (GtkCheckMenuItem *check_menu_item,
|
||||||
|
gboolean draw_radio_indicator);
|
||||||
|
gboolean gtk_check_menu_item_get_draw_as_radio (GtkCheckMenuItem *check_menu_item);
|
||||||
|
|
||||||
|
|
||||||
#ifndef GTK_DISABLE_DEPRECATED
|
#ifndef GTK_DISABLE_DEPRECATED
|
||||||
|
@ -32,8 +32,6 @@ static void gtk_radio_menu_item_class_init (GtkRadioMenuItemClass *klass);
|
|||||||
static void gtk_radio_menu_item_init (GtkRadioMenuItem *radio_menu_item);
|
static void gtk_radio_menu_item_init (GtkRadioMenuItem *radio_menu_item);
|
||||||
static void gtk_radio_menu_item_destroy (GtkObject *object);
|
static void gtk_radio_menu_item_destroy (GtkObject *object);
|
||||||
static void gtk_radio_menu_item_activate (GtkMenuItem *menu_item);
|
static void gtk_radio_menu_item_activate (GtkMenuItem *menu_item);
|
||||||
static void gtk_radio_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
|
|
||||||
GdkRectangle *area);
|
|
||||||
|
|
||||||
static GtkCheckMenuItemClass *parent_class = NULL;
|
static GtkCheckMenuItemClass *parent_class = NULL;
|
||||||
|
|
||||||
@ -185,25 +183,22 @@ gtk_radio_menu_item_class_init (GtkRadioMenuItemClass *klass)
|
|||||||
{
|
{
|
||||||
GtkObjectClass *object_class;
|
GtkObjectClass *object_class;
|
||||||
GtkMenuItemClass *menu_item_class;
|
GtkMenuItemClass *menu_item_class;
|
||||||
GtkCheckMenuItemClass *check_menu_item_class;
|
|
||||||
|
|
||||||
object_class = (GtkObjectClass*) klass;
|
object_class = (GtkObjectClass*) klass;
|
||||||
menu_item_class = (GtkMenuItemClass*) klass;
|
menu_item_class = (GtkMenuItemClass*) klass;
|
||||||
check_menu_item_class = (GtkCheckMenuItemClass*) klass;
|
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
object_class->destroy = gtk_radio_menu_item_destroy;
|
object_class->destroy = gtk_radio_menu_item_destroy;
|
||||||
|
|
||||||
menu_item_class->activate = gtk_radio_menu_item_activate;
|
menu_item_class->activate = gtk_radio_menu_item_activate;
|
||||||
|
|
||||||
check_menu_item_class->draw_indicator = gtk_radio_menu_item_draw_indicator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_radio_menu_item_init (GtkRadioMenuItem *radio_menu_item)
|
gtk_radio_menu_item_init (GtkRadioMenuItem *radio_menu_item)
|
||||||
{
|
{
|
||||||
radio_menu_item->group = g_slist_prepend (NULL, radio_menu_item);
|
radio_menu_item->group = g_slist_prepend (NULL, radio_menu_item);
|
||||||
|
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (radio_menu_item), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -294,77 +289,6 @@ gtk_radio_menu_item_activate (GtkMenuItem *menu_item)
|
|||||||
|
|
||||||
if (toggled)
|
if (toggled)
|
||||||
gtk_check_menu_item_toggled (check_menu_item);
|
gtk_check_menu_item_toggled (check_menu_item);
|
||||||
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (radio_menu_item));
|
gtk_widget_queue_draw (GTK_WIDGET (radio_menu_item));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gtk_radio_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
|
|
||||||
GdkRectangle *area)
|
|
||||||
{
|
|
||||||
GtkWidget *widget;
|
|
||||||
GtkStateType state_type;
|
|
||||||
GtkShadowType shadow_type;
|
|
||||||
gint width, height;
|
|
||||||
gint x, y;
|
|
||||||
gint offset;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_RADIO_MENU_ITEM (check_menu_item));
|
|
||||||
|
|
||||||
if (GTK_WIDGET_DRAWABLE (check_menu_item))
|
|
||||||
{
|
|
||||||
guint horizontal_padding;
|
|
||||||
guint toggle_spacing;
|
|
||||||
guint toggle_size;
|
|
||||||
|
|
||||||
widget = GTK_WIDGET (check_menu_item);
|
|
||||||
|
|
||||||
gtk_widget_style_get (GTK_WIDGET (check_menu_item),
|
|
||||||
"toggle_spacing", &toggle_spacing,
|
|
||||||
"horizontal_padding", &horizontal_padding,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
width = 8;
|
|
||||||
height = 8;
|
|
||||||
toggle_size = GTK_MENU_ITEM (check_menu_item)->toggle_size;
|
|
||||||
offset = GTK_CONTAINER (check_menu_item)->border_width +
|
|
||||||
widget->style->xthickness + 2;
|
|
||||||
|
|
||||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
|
||||||
{
|
|
||||||
x = widget->allocation.x + offset + horizontal_padding +
|
|
||||||
(toggle_size - toggle_spacing - width) / 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
x = widget->allocation.x + widget->allocation.width -
|
|
||||||
offset - horizontal_padding - toggle_size + toggle_spacing +
|
|
||||||
(toggle_size - toggle_spacing - width) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
y = widget->allocation.y + (widget->allocation.height - height) / 2;
|
|
||||||
|
|
||||||
if (check_menu_item->active ||
|
|
||||||
check_menu_item->always_show_toggle ||
|
|
||||||
(GTK_WIDGET_STATE (check_menu_item) == GTK_STATE_PRELIGHT))
|
|
||||||
{
|
|
||||||
state_type = GTK_WIDGET_STATE (widget);
|
|
||||||
if (check_menu_item->active ||
|
|
||||||
!check_menu_item->always_show_toggle)
|
|
||||||
shadow_type = GTK_SHADOW_IN;
|
|
||||||
else
|
|
||||||
shadow_type = GTK_SHADOW_OUT;
|
|
||||||
|
|
||||||
if (check_menu_item->inconsistent)
|
|
||||||
shadow_type = GTK_SHADOW_ETCHED_IN;
|
|
||||||
|
|
||||||
if (!GTK_WIDGET_IS_SENSITIVE (widget))
|
|
||||||
state_type = GTK_STATE_INSENSITIVE;
|
|
||||||
|
|
||||||
gtk_paint_option (widget->style, widget->window,
|
|
||||||
state_type, shadow_type,
|
|
||||||
area, widget, "option",
|
|
||||||
x, y, width, height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "gtktogglebutton.h"
|
#include "gtktogglebutton.h"
|
||||||
#include "gtkstock.h"
|
#include "gtkstock.h"
|
||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
|
#include "gtkradiotoolbutton.h"
|
||||||
|
|
||||||
#define MENU_ID "gtk-toggle-tool-button-menu-id"
|
#define MENU_ID "gtk-toggle-tool-button-menu-id"
|
||||||
|
|
||||||
@ -115,9 +116,17 @@ gtk_toggle_tool_button_class_init (GtkToggleToolButtonClass *klass)
|
|||||||
static void
|
static void
|
||||||
gtk_toggle_tool_button_init (GtkToggleToolButton *button)
|
gtk_toggle_tool_button_init (GtkToggleToolButton *button)
|
||||||
{
|
{
|
||||||
|
GtkToolButton *tool_button = GTK_TOOL_BUTTON (button);
|
||||||
|
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (_gtk_tool_button_get_button (tool_button));
|
||||||
|
|
||||||
button->priv = GTK_TOGGLE_TOOL_BUTTON_GET_PRIVATE (button);
|
button->priv = GTK_TOGGLE_TOOL_BUTTON_GET_PRIVATE (button);
|
||||||
|
|
||||||
g_signal_connect_object (_gtk_tool_button_get_button (GTK_TOOL_BUTTON (button)),
|
/* If the real button is a radio button, it may have been
|
||||||
|
* active at the time it was created.
|
||||||
|
*/
|
||||||
|
button->priv->active = gtk_toggle_button_get_active (toggle_button);
|
||||||
|
|
||||||
|
g_signal_connect_object (toggle_button,
|
||||||
"toggled", G_CALLBACK (button_toggled), button, 0);
|
"toggled", G_CALLBACK (button_toggled), button, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,24 +138,30 @@ gtk_toggle_tool_button_create_menu_proxy (GtkToolItem *item)
|
|||||||
GtkWidget *menu_item = NULL;
|
GtkWidget *menu_item = NULL;
|
||||||
GtkStockItem stock_item;
|
GtkStockItem stock_item;
|
||||||
gboolean use_mnemonic = TRUE;
|
gboolean use_mnemonic = TRUE;
|
||||||
const char *label = "";
|
const char *label;
|
||||||
|
|
||||||
GtkWidget *label_widget = gtk_tool_button_get_label_widget (tool_button);
|
GtkWidget *label_widget = gtk_tool_button_get_label_widget (tool_button);
|
||||||
const gchar *label_text = gtk_tool_button_get_label (tool_button);
|
const gchar *label_text = gtk_tool_button_get_label (tool_button);
|
||||||
gboolean use_underline = gtk_tool_button_get_use_underline (tool_button);
|
|
||||||
const gchar *stock_id = gtk_tool_button_get_stock_id (tool_button);
|
const gchar *stock_id = gtk_tool_button_get_stock_id (tool_button);
|
||||||
|
|
||||||
if (label_widget && GTK_IS_LABEL (label_widget))
|
if (label_widget && GTK_IS_LABEL (label_widget))
|
||||||
{
|
{
|
||||||
label = gtk_label_get_label (GTK_LABEL (label_widget));
|
label = gtk_label_get_label (GTK_LABEL (label_widget));
|
||||||
|
use_mnemonic = gtk_label_get_use_underline (GTK_LABEL (label_widget));
|
||||||
}
|
}
|
||||||
else if (label_text)
|
else if (label_text)
|
||||||
{
|
{
|
||||||
label = label_text;
|
label = label_text;
|
||||||
use_mnemonic = use_underline;
|
use_mnemonic = gtk_tool_button_get_use_underline (tool_button);
|
||||||
}
|
}
|
||||||
else if (stock_id && gtk_stock_lookup (stock_id, &stock_item))
|
else if (stock_id && gtk_stock_lookup (stock_id, &stock_item))
|
||||||
|
{
|
||||||
label = stock_item.label;
|
label = stock_item.label;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
label = "";
|
||||||
|
}
|
||||||
|
|
||||||
if (use_mnemonic)
|
if (use_mnemonic)
|
||||||
menu_item = gtk_check_menu_item_new_with_mnemonic (label);
|
menu_item = gtk_check_menu_item_new_with_mnemonic (label);
|
||||||
@ -156,6 +171,12 @@ gtk_toggle_tool_button_create_menu_proxy (GtkToolItem *item)
|
|||||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
|
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
|
||||||
toggle_tool_button->priv->active);
|
toggle_tool_button->priv->active);
|
||||||
|
|
||||||
|
if (GTK_IS_RADIO_TOOL_BUTTON (toggle_tool_button))
|
||||||
|
{
|
||||||
|
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (menu_item),
|
||||||
|
TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_connect_closure_by_id (menu_item,
|
g_signal_connect_closure_by_id (menu_item,
|
||||||
g_signal_lookup ("activate", G_OBJECT_TYPE (menu_item)), 0,
|
g_signal_lookup ("activate", G_OBJECT_TYPE (menu_item)), 0,
|
||||||
g_cclosure_new_object (G_CALLBACK (menu_item_activated),
|
g_cclosure_new_object (G_CALLBACK (menu_item_activated),
|
||||||
|
@ -57,6 +57,11 @@
|
|||||||
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
|
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
|
||||||
#define DEFAULT_TOOLBAR_STYLE GTK_TOOLBAR_BOTH
|
#define DEFAULT_TOOLBAR_STYLE GTK_TOOLBAR_BOTH
|
||||||
|
|
||||||
|
#define MAX_HOMOGENEOUS_N_CHARS 13 /* Items that are wider than this do not participate in
|
||||||
|
* the homogeneous game. In units of
|
||||||
|
* pango_font_get_estimated_char_width().
|
||||||
|
*/
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_ORIENTATION,
|
PROP_ORIENTATION,
|
||||||
@ -620,14 +625,29 @@ static gboolean
|
|||||||
toolbar_item_is_homogeneous (GtkToolbar *toolbar,
|
toolbar_item_is_homogeneous (GtkToolbar *toolbar,
|
||||||
GtkToolItem *item)
|
GtkToolItem *item)
|
||||||
{
|
{
|
||||||
gboolean result = FALSE;
|
gboolean result;
|
||||||
|
GtkWidget *widget = GTK_WIDGET (item);
|
||||||
|
GtkRequisition requisition;
|
||||||
|
PangoContext *context;
|
||||||
|
PangoFontMetrics *metrics;
|
||||||
|
int char_width;
|
||||||
|
gint max_homogeneous_pixels;
|
||||||
|
|
||||||
if ((gtk_tool_item_get_homogeneous (item) && !GTK_IS_SEPARATOR_TOOL_ITEM (item)))
|
context = gtk_widget_get_pango_context (widget);
|
||||||
result = TRUE;
|
metrics = pango_context_get_metrics (context,
|
||||||
|
widget->style->font_desc,
|
||||||
|
pango_context_get_language (context));
|
||||||
|
char_width = pango_font_metrics_get_approximate_char_width (metrics);
|
||||||
|
max_homogeneous_pixels = PANGO_PIXELS (MAX_HOMOGENEOUS_N_CHARS * char_width);
|
||||||
|
|
||||||
if (gtk_tool_item_get_is_important (item) &&
|
result = gtk_tool_item_get_homogeneous (item) && !GTK_IS_SEPARATOR_TOOL_ITEM (item);
|
||||||
|
|
||||||
|
gtk_widget_size_request (GTK_WIDGET (item), &requisition);
|
||||||
|
|
||||||
|
if ((gtk_tool_item_get_is_important (item) &&
|
||||||
toolbar->style == GTK_TOOLBAR_BOTH_HORIZ &&
|
toolbar->style == GTK_TOOLBAR_BOTH_HORIZ &&
|
||||||
toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
|
toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) ||
|
||||||
|
requisition.width > max_homogeneous_pixels)
|
||||||
{
|
{
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
}
|
}
|
||||||
@ -1447,7 +1467,7 @@ gtk_toolbar_move_focus (GtkToolbar *toolbar,
|
|||||||
|
|
||||||
g_list_free (children);
|
g_list_free (children);
|
||||||
|
|
||||||
return TRUE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The focus handler for the toolbar. It called when the user presses
|
/* The focus handler for the toolbar. It called when the user presses
|
||||||
@ -2679,6 +2699,9 @@ gtk_toolbar_get_drop_index (GtkToolbar *toolbar,
|
|||||||
* Inserts a new item into the toolbar. You must specify the position
|
* Inserts a new item into the toolbar. You must specify the position
|
||||||
* in the toolbar where it will be inserted.
|
* in the toolbar where it will be inserted.
|
||||||
*
|
*
|
||||||
|
* @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
|
||||||
|
* arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
|
||||||
|
*
|
||||||
* Return value: the new toolbar item as a #GtkWidget.
|
* Return value: the new toolbar item as a #GtkWidget.
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@ -2709,6 +2732,9 @@ gtk_toolbar_append_item (GtkToolbar *toolbar,
|
|||||||
*
|
*
|
||||||
* Adds a new button to the beginning (top or left edges) of the given toolbar.
|
* Adds a new button to the beginning (top or left edges) of the given toolbar.
|
||||||
*
|
*
|
||||||
|
* @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
|
||||||
|
* arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
|
||||||
|
*
|
||||||
* Return value: the new toolbar item as a #GtkWidget.
|
* Return value: the new toolbar item as a #GtkWidget.
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@ -2741,6 +2767,9 @@ gtk_toolbar_prepend_item (GtkToolbar *toolbar,
|
|||||||
* Inserts a new item into the toolbar. You must specify the position in the
|
* Inserts a new item into the toolbar. You must specify the position in the
|
||||||
* toolbar where it will be inserted.
|
* toolbar where it will be inserted.
|
||||||
*
|
*
|
||||||
|
* @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
|
||||||
|
* arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
|
||||||
|
*
|
||||||
* Return value: the new toolbar item as a #GtkWidget.
|
* Return value: the new toolbar item as a #GtkWidget.
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@ -2775,6 +2804,9 @@ gtk_toolbar_insert_item (GtkToolbar *toolbar,
|
|||||||
* @stock_id is not a known stock item ID, it's inserted verbatim,
|
* @stock_id is not a known stock item ID, it's inserted verbatim,
|
||||||
* except that underscores used to mark mnemonics are removed.
|
* except that underscores used to mark mnemonics are removed.
|
||||||
*
|
*
|
||||||
|
* @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
|
||||||
|
* arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
|
||||||
|
*
|
||||||
* Returns: the inserted widget
|
* Returns: the inserted widget
|
||||||
*/
|
*/
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
@ -2965,6 +2997,9 @@ gtk_toolbar_insert_widget (GtkToolbar *toolbar,
|
|||||||
* the radio group for the new element. In all other cases, @widget must
|
* the radio group for the new element. In all other cases, @widget must
|
||||||
* be %NULL.
|
* be %NULL.
|
||||||
*
|
*
|
||||||
|
* @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
|
||||||
|
* arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
|
||||||
|
*
|
||||||
* Return value: the new toolbar element as a #GtkWidget.
|
* Return value: the new toolbar element as a #GtkWidget.
|
||||||
**/
|
**/
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
@ -3003,6 +3038,9 @@ gtk_toolbar_append_element (GtkToolbar *toolbar,
|
|||||||
* the radio group for the new element. In all other cases, @widget must
|
* the radio group for the new element. In all other cases, @widget must
|
||||||
* be %NULL.
|
* be %NULL.
|
||||||
*
|
*
|
||||||
|
* @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
|
||||||
|
* arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
|
||||||
|
*
|
||||||
* Return value: the new toolbar element as a #GtkWidget.
|
* Return value: the new toolbar element as a #GtkWidget.
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
@ -3042,6 +3080,9 @@ gtk_toolbar_prepend_element (GtkToolbar *toolbar,
|
|||||||
* the radio group for the new element. In all other cases, @widget must
|
* the radio group for the new element. In all other cases, @widget must
|
||||||
* be %NULL.
|
* be %NULL.
|
||||||
*
|
*
|
||||||
|
* @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
|
||||||
|
* arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
|
||||||
|
*
|
||||||
* Return value: the new toolbar element as a #GtkWidget.
|
* Return value: the new toolbar element as a #GtkWidget.
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
|
@ -554,12 +554,10 @@ gtk_tool_button_create_menu_proxy (GtkToolItem *item)
|
|||||||
else if (button->priv->stock_id && gtk_stock_lookup (button->priv->stock_id, &stock_item))
|
else if (button->priv->stock_id && gtk_stock_lookup (button->priv->stock_id, &stock_item))
|
||||||
{
|
{
|
||||||
label = stock_item.label;
|
label = stock_item.label;
|
||||||
use_mnemonic = FALSE;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
label = "";
|
label = "";
|
||||||
use_mnemonic = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_mnemonic)
|
if (use_mnemonic)
|
||||||
|
Loading…
Reference in New Issue
Block a user