Commit 7913e63f authored by Soeren Sandmann's avatar Soeren Sandmann Committed by Søren Sandmann Pedersen

remove correction on x when detail is "menuitem". With the new menu look

Tue Jul  8 19:57:14 2003  Soeren Sandmann  <sandmann@daimi.au.dk>

	* gtk/gtkstyle.c (gtk_default_draw_arrow): remove correction on x
	when detail is "menuitem". With the new menu look is isn't needed
	anymore.

	* gtk/gtktoolitem.c (gtk_tool_item_toolbar_reconfigured): queue a
	resize here, so that tool items will get a chance to relayout
	themselves based on the toolbar configuration.

	change DEFAULT_SPACE_SIZE to 4 instead of 5

	* gtk/gtktoolbar.c
	Get rid of "!GTK_BIN (item)->child means separator". Separators
	are widgets in their own right

	change DEFAULT_SPACE_SIZE to 4 instead of 5

	(get_space_size): remove this function
	(toolbar_item_is_homogeneous): new function

	* gtk/gtkseparatortoolitem.c
	(gtk_separator_tool_item_size_request): new function.

Tue Jul  8 14:10:35 2003  Soeren Sandmann  <sandmann@daimi.au.dk>

	* gtk/gtktoggletoolbutton.h: use private data, add new
	internal function _gtk_toggle_tool_button_get_button()

	* gtk/gtktoolbutton.h: move to private data

	* gtk/gtkradiotoolbutton.c, gtk/gtktoolbutton.c: updates for new
	private data.
