forked from AuroraMiddleware/gtk
toolbar: port to use a gadget
This commit is contained in:
parent
d64304997f
commit
48596090af
266
gtk/gtktoolbar.c
266
gtk/gtktoolbar.c
@ -39,6 +39,7 @@
|
|||||||
#include "gtkbindings.h"
|
#include "gtkbindings.h"
|
||||||
#include "gtkbox.h"
|
#include "gtkbox.h"
|
||||||
#include "gtkcontainerprivate.h"
|
#include "gtkcontainerprivate.h"
|
||||||
|
#include "gtkcsscustomgadgetprivate.h"
|
||||||
#include "gtkcssnodeprivate.h"
|
#include "gtkcssnodeprivate.h"
|
||||||
#include "gtkimage.h"
|
#include "gtkimage.h"
|
||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
@ -122,6 +123,9 @@ struct _GtkToolbarPrivate
|
|||||||
|
|
||||||
GdkWindow *event_window;
|
GdkWindow *event_window;
|
||||||
|
|
||||||
|
GtkCssGadget *gadget;
|
||||||
|
GtkAllocation prev_allocation;
|
||||||
|
|
||||||
GList *content;
|
GList *content;
|
||||||
|
|
||||||
GTimer *timer;
|
GTimer *timer;
|
||||||
@ -252,6 +256,27 @@ static void gtk_toolbar_update_button_relief (GtkToolbar *toolbar
|
|||||||
static gboolean gtk_toolbar_popup_menu (GtkWidget *toolbar);
|
static gboolean gtk_toolbar_popup_menu (GtkWidget *toolbar);
|
||||||
static void gtk_toolbar_reconfigured (GtkToolbar *toolbar);
|
static void gtk_toolbar_reconfigured (GtkToolbar *toolbar);
|
||||||
|
|
||||||
|
static void gtk_toolbar_allocate (GtkCssGadget *gadget,
|
||||||
|
const GtkAllocation *allocation,
|
||||||
|
int baseline,
|
||||||
|
GtkAllocation *out_clip,
|
||||||
|
gpointer data);
|
||||||
|
static void gtk_toolbar_measure (GtkCssGadget *gadget,
|
||||||
|
GtkOrientation orientation,
|
||||||
|
int for_size,
|
||||||
|
int *minimum,
|
||||||
|
int *natural,
|
||||||
|
int *minimum_baseline,
|
||||||
|
int *natural_baseline,
|
||||||
|
gpointer data);
|
||||||
|
static gboolean gtk_toolbar_render (GtkCssGadget *gadget,
|
||||||
|
cairo_t *cr,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
static GtkReliefStyle get_button_relief (GtkToolbar *toolbar);
|
static GtkReliefStyle get_button_relief (GtkToolbar *toolbar);
|
||||||
static gint get_max_child_expand (GtkToolbar *toolbar);
|
static gint get_max_child_expand (GtkToolbar *toolbar);
|
||||||
|
|
||||||
@ -679,6 +704,7 @@ gtk_toolbar_init (GtkToolbar *toolbar)
|
|||||||
{
|
{
|
||||||
GtkToolbarPrivate *priv;
|
GtkToolbarPrivate *priv;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
GtkCssNode *widget_node;
|
||||||
|
|
||||||
widget = GTK_WIDGET (toolbar);
|
widget = GTK_WIDGET (toolbar);
|
||||||
toolbar->priv = gtk_toolbar_get_instance_private (toolbar);
|
toolbar->priv = gtk_toolbar_get_instance_private (toolbar);
|
||||||
@ -694,6 +720,14 @@ gtk_toolbar_init (GtkToolbar *toolbar)
|
|||||||
|
|
||||||
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (toolbar));
|
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (toolbar));
|
||||||
|
|
||||||
|
widget_node = gtk_widget_get_css_node (widget);
|
||||||
|
priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node,
|
||||||
|
widget,
|
||||||
|
gtk_toolbar_measure,
|
||||||
|
gtk_toolbar_allocate,
|
||||||
|
gtk_toolbar_render,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
priv->arrow_button = gtk_toggle_button_new ();
|
priv->arrow_button = gtk_toggle_button_new ();
|
||||||
g_signal_connect (priv->arrow_button, "button-press-event",
|
g_signal_connect (priv->arrow_button, "button-press-event",
|
||||||
G_CALLBACK (gtk_toolbar_arrow_button_press), toolbar);
|
G_CALLBACK (gtk_toolbar_arrow_button_press), toolbar);
|
||||||
@ -867,24 +901,20 @@ gtk_toolbar_unrealize (GtkWidget *widget)
|
|||||||
GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unrealize (widget);
|
GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unrealize (widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gboolean
|
||||||
gtk_toolbar_draw (GtkWidget *widget,
|
gtk_toolbar_render (GtkCssGadget *gadget,
|
||||||
cairo_t *cr)
|
cairo_t *cr,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
|
||||||
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
|
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
|
||||||
GtkToolbarPrivate *priv = toolbar->priv;
|
GtkToolbarPrivate *priv = toolbar->priv;
|
||||||
GtkStyleContext *context;
|
|
||||||
GList *list;
|
GList *list;
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (widget);
|
|
||||||
|
|
||||||
gtk_render_background (context, cr, 0, 0,
|
|
||||||
gtk_widget_get_allocated_width (widget),
|
|
||||||
gtk_widget_get_allocated_height (widget));
|
|
||||||
gtk_render_frame (context, cr, 0, 0,
|
|
||||||
gtk_widget_get_allocated_width (widget),
|
|
||||||
gtk_widget_get_allocated_height (widget));
|
|
||||||
|
|
||||||
for (list = priv->content; list != NULL; list = list->next)
|
for (list = priv->content; list != NULL; list = list->next)
|
||||||
{
|
{
|
||||||
ToolbarContent *content = list->data;
|
ToolbarContent *content = list->data;
|
||||||
@ -899,31 +929,29 @@ gtk_toolbar_draw (GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gint
|
||||||
get_widget_padding_and_border (GtkWidget *widget,
|
gtk_toolbar_draw (GtkWidget *widget,
|
||||||
GtkBorder *padding)
|
cairo_t *cr)
|
||||||
{
|
{
|
||||||
GtkStyleContext *context;
|
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
|
||||||
GtkStateFlags state;
|
GtkToolbarPrivate *priv = toolbar->priv;
|
||||||
GtkBorder tmp;
|
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (widget);
|
gtk_css_gadget_draw (priv->gadget, cr);
|
||||||
state = gtk_style_context_get_state (context);
|
|
||||||
|
|
||||||
gtk_style_context_get_padding (context, state, padding);
|
return FALSE;
|
||||||
gtk_style_context_get_border (context, state, &tmp);
|
|
||||||
|
|
||||||
padding->top += tmp.top;
|
|
||||||
padding->right += tmp.right;
|
|
||||||
padding->bottom += tmp.bottom;
|
|
||||||
padding->left += tmp.left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_toolbar_size_request (GtkWidget *widget,
|
gtk_toolbar_measure (GtkCssGadget *gadget,
|
||||||
GtkRequisition *min_requisition,
|
GtkOrientation orientation,
|
||||||
GtkRequisition *nat_requisition)
|
int for_size,
|
||||||
|
int *minimum,
|
||||||
|
int *natural,
|
||||||
|
int *minimum_baseline,
|
||||||
|
int *natural_baseline,
|
||||||
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
|
||||||
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
|
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
|
||||||
GtkToolbarPrivate *priv = toolbar->priv;
|
GtkToolbarPrivate *priv = toolbar->priv;
|
||||||
GList *list;
|
GList *list;
|
||||||
@ -933,10 +961,8 @@ gtk_toolbar_size_request (GtkWidget *widget,
|
|||||||
gint max_homogeneous_child_height;
|
gint max_homogeneous_child_height;
|
||||||
gint homogeneous_size;
|
gint homogeneous_size;
|
||||||
gint pack_front_size;
|
gint pack_front_size;
|
||||||
GtkBorder padding;
|
GtkRequisition arrow_requisition, min_requisition, nat_requisition;
|
||||||
gint extra_width, extra_height;
|
|
||||||
GtkRequisition arrow_requisition;
|
|
||||||
|
|
||||||
max_homogeneous_child_width = 0;
|
max_homogeneous_child_width = 0;
|
||||||
max_homogeneous_child_height = 0;
|
max_homogeneous_child_height = 0;
|
||||||
max_child_width = 0;
|
max_child_width = 0;
|
||||||
@ -1003,35 +1029,34 @@ gtk_toolbar_size_request (GtkWidget *widget,
|
|||||||
|
|
||||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
{
|
{
|
||||||
nat_requisition->width = pack_front_size;
|
nat_requisition.width = pack_front_size;
|
||||||
nat_requisition->height = MAX (max_child_height, arrow_requisition.height);
|
nat_requisition.height = MAX (max_child_height, arrow_requisition.height);
|
||||||
|
|
||||||
min_requisition->width = priv->show_arrow ? arrow_requisition.width : nat_requisition->width;
|
min_requisition.width = priv->show_arrow ? arrow_requisition.width : nat_requisition.width;
|
||||||
min_requisition->height = nat_requisition->height;
|
min_requisition.height = nat_requisition.height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nat_requisition->height = pack_front_size;
|
nat_requisition.width = MAX (max_child_width, arrow_requisition.width);
|
||||||
nat_requisition->width = MAX (max_child_width, arrow_requisition.width);
|
nat_requisition.height = pack_front_size;
|
||||||
|
|
||||||
min_requisition->height = priv->show_arrow ? arrow_requisition.height : nat_requisition->height;
|
min_requisition.width = nat_requisition.width;
|
||||||
min_requisition->width = nat_requisition->width;
|
min_requisition.height = priv->show_arrow ? arrow_requisition.height : nat_requisition.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extra spacing */
|
|
||||||
get_widget_padding_and_border (widget, &padding);
|
|
||||||
|
|
||||||
extra_width = padding.left + padding.right;
|
|
||||||
extra_height = padding.top + padding.bottom;
|
|
||||||
|
|
||||||
nat_requisition->width += extra_width;
|
|
||||||
nat_requisition->height += extra_height;
|
|
||||||
|
|
||||||
min_requisition->width += extra_width;
|
|
||||||
min_requisition->height += extra_height;
|
|
||||||
|
|
||||||
priv->button_maxw = max_homogeneous_child_width;
|
priv->button_maxw = max_homogeneous_child_width;
|
||||||
priv->button_maxh = max_homogeneous_child_height;
|
priv->button_maxh = max_homogeneous_child_height;
|
||||||
|
|
||||||
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
|
{
|
||||||
|
*minimum = min_requisition.width;
|
||||||
|
*natural = nat_requisition.width;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*minimum = min_requisition.height;
|
||||||
|
*natural = nat_requisition.height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1039,12 +1064,14 @@ gtk_toolbar_get_preferred_width (GtkWidget *widget,
|
|||||||
gint *minimum,
|
gint *minimum,
|
||||||
gint *natural)
|
gint *natural)
|
||||||
{
|
{
|
||||||
GtkRequisition min_requisition, nat_requisition;
|
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
|
||||||
|
GtkToolbarPrivate *priv = toolbar->priv;
|
||||||
|
|
||||||
gtk_toolbar_size_request (widget, &min_requisition, &nat_requisition);
|
gtk_css_gadget_get_preferred_size (priv->gadget,
|
||||||
|
GTK_ORIENTATION_HORIZONTAL,
|
||||||
*minimum = min_requisition.width;
|
-1,
|
||||||
*natural = nat_requisition.width;
|
minimum, natural,
|
||||||
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1052,12 +1079,14 @@ gtk_toolbar_get_preferred_height (GtkWidget *widget,
|
|||||||
gint *minimum,
|
gint *minimum,
|
||||||
gint *natural)
|
gint *natural)
|
||||||
{
|
{
|
||||||
GtkRequisition min_requisition, nat_requisition;
|
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
|
||||||
|
GtkToolbarPrivate *priv = toolbar->priv;
|
||||||
|
|
||||||
gtk_toolbar_size_request (widget, &min_requisition, &nat_requisition);
|
gtk_css_gadget_get_preferred_size (priv->gadget,
|
||||||
|
GTK_ORIENTATION_VERTICAL,
|
||||||
*minimum = min_requisition.height;
|
-1,
|
||||||
*natural = nat_requisition.height;
|
minimum, natural,
|
||||||
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
@ -1255,13 +1284,12 @@ rect_within (GtkAllocation *a1,
|
|||||||
static void
|
static void
|
||||||
gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
|
gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
|
||||||
{
|
{
|
||||||
GtkAllocation allocation;
|
GtkAllocation content_allocation;
|
||||||
GtkWidget *widget = GTK_WIDGET (toolbar);
|
GtkWidget *widget = GTK_WIDGET (toolbar);
|
||||||
GtkToolbarPrivate *priv = toolbar->priv;
|
GtkToolbarPrivate *priv = toolbar->priv;
|
||||||
GList *list;
|
GList *list;
|
||||||
gint cur_x;
|
gint cur_x;
|
||||||
gint cur_y;
|
gint cur_y;
|
||||||
GtkBorder padding;
|
|
||||||
gboolean rtl;
|
gboolean rtl;
|
||||||
gboolean vertical;
|
gboolean vertical;
|
||||||
|
|
||||||
@ -1281,26 +1309,25 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
|
|||||||
g_source_set_name_by_id (priv->idle_id, "[gtk+] slide_idle_handler");
|
g_source_set_name_by_id (priv->idle_id, "[gtk+] slide_idle_handler");
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_css_gadget_get_content_allocation (priv->gadget,
|
||||||
|
&content_allocation, NULL);
|
||||||
|
|
||||||
rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
|
rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
|
||||||
vertical = (priv->orientation == GTK_ORIENTATION_VERTICAL);
|
vertical = (priv->orientation == GTK_ORIENTATION_VERTICAL);
|
||||||
|
|
||||||
get_widget_padding_and_border (GTK_WIDGET (toolbar), &padding);
|
|
||||||
|
|
||||||
if (rtl)
|
if (rtl)
|
||||||
{
|
{
|
||||||
cur_x = allocation.width - padding.right;
|
cur_x = content_allocation.width;
|
||||||
cur_y = allocation.height - padding.top;
|
cur_y = content_allocation.height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cur_x = padding.left;
|
cur_x = 0;
|
||||||
cur_y = padding.top;
|
cur_y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_x += allocation.x;
|
cur_x += content_allocation.x;
|
||||||
cur_y += allocation.y;
|
cur_y += content_allocation.y;
|
||||||
|
|
||||||
for (list = priv->content; list != NULL; list = list->next)
|
for (list = priv->content; list != NULL; list = list->next)
|
||||||
{
|
{
|
||||||
@ -1313,7 +1340,7 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
|
|||||||
toolbar_content_get_allocation (content, &item_allocation);
|
toolbar_content_get_allocation (content, &item_allocation);
|
||||||
|
|
||||||
if ((state == NORMAL &&
|
if ((state == NORMAL &&
|
||||||
rect_within (&item_allocation, &allocation)) ||
|
rect_within (&item_allocation, &content_allocation)) ||
|
||||||
state == OVERFLOWN)
|
state == OVERFLOWN)
|
||||||
{
|
{
|
||||||
new_start_allocation = item_allocation;
|
new_start_allocation = item_allocation;
|
||||||
@ -1325,15 +1352,13 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
|
|||||||
|
|
||||||
if (vertical)
|
if (vertical)
|
||||||
{
|
{
|
||||||
new_start_allocation.width = allocation.width -
|
new_start_allocation.width = content_allocation.width;
|
||||||
padding.left - padding.right;
|
|
||||||
new_start_allocation.height = 0;
|
new_start_allocation.height = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
new_start_allocation.width = 0;
|
new_start_allocation.width = 0;
|
||||||
new_start_allocation.height = allocation.height -
|
new_start_allocation.height = content_allocation.height;
|
||||||
padding.top - padding.bottom;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1483,16 +1508,18 @@ rebuild_menu (GtkToolbar *toolbar)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_toolbar_size_allocate (GtkWidget *widget,
|
gtk_toolbar_allocate (GtkCssGadget *gadget,
|
||||||
GtkAllocation *allocation)
|
const GtkAllocation *allocation,
|
||||||
|
int baseline,
|
||||||
|
GtkAllocation *out_clip,
|
||||||
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkAllocation widget_allocation;
|
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
|
||||||
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
|
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
|
||||||
GtkToolbarPrivate *priv = toolbar->priv;
|
GtkToolbarPrivate *priv = toolbar->priv;
|
||||||
|
GtkAllocation arrow_allocation, item_area, widget_allocation;
|
||||||
GtkAllocation *allocations;
|
GtkAllocation *allocations;
|
||||||
ItemState *new_states;
|
ItemState *new_states;
|
||||||
GtkAllocation arrow_allocation;
|
|
||||||
GtkBorder padding;
|
|
||||||
gint arrow_size;
|
gint arrow_size;
|
||||||
gint size, pos, short_size;
|
gint size, pos, short_size;
|
||||||
GList *list;
|
GList *list;
|
||||||
@ -1505,14 +1532,13 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
|
|||||||
GtkRequisition arrow_requisition;
|
GtkRequisition arrow_requisition;
|
||||||
gboolean overflowing;
|
gboolean overflowing;
|
||||||
gboolean size_changed;
|
gboolean size_changed;
|
||||||
GtkAllocation item_area;
|
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &widget_allocation);
|
gtk_widget_get_allocation (widget, &widget_allocation);
|
||||||
size_changed = FALSE;
|
size_changed = FALSE;
|
||||||
if (widget_allocation.x != allocation->x ||
|
if (widget_allocation.x != priv->prev_allocation.x ||
|
||||||
widget_allocation.y != allocation->y ||
|
widget_allocation.y != priv->prev_allocation.y ||
|
||||||
widget_allocation.width != allocation->width ||
|
widget_allocation.width != priv->prev_allocation.width ||
|
||||||
widget_allocation.height != allocation->height)
|
widget_allocation.height != priv->prev_allocation.height)
|
||||||
{
|
{
|
||||||
size_changed = TRUE;
|
size_changed = TRUE;
|
||||||
}
|
}
|
||||||
@ -1520,30 +1546,19 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
|
|||||||
if (size_changed)
|
if (size_changed)
|
||||||
gtk_toolbar_stop_sliding (toolbar);
|
gtk_toolbar_stop_sliding (toolbar);
|
||||||
|
|
||||||
gtk_widget_set_allocation (widget, allocation);
|
|
||||||
|
|
||||||
if (gtk_widget_get_realized (widget))
|
|
||||||
gdk_window_move_resize (priv->event_window,
|
|
||||||
allocation->x,
|
|
||||||
allocation->y,
|
|
||||||
allocation->width,
|
|
||||||
allocation->height);
|
|
||||||
|
|
||||||
|
|
||||||
gtk_widget_get_preferred_size (priv->arrow_button,
|
gtk_widget_get_preferred_size (priv->arrow_button,
|
||||||
&arrow_requisition, NULL);
|
&arrow_requisition, NULL);
|
||||||
get_widget_padding_and_border (widget, &padding);
|
|
||||||
|
|
||||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
{
|
{
|
||||||
available_size = size = allocation->width - padding.left - padding.right;
|
available_size = size = allocation->width;
|
||||||
short_size = allocation->height - padding.top - padding.bottom;
|
short_size = allocation->height;
|
||||||
arrow_size = arrow_requisition.width;
|
arrow_size = arrow_requisition.width;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
available_size = size = allocation->height - padding.top - padding.bottom;
|
available_size = size = allocation->height;
|
||||||
short_size = allocation->width - padding.left - padding.right;
|
short_size = allocation->width;
|
||||||
arrow_size = arrow_requisition.height;
|
arrow_size = arrow_requisition.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1714,18 +1729,18 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
|
|||||||
/* translate the items by allocation->(x,y) */
|
/* translate the items by allocation->(x,y) */
|
||||||
for (i = 0; i < n_items; ++i)
|
for (i = 0; i < n_items; ++i)
|
||||||
{
|
{
|
||||||
allocations[i].x += allocation->x + padding.left;
|
allocations[i].x += allocation->x;
|
||||||
allocations[i].y += allocation->y + padding.top;
|
allocations[i].y += allocation->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_arrow)
|
if (need_arrow)
|
||||||
{
|
{
|
||||||
arrow_allocation.x += allocation->x + padding.left;
|
arrow_allocation.x += allocation->x;
|
||||||
arrow_allocation.y += allocation->y + padding.top;
|
arrow_allocation.y += allocation->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
item_area.x += allocation->x + padding.left;
|
item_area.x += allocation->x;
|
||||||
item_area.y += allocation->y + padding.top;
|
item_area.y += allocation->y;
|
||||||
|
|
||||||
/* did anything change? */
|
/* did anything change? */
|
||||||
for (list = priv->content, i = 0; list != NULL; list = list->next, i++)
|
for (list = priv->content, i = 0; list != NULL; list = list->next, i++)
|
||||||
@ -1824,8 +1839,31 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
g_free (allocations);
|
g_free (allocations);
|
||||||
g_free (new_states);
|
g_free (new_states);
|
||||||
|
}
|
||||||
|
|
||||||
_gtk_widget_set_simple_clip (widget, NULL);
|
static void
|
||||||
|
gtk_toolbar_size_allocate (GtkWidget *widget,
|
||||||
|
GtkAllocation *allocation)
|
||||||
|
{
|
||||||
|
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
|
||||||
|
GtkToolbarPrivate *priv = toolbar->priv;
|
||||||
|
GtkAllocation clip;
|
||||||
|
|
||||||
|
gtk_widget_set_allocation (widget, allocation);
|
||||||
|
|
||||||
|
if (gtk_widget_get_realized (widget))
|
||||||
|
gdk_window_move_resize (priv->event_window,
|
||||||
|
allocation->x,
|
||||||
|
allocation->y,
|
||||||
|
allocation->width,
|
||||||
|
allocation->height);
|
||||||
|
|
||||||
|
gtk_css_gadget_allocate (priv->gadget,
|
||||||
|
allocation,
|
||||||
|
gtk_widget_get_allocated_baseline (widget),
|
||||||
|
&clip);
|
||||||
|
|
||||||
|
gtk_widget_set_clip (widget, &clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -3075,6 +3113,8 @@ gtk_toolbar_finalize (GObject *object)
|
|||||||
if (priv->idle_id)
|
if (priv->idle_id)
|
||||||
g_source_remove (priv->idle_id);
|
g_source_remove (priv->idle_id);
|
||||||
|
|
||||||
|
g_clear_object (&priv->gadget);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gtk_toolbar_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gtk_toolbar_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user