#include "gtkmenu.h"
#include "gtkmenuitem.h"
#include "gtklabel.h"
-#include "gtksizerequest.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtkbindings.h"
#include "gtkdnd.h"
#include "gtkbuildable.h"
+
+/**
+ * SECTION:gtknotebook
+ * @Short_description: A tabbed notebook container
+ * @Title: GtkNotebook
+ * @See_also: #GtkContainer
+ *
+ * The #GtkNotebook widget is a #GtkContainer whose children are pages that
+ * can be switched between using tab labels along one edge.
+ *
+ * There are many configuration options for GtkNotebook. Among other
+ * things, you can choose on which edge the tabs appear
+ * (see gtk_notebook_set_tab_pos()), whether, if there are too many
+ * tabs to fit the notebook should be made bigger or scrolling
+ * arrows added (see gtk_notebook_set_scrollable()), and whether there
+ * will be a popup menu allowing the users to switch pages.
+ * (see gtk_notebook_popup_enable(), gtk_notebook_popup_disable())
+ *
+ * <refsect2 id="GtkNotebook-BUILDER-UI">
+ * <title>GtkNotebook as GtkBuildable</title>
+ * <para>
+ * The GtkNotebook implementation of the #GtkBuildable interface
+ * supports placing children into tabs by specifying "tab" as the
+ * "type" attribute of a <child> element. Note that the content
+ * of the tab must be created before the tab can be filled.
+ * A tab child can be specified without specifying a <child>
+ * type attribute.
+ *
+ * To add a child widget in the notebooks action area, specify
+ * "action-start" or "action-end" as the "type" attribute of the <child>
+ * element.
+ * </para>
+ * <example>
+ * <title>A UI definition fragment with GtkNotebook</title>
+ * <programlisting><![CDATA[
+ * <object class="GtkNotebook">
+ * <child>
+ * <object class="GtkLabel" id="notebook-content">
+ * <property name="label">Content</property>
+ * </object>
+ * </child>
+ * <child type="tab">
+ * <object class="GtkLabel" id="notebook-tab">
+ * <property name="label">Tab</property>
+ * </object>
+ * </child>
+ * </object>
+ * ]]></programlisting>
+ * </example>
+ * </refsect2>
+ */
+
+
#define SCROLL_DELAY_FACTOR 5
#define SCROLL_THRESHOLD 12
#define DND_THRESHOLD_MULTIPLIER 4
gboolean *fill,
GtkPackType *pack_type);
-/*** GtkObject Methods ***/
-static void gtk_notebook_destroy (GtkObject *object);
+/*** GObject Methods ***/
static void gtk_notebook_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
/*** GtkWidget Methods ***/
+static void gtk_notebook_destroy (GtkWidget *widget);
static void gtk_notebook_map (GtkWidget *widget);
static void gtk_notebook_unmap (GtkWidget *widget);
static void gtk_notebook_realize (GtkWidget *widget);
GtkRequisition *requisition);
static void gtk_notebook_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-static gint gtk_notebook_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gint gtk_notebook_draw (GtkWidget *widget,
+ cairo_t *cr);
static gint gtk_notebook_button_press (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_notebook_button_release (GtkWidget *widget,
/*** GtkNotebook Drawing Functions ***/
static void gtk_notebook_paint (GtkWidget *widget,
- GdkRectangle *area);
+ cairo_t *cr);
static void gtk_notebook_draw_tab (GtkNotebook *notebook,
GtkNotebookPage *page,
- GdkRectangle *area);
+ cairo_t *cr);
static void gtk_notebook_draw_arrow (GtkNotebook *notebook,
+ cairo_t *cr,
GtkNotebookArrow arrow);
/*** GtkNotebook Size Allocate Functions ***/
return continue_emission;
}
+static void
+gtk_notebook_compute_expand (GtkWidget *widget,
+ gboolean *hexpand_p,
+ gboolean *vexpand_p)
+{
+ GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+ GtkNotebookPrivate *priv = notebook->priv;
+ gboolean hexpand;
+ gboolean vexpand;
+ GList *list;
+ GtkNotebookPage *page;
+
+ hexpand = FALSE;
+ vexpand = FALSE;
+
+ for (list = priv->children; list; list = list->next)
+ {
+ page = list->data;
+
+ hexpand = hexpand ||
+ gtk_widget_compute_expand (page->child, GTK_ORIENTATION_HORIZONTAL);
+
+ vexpand = vexpand ||
+ gtk_widget_compute_expand (page->child, GTK_ORIENTATION_VERTICAL);
+
+ if (hexpand & vexpand)
+ break;
+ }
+
+ *hexpand_p = hexpand;
+ *vexpand_p = vexpand;
+}
+
static void
gtk_notebook_class_init (GtkNotebookClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
GtkBindingSet *binding_set;
gobject_class->set_property = gtk_notebook_set_property;
gobject_class->get_property = gtk_notebook_get_property;
- object_class->destroy = gtk_notebook_destroy;
+ widget_class->destroy = gtk_notebook_destroy;
widget_class->map = gtk_notebook_map;
widget_class->unmap = gtk_notebook_unmap;
widget_class->realize = gtk_notebook_realize;
widget_class->unrealize = gtk_notebook_unrealize;
widget_class->size_request = gtk_notebook_size_request;
widget_class->size_allocate = gtk_notebook_size_allocate;
- widget_class->expose_event = gtk_notebook_expose;
+ widget_class->draw = gtk_notebook_draw;
widget_class->button_press_event = gtk_notebook_button_press;
widget_class->button_release_event = gtk_notebook_button_release;
widget_class->popup_menu = gtk_notebook_popup_menu;
widget_class->drag_drop = gtk_notebook_drag_drop;
widget_class->drag_data_get = gtk_notebook_drag_data_get;
widget_class->drag_data_received = gtk_notebook_drag_data_received;
+ widget_class->compute_expand = gtk_notebook_compute_expand;
container_class->add = gtk_notebook_add;
container_class->remove = gtk_notebook_remove;
P_("Whether the child's tab should fill the allocated area"),
TRUE,
GTK_PARAM_READWRITE));
+
+ /**
+ * GtkNotebook:tab-pack:
+ *
+ * Deprecated: 2.20: The tab packing functionality of children should not
+ * be used anymore and support will be removed in the future.
+ */
gtk_container_class_install_child_property (container_class,
CHILD_PROP_TAB_PACK,
g_param_spec_enum ("tab-pack",
0,
GTK_PARAM_READABLE));
+ /**
+ * GtkNotebook::switch-page:
+ * @notebook: the object which received the signal.
+ * @page: the new current page
+ * @page_num: the index of the page
+ *
+ * Emitted when the user or a function changes the current page.
+ */
notebook_signals[SWITCH_PAGE] =
g_signal_new (I_("switch-page"),
G_TYPE_FROM_CLASS (gobject_class),
g_signal_new (I_("page-reordered"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- _gtk_marshal_VOID__OBJECT_UINT,
+ G_STRUCT_OFFSET (GtkNotebookClass, page_reordered),
+ NULL, NULL,
+ _gtk_marshal_VOID__OBJECT_UINT,
G_TYPE_NONE, 2,
- GTK_TYPE_WIDGET,
- G_TYPE_UINT);
+ GTK_TYPE_WIDGET,
+ G_TYPE_UINT);
/**
* GtkNotebook::page-removed:
* @notebook: the #GtkNotebook
g_signal_new (I_("page-removed"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- _gtk_marshal_VOID__OBJECT_UINT,
+ G_STRUCT_OFFSET (GtkNotebookClass, page_removed),
+ NULL, NULL,
+ _gtk_marshal_VOID__OBJECT_UINT,
G_TYPE_NONE, 2,
- GTK_TYPE_WIDGET,
- G_TYPE_UINT);
+ GTK_TYPE_WIDGET,
+ G_TYPE_UINT);
/**
* GtkNotebook::page-added:
* @notebook: the #GtkNotebook
g_signal_new (I_("page-added"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- _gtk_marshal_VOID__OBJECT_UINT,
+ G_STRUCT_OFFSET (GtkNotebookClass, page_added),
+ NULL, NULL,
+ _gtk_marshal_VOID__OBJECT_UINT,
G_TYPE_NONE, 2,
- GTK_TYPE_WIDGET,
- G_TYPE_UINT);
+ GTK_TYPE_WIDGET,
+ G_TYPE_UINT);
/**
* GtkNotebook::create-window:
return g_object_new (GTK_TYPE_NOTEBOOK, NULL);
}
-/* Private GtkObject Methods :
- *
- * gtk_notebook_destroy
- * gtk_notebook_set_arg
- * gtk_notebook_get_arg
+/* Private GObject Methods :
+ *
+ * gtk_notebook_set_property
+ * gtk_notebook_get_property
*/
-static void
-gtk_notebook_destroy (GtkObject *object)
-{
- GtkNotebook *notebook = GTK_NOTEBOOK (object);
- GtkNotebookPrivate *priv = notebook->priv;
-
- if (priv->menu)
- gtk_notebook_popup_disable (notebook);
-
- if (priv->source_targets)
- {
- gtk_target_list_unref (priv->source_targets);
- priv->source_targets = NULL;
- }
-
- if (priv->switch_tab_timer)
- {
- g_source_remove (priv->switch_tab_timer);
- priv->switch_tab_timer = 0;
- }
-
- GTK_OBJECT_CLASS (gtk_notebook_parent_class)->destroy (object);
-}
-
static void
gtk_notebook_set_property (GObject *object,
guint prop_id,
}
/* Private GtkWidget Methods :
- *
+ *
+ * gtk_notebook_destroy
* gtk_notebook_map
* gtk_notebook_unmap
* gtk_notebook_realize
* gtk_notebook_size_request
* gtk_notebook_size_allocate
- * gtk_notebook_expose
+ * gtk_notebook_draw
* gtk_notebook_scroll
* gtk_notebook_button_press
* gtk_notebook_button_release
* gtk_notebook_drag_data_get
* gtk_notebook_drag_data_received
*/
+static void
+gtk_notebook_destroy (GtkWidget *widget)
+{
+ GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+ GtkNotebookPrivate *priv = notebook->priv;
+
+ if (priv->menu)
+ gtk_notebook_popup_disable (notebook);
+
+ if (priv->source_targets)
+ {
+ gtk_target_list_unref (priv->source_targets);
+ priv->source_targets = NULL;
+ }
+
+ if (priv->switch_tab_timer)
+ {
+ g_source_remove (priv->switch_tab_timer);
+ priv->switch_tab_timer = 0;
+ }
+
+ GTK_WIDGET_CLASS (gtk_notebook_parent_class)->destroy (widget);
+}
+
static gboolean
gtk_notebook_get_event_window_position (GtkNotebook *notebook,
GdkRectangle *rectangle)
{
if (priv->action_widget[i] &&
gtk_widget_get_visible (priv->action_widget[i]) &&
- GTK_WIDGET_CHILD_VISIBLE (priv->action_widget[i]) &&
+ gtk_widget_get_child_visible (priv->action_widget[i]) &&
!gtk_widget_get_mapped (priv->action_widget[i]))
gtk_widget_map (priv->action_widget[i]);
}
if (gtk_widget_get_visible (page->child))
{
vis_pages++;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (page->child),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (page->child,
+ &child_requisition, NULL);
requisition->width = MAX (requisition->width,
child_requisition.width);
if (!gtk_widget_get_visible (page->tab_label))
gtk_widget_show (page->tab_label);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (page->tab_label),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (page->tab_label,
+ &child_requisition, NULL);
page->requisition.width = child_requisition.width + 2 * style->xthickness;
page->requisition.height = child_requisition.height + 2 * style->ythickness;
{
if (priv->action_widget[i])
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->action_widget[i]),
- &action_widget_requisition[i], NULL);
+ gtk_widget_get_preferred_size (priv->action_widget[i],
+ &action_widget_requisition[i], NULL);
action_widget_requisition[i].width += style->xthickness;
action_widget_requisition[i].height += style->ythickness;
}
widget_allocation.y = allocation->y + border_width;
is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->action_widget[i]),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (priv->action_widget[i],
+ &requisition, NULL);
switch (tab_pos)
{
}
static gint
-gtk_notebook_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gtk_notebook_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPrivate *priv = notebook->priv;
+ GtkAllocation allocation;
+ GdkWindow *window;
gint i;
- if (gtk_widget_is_drawable (widget))
+ gtk_widget_get_allocation (widget, &allocation);
+
+ window = gtk_widget_get_window (widget);
+ if (gtk_cairo_should_draw_window (cr, window))
{
- gtk_notebook_paint (widget, &event->area);
+ cairo_save (cr);
+
+ cairo_translate (cr, -allocation.x, -allocation.y);
+ gtk_notebook_paint (widget, cr);
+
+ cairo_restore (cr);
+
if (priv->show_tabs)
{
GtkNotebookPage *page;
{
page = GTK_NOTEBOOK_PAGE (pages);
- if (gtk_widget_get_window (page->tab_label) == event->window &&
- gtk_widget_is_drawable (page->tab_label))
- gtk_container_propagate_expose (GTK_CONTAINER (notebook),
- page->tab_label, event);
+ if (gtk_widget_get_parent (page->tab_label) == widget)
+ gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+ page->tab_label, cr);
}
}
- if (priv->cur_page)
- gtk_container_propagate_expose (GTK_CONTAINER (notebook),
- priv->cur_page->child,
- event);
+ if (priv->cur_page && priv->operation != DRAG_OPERATION_REORDER)
+ gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+ priv->cur_page->child,
+ cr);
if (priv->show_tabs)
{
for (i = 0; i < N_ACTION_WIDGETS; i++)
{
- if (priv->action_widget[i] &&
- gtk_widget_is_drawable (priv->action_widget[i]))
- gtk_container_propagate_expose (GTK_CONTAINER (notebook),
- priv->action_widget[i], event);
+ if (priv->action_widget[i])
+ gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+ priv->action_widget[i], cr);
}
}
}
- if (event->window == priv->drag_window)
+ if (priv->operation == DRAG_OPERATION_REORDER &&
+ gtk_cairo_should_draw_window (cr, priv->drag_window))
{
- GdkRectangle area = { 0, };
- cairo_t *cr;
+ cairo_save (cr);
+ gtk_cairo_transform_to_window (cr, widget, priv->drag_window);
/* FIXME: This is a workaround to make tabs reordering work better
* with engines with rounded tabs. If the drag window background
* Ideally, these corners should be made transparent, Either by using
* ARGB visuals or shape windows.
*/
- cr = gdk_cairo_create (priv->drag_window);
gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->bg [GTK_STATE_NORMAL]);
cairo_paint (cr);
- cairo_destroy (cr);
- gdk_drawable_get_size (priv->drag_window,
- &area.width, &area.height);
gtk_notebook_draw_tab (notebook,
priv->cur_page,
- &area);
- gtk_container_propagate_expose (GTK_CONTAINER (notebook),
- priv->cur_page->tab_label, event);
+ cr);
+
+ cairo_restore (cr);
+
+ gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+ priv->cur_page->tab_label, cr);
}
return FALSE;
gdk_window_get_origin (gtk_widget_get_window (w), x, y);
gtk_widget_get_allocation (w, &allocation);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+ &requisition, NULL);
if (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL)
*x += allocation.x + allocation.width - requisition.width;
return POINTER_BETWEEN;
gdk_window_get_position (priv->event_window, &wx, &wy);
- gdk_drawable_get_size (GDK_DRAWABLE (priv->event_window), &width, &height);
+ width = gdk_window_get_width (priv->event_window);
+ height = gdk_window_get_height (priv->event_window);
if (priv->tab_pos == GTK_POS_TOP ||
priv->tab_pos == GTK_POS_BOTTOM)
dnd_threshold *= DND_THRESHOLD_MULTIPLIER;
gdk_window_get_position (priv->event_window, &rectangle.x, &rectangle.y);
- gdk_drawable_get_size (GDK_DRAWABLE (priv->event_window), &rectangle.width, &rectangle.height);
+ rectangle.width = gdk_window_get_width (priv->event_window);
+ rectangle.height = gdk_window_get_height (priv->event_window);
rectangle.x -= dnd_threshold;
rectangle.width += 2 * dnd_threshold;
}
static gboolean
-on_drag_icon_expose (GtkWidget *widget,
- GdkEventExpose *event,
- gpointer data)
+on_drag_icon_draw (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer data)
{
GtkWidget *notebook, *child;
GtkRequisition requisition;
notebook = GTK_WIDGET (data);
child = gtk_bin_get_child (GTK_BIN (widget));
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (widget,
+ &requisition, NULL);
gap_pos = get_tab_gap_pos (GTK_NOTEBOOK (notebook));
gtk_paint_extension (gtk_widget_get_style (notebook),
- gtk_widget_get_window (widget),
+ cr,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- NULL, widget, "tab",
+ widget, "tab",
0, 0,
requisition.width, requisition.height,
gap_pos);
if (child)
- gtk_container_propagate_expose (GTK_CONTAINER (widget), child, event);
+ gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr);
return TRUE;
}
priv->detached_tab->allocation.height);
g_object_unref (tab_label);
- g_signal_connect (G_OBJECT (priv->dnd_window), "expose-event",
- G_CALLBACK (on_drag_icon_expose), notebook);
+ g_signal_connect (G_OBJECT (priv->dnd_window), "draw",
+ G_CALLBACK (on_drag_icon_draw), notebook);
gtk_drag_set_icon_widget (context, priv->dnd_window, -2, -2);
}
GList * next_list;
gint need_resize = FALSE;
GtkWidget *tab_label;
-
gboolean destroying;
- destroying = GTK_OBJECT_FLAGS (notebook) & GTK_IN_DESTRUCTION;
+ destroying = gtk_widget_in_destruction (GTK_WIDGET (notebook));
next_list = gtk_notebook_search_page (notebook, list, STEP_NEXT, TRUE);
if (!next_list)
*/
static void
gtk_notebook_paint (GtkWidget *widget,
- GdkRectangle *area)
+ cairo_t *cr)
{
GtkNotebook *notebook;
GtkNotebookPrivate *priv;
if (priv->show_border && (!priv->show_tabs || !priv->children))
{
- gtk_paint_box (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
+ gtk_paint_box (gtk_widget_get_style (widget), cr,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- area, widget, "notebook",
+ widget, "notebook",
x, y, width, height);
return;
}
break;
}
}
- gtk_paint_box_gap (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
+ gtk_paint_box_gap (gtk_widget_get_style (widget), cr,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- area, widget, "notebook",
+ widget, "notebook",
x, y, width, height,
tab_pos, gap_x, gap_width);
if (!gtk_widget_get_mapped (page->tab_label))
showarrow = TRUE;
else if (page != priv->cur_page)
- gtk_notebook_draw_tab (notebook, page, area);
+ gtk_notebook_draw_tab (notebook, page, cr);
}
if (showarrow && priv->scrollable)
{
if (priv->has_before_previous)
- gtk_notebook_draw_arrow (notebook, ARROW_LEFT_BEFORE);
+ gtk_notebook_draw_arrow (notebook, cr, ARROW_LEFT_BEFORE);
if (priv->has_before_next)
- gtk_notebook_draw_arrow (notebook, ARROW_RIGHT_BEFORE);
+ gtk_notebook_draw_arrow (notebook, cr, ARROW_RIGHT_BEFORE);
if (priv->has_after_previous)
- gtk_notebook_draw_arrow (notebook, ARROW_LEFT_AFTER);
+ gtk_notebook_draw_arrow (notebook, cr, ARROW_LEFT_AFTER);
if (priv->has_after_next)
- gtk_notebook_draw_arrow (notebook, ARROW_RIGHT_AFTER);
+ gtk_notebook_draw_arrow (notebook, cr, ARROW_RIGHT_AFTER);
}
- gtk_notebook_draw_tab (notebook, priv->cur_page, area);
+
+ if (priv->operation != DRAG_OPERATION_REORDER)
+ gtk_notebook_draw_tab (notebook, priv->cur_page, cr);
}
static void
gtk_notebook_draw_tab (GtkNotebook *notebook,
GtkNotebookPage *page,
- GdkRectangle *area)
+ cairo_t *cr)
{
GtkNotebookPrivate *priv;
- GdkRectangle page_area;
GtkStateType state_type;
- GtkPositionType gap_side;
- GdkWindow *window;
GtkWidget *widget;
if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) ||
widget = GTK_WIDGET (notebook);
priv = notebook->priv;
- if (priv->operation == DRAG_OPERATION_REORDER && page == priv->cur_page)
- window = priv->drag_window;
- else
- window = gtk_widget_get_window (widget);
-
- page_area.x = page->allocation.x;
- page_area.y = page->allocation.y;
- page_area.width = page->allocation.width;
- page_area.height = page->allocation.height;
-
- gap_side = get_tab_gap_pos (notebook);
-
if (priv->cur_page == page)
state_type = GTK_STATE_NORMAL;
else
state_type = GTK_STATE_ACTIVE;
- gtk_paint_extension (gtk_widget_get_style (widget), window,
+ gtk_paint_extension (gtk_widget_get_style (widget), cr,
state_type, GTK_SHADOW_OUT,
- area, widget, "tab",
- page_area.x, page_area.y,
- page_area.width, page_area.height,
- gap_side);
+ widget, "tab",
+ page->allocation.x,
+ page->allocation.y,
+ page->allocation.width,
+ page->allocation.height,
+ get_tab_gap_pos (notebook));
if (gtk_widget_has_focus (widget) &&
priv->cur_page == page)
gtk_widget_get_allocation (page->tab_label, &allocation);
gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL);
- gtk_paint_focus (gtk_widget_get_style (widget), window,
- gtk_widget_get_state (widget), area, widget, "tab",
+ gtk_paint_focus (gtk_widget_get_style (widget), cr,
+ gtk_widget_get_state (widget), widget, "tab",
allocation.x - focus_width,
allocation.y - focus_width,
allocation.width + 2 * focus_width,
static void
gtk_notebook_draw_arrow (GtkNotebook *notebook,
+ cairo_t *cr,
GtkNotebookArrow nbarrow)
{
GtkNotebookPrivate *priv = notebook->priv;
GdkRectangle arrow_rect;
GtkArrowType arrow;
gboolean is_rtl, left;
+ gint scroll_arrow_hlength;
+ gint scroll_arrow_vlength;
+ gint arrow_size;
widget = GTK_WIDGET (notebook);
- if (gtk_widget_is_drawable (widget))
- {
- gint scroll_arrow_hlength;
- gint scroll_arrow_vlength;
- gint arrow_size;
+ gtk_notebook_get_arrow_rect (notebook, &arrow_rect, nbarrow);
- gtk_notebook_get_arrow_rect (notebook, &arrow_rect, nbarrow);
-
- is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
- left = (ARROW_IS_LEFT (nbarrow) && !is_rtl) ||
- (!ARROW_IS_LEFT (nbarrow) && is_rtl);
-
- gtk_widget_style_get (widget,
- "scroll-arrow-hlength", &scroll_arrow_hlength,
- "scroll-arrow-vlength", &scroll_arrow_vlength,
- NULL);
+ is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
+ left = (ARROW_IS_LEFT (nbarrow) && !is_rtl) ||
+ (!ARROW_IS_LEFT (nbarrow) && is_rtl);
- if (priv->in_child == nbarrow)
- {
- if (priv->click_child == nbarrow)
- state_type = GTK_STATE_ACTIVE;
- else
- state_type = GTK_STATE_PRELIGHT;
- }
- else
- state_type = gtk_widget_get_state (widget);
+ gtk_widget_style_get (widget,
+ "scroll-arrow-hlength", &scroll_arrow_hlength,
+ "scroll-arrow-vlength", &scroll_arrow_vlength,
+ NULL);
+ if (priv->in_child == nbarrow)
+ {
if (priv->click_child == nbarrow)
- shadow_type = GTK_SHADOW_IN;
+ state_type = GTK_STATE_ACTIVE;
else
- shadow_type = GTK_SHADOW_OUT;
+ state_type = GTK_STATE_PRELIGHT;
+ }
+ else
+ state_type = gtk_widget_get_state (widget);
- if (priv->focus_tab &&
- !gtk_notebook_search_page (notebook, priv->focus_tab,
- left ? STEP_PREV : STEP_NEXT, TRUE))
- {
- shadow_type = GTK_SHADOW_ETCHED_IN;
- state_type = GTK_STATE_INSENSITIVE;
- }
-
- if (priv->tab_pos == GTK_POS_LEFT ||
- priv->tab_pos == GTK_POS_RIGHT)
- {
- arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_UP : GTK_ARROW_DOWN);
- arrow_size = scroll_arrow_vlength;
- }
- else
- {
- arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT);
- arrow_size = scroll_arrow_hlength;
- }
+ if (priv->click_child == nbarrow)
+ shadow_type = GTK_SHADOW_IN;
+ else
+ shadow_type = GTK_SHADOW_OUT;
- gtk_paint_arrow (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget), state_type,
- shadow_type, NULL, widget, "notebook",
- arrow, TRUE, arrow_rect.x, arrow_rect.y,
- arrow_size, arrow_size);
+ if (priv->focus_tab &&
+ !gtk_notebook_search_page (notebook, priv->focus_tab,
+ left ? STEP_PREV : STEP_NEXT, TRUE))
+ {
+ shadow_type = GTK_SHADOW_ETCHED_IN;
+ state_type = GTK_STATE_INSENSITIVE;
}
+
+ if (priv->tab_pos == GTK_POS_LEFT ||
+ priv->tab_pos == GTK_POS_RIGHT)
+ {
+ arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_UP : GTK_ARROW_DOWN);
+ arrow_size = scroll_arrow_vlength;
+ }
+ else
+ {
+ arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT);
+ arrow_size = scroll_arrow_hlength;
+ }
+
+ gtk_paint_arrow (gtk_widget_get_style (widget),
+ cr, state_type,
+ shadow_type, widget, "notebook",
+ arrow, TRUE, arrow_rect.x, arrow_rect.y,
+ arrow_size, arrow_size);
}
/* Private GtkNotebook Size Allocate Functions:
}
else /* !show_arrows */
{
+ GtkOrientation tab_expand_orientation;
gint c = 0;
*n = 0;
+ if (priv->tab_pos == GTK_POS_TOP || priv->tab_pos == GTK_POS_BOTTOM)
+ tab_expand_orientation = GTK_ORIENTATION_HORIZONTAL;
+ else
+ tab_expand_orientation = GTK_ORIENTATION_VERTICAL;
*remaining_space = max - min - tab_overlap - tab_space;
children = priv->children;
priv->first_tab = gtk_notebook_search_page (notebook, NULL,
c++;
- if (page->expand)
+ if (page->expand ||
+ (gtk_widget_compute_expand (page->tab_label, tab_expand_orientation)))
(*n)++;
}
guint border_width;
gboolean gap_left, packing_changed;
GtkAllocation child_allocation = { 0, };
+ GtkOrientation tab_expand_orientation;
widget = GTK_WIDGET (notebook);
container = GTK_CONTAINER (notebook);
bottom_y = top_y + priv->cur_page->allocation.height;
gap_left = packing_changed = FALSE;
+ if (priv->tab_pos == GTK_POS_TOP || priv->tab_pos == GTK_POS_BOTTOM)
+ tab_expand_orientation = GTK_ORIENTATION_HORIZONTAL;
+ else
+ tab_expand_orientation = GTK_ORIENTATION_VERTICAL;
+
while (*children && *children != last_child)
{
page = (*children)->data;
continue;
tab_extra_space = 0;
- if (*expanded_tabs && (showarrow || page->expand || priv->homogeneous))
+ if (*expanded_tabs && (showarrow || page->expand || gtk_widget_compute_expand (page->tab_label, tab_expand_orientation) || priv->homogeneous))
{
tab_extra_space = *remaining_space / *expanded_tabs;
*remaining_space -= tab_extra_space;
xthickness = style->xthickness;
ythickness = style->ythickness;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (page->tab_label),
- &tab_requisition, NULL);
+ gtk_widget_get_preferred_size (page->tab_label, &tab_requisition, NULL);
gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
"tab-curvature", &tab_curvature,
/**
* gtk_notebook_set_group_name:
* @notebook: a #GtkNotebook
- * @name: (allow-none): the name of the notebook group, or %NULL to unset it
+ * @group_name: (allow-none): the name of the notebook group,
+ * or %NULL to unset it
*
* Sets a group name for @notebook.
*