parent b3b16beb
Tue Jul 8 19:57:14 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkstyle.c (gtk_default_draw_arrow): remove correction on x
when detail is "menuitem". With the new menu look is isn't needed
anymore.
* gtk/gtktoolitem.c (gtk_tool_item_toolbar_reconfigured): queue a
resize here, so that tool items will get a chance to relayout
themselves based on the toolbar configuration.
change DEFAULT_SPACE_SIZE to 4 instead of 5
* gtk/gtktoolbar.c
Get rid of "!GTK_BIN (item)->child means separator". Separators
are widgets in their own right
change DEFAULT_SPACE_SIZE to 4 instead of 5
(get_space_size): remove this function
(toolbar_item_is_homogeneous): new function
* gtk/gtkseparatortoolitem.c
(gtk_separator_tool_item_size_request): new function.
Tue Jul 8 14:10:35 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoggletoolbutton.h: use private data, add new
internal function _gtk_toggle_tool_button_get_button()
* gtk/gtktoolbutton.h: move to private data
* gtk/gtkradiotoolbutton.c, gtk/gtktoolbutton.c: updates for new
private data.
Tue Jul 8 12:50:20 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_get_icon_widget): fix a
......
Tue Jul 8 19:57:14 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkstyle.c (gtk_default_draw_arrow): remove correction on x
when detail is "menuitem". With the new menu look is isn't needed
anymore.
* gtk/gtktoolitem.c (gtk_tool_item_toolbar_reconfigured): queue a
resize here, so that tool items will get a chance to relayout
themselves based on the toolbar configuration.
change DEFAULT_SPACE_SIZE to 4 instead of 5
* gtk/gtktoolbar.c
Get rid of "!GTK_BIN (item)->child means separator". Separators
are widgets in their own right
change DEFAULT_SPACE_SIZE to 4 instead of 5
(get_space_size): remove this function
(toolbar_item_is_homogeneous): new function
* gtk/gtkseparatortoolitem.c
(gtk_separator_tool_item_size_request): new function.
Tue Jul 8 14:10:35 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoggletoolbutton.h: use private data, add new
internal function _gtk_toggle_tool_button_get_button()
* gtk/gtktoolbutton.h: move to private data
* gtk/gtkradiotoolbutton.c, gtk/gtktoolbutton.c: updates for new
private data.
Tue Jul 8 12:50:20 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_get_icon_widget): fix a
......
Tue Jul 8 19:57:14 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkstyle.c (gtk_default_draw_arrow): remove correction on x
when detail is "menuitem". With the new menu look is isn't needed
anymore.
* gtk/gtktoolitem.c (gtk_tool_item_toolbar_reconfigured): queue a
resize here, so that tool items will get a chance to relayout
themselves based on the toolbar configuration.
change DEFAULT_SPACE_SIZE to 4 instead of 5
* gtk/gtktoolbar.c
Get rid of "!GTK_BIN (item)->child means separator". Separators
are widgets in their own right
change DEFAULT_SPACE_SIZE to 4 instead of 5
(get_space_size): remove this function
(toolbar_item_is_homogeneous): new function
* gtk/gtkseparatortoolitem.c
(gtk_separator_tool_item_size_request): new function.
Tue Jul 8 14:10:35 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoggletoolbutton.h: use private data, add new
internal function _gtk_toggle_tool_button_get_button()
* gtk/gtktoolbutton.h: move to private data
* gtk/gtkradiotoolbutton.c, gtk/gtktoolbutton.c: updates for new
private data.
Tue Jul 8 12:50:20 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_get_icon_widget): fix a
......
Tue Jul 8 19:57:14 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkstyle.c (gtk_default_draw_arrow): remove correction on x
when detail is "menuitem". With the new menu look is isn't needed
anymore.
* gtk/gtktoolitem.c (gtk_tool_item_toolbar_reconfigured): queue a
resize here, so that tool items will get a chance to relayout
themselves based on the toolbar configuration.
change DEFAULT_SPACE_SIZE to 4 instead of 5
* gtk/gtktoolbar.c
Get rid of "!GTK_BIN (item)->child means separator". Separators
are widgets in their own right
change DEFAULT_SPACE_SIZE to 4 instead of 5
(get_space_size): remove this function
(toolbar_item_is_homogeneous): new function
* gtk/gtkseparatortoolitem.c
(gtk_separator_tool_item_size_request): new function.
Tue Jul 8 14:10:35 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoggletoolbutton.h: use private data, add new
internal function _gtk_toggle_tool_button_get_button()
* gtk/gtktoolbutton.h: move to private data
* gtk/gtkradiotoolbutton.c, gtk/gtktoolbutton.c: updates for new
private data.
Tue Jul 8 12:50:20 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_get_icon_widget): fix a
......
Tue Jul 8 19:57:14 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkstyle.c (gtk_default_draw_arrow): remove correction on x
when detail is "menuitem". With the new menu look is isn't needed
anymore.
* gtk/gtktoolitem.c (gtk_tool_item_toolbar_reconfigured): queue a
resize here, so that tool items will get a chance to relayout
themselves based on the toolbar configuration.
change DEFAULT_SPACE_SIZE to 4 instead of 5
* gtk/gtktoolbar.c
Get rid of "!GTK_BIN (item)->child means separator". Separators
are widgets in their own right
change DEFAULT_SPACE_SIZE to 4 instead of 5
(get_space_size): remove this function
(toolbar_item_is_homogeneous): new function
* gtk/gtkseparatortoolitem.c
(gtk_separator_tool_item_size_request): new function.
Tue Jul 8 14:10:35 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoggletoolbutton.h: use private data, add new
internal function _gtk_toggle_tool_button_get_button()
* gtk/gtktoolbutton.h: move to private data
* gtk/gtkradiotoolbutton.c, gtk/gtktoolbutton.c: updates for new
private data.
Tue Jul 8 12:50:20 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_get_icon_widget): fix a
......
......@@ -67,7 +67,8 @@ gtk_radio_tool_button_class_init (GtkRadioToolButtonClass *klass)
static void
gtk_radio_tool_button_init (GtkRadioToolButton *button)
{
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (GTK_TOOL_BUTTON (button)->button), FALSE);
GtkToolButton *tool_button = GTK_TOOL_BUTTON (button);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (_gtk_tool_button_get_button (tool_button)), FALSE);
}
GtkToolItem *
......@@ -128,12 +129,18 @@ gtk_radio_tool_button_new_with_stock_from_widget (GtkWidget *group)
return gtk_radio_tool_button_new (list);
}
static GtkRadioButton *
get_radio_button (GtkRadioToolButton *button)
{
return GTK_RADIO_BUTTON (_gtk_tool_button_get_button (GTK_TOOL_BUTTON (button)));
}
GSList *
gtk_radio_tool_button_get_group (GtkRadioToolButton *button)
{
g_return_val_if_fail (GTK_IS_RADIO_TOOL_BUTTON (button), NULL);
return gtk_radio_button_get_group (GTK_RADIO_BUTTON (GTK_TOOL_BUTTON (button)->button));
return gtk_radio_button_get_group (get_radio_button (button));
}
void
......@@ -142,6 +149,6 @@ gtk_radio_tool_button_set_group (GtkRadioToolButton *button,
{
g_return_if_fail (GTK_IS_RADIO_TOOL_BUTTON (button));
gtk_radio_button_set_group (GTK_RADIO_BUTTON (GTK_TOOL_BUTTON (button)->button), group);
gtk_radio_button_set_group (get_radio_button (button), group);
}
......@@ -27,7 +27,7 @@
#include "gtktoolbar.h"
/* note: keep in sync with DEFAULT_SPACE_SIZE and DEFAULT_SPACE_STYLE in gtktoolbar.c */
#define DEFAULT_SPACE_SIZE 5
#define DEFAULT_SPACE_SIZE 4
#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE
#define SPACE_LINE_DIVISION 10
......@@ -35,6 +35,8 @@
#define SPACE_LINE_END 7
static void gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class);
static void gtk_separator_tool_item_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static gboolean gtk_separator_tool_item_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_separator_tool_item_add (GtkContainer *container,
......@@ -115,6 +117,7 @@ gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class)
toolitem_class = (GtkToolItemClass *)class;
widget_class = (GtkWidgetClass *)class;
widget_class->size_request = gtk_separator_tool_item_size_request;
widget_class->expose_event = gtk_separator_tool_item_expose;
container_class->add = gtk_separator_tool_item_add;
......@@ -127,6 +130,25 @@ gtk_separator_tool_item_add (GtkContainer *container,
g_warning("attempt to add a child to an GtkSeparatorToolItem");
}
static void
gtk_separator_tool_item_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkToolItem *item = GTK_TOOL_ITEM (widget);
GtkOrientation orientation = gtk_tool_item_get_orientation (item);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
requisition->width = get_space_size (item);
requisition->height = 1;
}
else
{
requisition->height = get_space_size (item);
requisition->width = 1;
}
}
static gboolean
gtk_separator_tool_item_expose (GtkWidget *widget,
GdkEventExpose *event)
......@@ -143,7 +165,7 @@ gtk_separator_tool_item_expose (GtkWidget *widget,
allocation = &(widget->allocation);
orientation = gtk_tool_item_get_orientation (tool_item);
area = &(event->area);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
gtk_paint_vline (widget->style, widget->window,
......
......@@ -3095,10 +3095,6 @@ gtk_default_draw_arrow (GtkStyle *style,
calculate_arrow_geometry (arrow_type, &x, &y, &width, &height);
if (detail && strcmp (detail, "menuitem") == 0
&& gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
x = original_x + original_width - width;
if (detail && strcmp (detail, "menu_scroll_arrow_up") == 0)
y++;
......
......@@ -33,6 +33,11 @@ enum {
LAST_SIGNAL
};
struct _GtkToggleToolButtonPrivate
{
guint active : 1;
};
static void gtk_toggle_tool_button_init (GtkToggleToolButton *button);
static void gtk_toggle_tool_button_class_init (GtkToggleToolButtonClass *klass);
......@@ -102,8 +107,10 @@ gtk_toggle_tool_button_class_init (GtkToggleToolButtonClass *klass)
static void
gtk_toggle_tool_button_init (GtkToggleToolButton *button)
{
g_signal_connect_object (GTK_TOOL_BUTTON (button)->button, "toggled",
G_CALLBACK (button_toggled), button, 0);
button->priv = g_new0 (GtkToggleToolButtonPrivate, 1);
g_signal_connect_object (_gtk_tool_button_get_button (GTK_TOOL_BUTTON (button)),
"toggled", G_CALLBACK (button_toggled), button, 0);
}
static gboolean
......@@ -116,14 +123,21 @@ gtk_toggle_tool_button_create_menu_proxy (GtkToolItem *item)
gboolean use_mnemonic = TRUE;
const char *label = "";
if (tool_button->label_widget && GTK_IS_LABEL (tool_button->label_widget))
label = gtk_label_get_label (GTK_LABEL (tool_button->label_widget));
else if (tool_button->label_text)
GtkWidget *label_widget = gtk_tool_button_get_label_widget (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);
if (label_widget && GTK_IS_LABEL (label_widget))
{
label = gtk_label_get_label (GTK_LABEL (label_widget));
}
else if (label_text)
{
label = tool_button->label_text;
use_mnemonic = tool_button->use_underline;
label = label_text;
use_mnemonic = use_underline;
}
else if (tool_button->stock_id && gtk_stock_lookup (tool_button->stock_id, &stock_item))
else if (stock_id && gtk_stock_lookup (stock_id, &stock_item))
label = stock_item.label;
if (use_mnemonic)
......@@ -132,7 +146,7 @@ gtk_toggle_tool_button_create_menu_proxy (GtkToolItem *item)
menu_item = gtk_check_menu_item_new_with_label (label);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
toggle_tool_button->active);
toggle_tool_button->priv->active);
g_signal_connect_closure_by_id (menu_item,
g_signal_lookup ("activate", G_OBJECT_TYPE (menu_item)), 0,
......@@ -164,12 +178,12 @@ menu_item_activated (GtkWidget *menu_item,
GtkToolButton *tool_button = GTK_TOOL_BUTTON (toggle_tool_button);
gboolean menu_active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item));
if (toggle_tool_button->active != menu_active)
if (toggle_tool_button->priv->active != menu_active)
{
toggle_tool_button->active = menu_active;
toggle_tool_button->priv->active = menu_active;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tool_button->button),
toggle_tool_button->active);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (_gtk_tool_button_get_button (tool_button)),
toggle_tool_button->priv->active);
g_signal_emit (G_OBJECT (toggle_tool_button), toggle_signals[TOGGLED], 0);
}
......@@ -181,17 +195,17 @@ button_toggled (GtkWidget *widget,
{
gboolean toggle_active = GTK_TOGGLE_BUTTON (widget)->active;
if (toggle_tool_button->active != toggle_active)
if (toggle_tool_button->priv->active != toggle_active)
{
GtkWidget *menu_item;
toggle_tool_button->active = toggle_active;
toggle_tool_button->priv->active = toggle_active;
if ((menu_item =
gtk_tool_item_get_proxy_menu_item (GTK_TOOL_ITEM (toggle_tool_button), MENU_ID)))
{
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
toggle_tool_button->active);
toggle_tool_button->priv->active);
}
g_signal_emit (G_OBJECT (toggle_tool_button), toggle_signals[TOGGLED], 0);
......@@ -231,8 +245,8 @@ gtk_toggle_tool_button_set_active (GtkToggleToolButton *button,
is_active = is_active != FALSE;
if (button->active != is_active)
gtk_button_clicked (GTK_BUTTON (GTK_TOOL_BUTTON (button)->button));
if (button->priv->active != is_active)
gtk_button_clicked (GTK_BUTTON (_gtk_tool_button_get_button (GTK_TOOL_BUTTON (button))));
}
gboolean
......@@ -240,5 +254,5 @@ gtk_toggle_tool_button_get_active (GtkToggleToolButton *button)
{
g_return_val_if_fail (GTK_IS_TOGGLE_TOOL_BUTTON (button), FALSE);
return button->active;
return button->priv->active;
}
......@@ -27,24 +27,25 @@
G_BEGIN_DECLS
#define GTK_TYPE_TOGGLE_TOOL_BUTTON (gtk_toggle_tool_button_get_type ())
#define GTK_TOGGLE_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TOGGLE_TOOL_BUTTON, GtkToggleToolButton))
#define GTK_TOGGLE_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TOGGLE_TOOL_BUTTON, GtkToggleToolButtonClass))
#define GTK_IS_TOGGLE_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TOGGLE_TOOL_BUTTON))
#define GTK_IS_TOGGLE_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GTK_TYPE_TOGGLE_TOOL_BUTTON))
#define GTK_TOGGLE_TOOL_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_TOGGLE_TOOL_BUTTON, GtkToggleToolButtonClass))
#define GTK_TYPE_TOGGLE_TOOL_BUTTON (gtk_toggle_tool_button_get_type ())
#define GTK_TOGGLE_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TOGGLE_TOOL_BUTTON, GtkToggleToolButton))
#define GTK_TOGGLE_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TOGGLE_TOOL_BUTTON, GtkToggleToolButtonClass))
#define GTK_IS_TOGGLE_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TOGGLE_TOOL_BUTTON))
#define GTK_IS_TOGGLE_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GTK_TYPE_TOGGLE_TOOL_BUTTON))
#define GTK_TOGGLE_TOOL_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_TOGGLE_TOOL_BUTTON, GtkToggleToolButtonClass))
#define GTK_TOGGLE_TOOL_BUTTON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_TOOL_BUTTON, GtkToggleToolButtonPrivate))
#define GTK_TOGGLE_TOOL_BUTTON_GET_PRIVATE(obj) (
typedef struct _GtkToggleToolButton GtkToggleToolButton;
typedef struct _GtkToggleToolButtonClass GtkToggleToolButtonClass;
typedef struct _GtkToggleToolButton GtkToggleToolButton;
typedef struct _GtkToggleToolButtonClass GtkToggleToolButtonClass;
typedef struct _GtkToggleToolButtonPrivate GtkToggleToolButtonPrivate;
struct _GtkToggleToolButton
{
GtkToolButton parent;
/*< private >*/
GtkWidget *menu_item;
guint active : 1;
GtkToggleToolButtonPrivate *priv;
};
struct _GtkToggleToolButtonClass
......
......@@ -51,7 +51,7 @@
#define DEFAULT_IPADDING 0
/* note: keep in sync with DEFAULT_SPACE_SIZE and DEFAULT_SPACE_STYLE in gtkseparatortoolitem.c */
#define DEFAULT_SPACE_SIZE 5
#define DEFAULT_SPACE_SIZE 4
#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
......@@ -161,7 +161,6 @@ static void gtk_toolbar_arrow_button_clicked (GtkWidget *bu
GtkToolbar *toolbar);
static void gtk_toolbar_update_button_relief (GtkToolbar *toolbar);
static GtkReliefStyle get_button_relief (GtkToolbar *toolbar);
static gint get_space_size (GtkToolbar *toolbar);
static gint get_internal_padding (GtkToolbar *toolbar);
static void gtk_toolbar_remove_tool_item (GtkToolbar *toolbar,
GtkToolItem *item);
......@@ -564,6 +563,12 @@ toolbar_item_visible (GtkToolbar *toolbar,
return FALSE;
}
static gboolean
toolbar_item_is_homogeneous (GtkToolItem *item)
{
return (gtk_tool_item_get_homogeneous (item) && !GTK_IS_SEPARATOR_TOOL_ITEM (item));
}
static void
toolbar_item_set_is_overflow (GtkToolItem *item,
gboolean is_overflow)
......@@ -773,7 +778,6 @@ gtk_toolbar_size_request (GtkWidget *widget,
{
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
gint space_size = get_space_size (toolbar);
GList *list;
gint max_child_height;
gint max_child_width;
......@@ -803,7 +807,7 @@ gtk_toolbar_size_request (GtkWidget *widget,
max_child_width = MAX (max_child_width, requisition.width);
max_child_height = MAX (max_child_height, requisition.height);
if (gtk_tool_item_get_homogeneous (item) && GTK_BIN (item)->child)
if (toolbar_item_is_homogeneous (item))
{
max_homogeneous_child_width = MAX (max_homogeneous_child_width, requisition.width);
max_homogeneous_child_height = MAX (max_homogeneous_child_height, requisition.height);
......@@ -825,11 +829,7 @@ gtk_toolbar_size_request (GtkWidget *widget,
if (!toolbar_item_visible (toolbar, item))
continue;
if (!GTK_BIN (item)->child)
{
size = space_size;
}
else if (gtk_tool_item_get_homogeneous (item))
if (toolbar_item_is_homogeneous (item))
{
size = homogeneous_size;
}
......@@ -922,21 +922,18 @@ get_item_size (GtkToolbar *toolbar,
GtkRequisition requisition;
GtkToolItem *item = GTK_TOOL_ITEM (child);
if (!GTK_BIN (item)->child)
return get_space_size (toolbar);
gtk_widget_get_child_requisition (child, &requisition);
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (gtk_tool_item_get_homogeneous (item))
if (toolbar_item_is_homogeneous (item))
return toolbar->button_maxw;
else
return requisition.width;
}
else
{
if (gtk_tool_item_get_homogeneous (item))
if (toolbar_item_is_homogeneous (item))
return toolbar->button_maxh;
else
return requisition.height;
......@@ -949,7 +946,6 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
{
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
gint space_size;
GtkAllocation *allocations;
GtkAllocation arrow_allocation;
gint arrow_size;
......@@ -967,8 +963,6 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
widget->allocation = *allocation;
space_size = get_space_size (toolbar);
border_width = GTK_CONTAINER (toolbar)->border_width;
if (GTK_WIDGET_REALIZED (widget))
......@@ -1093,7 +1087,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
if (toolbar_item_visible (toolbar, item) &&
gtk_tool_item_get_expand (item) &&
!toolbar_item_get_is_overflow (item) && GTK_BIN (item)->child)
!toolbar_item_get_is_overflow (item) &&
!GTK_IS_SEPARATOR_TOOL_ITEM (item))
{
n_expand_items++;
}
......@@ -1104,7 +1099,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
GtkToolItem *item = list->data;
if (toolbar_item_visible (toolbar, item) && gtk_tool_item_get_expand (item) &&
!toolbar_item_get_is_overflow (item) && GTK_BIN (item)->child)
!toolbar_item_get_is_overflow (item) &&
!GTK_IS_SEPARATOR_TOOL_ITEM (item))
{
gint extra = size / n_expand_items;
if (size % n_expand_items != 0)
......@@ -2019,18 +2015,6 @@ get_button_relief (GtkToolbar *toolbar)
return button_relief;
}
static gint
get_space_size (GtkToolbar *toolbar)
{
gint space_size = DEFAULT_SPACE_SIZE;
gtk_widget_style_get (GTK_WIDGET (toolbar),
"space_size", &space_size,
NULL);
return space_size;
}
static gint
get_internal_padding (GtkToolbar *toolbar)
{
......@@ -2515,9 +2499,10 @@ gtk_toolbar_remove_space (GtkToolbar *toolbar,
return;
}
if (GTK_BIN (item)->child)
if (!GTK_IS_SEPARATOR_TOOL_ITEM (item))
{
g_warning ("Toolbar position %d is not a space", position);
return;
}
gtk_toolbar_remove_tool_item (toolbar, item);
......@@ -2686,19 +2671,19 @@ gtk_toolbar_internal_insert_element (GtkToolbar *toolbar,
case GTK_TOOLBAR_CHILD_BUTTON:
item = gtk_tool_button_new (NULL, NULL);
child->widget = GTK_TOOL_BUTTON (item)->button;
child->widget = _gtk_tool_button_get_button (GTK_TOOL_BUTTON (item));
break;
case GTK_TOOLBAR_CHILD_TOGGLEBUTTON:
item = gtk_toggle_tool_button_new ();
child->widget = GTK_TOOL_BUTTON (item)->button;
child->widget = _gtk_tool_button_get_button (GTK_TOOL_BUTTON (item));
break;
case GTK_TOOLBAR_CHILD_RADIOBUTTON:
item = gtk_radio_tool_button_new (widget
? gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget))
: NULL);
child->widget = GTK_TOOL_BUTTON (item)->button;
child->widget = _gtk_tool_button_get_button (GTK_TOOL_BUTTON (item));
break;
}
......
......@@ -78,6 +78,18 @@ static void gtk_tool_button_construct_contents (GtkToolItem *tool_item);
static GObjectClass *parent_class = NULL;
static guint toolbutton_signals[LAST_SIGNAL] = { 0 };
struct _GtkToolButtonPrivate
{
GtkWidget *button;
gchar *stock_id;
gchar *label_text;
GtkWidget *label_widget;
GtkWidget *icon_widget;
guint use_underline : 1;
};
GType
gtk_tool_button_get_type (void)
{
......@@ -212,17 +224,19 @@ gtk_tool_button_init (GtkToolButton *button,
GtkToolButtonClass *klass)
{
GtkToolItem *toolitem = GTK_TOOL_ITEM (button);
button->priv = g_new0 (GtkToolButtonPrivate, 1);
gtk_tool_item_set_homogeneous (toolitem, TRUE);
/* create button */
button->button = g_object_new (klass->button_type, NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (button->button), FALSE);
g_signal_connect_object (button->button, "clicked",
button->priv->button = g_object_new (klass->button_type, NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (button->priv->button), FALSE);
g_signal_connect_object (button->priv->button, "clicked",
G_CALLBACK (button_clicked), button, 0);
gtk_container_add (GTK_CONTAINER (button), button->button);
gtk_widget_show (button->button);
gtk_container_add (GTK_CONTAINER (button), button->priv->button);
gtk_widget_show (button->priv->button);
}
static void
......@@ -295,24 +309,24 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
gtk_tool_item_set_proxy_menu_item (tool_item, MENU_ID, NULL);
}
if (button->icon_widget && button->icon_widget->parent)
if (button->priv->icon_widget && button->priv->icon_widget->parent)
{
gtk_container_remove (GTK_CONTAINER (button->icon_widget->parent),
button->icon_widget);
gtk_container_remove (GTK_CONTAINER (button->priv->icon_widget->parent),
button->priv->icon_widget);
}
if (button->label_widget && button->label_widget->parent)
if (button->priv->label_widget && button->priv->label_widget->parent)
{
gtk_container_remove (GTK_CONTAINER (button->label_widget->parent),
button->label_widget);
gtk_container_remove (GTK_CONTAINER (button->priv->label_widget->parent),
button->priv->label_widget);
}
if (GTK_BIN (button->button)->child)
if (GTK_BIN (button->priv->button)->child)
{
/* Note: we are not destroying the label_widget or icon_widget
* here because they were removed from their containers above
*/
gtk_widget_destroy (GTK_BIN (button->button)->child);
gtk_widget_destroy (GTK_BIN (button->priv->button)->child);
}
style = gtk_tool_item_get_toolbar_style (GTK_TOOL_ITEM (button));
......@@ -325,9 +339,9 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
if (need_label)
{
if (button->label_widget)
if (button->priv->label_widget)
{
label = button->label_widget;
label = button->priv->label_widget;
}
else
{
......@@ -335,12 +349,12 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
gboolean elide;
gchar *label_text;
if (button->label_text)
if (button->priv->label_text)
{
label_text = button->label_text;
elide = button->use_underline;
label_text = button->priv->label_text;
elide = button->priv->use_underline;
}
else if (button->stock_id && gtk_stock_lookup (button->stock_id, &stock_item))
else if (button->priv->stock_id && gtk_stock_lookup (button->priv->stock_id, &stock_item))
{
label_text = stock_item.label;
elide = TRUE;
......@@ -367,20 +381,20 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
icon_size = gtk_tool_item_get_icon_size (GTK_TOOL_ITEM (button));
if (need_icon)
{
if (button->icon_widget)
if (button->priv->icon_widget)
{
icon = button->icon_widget;
icon = button->priv->icon_widget;
if (GTK_IS_IMAGE (icon))
{
g_object_set (G_OBJECT (button->icon_widget),
g_object_set (G_OBJECT (button->priv->icon_widget),
"icon-size", icon_size,
NULL);
}
}
else if (button->stock_id)
else if (button->priv->stock_id)
{
icon = gtk_image_new_from_stock (button->stock_id, icon_size);
icon = gtk_image_new_from_stock (button->priv->stock_id, icon_size);
gtk_widget_show (icon);
}
}
......@@ -389,32 +403,32 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)