fix a type check, (#116947, Krasimir Angelov)

Tue Jul  8 12:50:20 2003  Soeren Sandmann  <sandmann@daimi.au.dk>

	* gtk/gtktoolbutton.c (gtk_tool_button_get_icon_widget): fix a
	type check, (#116947, Krasimir Angelov)

	* gtk/gtktoolbar.c: Use new GtkToolItem accessors.

	* gtk/gtktoolitem.[ch]: Use a private struct to hold the instance
	data. Not instance private data yet, because of bug 116921.

	* gtk/gtktoolitem.h: new accessors:
		gtk_tool_item_get_homogeneous ()
		gtk_tool_item_get_expand ()
		gtk_tool_item_get_pack_end ()
		gtk_tool_item_get_use_drag_window ()
This commit is contained in:
Soeren Sandmann 2003-07-08 10:58:23 +00:00 committed by Søren Sandmann Pedersen
parent f74f620ca9
commit b3b16bebcf
10 changed files with 278 additions and 108 deletions

View File

@ -1,3 +1,19 @@
Tue Jul 8 12:50:20 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_get_icon_widget): fix a
type check, (#116947, Krasimir Angelov)
* gtk/gtktoolbar.c: Use new GtkToolItem accessors.
* gtk/gtktoolitem.[ch]: Use a private struct to hold the instance
data. Not instance private data yet, because of bug 116921.
* gtk/gtktoolitem.h: new accessors:
gtk_tool_item_get_homogeneous ()
gtk_tool_item_get_expand ()
gtk_tool_item_get_pack_end ()
gtk_tool_item_get_use_drag_window ()
Mon Jul 7 16:50:32 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkcellrenderertext.c

View File

@ -1,3 +1,19 @@
Tue Jul 8 12:50:20 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_get_icon_widget): fix a
type check, (#116947, Krasimir Angelov)
* gtk/gtktoolbar.c: Use new GtkToolItem accessors.
* gtk/gtktoolitem.[ch]: Use a private struct to hold the instance
data. Not instance private data yet, because of bug 116921.
* gtk/gtktoolitem.h: new accessors:
gtk_tool_item_get_homogeneous ()
gtk_tool_item_get_expand ()
gtk_tool_item_get_pack_end ()
gtk_tool_item_get_use_drag_window ()
Mon Jul 7 16:50:32 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkcellrenderertext.c

View File

@ -1,3 +1,19 @@
Tue Jul 8 12:50:20 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_get_icon_widget): fix a
type check, (#116947, Krasimir Angelov)
* gtk/gtktoolbar.c: Use new GtkToolItem accessors.
* gtk/gtktoolitem.[ch]: Use a private struct to hold the instance
data. Not instance private data yet, because of bug 116921.
* gtk/gtktoolitem.h: new accessors:
gtk_tool_item_get_homogeneous ()
gtk_tool_item_get_expand ()
gtk_tool_item_get_pack_end ()
gtk_tool_item_get_use_drag_window ()
Mon Jul 7 16:50:32 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkcellrenderertext.c

View File

@ -1,3 +1,19 @@
Tue Jul 8 12:50:20 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_get_icon_widget): fix a
type check, (#116947, Krasimir Angelov)
* gtk/gtktoolbar.c: Use new GtkToolItem accessors.
* gtk/gtktoolitem.[ch]: Use a private struct to hold the instance
data. Not instance private data yet, because of bug 116921.
* gtk/gtktoolitem.h: new accessors:
gtk_tool_item_get_homogeneous ()
gtk_tool_item_get_expand ()
gtk_tool_item_get_pack_end ()
gtk_tool_item_get_use_drag_window ()
Mon Jul 7 16:50:32 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkcellrenderertext.c

View File

@ -1,3 +1,19 @@
Tue Jul 8 12:50:20 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_get_icon_widget): fix a
type check, (#116947, Krasimir Angelov)
* gtk/gtktoolbar.c: Use new GtkToolItem accessors.
* gtk/gtktoolitem.[ch]: Use a private struct to hold the instance
data. Not instance private data yet, because of bug 116921.
* gtk/gtktoolitem.h: new accessors:
gtk_tool_item_get_homogeneous ()
gtk_tool_item_get_expand ()
gtk_tool_item_get_pack_end ()
gtk_tool_item_get_use_drag_window ()
Mon Jul 7 16:50:32 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkcellrenderertext.c

View File

@ -539,8 +539,10 @@ toolbar_item_visible (GtkToolbar *toolbar,
GtkToolItem *item)
{
if (GTK_WIDGET_VISIBLE (item) &&
((toolbar->orientation == GTK_ORIENTATION_HORIZONTAL && item->visible_horizontal) ||
(toolbar->orientation == GTK_ORIENTATION_VERTICAL && item->visible_vertical)))
((toolbar->orientation == GTK_ORIENTATION_HORIZONTAL &&
gtk_tool_item_get_visible_horizontal (item)) ||
(toolbar->orientation == GTK_ORIENTATION_VERTICAL &&
gtk_tool_item_get_visible_vertical (item))))
{
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
@ -562,6 +564,23 @@ toolbar_item_visible (GtkToolbar *toolbar,
return FALSE;
}
static void
toolbar_item_set_is_overflow (GtkToolItem *item,
gboolean is_overflow)
{
g_object_set_data (G_OBJECT (item), "gtk-toolbar-item-is-overflow", GINT_TO_POINTER (is_overflow));
}
static gboolean
toolbar_item_get_is_overflow (GtkToolItem *item)
{
gpointer result;
result = g_object_get_data (G_OBJECT (item), "gtk-toolbar-item-is-overflow");
return GPOINTER_TO_INT (result);
}
static void
gtk_toolbar_set_property (GObject *object,
guint prop_id,
@ -784,7 +803,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 (item)->homogeneous && GTK_BIN (item)->child)
if (gtk_tool_item_get_homogeneous (item) && GTK_BIN (item)->child)
{
max_homogeneous_child_width = MAX (max_homogeneous_child_width, requisition.width);
max_homogeneous_child_height = MAX (max_homogeneous_child_height, requisition.height);
@ -810,7 +829,7 @@ gtk_toolbar_size_request (GtkWidget *widget,
{
size = space_size;
}
else if (item->homogeneous)
else if (gtk_tool_item_get_homogeneous (item))
{
size = homogeneous_size;
}
@ -826,7 +845,7 @@ gtk_toolbar_size_request (GtkWidget *widget,
size = requisition.height;
}
if (item->pack_end)
if (gtk_tool_item_get_pack_end (item))
pack_end_size += size;
else
pack_front_size += size;
@ -910,14 +929,14 @@ get_item_size (GtkToolbar *toolbar,
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (item->homogeneous)
if (gtk_tool_item_get_homogeneous (item))
return toolbar->button_maxw;
else
return requisition.width;
}
else
{
if (item->homogeneous)
if (gtk_tool_item_get_homogeneous (item))
return toolbar->button_maxh;
else
return requisition.height;
@ -1007,7 +1026,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation = &(allocations[n_items - i - 1]);
gint item_size;
if (!item->pack_end || !toolbar_item_visible (toolbar, item))
if (!gtk_tool_item_get_pack_end (item) || !toolbar_item_visible (toolbar, item))
continue;
item_size = get_item_size (toolbar, GTK_WIDGET (item));
@ -1015,15 +1034,15 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
{
size -= item_size;
allocation->width = item_size;
item->overflow_item = FALSE;
toolbar_item_set_is_overflow (item, FALSE);
}
else
{
while (list)
{
item = list->data;
if (item->pack_end)
item->overflow_item = TRUE;
if (gtk_tool_item_get_pack_end (item))
toolbar_item_set_is_overflow (item, TRUE);
list = list->prev;
}
@ -1037,7 +1056,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
GtkToolItem *item = list->data;
gint item_size;
if (item->pack_end || !toolbar_item_visible (toolbar, item))
if (gtk_tool_item_get_pack_end (item) || !toolbar_item_visible (toolbar, item))
continue;
item_size = get_item_size (toolbar, GTK_WIDGET (item));
@ -1045,15 +1064,15 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
{
size -= item_size;
allocations[i].width = item_size;
item->overflow_item = FALSE;
toolbar_item_set_is_overflow (item, FALSE);
}
else
{
while (list)
{
item = list->data;
if (!item->pack_end)
item->overflow_item = TRUE;
if (!gtk_tool_item_get_pack_end (item))
toolbar_item_set_is_overflow (item, TRUE);
list = list->next;
}
break;
@ -1072,8 +1091,9 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
{
GtkToolItem *item = list->data;
if (toolbar_item_visible (toolbar, item) && item->expand &&
!item->overflow_item && GTK_BIN (item)->child)
if (toolbar_item_visible (toolbar, item) &&
gtk_tool_item_get_expand (item) &&
!toolbar_item_get_is_overflow (item) && GTK_BIN (item)->child)
{
n_expand_items++;
}
@ -1083,8 +1103,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
{
GtkToolItem *item = list->data;
if (toolbar_item_visible (toolbar, item) && item->expand &&
!item->overflow_item && GTK_BIN (item)->child)
if (toolbar_item_visible (toolbar, item) && gtk_tool_item_get_expand (item) &&
!toolbar_item_get_is_overflow (item) && GTK_BIN (item)->child)
{
gint extra = size / n_expand_items;
if (size % n_expand_items != 0)
@ -1104,7 +1124,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
{
GtkToolItem *item = list->data;
if (toolbar_item_visible (toolbar, item) && !item->overflow_item && !item->pack_end)
if (toolbar_item_visible (toolbar, item) && !toolbar_item_get_is_overflow (item) && !gtk_tool_item_get_pack_end (item))
{
allocations[i].x = pos;
allocations[i].y = border_width;
@ -1120,7 +1140,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
{
GtkToolItem *item = list->data;
if (toolbar_item_visible (toolbar, item) && !item->overflow_item && item->pack_end)
if (toolbar_item_visible (toolbar, item) && !toolbar_item_get_is_overflow (item) && gtk_tool_item_get_pack_end (item))
{
GtkAllocation *allocation = &(allocations[n_items - i - 1]);
@ -1175,7 +1195,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
{
GtkToolItem *item = list->data;
if (toolbar_item_visible (toolbar, item) && !item->overflow_item)
if (toolbar_item_visible (toolbar, item) && !toolbar_item_get_is_overflow (item))
{
gtk_widget_size_allocate (GTK_WIDGET (item), &(allocations[i]));
gtk_widget_set_child_visible (GTK_WIDGET (item), TRUE);
@ -1244,7 +1264,7 @@ gtk_toolbar_list_children_in_focus_order (GtkToolbar *toolbar,
for (list = priv->items; list != NULL; list = list->next)
{
GtkToolItem *item = list->data;
if (!item->pack_end)
if (!gtk_tool_item_get_pack_end (item))
result = g_list_prepend (result, item);
}
@ -1252,7 +1272,7 @@ gtk_toolbar_list_children_in_focus_order (GtkToolbar *toolbar,
{
GtkToolItem *item = list->data;
if (item->pack_end)
if (gtk_tool_item_get_pack_end (item))
result = g_list_prepend (result, item);
}
@ -1516,7 +1536,7 @@ find_drop_pos (GtkToolbar *toolbar,
{
item = GTK_TOOL_ITEM (items->data);
index++;
if (GTK_WIDGET_DRAWABLE (item) && !item->pack_end)
if (GTK_WIDGET_DRAWABLE (item) && !gtk_tool_item_get_pack_end (item))
{
gint pos, distance;
@ -1639,15 +1659,15 @@ gtk_toolbar_get_child_property (GtkContainer *container,
switch (property_id)
{
case CHILD_PROP_PACK_END:
g_value_set_boolean (value, item->pack_end);
g_value_set_boolean (value, gtk_tool_item_get_pack_end (item));
break;
case CHILD_PROP_HOMOGENEOUS:
g_value_set_boolean (value, item->homogeneous);
g_value_set_boolean (value, gtk_tool_item_get_homogeneous (item));
break;
case CHILD_PROP_EXPAND:
g_value_set_boolean (value, item->expand);
g_value_set_boolean (value, gtk_tool_item_get_expand (item));
break;
default:
@ -1896,7 +1916,7 @@ show_menu (GtkToolbar *toolbar,
{
GtkToolItem *item = list->data;
if (toolbar_item_visible (toolbar, item) && item->overflow_item)
if (toolbar_item_visible (toolbar, item) && toolbar_item_get_is_overflow (item))
{
GtkWidget *menu_item = gtk_tool_item_retrieve_proxy_menu_item (item);

View File

@ -212,8 +212,8 @@ gtk_tool_button_init (GtkToolButton *button,
GtkToolButtonClass *klass)
{
GtkToolItem *toolitem = GTK_TOOL_ITEM (button);
toolitem->homogeneous = TRUE;
gtk_tool_item_set_homogeneous (toolitem, TRUE);
/* create button */
button->button = g_object_new (klass->button_type, NULL);
@ -257,8 +257,8 @@ gtk_tool_button_size_allocate (GtkWidget *widget,
widget->allocation = *allocation;
border_width = GTK_CONTAINER (widget)->border_width;
if (toolitem->drag_window && GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (toolitem->drag_window,
if (gtk_tool_item_get_use_drag_window (toolitem) && GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (_gtk_tool_item_get_drag_window (toolitem),
widget->allocation.x + border_width,
widget->allocation.y + border_width,
widget->allocation.width - border_width * 2,
@ -776,7 +776,7 @@ gtk_tool_button_get_label_widget (GtkToolButton *button)
GtkWidget *
gtk_tool_button_get_icon_widget (GtkToolButton *button)
{
g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
g_return_val_if_fail (GTK_IS_TOOL_BUTTON (button), NULL);
return button->icon_widget;
}

View File

@ -44,6 +44,25 @@ enum {
PROP_VISIBLE_VERTICAL,
};
struct _GtkToolItemPrivate
{
gchar *tip_text;
gchar *tip_private;
guint visible_horizontal : 1;
guint visible_vertical : 1;
guint homogeneous : 1;
guint expand : 1;
guint pack_end : 1;
guint use_drag_window : 1;
guint overflow_item : 1;
GdkWindow *drag_window;
gchar *menu_item_id;
GtkWidget *menu_item;
};
static void gtk_tool_item_init (GtkToolItem *toolitem);
static void gtk_tool_item_class_init (GtkToolItemClass *class);
static void gtk_tool_item_finalize (GObject *object);
@ -170,6 +189,11 @@ gtk_tool_item_class_init (GtkToolItemClass *klass)
GTK_TYPE_TOOLTIPS,
G_TYPE_STRING,
G_TYPE_STRING);
/* FIXME: enable this when bug 116921 is fixed */
#if 0
g_type_class_add_private (object_class, sizeof (GtkToolItemPrivate));
#endif
}
static void
@ -177,10 +201,16 @@ gtk_tool_item_init (GtkToolItem *toolitem)
{
GTK_WIDGET_UNSET_FLAGS (toolitem, GTK_CAN_FOCUS);
toolitem->visible_horizontal = TRUE;
toolitem->visible_vertical = TRUE;
toolitem->homogeneous = FALSE;
toolitem->expand = FALSE;
/* FIXME: enable this when bug 116921 is fixed */
#if 0
toolitem->priv = GTK_TOOL_ITEM_GET_PRIVATE (toolitem);
#endif
toolitem->priv = g_new0 (GtkToolItemPrivate, 1);
toolitem->priv->visible_horizontal = TRUE;
toolitem->priv->visible_vertical = TRUE;
toolitem->priv->homogeneous = FALSE;
toolitem->priv->expand = FALSE;
}
static void
@ -188,8 +218,8 @@ gtk_tool_item_finalize (GObject *object)
{
GtkToolItem *item = GTK_TOOL_ITEM (object);
if (item->menu_item)
g_object_unref (item->menu_item);
if (item->priv->menu_item)
g_object_unref (item->priv->menu_item);
if (G_OBJECT_CLASS (parent_class)->finalize)
G_OBJECT_CLASS (parent_class)->finalize (object);
@ -234,10 +264,10 @@ gtk_tool_item_get_property (GObject *object,
switch (prop_id)
{
case PROP_VISIBLE_HORIZONTAL:
g_value_set_boolean (value, toolitem->visible_horizontal);
g_value_set_boolean (value, toolitem->priv->visible_horizontal);
break;
case PROP_VISIBLE_VERTICAL:
g_value_set_boolean (value, toolitem->visible_vertical);
g_value_set_boolean (value, toolitem->priv->visible_vertical);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -251,7 +281,7 @@ create_drag_window (GtkToolItem *toolitem)
GdkWindowAttr attributes;
gint attributes_mask, border_width;
g_return_if_fail (toolitem->use_drag_window == TRUE);
g_return_if_fail (toolitem->priv->use_drag_window == TRUE);
widget = GTK_WIDGET (toolitem);
border_width = GTK_CONTAINER (toolitem)->border_width;
@ -267,9 +297,9 @@ create_drag_window (GtkToolItem *toolitem)
attributes_mask = GDK_WA_X | GDK_WA_Y;
toolitem->drag_window = gdk_window_new (gtk_widget_get_parent_window (widget),
toolitem->priv->drag_window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (toolitem->drag_window, toolitem);
gdk_window_set_user_data (toolitem->priv->drag_window, toolitem);
}
static void
@ -283,7 +313,7 @@ gtk_tool_item_realize (GtkWidget *widget)
widget->window = gtk_widget_get_parent_window (widget);
g_object_ref (widget->window);
if (toolitem->use_drag_window)
if (toolitem->priv->use_drag_window)
create_drag_window(toolitem);
widget->style = gtk_style_attach (widget->style, widget->window);
@ -292,11 +322,11 @@ gtk_tool_item_realize (GtkWidget *widget)
static void
destroy_drag_window (GtkToolItem *toolitem)
{
if (toolitem->drag_window)
if (toolitem->priv->drag_window)
{
gdk_window_set_user_data (toolitem->drag_window, NULL);
gdk_window_destroy (toolitem->drag_window);
toolitem->drag_window = NULL;
gdk_window_set_user_data (toolitem->priv->drag_window, NULL);
gdk_window_destroy (toolitem->priv->drag_window);
toolitem->priv->drag_window = NULL;
}
}
@ -319,8 +349,8 @@ gtk_tool_item_map (GtkWidget *widget)
toolitem = GTK_TOOL_ITEM (widget);
GTK_WIDGET_CLASS (parent_class)->map (widget);
if (toolitem->drag_window)
gdk_window_show (toolitem->drag_window);
if (toolitem->priv->drag_window)
gdk_window_show (toolitem->priv->drag_window);
}
static void
@ -329,8 +359,8 @@ gtk_tool_item_unmap (GtkWidget *widget)
GtkToolItem *toolitem;
toolitem = GTK_TOOL_ITEM (widget);
if (toolitem->drag_window)
gdk_window_hide (toolitem->drag_window);
if (toolitem->priv->drag_window)
gdk_window_hide (toolitem->priv->drag_window);
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
}
@ -368,8 +398,8 @@ gtk_tool_item_size_allocate (GtkWidget *widget,
widget->allocation = *allocation;
border_width = GTK_CONTAINER (widget)->border_width;
if (toolitem->drag_window)
gdk_window_move_resize (toolitem->drag_window,
if (toolitem->priv->drag_window)
gdk_window_move_resize (toolitem->priv->drag_window,
widget->allocation.x + border_width,
widget->allocation.y + border_width,
widget->allocation.width - border_width * 2,
@ -488,14 +518,22 @@ gtk_tool_item_set_expand (GtkToolItem *tool_item,
expand = expand != FALSE;
if (tool_item->expand != expand)
if (tool_item->priv->expand != expand)
{
tool_item->expand = expand;
tool_item->priv->expand = expand;
gtk_widget_child_notify (GTK_WIDGET (tool_item), "expand");
gtk_widget_queue_resize (GTK_WIDGET (tool_item));
}
}
gboolean
gtk_tool_item_get_expand (GtkToolItem *tool_item)
{
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
return tool_item->priv->expand;
}
void
gtk_tool_item_set_pack_end (GtkToolItem *tool_item,
gboolean pack_end)
@ -504,14 +542,22 @@ gtk_tool_item_set_pack_end (GtkToolItem *tool_item,
pack_end = pack_end != FALSE;
if (tool_item->pack_end != pack_end)
if (tool_item->priv->pack_end != pack_end)
{
tool_item->pack_end = pack_end;
tool_item->priv->pack_end = pack_end;
gtk_widget_child_notify (GTK_WIDGET (tool_item), "pack_end");
gtk_widget_queue_resize (GTK_WIDGET (tool_item));
}
}
gboolean
gtk_tool_item_get_pack_end (GtkToolItem *tool_item)
{
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
return tool_item->priv->pack_end;
}
void
gtk_tool_item_set_homogeneous (GtkToolItem *tool_item,
gboolean homogeneous)
@ -520,14 +566,22 @@ gtk_tool_item_set_homogeneous (GtkToolItem *tool_item,
homogeneous = homogeneous != FALSE;
if (tool_item->homogeneous != homogeneous)
if (tool_item->priv->homogeneous != homogeneous)
{
tool_item->homogeneous = homogeneous;
tool_item->priv->homogeneous = homogeneous;
gtk_widget_child_notify (GTK_WIDGET (tool_item), "homogeneous");
gtk_widget_queue_resize (GTK_WIDGET (tool_item));
}
}
gboolean
gtk_tool_item_get_homogeneous (GtkToolItem *tool_item)
{
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
return tool_item->priv->homogeneous;
}
static gboolean
gtk_tool_item_real_set_tooltip (GtkToolItem *tool_item,
GtkTooltips *tooltips,
@ -566,17 +620,17 @@ gtk_tool_item_set_use_drag_window (GtkToolItem *toolitem,
use_drag_window = use_drag_window != FALSE;
if (toolitem->use_drag_window != use_drag_window)
if (toolitem->priv->use_drag_window != use_drag_window)
{
toolitem->use_drag_window = use_drag_window;
toolitem->priv->use_drag_window = use_drag_window;
if (use_drag_window)
{
if (!toolitem->drag_window && GTK_WIDGET_REALIZED (toolitem))
if (!toolitem->priv->drag_window && GTK_WIDGET_REALIZED (toolitem))
{
create_drag_window(toolitem);
if (GTK_WIDGET_MAPPED (toolitem))
gdk_window_show (toolitem->drag_window);
gdk_window_show (toolitem->priv->drag_window);
}
}
else
@ -586,6 +640,14 @@ gtk_tool_item_set_use_drag_window (GtkToolItem *toolitem,
}
}
gboolean
gtk_tool_item_get_use_drag_window (GtkToolItem *toolitem)
{
g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
return toolitem->priv->use_drag_window;
}
void
gtk_tool_item_set_visible_horizontal (GtkToolItem *toolitem,
gboolean visible_horizontal)
@ -594,9 +656,9 @@ gtk_tool_item_set_visible_horizontal (GtkToolItem *toolitem,
visible_horizontal = visible_horizontal != FALSE;
if (toolitem->visible_horizontal != visible_horizontal)
if (toolitem->priv->visible_horizontal != visible_horizontal)
{
toolitem->visible_horizontal = visible_horizontal;
toolitem->priv->visible_horizontal = visible_horizontal;
g_object_notify (G_OBJECT (toolitem), "visible_horizontal");
@ -609,7 +671,7 @@ gtk_tool_item_get_visible_horizontal (GtkToolItem *toolitem)
{
g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
return toolitem->visible_horizontal;
return toolitem->priv->visible_horizontal;
}
void
@ -620,9 +682,9 @@ gtk_tool_item_set_visible_vertical (GtkToolItem *toolitem,
visible_vertical = visible_vertical != FALSE;
if (toolitem->visible_vertical != visible_vertical)
if (toolitem->priv->visible_vertical != visible_vertical)
{
toolitem->visible_vertical = visible_vertical;
toolitem->priv->visible_vertical = visible_vertical;
g_object_notify (G_OBJECT (toolitem), "visible_vertical");
@ -635,7 +697,7 @@ gtk_tool_item_get_visible_vertical (GtkToolItem *toolitem)
{
g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
return toolitem->visible_vertical;
return toolitem->priv->visible_vertical;
}
GtkWidget *
@ -647,7 +709,7 @@ gtk_tool_item_retrieve_proxy_menu_item (GtkToolItem *tool_item)
g_signal_emit (tool_item, toolitem_signals[CREATE_MENU_PROXY], 0, &retval);
return tool_item->menu_item;
return tool_item->priv->menu_item;
}
GtkWidget *
@ -657,8 +719,8 @@ gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item,
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
g_return_val_if_fail (menu_item_id != NULL, NULL);
if (tool_item->menu_item_id && strcmp (tool_item->menu_item_id, menu_item_id) == 0)
return tool_item->menu_item;
if (tool_item->priv->menu_item_id && strcmp (tool_item->priv->menu_item_id, menu_item_id) == 0)
return tool_item->priv->menu_item;
return NULL;
}
@ -672,15 +734,15 @@ gtk_tool_item_set_proxy_menu_item (GtkToolItem *tool_item,
g_return_if_fail (menu_item == NULL || GTK_IS_MENU_ITEM (menu_item));
g_return_if_fail (menu_item_id != NULL);
if (tool_item->menu_item_id)
g_free (tool_item->menu_item_id);
if (tool_item->priv->menu_item_id)
g_free (tool_item->priv->menu_item_id);
tool_item->menu_item_id = g_strdup (menu_item_id);
tool_item->priv->menu_item_id = g_strdup (menu_item_id);
if (tool_item->menu_item != menu_item)
if (tool_item->priv->menu_item != menu_item)
{
if (tool_item->menu_item)
g_object_unref (G_OBJECT (tool_item->menu_item));
if (tool_item->priv->menu_item)
g_object_unref (G_OBJECT (tool_item->priv->menu_item));
if (menu_item)
{
@ -688,6 +750,12 @@ gtk_tool_item_set_proxy_menu_item (GtkToolItem *tool_item,
gtk_object_sink (GTK_OBJECT (menu_item));
}
tool_item->menu_item = menu_item;
tool_item->priv->menu_item = menu_item;
}
}
GdkWindow *
_gtk_tool_item_get_drag_window (GtkToolItem *tool_item)
{
return tool_item->priv->drag_window;
}

View File

@ -28,11 +28,12 @@
#include <gtk/gtkmenuitem.h>
#define GTK_TYPE_TOOL_ITEM (gtk_tool_item_get_type ())
#define GTK_TOOL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TOOL_ITEM, GtkToolItem))
#define GTK_TOOL_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_TOOL_ITEM, GtkToolItem))
#define GTK_TOOL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TOOL_ITEM, GtkToolItemClass))
#define GTK_IS_TOOL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TOOL_ITEM))
#define GTK_IS_TOOL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GTK_TYPE_TOOL_ITEM))
#define GTK_TOOL_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_TOOL_ITEM, GtkToolItemClass))
#define GTK_IS_TOOL_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_TOOL_ITEM))
#define GTK_IS_TOOL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((o), GTK_TYPE_TOOL_ITEM))
#define GTK_TOOL_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GTK_TYPE_TOOL_ITEM, GtkToolItemClass))
#define GTK_TOOL_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_TOOL_ITEM, GtkToolItemPrivate))
typedef struct _GtkToolItem GtkToolItem;
typedef struct _GtkToolItemClass GtkToolItemClass;
@ -42,22 +43,7 @@ struct _GtkToolItem
{
GtkBin parent;
/*< private >*/
gchar *tip_text;
gchar *tip_private;
GdkWindow *drag_window;
guint visible_horizontal : 1;
guint visible_vertical : 1;
guint homogeneous : 1;
guint expand : 1;
guint pack_end : 1;
guint use_drag_window : 1;
guint overflow_item : 1;
GtkWidget *menu_item;
gchar *menu_item_id;
GtkToolItemPrivate *priv;
};
struct _GtkToolItemClass
@ -77,28 +63,41 @@ GType gtk_tool_item_get_type (void);
GtkToolItem *gtk_tool_item_new (void);
void gtk_tool_item_toolbar_reconfigured (GtkToolItem *tool_item);
void gtk_tool_item_set_homogeneous (GtkToolItem *tool_item,
gboolean homogeneous);
gboolean gtk_tool_item_get_homogeneous (GtkToolItem *tool_item);
void gtk_tool_item_set_expand (GtkToolItem *tool_item,
gboolean expand);
gboolean gtk_tool_item_get_expand (GtkToolItem *tool_item);
void gtk_tool_item_set_pack_end (GtkToolItem *tool_item,
gboolean pack_end);
gboolean gtk_tool_item_get_pack_end (GtkToolItem *tool_item);
void gtk_tool_item_set_tooltip (GtkToolItem *tool_item,
GtkTooltips *tooltips,
const gchar *tip_text,
const gchar *tip_private);
void gtk_tool_item_set_use_drag_window (GtkToolItem *toolitem,
gboolean use_drag_window);
gboolean gtk_tool_item_get_use_drag_window (GtkToolItem *toolitem);
void gtk_tool_item_set_visible_horizontal (GtkToolItem *toolitem,
gboolean visible_horizontal);
gboolean gtk_tool_item_get_visible_horizontal (GtkToolItem *toolitem);
void gtk_tool_item_set_visible_vertical (GtkToolItem *toolitem,
gboolean visible_horizontal);
gboolean gtk_tool_item_get_visible_vertical (GtkToolItem *toolitem);
GtkIconSize gtk_tool_item_get_icon_size (GtkToolItem *tool_item);
GtkOrientation gtk_tool_item_get_orientation (GtkToolItem *tool_item);
GtkToolbarStyle gtk_tool_item_get_toolbar_style (GtkToolItem *tool_item);
GtkReliefStyle gtk_tool_item_get_relief_style (GtkToolItem *tool_item);
GtkWidget * gtk_tool_item_retrieve_proxy_menu_item (GtkToolItem *tool_item);
GtkWidget * gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item,
const gchar *menu_item_id);
@ -106,5 +105,8 @@ void gtk_tool_item_set_proxy_menu_item (GtkToolItem *tool_item,
const gchar *menu_item_id,
GtkWidget *menu_item);
/* internal function */
GdkWindow *_gtk_tool_item_get_drag_window (GtkToolItem *tool_item);
#endif /* __GTK_TOOL_ITEM_H__ */

View File

@ -150,7 +150,7 @@ set_expand_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
gtk_tree_model_get (model, iter, 0, &tool_item, -1);
g_object_set (G_OBJECT (cell), "active", tool_item->expand, NULL);
g_object_set (G_OBJECT (cell), "active", gtk_tool_item_get_expand (tool_item), NULL);
g_object_unref (tool_item);
}
@ -166,7 +166,7 @@ expand_toggled(GtkCellRendererToggle *cell, const gchar *path_str,
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, 0, &tool_item, -1);
gtk_tool_item_set_expand (tool_item, !tool_item->expand);
gtk_tool_item_set_expand (tool_item, !gtk_tool_item_get_expand (tool_item));
g_object_unref (tool_item);
gtk_tree_model_row_changed (model, path, &iter);
@ -181,7 +181,7 @@ set_pack_end_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
gtk_tree_model_get (model, iter, 0, &tool_item, -1);
g_object_set (G_OBJECT (cell), "active", tool_item->pack_end, NULL);
g_object_set (G_OBJECT (cell), "active", gtk_tool_item_get_pack_end (tool_item), NULL);
g_object_unref (tool_item);
}
@ -197,7 +197,7 @@ pack_end_toggled(GtkCellRendererToggle *cell, const gchar *path_str,
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, 0, &tool_item, -1);
gtk_tool_item_set_pack_end (tool_item, !tool_item->pack_end);
gtk_tool_item_set_pack_end (tool_item, !gtk_tool_item_get_pack_end (tool_item));
g_object_unref (tool_item);
gtk_tree_model_row_changed (model, path, &iter);
@ -212,7 +212,7 @@ set_homogeneous_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
gtk_tree_model_get (model, iter, 0, &tool_item, -1);
g_object_set (G_OBJECT (cell), "active", tool_item->homogeneous, NULL);
g_object_set (G_OBJECT (cell), "active", gtk_tool_item_get_homogeneous (tool_item), NULL);
g_object_unref (tool_item);
}
@ -228,7 +228,7 @@ homogeneous_toggled(GtkCellRendererToggle *cell, const gchar *path_str,
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, 0, &tool_item, -1);
gtk_tool_item_set_homogeneous (tool_item, !tool_item->homogeneous);
gtk_tool_item_set_homogeneous (tool_item, !gtk_tool_item_get_homogeneous (tool_item));
g_object_unref (tool_item);
gtk_tree_model_row_changed (model, path, &iter);