Add support for up to four scroll arrows. Control their display by new

2003-05-23  Matthias Clasen  <maclas@gmx.de>

	* gtk/gtknotebook.c: Add support for up to four scroll
	arrows. Control their display by new style properties
	"has_forward_stepper", "has_backward_stepper",
	"has_secondary_forward_stepper" and
	has_secondary_backward_stepper". (#110540)

	* gtk/gtknotebook.h (struct _GtkNotebook): Make in_child and
	click_child three bits wide, add
	has_{before,after}_{previous,next} fields.
This commit is contained in:
Matthias Clasen 2003-05-22 22:34:31 +00:00 committed by Matthias Clasen
parent a32adaf4f9
commit ed1468ba4c
7 changed files with 276 additions and 113 deletions

View File

@ -1,5 +1,15 @@
2003-05-23 Matthias Clasen <maclas@gmx.de> 2003-05-23 Matthias Clasen <maclas@gmx.de>
* gtk/gtknotebook.c: Add support for up to four scroll
arrows. Control their display by new style properties
"has_forward_stepper", "has_backward_stepper",
"has_secondary_forward_stepper" and
has_secondary_backward_stepper". (#110540)
* gtk/gtknotebook.h (struct _GtkNotebook): Make in_child and
click_child three bits wide, add
has_{before,after}_{previous,next} fields.
* gtk/gtkcolorsel.c (gtk_color_selection_init): Update color on * gtk/gtkcolorsel.c (gtk_color_selection_init): Update color on
focus out of hex_entry. (#112665) focus out of hex_entry. (#112665)
(hex_focus_out): New signal handler for focus out of hex entry. (hex_focus_out): New signal handler for focus out of hex entry.

View File

@ -1,5 +1,15 @@
2003-05-23 Matthias Clasen <maclas@gmx.de> 2003-05-23 Matthias Clasen <maclas@gmx.de>
* gtk/gtknotebook.c: Add support for up to four scroll
arrows. Control their display by new style properties
"has_forward_stepper", "has_backward_stepper",
"has_secondary_forward_stepper" and
has_secondary_backward_stepper". (#110540)
* gtk/gtknotebook.h (struct _GtkNotebook): Make in_child and
click_child three bits wide, add
has_{before,after}_{previous,next} fields.
* gtk/gtkcolorsel.c (gtk_color_selection_init): Update color on * gtk/gtkcolorsel.c (gtk_color_selection_init): Update color on
focus out of hex_entry. (#112665) focus out of hex_entry. (#112665)
(hex_focus_out): New signal handler for focus out of hex entry. (hex_focus_out): New signal handler for focus out of hex entry.

View File

@ -1,5 +1,15 @@
2003-05-23 Matthias Clasen <maclas@gmx.de> 2003-05-23 Matthias Clasen <maclas@gmx.de>
* gtk/gtknotebook.c: Add support for up to four scroll
arrows. Control their display by new style properties
"has_forward_stepper", "has_backward_stepper",
"has_secondary_forward_stepper" and
has_secondary_backward_stepper". (#110540)
* gtk/gtknotebook.h (struct _GtkNotebook): Make in_child and
click_child three bits wide, add
has_{before,after}_{previous,next} fields.
* gtk/gtkcolorsel.c (gtk_color_selection_init): Update color on * gtk/gtkcolorsel.c (gtk_color_selection_init): Update color on
focus out of hex_entry. (#112665) focus out of hex_entry. (#112665)
(hex_focus_out): New signal handler for focus out of hex entry. (hex_focus_out): New signal handler for focus out of hex entry.

View File

@ -1,5 +1,15 @@
2003-05-23 Matthias Clasen <maclas@gmx.de> 2003-05-23 Matthias Clasen <maclas@gmx.de>
* gtk/gtknotebook.c: Add support for up to four scroll
arrows. Control their display by new style properties
"has_forward_stepper", "has_backward_stepper",
"has_secondary_forward_stepper" and
has_secondary_backward_stepper". (#110540)
* gtk/gtknotebook.h (struct _GtkNotebook): Make in_child and
click_child three bits wide, add
has_{before,after}_{previous,next} fields.
* gtk/gtkcolorsel.c (gtk_color_selection_init): Update color on * gtk/gtkcolorsel.c (gtk_color_selection_init): Update color on
focus out of hex_entry. (#112665) focus out of hex_entry. (#112665)
(hex_focus_out): New signal handler for focus out of hex entry. (hex_focus_out): New signal handler for focus out of hex entry.

View File

@ -1,5 +1,15 @@
2003-05-23 Matthias Clasen <maclas@gmx.de> 2003-05-23 Matthias Clasen <maclas@gmx.de>
* gtk/gtknotebook.c: Add support for up to four scroll
arrows. Control their display by new style properties
"has_forward_stepper", "has_backward_stepper",
"has_secondary_forward_stepper" and
has_secondary_backward_stepper". (#110540)
* gtk/gtknotebook.h (struct _GtkNotebook): Make in_child and
click_child three bits wide, add
has_{before,after}_{previous,next} fields.
* gtk/gtkcolorsel.c (gtk_color_selection_init): Update color on * gtk/gtkcolorsel.c (gtk_color_selection_init): Update color on
focus out of hex_entry. (#112665) focus out of hex_entry. (#112665)
(hex_focus_out): New signal handler for focus out of hex entry. (hex_focus_out): New signal handler for focus out of hex entry.

View File

@ -58,6 +58,18 @@ enum {
STEP_NEXT STEP_NEXT
}; };
typedef enum
{
ARROW_NONE,
ARROW_LEFT_BEFORE,
ARROW_RIGHT_BEFORE,
ARROW_LEFT_AFTER,
ARROW_RIGHT_AFTER
} GtkNotebookArrow;
#define ARROW_IS_LEFT(arrow) ((arrow) == ARROW_LEFT_BEFORE || (arrow) == ARROW_LEFT_AFTER)
#define ARROW_IS_BEFORE(arrow) ((arrow) == ARROW_LEFT_BEFORE || (arrow) == ARROW_RIGHT_BEFORE)
enum { enum {
PROP_0, PROP_0,
PROP_TAB_POS, PROP_TAB_POS,
@ -165,6 +177,8 @@ static void gtk_notebook_state_changed (GtkWidget *widget,
static void gtk_notebook_draw_focus (GtkWidget *widget); static void gtk_notebook_draw_focus (GtkWidget *widget);
static gint gtk_notebook_focus (GtkWidget *widget, static gint gtk_notebook_focus (GtkWidget *widget,
GtkDirectionType direction); GtkDirectionType direction);
static void gtk_notebook_style_set (GtkWidget *widget,
GtkStyle *previous);
/*** GtkContainer Methods ***/ /*** GtkContainer Methods ***/
static void gtk_notebook_set_child_property (GtkContainer *container, static void gtk_notebook_set_child_property (GtkContainer *container,
@ -356,6 +370,7 @@ gtk_notebook_class_init (GtkNotebookClass *class)
widget_class->state_changed = gtk_notebook_state_changed; widget_class->state_changed = gtk_notebook_state_changed;
widget_class->focus_in_event = gtk_notebook_focus_in; widget_class->focus_in_event = gtk_notebook_focus_in;
widget_class->focus = gtk_notebook_focus; widget_class->focus = gtk_notebook_focus;
widget_class->style_set = gtk_notebook_style_set;
container_class->add = gtk_notebook_add; container_class->add = gtk_notebook_add;
container_class->remove = gtk_notebook_remove; container_class->remove = gtk_notebook_remove;
@ -495,6 +510,38 @@ gtk_notebook_class_init (GtkNotebookClass *class)
GTK_TYPE_PACK_TYPE, GTK_PACK_START, GTK_TYPE_PACK_TYPE, GTK_PACK_START,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("has_secondary backward_stepper",
_("Secondary backward stepper"),
_("Display a second backward arrow button on the opposite end of the tab area"),
FALSE,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("has_secondary_forward_stepper",
_("Secondary forward stepper"),
_("Display a second forward arrow button on the opposite end of the tab area"),
FALSE,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("has_backward_stepper",
_("Backward stepper"),
_("Display the standard backward arrow button"),
TRUE,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("has_forward_stepper",
_("Forward stepper"),
_("Display the standard forward arrow button"),
TRUE,
G_PARAM_READABLE));
notebook_signals[SWITCH_PAGE] = notebook_signals[SWITCH_PAGE] =
g_signal_new ("switch_page", g_signal_new ("switch_page",
G_TYPE_FROM_CLASS (gobject_class), G_TYPE_FROM_CLASS (gobject_class),
@ -624,6 +671,11 @@ gtk_notebook_init (GtkNotebook *notebook)
notebook->child_has_focus = FALSE; notebook->child_has_focus = FALSE;
notebook->have_visible_child = FALSE; notebook->have_visible_child = FALSE;
notebook->focus_out = FALSE; notebook->focus_out = FALSE;
notebook->has_before_previous = 1;
notebook->has_before_next = 0;
notebook->has_after_previous = 0;
notebook->has_after_next = 1;
} }
static gboolean static gboolean
@ -1215,7 +1267,7 @@ gtk_notebook_size_request (GtkWidget *widget,
if (notebook->scrollable && vis_pages > 1 && if (notebook->scrollable && vis_pages > 1 &&
widget->requisition.height < tab_height) widget->requisition.height < tab_height)
tab_width = MAX (tab_width, ARROW_SPACING +2 * ARROW_SIZE); tab_width = MAX (tab_width, ARROW_SPACING + 2 * ARROW_SIZE);
padding = 2 * (TAB_CURVATURE + focus_width + padding = 2 * (TAB_CURVATURE + focus_width +
notebook->tab_vborder) - TAB_OVERLAP; notebook->tab_vborder) - TAB_OVERLAP;
@ -1458,85 +1510,120 @@ gtk_notebook_show_arrows (GtkNotebook *notebook)
} }
static void static void
gtk_notebook_get_arrow_rect (GtkNotebook *notebook, gtk_notebook_get_arrow_rect (GtkNotebook *notebook,
GdkRectangle *rectangle) GdkRectangle *rectangle,
GtkNotebookArrow arrow)
{ {
GdkRectangle event_window_pos; GdkRectangle event_window_pos;
gboolean before = ARROW_IS_BEFORE (arrow);
gboolean left = ARROW_IS_LEFT (arrow);
if (gtk_notebook_get_event_window_position (notebook, &event_window_pos)) if (gtk_notebook_get_event_window_position (notebook, &event_window_pos))
{ {
rectangle->width = 2 * ARROW_SIZE + ARROW_SPACING; rectangle->width = ARROW_SIZE;
rectangle->height = ARROW_SIZE; rectangle->height = ARROW_SIZE;
switch (notebook->tab_pos) switch (notebook->tab_pos)
{ {
case GTK_POS_LEFT: case GTK_POS_LEFT:
case GTK_POS_RIGHT: case GTK_POS_RIGHT:
if ((before && (notebook->has_before_previous != notebook->has_before_next)) ||
(!before && (notebook->has_after_previous != notebook->has_after_next)))
rectangle->x = event_window_pos.x + (event_window_pos.width - rectangle->width) / 2; rectangle->x = event_window_pos.x + (event_window_pos.width - rectangle->width) / 2;
rectangle->y = event_window_pos.y + event_window_pos.height - rectangle->height; else if (left)
rectangle->x = event_window_pos.x + event_window_pos.width / 2 - rectangle->width;
else
rectangle->x = event_window_pos.x + event_window_pos.width / 2;
rectangle->y = event_window_pos.y;
if (!before)
rectangle->y += event_window_pos.height - rectangle->height;
break; break;
case GTK_POS_TOP: case GTK_POS_TOP:
case GTK_POS_BOTTOM: case GTK_POS_BOTTOM:
rectangle->x = event_window_pos.x + event_window_pos.width - rectangle->width; if (before)
{
if (left || !notebook->has_before_previous)
rectangle->x = event_window_pos.x;
else
rectangle->x = event_window_pos.x + rectangle->width;
}
else
{
if (!left || !notebook->has_after_next)
rectangle->x = event_window_pos.x + event_window_pos.width - rectangle->width;
else
rectangle->x = event_window_pos.x + event_window_pos.width - 2 * rectangle->width;
}
rectangle->y = event_window_pos.y + (event_window_pos.height - rectangle->height) / 2; rectangle->y = event_window_pos.y + (event_window_pos.height - rectangle->height) / 2;
break; break;
} }
} }
} }
static GtkArrowType static GtkNotebookArrow
gtk_notebook_get_arrow (GtkNotebook *notebook, gtk_notebook_get_arrow (GtkNotebook *notebook,
gint x, gint x,
gint y) gint y)
{ {
GdkRectangle arrow_rect; GdkRectangle arrow_rect;
GdkRectangle event_window_pos; GdkRectangle event_window_pos;
gint i;
gint x0, y0;
GtkNotebookArrow arrow[4];
arrow[0] = notebook->has_before_previous ? ARROW_LEFT_BEFORE : ARROW_NONE;
arrow[1] = notebook->has_before_next ? ARROW_RIGHT_BEFORE : ARROW_NONE;
arrow[2] = notebook->has_after_previous ? ARROW_LEFT_AFTER : ARROW_NONE;
arrow[3] = notebook->has_after_next ? ARROW_RIGHT_AFTER : ARROW_NONE;
if (gtk_notebook_show_arrows (notebook)) if (gtk_notebook_show_arrows (notebook))
{ {
gtk_notebook_get_event_window_position (notebook, &event_window_pos); gtk_notebook_get_event_window_position (notebook, &event_window_pos);
gtk_notebook_get_arrow_rect (notebook, &arrow_rect); for (i = 0; i < 4; i++)
{
if (arrow[i] == ARROW_NONE)
continue;
x -= arrow_rect.x; gtk_notebook_get_arrow_rect (notebook, &arrow_rect, arrow[i]);
y -= arrow_rect.y;
if (y >= 0 && y < arrow_rect.height) x0 = x - arrow_rect.x;
{ y0 = y - arrow_rect.y;
if (x >= 0 && x < ARROW_SIZE + ARROW_SPACING / 2)
return GTK_ARROW_LEFT; if (y0 >= 0 && y0 < arrow_rect.height &&
else if (x >= ARROW_SIZE + ARROW_SPACING / 2 && x < arrow_rect.width) x0 >= 0 && x0 < arrow_rect.width)
return GTK_ARROW_RIGHT; return arrow[i];
} }
} }
return 0; return ARROW_NONE;
} }
static void static void
gtk_notebook_do_arrow (GtkNotebook *notebook, gtk_notebook_do_arrow (GtkNotebook *notebook,
GtkArrowType arrow) GtkNotebookArrow arrow)
{ {
GtkWidget *widget = GTK_WIDGET (notebook); GtkWidget *widget = GTK_WIDGET (notebook);
GtkDirectionType dir; GtkDirectionType dir;
gboolean left = ARROW_IS_LEFT (arrow);
if (!notebook->focus_tab || if (!notebook->focus_tab ||
gtk_notebook_search_page (notebook, notebook->focus_tab, gtk_notebook_search_page (notebook, notebook->focus_tab,
arrow == GTK_ARROW_LEFT ? STEP_PREV : STEP_NEXT, left ? STEP_PREV : STEP_NEXT,
TRUE)) TRUE))
{ {
if (notebook->tab_pos == GTK_POS_LEFT || if (notebook->tab_pos == GTK_POS_LEFT ||
notebook->tab_pos == GTK_POS_RIGHT) notebook->tab_pos == GTK_POS_RIGHT)
dir = (arrow == GTK_ARROW_LEFT) ? GTK_DIR_UP : GTK_DIR_DOWN; dir = left ? GTK_DIR_UP : GTK_DIR_DOWN;
else else
dir = (arrow == GTK_ARROW_LEFT) ? GTK_DIR_LEFT : GTK_DIR_RIGHT; dir = left ? GTK_DIR_LEFT : GTK_DIR_RIGHT;
gtk_widget_child_focus (widget, dir); gtk_widget_child_focus (widget, dir);
} }
} }
static gboolean static gboolean
gtk_notebook_arrow_button_press (GtkNotebook *notebook, gtk_notebook_arrow_button_press (GtkNotebook *notebook,
GtkArrowType arrow, GtkNotebookArrow arrow,
GdkEventButton *event) GdkEventButton *event)
{ {
GtkWidget *widget = GTK_WIDGET (notebook); GtkWidget *widget = GTK_WIDGET (notebook);
@ -1564,7 +1651,7 @@ gtk_notebook_arrow_button_press (GtkNotebook *notebook,
gtk_notebook_switch_focus_tab (notebook, gtk_notebook_switch_focus_tab (notebook,
gtk_notebook_search_page (notebook, gtk_notebook_search_page (notebook,
NULL, NULL,
arrow == GTK_ARROW_LEFT ? STEP_NEXT : STEP_PREV, ARROW_IS_LEFT (arrow) ? STEP_NEXT : STEP_PREV,
TRUE)); TRUE));
gtk_notebook_redraw_arrows (notebook); gtk_notebook_redraw_arrows (notebook);
@ -1612,7 +1699,7 @@ gtk_notebook_button_press (GtkWidget *widget,
GtkNotebook *notebook = GTK_NOTEBOOK (widget); GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPage *page; GtkNotebookPage *page;
GList *children; GList *children;
GtkArrowType arrow; GtkNotebookArrow arrow;
gint num; gint num;
gint x, y; gint x, y;
@ -1713,7 +1800,7 @@ gtk_notebook_enter_notify (GtkWidget *widget,
GdkEventCrossing *event) GdkEventCrossing *event)
{ {
GtkNotebook *notebook; GtkNotebook *notebook;
GtkArrowType arrow; GtkNotebookArrow arrow;
gint x, y; gint x, y;
g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE); g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE);
@ -1742,7 +1829,7 @@ gtk_notebook_leave_notify (GtkWidget *widget,
GdkEventCrossing *event) GdkEventCrossing *event)
{ {
GtkNotebook *notebook = GTK_NOTEBOOK (widget); GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkArrowType arrow; GtkNotebookArrow arrow;
gint x, y; gint x, y;
if (!get_widget_coordinates (widget, (GdkEvent *)event, &x, &y)) if (!get_widget_coordinates (widget, (GdkEvent *)event, &x, &y))
@ -1764,7 +1851,7 @@ gtk_notebook_motion_notify (GtkWidget *widget,
GdkEventMotion *event) GdkEventMotion *event)
{ {
GtkNotebook *notebook = GTK_NOTEBOOK (widget); GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkArrowType arrow; GtkNotebookArrow arrow;
gint x, y; gint x, y;
if (notebook->button) if (notebook->button)
@ -1834,6 +1921,34 @@ gtk_notebook_draw_focus (GtkWidget *widget)
} }
} }
static void
gtk_notebook_style_set (GtkWidget *widget,
GtkStyle *previous)
{
GtkNotebook *notebook;
gboolean has_before_previous;
gboolean has_before_next;
gboolean has_after_previous;
gboolean has_after_next;
notebook = GTK_NOTEBOOK (widget);
gtk_widget_style_get (widget,
"has_backward_stepper", &has_before_previous,
"has_secondary_forward_stepper", &has_before_next,
"has_secondary_backward_stepper", &has_after_previous,
"has_forward_stepper", &has_after_next,
NULL);
notebook->has_before_previous = has_before_previous;
notebook->has_before_next = has_before_next;
notebook->has_after_previous = has_after_previous;
notebook->has_after_next = has_after_next;
(* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous);
}
/* Private GtkContainer Methods : /* Private GtkContainer Methods :
* *
* gtk_notebook_set_child_arg * gtk_notebook_set_child_arg
@ -2326,9 +2441,23 @@ gtk_notebook_redraw_arrows (GtkNotebook *notebook)
if (GTK_WIDGET_MAPPED (notebook) && gtk_notebook_show_arrows (notebook)) if (GTK_WIDGET_MAPPED (notebook) && gtk_notebook_show_arrows (notebook))
{ {
GdkRectangle rect; GdkRectangle rect;
gint i;
GtkNotebookArrow arrow[4];
gtk_notebook_get_arrow_rect (notebook, &rect); arrow[0] = notebook->has_before_previous ? ARROW_LEFT_BEFORE : ARROW_NONE;
gdk_window_invalidate_rect (GTK_WIDGET (notebook)->window, &rect, FALSE); arrow[1] = notebook->has_before_next ? ARROW_RIGHT_BEFORE : ARROW_NONE;
arrow[2] = notebook->has_after_previous ? ARROW_LEFT_AFTER : ARROW_NONE;
arrow[3] = notebook->has_after_next ? ARROW_RIGHT_AFTER : ARROW_NONE;
for (i = 0; i < 4; i++)
{
if (arrow[i] == ARROW_NONE)
continue;
gtk_notebook_get_arrow_rect (notebook, &rect, arrow[i]);
gdk_window_invalidate_rect (GTK_WIDGET (notebook)->window,
&rect, FALSE);
}
} }
} }
@ -2713,8 +2842,14 @@ gtk_notebook_paint (GtkWidget *widget,
if (showarrow && notebook->scrollable) if (showarrow && notebook->scrollable)
{ {
gtk_notebook_draw_arrow (notebook, GTK_ARROW_LEFT); if (notebook->has_before_previous)
gtk_notebook_draw_arrow (notebook, GTK_ARROW_RIGHT); gtk_notebook_draw_arrow (notebook, ARROW_LEFT_BEFORE);
if (notebook->has_before_next)
gtk_notebook_draw_arrow (notebook, ARROW_RIGHT_BEFORE);
if (notebook->has_after_previous)
gtk_notebook_draw_arrow (notebook, ARROW_LEFT_AFTER);
if (notebook->has_after_next)
gtk_notebook_draw_arrow (notebook, ARROW_RIGHT_AFTER);
} }
gtk_notebook_draw_tab (notebook, notebook->cur_page, area); gtk_notebook_draw_tab (notebook, notebook->cur_page, area);
} }
@ -2809,25 +2944,24 @@ gtk_notebook_draw_tab (GtkNotebook *notebook,
} }
static void static void
gtk_notebook_draw_arrow (GtkNotebook *notebook, gtk_notebook_draw_arrow (GtkNotebook *notebook,
guint arrow) GtkNotebookArrow nbarrow)
{ {
GtkStateType state_type; GtkStateType state_type;
GtkShadowType shadow_type; GtkShadowType shadow_type;
GtkWidget *widget; GtkWidget *widget;
GdkRectangle arrow_rect; GdkRectangle arrow_rect;
GtkArrowType arrow;
gtk_notebook_get_arrow_rect (notebook, &arrow_rect); gtk_notebook_get_arrow_rect (notebook, &arrow_rect, nbarrow);
g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); widget = GTK_WIDGET (notebook);
widget = GTK_WIDGET(notebook);
if (GTK_WIDGET_DRAWABLE (notebook)) if (GTK_WIDGET_DRAWABLE (notebook))
{ {
if (notebook->in_child == arrow) if (notebook->in_child == nbarrow)
{ {
if (notebook->click_child == arrow) if (notebook->click_child == nbarrow)
state_type = GTK_STATE_ACTIVE; state_type = GTK_STATE_ACTIVE;
else else
state_type = GTK_STATE_PRELIGHT; state_type = GTK_STATE_PRELIGHT;
@ -2835,49 +2969,29 @@ gtk_notebook_draw_arrow (GtkNotebook *notebook,
else else
state_type = GTK_WIDGET_STATE (widget); state_type = GTK_WIDGET_STATE (widget);
if (notebook->click_child == arrow) if (notebook->click_child == nbarrow)
shadow_type = GTK_SHADOW_IN; shadow_type = GTK_SHADOW_IN;
else else
shadow_type = GTK_SHADOW_OUT; shadow_type = GTK_SHADOW_OUT;
if (arrow == GTK_ARROW_LEFT) if (notebook->focus_tab &&
!gtk_notebook_search_page (notebook, notebook->focus_tab,
ARROW_IS_LEFT (nbarrow) ? STEP_PREV : STEP_NEXT, TRUE))
{ {
if (notebook->focus_tab && shadow_type = GTK_SHADOW_ETCHED_IN;
!gtk_notebook_search_page (notebook, notebook->focus_tab, state_type = GTK_STATE_INSENSITIVE;
STEP_PREV, TRUE))
{
shadow_type = GTK_SHADOW_ETCHED_IN;
state_type = GTK_STATE_INSENSITIVE;
}
if (notebook->tab_pos == GTK_POS_LEFT ||
notebook->tab_pos == GTK_POS_RIGHT)
arrow = GTK_ARROW_UP;
gtk_paint_arrow (widget->style, widget->window, state_type,
shadow_type, NULL, widget, "notebook",
arrow, TRUE,
arrow_rect.x, arrow_rect.y, ARROW_SIZE, ARROW_SIZE);
} }
if (notebook->tab_pos == GTK_POS_LEFT ||
notebook->tab_pos == GTK_POS_RIGHT)
arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_UP : GTK_ARROW_DOWN);
else else
{ arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT);
if (notebook->focus_tab &&
!gtk_notebook_search_page (notebook, notebook->focus_tab, gtk_paint_arrow (widget->style, widget->window, state_type,
STEP_NEXT, TRUE)) shadow_type, NULL, widget, "notebook",
{ arrow, TRUE, arrow_rect.x, arrow_rect.y,
shadow_type = GTK_SHADOW_ETCHED_IN; ARROW_SIZE, ARROW_SIZE);
state_type = GTK_STATE_INSENSITIVE;
}
if (notebook->tab_pos == GTK_POS_LEFT ||
notebook->tab_pos == GTK_POS_RIGHT)
arrow = GTK_ARROW_DOWN;
gtk_paint_arrow (widget->style, widget->window, state_type,
shadow_type, NULL, widget, "notebook",
arrow, TRUE, arrow_rect.x + ARROW_SIZE + ARROW_SPACING,
arrow_rect.y, ARROW_SIZE, ARROW_SIZE);
}
} }
} }
@ -2900,8 +3014,6 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook)
gboolean showarrow = FALSE; gboolean showarrow = FALSE;
gint tab_space = 0; gint tab_space = 0;
gint delta; gint delta;
gint x = 0;
gint y = 0;
gint i; gint i;
gint n = 1; gint n = 1;
gint old_fill = 0; gint old_fill = 0;
@ -2967,20 +3079,22 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook)
showarrow = TRUE; showarrow = TRUE;
page = focus_tab->data; page = focus_tab->data;
tab_space = (allocation->width - TAB_OVERLAP - tab_space = allocation->width - TAB_OVERLAP -
page->requisition.width - page->requisition.width - 2 * container->border_width;
2 * (container->border_width + ARROW_SPACING + if (notebook->has_after_previous)
ARROW_SIZE)); tab_space -= ARROW_SPACING + ARROW_SIZE;
x = (allocation->width - 2 * ARROW_SIZE - ARROW_SPACING - if (notebook->has_after_next)
container->border_width); tab_space -= ARROW_SPACING + ARROW_SIZE;
if (notebook->has_before_previous)
page = notebook->children->data; {
if (notebook->tab_pos == GTK_POS_TOP) tab_space -= ARROW_SPACING + ARROW_SIZE;
y = (container->border_width + child_allocation.x += ARROW_SPACING + ARROW_SIZE;
(page->requisition.height - ARROW_SIZE) / 2); }
else if (notebook->has_before_next)
y = (allocation->height - container->border_width - {
ARROW_SIZE - (page->requisition.height - ARROW_SIZE) / 2); tab_space -= ARROW_SPACING + ARROW_SIZE;
child_allocation.x += ARROW_SPACING + ARROW_SIZE;
}
} }
break; break;
case GTK_POS_LEFT: case GTK_POS_LEFT:
@ -2998,22 +3112,16 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook)
{ {
showarrow = TRUE; showarrow = TRUE;
page = focus_tab->data; page = focus_tab->data;
tab_space = (allocation->height - tab_space = allocation->height
ARROW_SIZE - ARROW_SPACING - TAB_OVERLAP - - TAB_OVERLAP - 2 * container->border_width
2 * container->border_width - - page->requisition.height;
page->requisition.height); if (notebook->has_after_previous || notebook->has_after_next)
y = allocation->height - container->border_width - ARROW_SIZE; tab_space -= ARROW_SPACING + ARROW_SIZE;
if (notebook->has_before_previous || notebook->has_before_next)
page = notebook->children->data; {
if (notebook->tab_pos == GTK_POS_LEFT) tab_space -= ARROW_SPACING + ARROW_SIZE;
x = (container->border_width + child_allocation.y += ARROW_SPACING + ARROW_SIZE;
(page->requisition.width - }
(2 * ARROW_SIZE - ARROW_SPACING)) / 2);
else
x = (allocation->width - container->border_width -
(2 * ARROW_SIZE - ARROW_SPACING) -
(page->requisition.width -
(2 * ARROW_SIZE - ARROW_SPACING)) / 2);
} }
break; break;
} }

View File

@ -77,13 +77,18 @@ struct _GtkNotebook
guint show_border : 1; guint show_border : 1;
guint tab_pos : 2; guint tab_pos : 2;
guint scrollable : 1; guint scrollable : 1;
guint in_child : 2; guint in_child : 3;
guint click_child : 2; guint click_child : 3;
guint button : 2; guint button : 2;
guint need_timer : 1; guint need_timer : 1;
guint child_has_focus : 1; guint child_has_focus : 1;
guint have_visible_child : 1; guint have_visible_child : 1;
guint focus_out : 1; /* Flag used by ::move-focus-out implementation */ guint focus_out : 1; /* Flag used by ::move-focus-out implementation */
guint has_before_previous : 1;
guint has_before_next : 1;
guint has_after_previous : 1;
guint has_after_next : 1;
}; };
struct _GtkNotebookClass struct _GtkNotebookClass