diff options
Diffstat (limited to 'gtk/gtktoolbar.c')
-rw-r--r-- | gtk/gtktoolbar.c | 299 |
1 files changed, 166 insertions, 133 deletions
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index 3ff73c5975..69938f1c9e 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -80,7 +80,7 @@ typedef struct _ToolbarContent ToolbarContent; #define ACCEL_THRESHOLD 0.18 /* After how much time in seconds will items start speeding up */ -struct _GtkToolbarPriv +struct _GtkToolbarPrivate { GtkIconSize icon_size; GtkMenu *menu; @@ -602,7 +602,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass) add_ctrl_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD); add_ctrl_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); - g_type_class_add_private (gobject_class, sizeof (GtkToolbarPriv)); + g_type_class_add_private (gobject_class, sizeof (GtkToolbarPrivate)); } static void @@ -618,11 +618,11 @@ toolbar_tool_shell_iface_init (GtkToolShellIface *iface) static void gtk_toolbar_init (GtkToolbar *toolbar) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; toolbar->priv = G_TYPE_INSTANCE_GET_PRIVATE (toolbar, GTK_TYPE_TOOLBAR, - GtkToolbarPriv); + GtkToolbarPrivate); priv = toolbar->priv; gtk_widget_set_can_focus (GTK_WIDGET (toolbar), FALSE); @@ -667,7 +667,7 @@ gtk_toolbar_set_property (GObject *object, GParamSpec *pspec) { GtkToolbar *toolbar = GTK_TOOLBAR (object); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; switch (prop_id) { @@ -703,7 +703,7 @@ gtk_toolbar_get_property (GObject *object, GParamSpec *pspec) { GtkToolbar *toolbar = GTK_TOOLBAR (object); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; switch (prop_id) { @@ -732,7 +732,7 @@ static void gtk_toolbar_map (GtkWidget *widget) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->map (widget); @@ -744,7 +744,7 @@ static void gtk_toolbar_unmap (GtkWidget *widget) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (priv->event_window) gdk_window_hide (priv->event_window); @@ -755,22 +755,25 @@ gtk_toolbar_unmap (GtkWidget *widget) static void gtk_toolbar_realize (GtkWidget *widget) { + GtkAllocation allocation; GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; guint border_width; gtk_widget_set_realized (widget, TRUE); + gtk_widget_get_allocation (widget, &allocation); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); attributes.wclass = GDK_INPUT_ONLY; attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x + border_width; - attributes.y = widget->allocation.y + border_width; - attributes.width = widget->allocation.width - border_width * 2; - attributes.height = widget->allocation.height - border_width * 2; + attributes.x = allocation.x + border_width; + attributes.y = allocation.y + border_width; + attributes.width = allocation.width - border_width * 2; + attributes.height = allocation.height - border_width * 2; attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | @@ -779,9 +782,11 @@ gtk_toolbar_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y; - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); - widget->style = gtk_style_attach (widget->style, widget->window); + window = gtk_widget_get_parent_window (widget); + gtk_widget_set_window (widget, window); + g_object_ref (window); + + gtk_widget_style_attach (widget); priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); @@ -792,7 +797,7 @@ static void gtk_toolbar_unrealize (GtkWidget *widget) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (priv->event_window) { @@ -808,9 +813,9 @@ static gint gtk_toolbar_expose (GtkWidget *widget, GdkEventExpose *event) { + GtkAllocation allocation; GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; - + GtkToolbarPrivate *priv = toolbar->priv; GList *list; guint border_width; @@ -818,15 +823,16 @@ gtk_toolbar_expose (GtkWidget *widget, if (gtk_widget_is_drawable (widget)) { - gtk_paint_box (widget->style, - widget->window, + gtk_widget_get_allocation (widget, &allocation); + gtk_paint_box (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), gtk_widget_get_state (widget), get_shadow_type (toolbar), &event->area, widget, "toolbar", - border_width + widget->allocation.x, - border_width + widget->allocation.y, - widget->allocation.width - 2 * border_width, - widget->allocation.height - 2 * border_width); + border_width + allocation.x, + border_width + allocation.y, + allocation.width - 2 * border_width, + allocation.height - 2 * border_width); } for (list = priv->content; list != NULL; list = list->next) @@ -848,7 +854,7 @@ gtk_toolbar_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; gint max_child_height; gint max_child_width; @@ -960,8 +966,11 @@ gtk_toolbar_size_request (GtkWidget *widget, if (get_shadow_type (toolbar) != GTK_SHADOW_NONE) { - requisition->width += 2 * widget->style->xthickness; - requisition->height += 2 * widget->style->ythickness; + GtkStyle *style; + + style = gtk_widget_get_style (widget); + requisition->width += 2 * style->xthickness; + requisition->height += 2 * style->ythickness; } priv->button_maxw = max_homogeneous_child_width; @@ -974,7 +983,7 @@ position (GtkToolbar *toolbar, gint to, gdouble elapsed) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; gint n_pixels; if (!priv->animation) @@ -1007,7 +1016,7 @@ compute_intermediate_allocation (GtkToolbar *toolbar, const GtkAllocation *goal, GtkAllocation *intermediate) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; gdouble elapsed = g_timer_elapsed (priv->timer, NULL); intermediate->x = position (toolbar, start->x, goal->x, elapsed); @@ -1045,7 +1054,7 @@ static gint get_item_size (GtkToolbar *toolbar, ToolbarContent *content) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkRequisition requisition; toolbar_content_size_request (content, toolbar, &requisition); @@ -1070,7 +1079,7 @@ static gboolean slide_idle_handler (gpointer data) { GtkToolbar *toolbar = GTK_TOOLBAR (data); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; if (priv->need_sync) @@ -1163,8 +1172,10 @@ rect_within (GtkAllocation *a1, static void gtk_toolbar_begin_sliding (GtkToolbar *toolbar) { + GtkAllocation allocation; GtkWidget *widget = GTK_WIDGET (toolbar); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; + GtkStyle *style; GList *list; gint cur_x; gint cur_y; @@ -1184,25 +1195,28 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar) if (!priv->idle_id) priv->idle_id = gdk_threads_add_idle (slide_idle_handler, toolbar); - + + gtk_widget_get_allocation (widget, &allocation); + style = gtk_widget_get_style (widget); + rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL); vertical = (priv->orientation == GTK_ORIENTATION_VERTICAL); border_width = get_internal_padding (toolbar) + gtk_container_get_border_width (GTK_CONTAINER (toolbar)); if (rtl) { - cur_x = widget->allocation.width - border_width - widget->style->xthickness; - cur_y = widget->allocation.height - border_width - widget->style->ythickness; + cur_x = allocation.width - border_width - style->xthickness; + cur_y = allocation.height - border_width - style->ythickness; } else { - cur_x = border_width + widget->style->xthickness; - cur_y = border_width + widget->style->ythickness; + cur_x = border_width + style->xthickness; + cur_y = border_width + style->ythickness; } - - cur_x += widget->allocation.x; - cur_y += widget->allocation.y; - + + cur_x += allocation.x; + cur_y += allocation.y; + for (list = priv->content; list != NULL; list = list->next) { ToolbarContent *content = list->data; @@ -1214,7 +1228,7 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar) toolbar_content_get_allocation (content, &item_allocation); if ((state == NORMAL && - rect_within (&item_allocation, &(widget->allocation))) || + rect_within (&item_allocation, &allocation)) || state == OVERFLOWN) { new_start_allocation = item_allocation; @@ -1226,15 +1240,15 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar) if (vertical) { - new_start_allocation.width = widget->allocation.width - - 2 * border_width - 2 * widget->style->xthickness; + new_start_allocation.width = allocation.width - + 2 * border_width - 2 * style->xthickness; new_start_allocation.height = 0; } else { new_start_allocation.width = 0; - new_start_allocation.height = widget->allocation.height - - 2 * border_width - 2 * widget->style->ythickness; + new_start_allocation.height = allocation.height - + 2 * border_width - 2 * style->ythickness; } } @@ -1260,7 +1274,7 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar) static void gtk_toolbar_stop_sliding (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (priv->is_sliding) { @@ -1295,14 +1309,15 @@ static void remove_item (GtkWidget *menu_item, gpointer data) { - gtk_container_remove (GTK_CONTAINER (menu_item->parent), menu_item); + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (menu_item)), + menu_item); } static void menu_deactivated (GtkWidget *menu, GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->arrow_button), FALSE); } @@ -1312,7 +1327,7 @@ menu_detached (GtkWidget *widget, GtkMenu *menu) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; priv->menu = NULL; } @@ -1320,7 +1335,7 @@ menu_detached (GtkWidget *widget, static void rebuild_menu (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list, *children; if (!priv->menu) @@ -1386,11 +1401,13 @@ static void gtk_toolbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { + GtkAllocation widget_allocation; GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkAllocation *allocations; ItemState *new_states; GtkAllocation arrow_allocation; + GtkStyle *style; gint arrow_size; gint size, pos, short_size; GList *list; @@ -1407,20 +1424,23 @@ gtk_toolbar_size_allocate (GtkWidget *widget, gdouble elapsed; GtkAllocation item_area; GtkShadowType shadow_type; - + + style = gtk_widget_get_style (widget); + + gtk_widget_get_allocation (widget, &widget_allocation); size_changed = FALSE; - if (widget->allocation.x != allocation->x || - widget->allocation.y != allocation->y || - widget->allocation.width != allocation->width || - widget->allocation.height != allocation->height) + if (widget_allocation.x != allocation->x || + widget_allocation.y != allocation->y || + widget_allocation.width != allocation->width || + widget_allocation.height != allocation->height) { size_changed = TRUE; } if (size_changed) gtk_toolbar_stop_sliding (toolbar); - - widget->allocation = *allocation; + + gtk_widget_set_allocation (widget, allocation); border_width = gtk_container_get_border_width (GTK_CONTAINER (toolbar)); @@ -1448,8 +1468,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget, if (shadow_type != GTK_SHADOW_NONE) { - available_size -= 2 * widget->style->xthickness; - short_size -= 2 * widget->style->ythickness; + available_size -= 2 * style->xthickness; + short_size -= 2 * style->ythickness; } } else @@ -1460,8 +1480,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget, if (shadow_type != GTK_SHADOW_NONE) { - available_size -= 2 * widget->style->ythickness; - short_size -= 2 * widget->style->xthickness; + available_size -= 2 * style->ythickness; + short_size -= 2 * style->xthickness; } } @@ -1637,8 +1657,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget, if (shadow_type != GTK_SHADOW_NONE) { - allocations[i].x += widget->style->xthickness; - allocations[i].y += widget->style->ythickness; + allocations[i].x += style->xthickness; + allocations[i].y += style->ythickness; } } @@ -1649,8 +1669,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget, if (shadow_type != GTK_SHADOW_NONE) { - arrow_allocation.x += widget->style->xthickness; - arrow_allocation.y += widget->style->ythickness; + arrow_allocation.x += style->xthickness; + arrow_allocation.y += style->ythickness; } } @@ -1658,8 +1678,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget, item_area.y += allocation->y; if (shadow_type != GTK_SHADOW_NONE) { - item_area.x += widget->style->xthickness; - item_area.y += widget->style->ythickness; + item_area.x += style->xthickness; + item_area.y += style->ythickness; } /* did anything change? */ @@ -1766,7 +1786,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget, static void gtk_toolbar_update_button_relief (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkReliefStyle relief; relief = get_button_relief (toolbar); @@ -1784,13 +1804,15 @@ gtk_toolbar_style_set (GtkWidget *widget, GtkStyle *prev_style) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; priv->max_homogeneous_pixels = -1; if (gtk_widget_get_realized (widget)) - gtk_style_set_background (widget->style, widget->window, widget->state); - + gtk_style_set_background (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), + gtk_widget_get_state (widget)); + if (prev_style) gtk_toolbar_update_button_relief (GTK_TOOLBAR (widget)); } @@ -1799,7 +1821,7 @@ static GList * gtk_toolbar_list_children_in_focus_order (GtkToolbar *toolbar, GtkDirectionType dir) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *result = NULL; GList *list; gboolean rtl; @@ -1952,7 +1974,7 @@ toolbar_get_settings (GtkToolbar *toolbar) static void style_change_notify (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (!priv->style_set) { @@ -1965,7 +1987,7 @@ style_change_notify (GtkToolbar *toolbar) static void icon_size_change_notify (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (!priv->icon_size_set) { @@ -1978,7 +2000,7 @@ icon_size_change_notify (GtkToolbar *toolbar) static void animation_change_notify (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkSettings *settings = toolbar_get_settings (toolbar); gboolean animation; @@ -2010,7 +2032,7 @@ gtk_toolbar_screen_changed (GtkWidget *widget, GdkScreen *previous_screen) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkSettings *old_settings = toolbar_get_settings (toolbar); GtkSettings *settings; @@ -2051,7 +2073,7 @@ find_drop_index (GtkToolbar *toolbar, gint x, gint y) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *interesting_content; GList *list; GtkOrientation orientation; @@ -2141,7 +2163,7 @@ find_drop_index (GtkToolbar *toolbar, static void reset_all_placeholders (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; for (list = priv->content; list != NULL; list = list->next) @@ -2156,7 +2178,7 @@ static gint physical_to_logical (GtkToolbar *toolbar, gint physical) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; int logical; @@ -2181,7 +2203,7 @@ static gint logical_to_physical (GtkToolbar *toolbar, gint logical) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; gint physical; @@ -2231,7 +2253,7 @@ gtk_toolbar_set_drop_highlight_item (GtkToolbar *toolbar, gint index_) { ToolbarContent *content; - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; gint n_items; GtkRequisition requisition; GtkRequisition old_requisition; @@ -2387,7 +2409,7 @@ static void gtk_toolbar_show_all (GtkWidget *widget) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; for (list = priv->content; list != NULL; list = list->next) @@ -2404,7 +2426,7 @@ static void gtk_toolbar_hide_all (GtkWidget *widget) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; for (list = priv->content; list != NULL; list = list->next) @@ -2431,7 +2453,7 @@ gtk_toolbar_remove (GtkContainer *container, GtkWidget *widget) { GtkToolbar *toolbar = GTK_TOOLBAR (container); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; ToolbarContent *content_to_remove; GList *list; @@ -2462,7 +2484,7 @@ gtk_toolbar_forall (GtkContainer *container, gpointer callback_data) { GtkToolbar *toolbar = GTK_TOOLBAR (container); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; g_return_if_fail (callback != NULL); @@ -2497,7 +2519,7 @@ gtk_toolbar_child_type (GtkContainer *container) static void gtk_toolbar_reconfigured (GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; list = priv->content; @@ -2516,7 +2538,7 @@ static void gtk_toolbar_orientation_changed (GtkToolbar *toolbar, GtkOrientation orientation) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (priv->orientation != orientation) { @@ -2538,7 +2560,7 @@ static void gtk_toolbar_real_style_changed (GtkToolbar *toolbar, GtkToolbarStyle style) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (priv->style != style) { @@ -2558,8 +2580,9 @@ menu_position_func (GtkMenu *menu, gboolean *push_in, gpointer user_data) { + GtkAllocation allocation; GtkToolbar *toolbar = GTK_TOOLBAR (user_data); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkRequisition req; GtkRequisition menu_req; GdkRectangle monitor; @@ -2570,38 +2593,41 @@ menu_position_func (GtkMenu *menu, gtk_widget_size_request (GTK_WIDGET (menu), &menu_req); screen = gtk_widget_get_screen (GTK_WIDGET (menu)); - monitor_num = gdk_screen_get_monitor_at_window (screen, priv->arrow_button->window); + monitor_num = gdk_screen_get_monitor_at_window (screen, + gtk_widget_get_window (priv->arrow_button)); if (monitor_num < 0) monitor_num = 0; gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); + gtk_widget_get_allocation (priv->arrow_button, &allocation); + gdk_window_get_origin (GTK_BUTTON (priv->arrow_button)->event_window, x, y); if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR) - *x += priv->arrow_button->allocation.width - req.width; + *x += allocation.width - req.width; else *x += req.width - menu_req.width; - if ((*y + priv->arrow_button->allocation.height + menu_req.height) <= monitor.y + monitor.height) - *y += priv->arrow_button->allocation.height; + if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height) + *y += allocation.height; else if ((*y - menu_req.height) >= monitor.y) *y -= menu_req.height; - else if (monitor.y + monitor.height - (*y + priv->arrow_button->allocation.height) > *y) - *y += priv->arrow_button->allocation.height; + else if (monitor.y + monitor.height - (*y + allocation.height) > *y) + *y += allocation.height; else *y -= menu_req.height; } else { if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR) - *x += priv->arrow_button->allocation.width; + *x += allocation.width; else *x -= menu_req.width; if (*y + menu_req.height > monitor.y + monitor.height && - *y + priv->arrow_button->allocation.height - monitor.y > monitor.y + monitor.height - *y) - *y += priv->arrow_button->allocation.height - menu_req.height; + *y + allocation.height - monitor.y > monitor.y + monitor.height - *y) + *y += allocation.height - menu_req.height; } *push_in = FALSE; @@ -2611,7 +2637,7 @@ static void show_menu (GtkToolbar *toolbar, GdkEventButton *event) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; rebuild_menu (toolbar); @@ -2627,7 +2653,7 @@ static void gtk_toolbar_arrow_button_clicked (GtkWidget *button, GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->arrow_button)) && (!priv->menu || !gtk_widget_get_visible (GTK_WIDGET (priv->menu)))) @@ -2766,13 +2792,13 @@ gint gtk_toolbar_get_item_index (GtkToolbar *toolbar, GtkToolItem *item) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; GList *list; int n; g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), -1); g_return_val_if_fail (GTK_IS_TOOL_ITEM (item), -1); - g_return_val_if_fail (GTK_WIDGET (item)->parent == GTK_WIDGET (toolbar), -1); + g_return_val_if_fail (gtk_widget_get_parent (GTK_WIDGET (item)) == GTK_WIDGET (toolbar), -1); priv = toolbar->priv; @@ -2804,7 +2830,7 @@ void gtk_toolbar_set_style (GtkToolbar *toolbar, GtkToolbarStyle style) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); @@ -2841,7 +2867,7 @@ gtk_toolbar_get_style (GtkToolbar *toolbar) void gtk_toolbar_unset_style (GtkToolbar *toolbar) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; GtkToolbarStyle style; g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); @@ -2879,7 +2905,7 @@ gtk_toolbar_unset_style (GtkToolbar *toolbar) gint gtk_toolbar_get_n_items (GtkToolbar *toolbar) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), -1); @@ -2905,7 +2931,7 @@ GtkToolItem * gtk_toolbar_get_nth_item (GtkToolbar *toolbar, gint n) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; ToolbarContent *content; gint n_items; @@ -2978,7 +3004,7 @@ void gtk_toolbar_set_show_arrow (GtkToolbar *toolbar, gboolean show_arrow) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); @@ -3049,7 +3075,7 @@ gtk_toolbar_finalize (GObject *object) { GList *list; GtkToolbar *toolbar = GTK_TOOLBAR (object); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; if (priv->arrow_button) gtk_widget_unparent (priv->arrow_button); @@ -3094,7 +3120,7 @@ void gtk_toolbar_set_icon_size (GtkToolbar *toolbar, GtkIconSize icon_size) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); g_return_if_fail (icon_size != GTK_ICON_SIZE_INVALID); @@ -3128,7 +3154,7 @@ gtk_toolbar_set_icon_size (GtkToolbar *toolbar, void gtk_toolbar_unset_icon_size (GtkToolbar *toolbar) { - GtkToolbarPriv *priv; + GtkToolbarPrivate *priv; GtkIconSize size; g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); @@ -3186,7 +3212,7 @@ toolbar_content_new_tool_item (GtkToolbar *toolbar, gboolean is_placeholder, gint pos) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; ToolbarContent *content; content = g_slice_new0 (ToolbarContent); @@ -3216,7 +3242,7 @@ static void toolbar_content_remove (ToolbarContent *content, GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; gtk_widget_unparent (GTK_WIDGET (content->item)); @@ -3244,7 +3270,7 @@ calculate_max_homogeneous_pixels (GtkWidget *widget) context = gtk_widget_get_pango_context (widget); metrics = pango_context_get_metrics (context, - widget->style->font_desc, + gtk_widget_get_style (widget)->font_desc, pango_context_get_language (context)); char_width = pango_font_metrics_get_approximate_char_width (metrics); pango_font_metrics_unref (metrics); @@ -3270,7 +3296,7 @@ static gboolean toolbar_content_visible (ToolbarContent *content, GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkToolItem *item; item = content->item; @@ -3308,7 +3334,7 @@ static gboolean toolbar_content_is_homogeneous (ToolbarContent *content, GtkToolbar *toolbar) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkRequisition requisition; gboolean result; @@ -3593,8 +3619,11 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget, const GdkRectangle *area, const GtkAllocation *allocation) { - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GtkOrientation orientation; + GtkStateType state; + GtkStyle *style; + GdkWindow *window; const double start_fraction = (SPACE_LINE_START / SPACE_LINE_DIVISION); const double end_fraction = (SPACE_LINE_END / SPACE_LINE_DIVISION); @@ -3602,6 +3631,10 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget, orientation = toolbar? priv->orientation : GTK_ORIENTATION_HORIZONTAL; + style = gtk_widget_get_style (widget); + window = gtk_widget_get_window (widget); + state = gtk_widget_get_state (widget); + if (orientation == GTK_ORIENTATION_HORIZONTAL) { gboolean wide_separators; @@ -3613,20 +3646,20 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget, NULL); if (wide_separators) - gtk_paint_box (widget->style, widget->window, - gtk_widget_get_state (widget), GTK_SHADOW_ETCHED_OUT, + gtk_paint_box (style, window, + state, GTK_SHADOW_ETCHED_OUT, area, widget, "vseparator", allocation->x + (allocation->width - separator_width) / 2, allocation->y + allocation->height * start_fraction, separator_width, allocation->height * (end_fraction - start_fraction)); else - gtk_paint_vline (widget->style, widget->window, - gtk_widget_get_state (widget), area, widget, + gtk_paint_vline (style, window, + state, area, widget, "toolbar", allocation->y + allocation->height * start_fraction, allocation->y + allocation->height * end_fraction, - allocation->x + (allocation->width - widget->style->xthickness) / 2); + allocation->x + (allocation->width - style->xthickness) / 2); } else { @@ -3639,20 +3672,20 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget, NULL); if (wide_separators) - gtk_paint_box (widget->style, widget->window, - gtk_widget_get_state (widget), GTK_SHADOW_ETCHED_OUT, + gtk_paint_box (style, window, + state, GTK_SHADOW_ETCHED_OUT, area, widget, "hseparator", allocation->x + allocation->width * start_fraction, allocation->y + (allocation->height - separator_height) / 2, allocation->width * (end_fraction - start_fraction), separator_height); else - gtk_paint_hline (widget->style, widget->window, - gtk_widget_get_state (widget), area, widget, + gtk_paint_hline (style, window, + state, area, widget, "toolbar", allocation->x + allocation->width * start_fraction, allocation->x + allocation->width * end_fraction, - allocation->y + (allocation->height - widget->style->ythickness) / 2); + allocation->y + (allocation->height - style->ythickness) / 2); } } @@ -3703,7 +3736,7 @@ static GtkIconSize toolbar_get_icon_size (GtkToolShell *shell) { GtkToolbar *toolbar = GTK_TOOLBAR (shell); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; return priv->icon_size; } @@ -3712,7 +3745,7 @@ static GtkOrientation toolbar_get_orientation (GtkToolShell *shell) { GtkToolbar *toolbar = GTK_TOOLBAR (shell); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; return priv->orientation; } @@ -3721,7 +3754,7 @@ static GtkToolbarStyle toolbar_get_style (GtkToolShell *shell) { GtkToolbar *toolbar = GTK_TOOLBAR (shell); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; return priv->style; } @@ -3736,7 +3769,7 @@ static void toolbar_rebuild_menu (GtkToolShell *shell) { GtkToolbar *toolbar = GTK_TOOLBAR (shell); - GtkToolbarPriv *priv = toolbar->priv; + GtkToolbarPrivate *priv = toolbar->priv; GList *list; priv->need_rebuild = TRUE; |