summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorLars Hamann <lars@src.gnome.org>1998-06-10 21:48:21 +0000
committerLars Hamann <lars@src.gnome.org>1998-06-10 21:48:21 +0000
commit6b61461a404b910f9024299fd97fc9cb2423d781 (patch)
tree6e59f3660745d98ce7075074a4ca3ca262f3cf3d /gtk
parent344572dc7129d688a99bedff8ba3b8e46ffd0376 (diff)
downloadgdk-pixbuf-6b61461a404b910f9024299fd97fc9cb2423d781.tar.gz
adapted clist pixmap clipping
* gtk/gtkctree.c (draw_row): adapted clist pixmap clipping * gtk/gtknotebook.h (struct _GtkNotebookClass): * gtk/gtknotebook.c (gtk_real_notebook_switch_page): added missing argument (according to Joseph Coleman's bug report) * gtk/gtknotebook.c (gtk_notebook_set_focus_child): new class function to fix notebook focus handling
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkctree.c126
-rw-r--r--gtk/gtknotebook.c229
-rw-r--r--gtk/gtknotebook.h4
3 files changed, 247 insertions, 112 deletions
diff --git a/gtk/gtkctree.c b/gtk/gtkctree.c
index 06fa147ab..416add4cc 100644
--- a/gtk/gtkctree.c
+++ b/gtk/gtkctree.c
@@ -970,6 +970,7 @@ draw_row (GtkCList *clist,
gint i, offset = 0, width, height, pixmap_width = 0, string_width = 0;
gint xsrc, ysrc, xdest = 0, ydest;
gboolean need_redraw = TRUE;
+ gboolean draw_pixmap = FALSE;
g_return_if_fail (clist != NULL);
@@ -1418,29 +1419,10 @@ draw_row (GtkCList *clist,
if (pixmap_width && xdest + pixmap_width >= rect->x &&
xdest <= rect->x + rect->width)
- {
- if (GTK_CELL_PIXTEXT (clist_row->cell[i])->mask)
- {
- gdk_gc_set_clip_mask
- (fg_gc, GTK_CELL_PIXTEXT (clist_row->cell[i])->mask);
- gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
- }
- gdk_draw_pixmap (clist->clist_window, fg_gc,
- GTK_CELL_PIXTEXT
- (clist_row->cell[i])->pixmap, xsrc, ysrc,
- xdest, ydest, pixmap_width, height);
-
- if (xdest + pixmap_width >
- clip_rectangle.x + clip_rectangle.width)
- gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,
- rect->x + rect->width, ydest + 1,
- xdest + pixmap_width -
- (rect->x + rect->width), height - 1);
- }
+ draw_pixmap = TRUE;
- xdest += (GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing +
- pixmap_width);
break;
+
case GTK_JUSTIFY_RIGHT:
offset_x = 0;
@@ -1566,29 +1548,62 @@ draw_row (GtkCList *clist,
+ clist_row->cell[i].horizontal);
if (pixmap_width && xdest + pixmap_width >= rect->x &&
- xdest <= rect->x + rect->width && xdest >= clip_rectangle.x)
+ xdest <= rect->x + rect->width)
+ draw_pixmap = TRUE;
+ break;
+ default :
+ break;
+ }
+
+ if (draw_pixmap)
+ {
+ if (GTK_CELL_PIXTEXT (clist_row->cell[i])->mask)
{
gdk_gc_set_clip_mask
(fg_gc, GTK_CELL_PIXTEXT (clist_row->cell[i])->mask);
gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
- gdk_draw_pixmap (clist->clist_window, fg_gc,
- GTK_CELL_PIXTEXT
- (clist_row->cell[i])->pixmap,
- xsrc, ysrc, xdest, ydest,
- pixmap_width, height);
}
- xdest -= (GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing +
- string_width);
- break;
- default :
- break;
+ if (xdest < clip_rectangle.x)
+ {
+ xsrc = clip_rectangle.x - xdest;
+ pixmap_width -= xsrc;
+ xdest = clip_rectangle.x;
+ }
+
+ if (xdest + pixmap_width >
+ clip_rectangle.x + clip_rectangle.width)
+ pixmap_width =
+ (clip_rectangle.x + clip_rectangle.width) - xdest;
+
+ if (ydest < clip_rectangle.y)
+ {
+ ysrc = clip_rectangle.y - ydest;
+ height -= ysrc;
+ ydest = clip_rectangle.y;
+ }
+
+ if (ydest + height > clip_rectangle.y + clip_rectangle.height)
+ height = (clip_rectangle.y + clip_rectangle.height) - ydest;
+
+ gdk_draw_pixmap (clist->clist_window, fg_gc,
+ GTK_CELL_PIXTEXT
+ (clist_row->cell[i])->pixmap,
+ xsrc, ysrc, xdest, ydest,
+ pixmap_width, height);
}
if (string_width)
{
gint delta;
+ if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)
+ xdest -= (GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing +
+ string_width);
+ else
+ xdest += (GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing +
+ pixmap_width);
+
delta = CELL_SPACING - (rect->y - clip_rectangle.y);
if (delta > 0)
{
@@ -1641,6 +1656,29 @@ draw_row (GtkCList *clist,
(clist_row->cell[i])->mask);
gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
}
+
+ if (xdest < clip_rectangle.x)
+ {
+ xsrc = clip_rectangle.x - xdest;
+ pixmap_width -= xsrc;
+ xdest = clip_rectangle.x;
+ }
+
+ if (xdest + pixmap_width >
+ clip_rectangle.x + clip_rectangle.width)
+ pixmap_width = (clip_rectangle.x + clip_rectangle.width) -
+ xdest;
+
+ if (ydest < clip_rectangle.y)
+ {
+ ysrc = clip_rectangle.y - ydest;
+ height -= ysrc;
+ ydest = clip_rectangle.y;
+ }
+
+ if (ydest + height > clip_rectangle.y + clip_rectangle.height)
+ height = (clip_rectangle.y + clip_rectangle.height) - ydest;
+
gdk_draw_pixmap (clist->clist_window, fg_gc,
GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap,
xsrc, ysrc, xdest, ydest, pixmap_width, height);
@@ -1666,7 +1704,29 @@ draw_row (GtkCList *clist,
(clist_row->cell[i])->mask);
gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
}
-
+
+ if (xdest < clip_rectangle.x)
+ {
+ xsrc = clip_rectangle.x - xdest;
+ pixmap_width -= xsrc;
+ xdest = clip_rectangle.x;
+ }
+
+ if (xdest + pixmap_width >
+ clip_rectangle.x + clip_rectangle.width)
+ pixmap_width = (clip_rectangle.x + clip_rectangle.width)
+ - xdest;
+
+ if (ydest < clip_rectangle.y)
+ {
+ ysrc = clip_rectangle.y - ydest;
+ height -= ysrc;
+ ydest = clip_rectangle.y;
+ }
+
+ if (ydest + height > clip_rectangle.y + clip_rectangle.height)
+ height = (clip_rectangle.y + clip_rectangle.height) - ydest;
+
gdk_draw_pixmap (clist->clist_window, fg_gc,
GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
xsrc, ysrc, xdest, ydest, pixmap_width, height);
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 52eb3e9fa..d67bfaa62 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -94,6 +94,8 @@ static void gtk_notebook_switch_page (GtkNotebook *notebook,
static void gtk_notebook_draw_tab (GtkNotebook *notebook,
GtkNotebookPage *page,
GdkRectangle *area);
+static void gtk_notebook_set_focus_child (GtkContainer *container,
+ GtkWidget *child);
static gint gtk_notebook_focus_in (GtkWidget *widget,
GdkEventFocus *event);
static gint gtk_notebook_focus_out (GtkWidget *widget,
@@ -121,7 +123,8 @@ static void gtk_notebook_expose_tabs (GtkNotebook *notebook);
static void gtk_notebook_switch_focus_tab (GtkNotebook *notebook,
GList *new_child);
static void gtk_real_notebook_switch_page (GtkNotebook *notebook,
- GtkNotebookPage *page);
+ GtkNotebookPage *page,
+ gint page_num);
static void gtk_notebook_marshal_signal (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
@@ -215,6 +218,7 @@ gtk_notebook_class_init (GtkNotebookClass *class)
container_class->remove = gtk_notebook_remove;
container_class->foreach = gtk_notebook_foreach;
container_class->focus = gtk_notebook_focus;
+ container_class->set_focus_child = gtk_notebook_set_focus_child;
class->switch_page = gtk_real_notebook_switch_page;
}
@@ -240,6 +244,7 @@ gtk_notebook_init (GtkNotebook *notebook)
notebook->click_child = 0;
notebook->button = 0;
notebook->need_timer = 0;
+ notebook->child_has_focus = FALSE;
}
GtkWidget*
@@ -384,9 +389,6 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook,
if (!notebook->first_tab)
notebook->first_tab = notebook->children;
- if (!notebook->focus_tab)
- notebook->focus_tab = notebook->children;
-
gtk_widget_set_parent (child, GTK_WIDGET (notebook));
if (tab_label)
{
@@ -395,7 +397,10 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook,
}
if (!notebook->cur_page)
- gtk_notebook_switch_page (notebook, page, 0);
+ {
+ gtk_notebook_switch_page (notebook, page, 0);
+ notebook->focus_tab = NULL;
+ }
if (GTK_WIDGET_VISIBLE (notebook))
{
@@ -1479,9 +1484,6 @@ gtk_notebook_button_press (GtkWidget *widget,
|| notebook->button)
return FALSE;
- if (!GTK_WIDGET_HAS_FOCUS (widget) && !(GTK_CONTAINER (widget)->focus_child))
- gtk_widget_grab_focus (widget);
-
if (event->window == notebook->panel)
{
if (!GTK_WIDGET_HAS_FOCUS (widget))
@@ -1495,7 +1497,9 @@ gtk_notebook_button_press (GtkWidget *widget,
notebook->click_child = GTK_ARROW_LEFT;
if (event->button == 1)
{
- gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_LEFT);
+ if (!notebook->focus_tab || notebook->focus_tab->prev)
+ gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_LEFT);
+
if (!notebook->timer)
{
notebook->timer = gtk_timeout_add
@@ -1515,7 +1519,8 @@ gtk_notebook_button_press (GtkWidget *widget,
notebook->click_child = GTK_ARROW_RIGHT;
if (event->button == 1)
{
- gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_RIGHT);
+ if (!notebook->focus_tab || notebook->focus_tab->next)
+ gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_RIGHT);
if (!notebook->timer)
{
notebook->timer = gtk_timeout_add
@@ -1554,14 +1559,13 @@ gtk_notebook_button_press (GtkWidget *widget,
(event->x <= (page->allocation.x + page->allocation.width)) &&
(event->y <= (page->allocation.y + page->allocation.height)))
{
- gtk_container_set_focus_child (GTK_CONTAINER (notebook), NULL);
-
- if (page == notebook->cur_page &&
- notebook->focus_tab != children &&
+ if (page == notebook->cur_page && notebook->focus_tab &&
+ notebook->focus_tab != children &&
GTK_WIDGET_HAS_FOCUS (notebook))
{
GtkNotebookPage *old_page;
+ notebook->child_has_focus = FALSE;
old_page = (GtkNotebookPage *)
(notebook->focus_tab->data);
notebook->focus_tab = children;
@@ -1578,6 +1582,8 @@ gtk_notebook_button_press (GtkWidget *widget,
children = children->next;
num++;
}
+ if (!children && !GTK_WIDGET_HAS_FOCUS (widget))
+ gtk_widget_grab_focus (widget);
}
return FALSE;
}
@@ -1734,9 +1740,15 @@ gtk_notebook_timer (GtkNotebook *notebook)
if (notebook->timer)
{
if (notebook->click_child == GTK_ARROW_LEFT)
- gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_LEFT);
+ {
+ if (!notebook->focus_tab || notebook->focus_tab->prev)
+ gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_LEFT);
+ }
else if (notebook->click_child == GTK_ARROW_RIGHT)
- gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_RIGHT);
+ {
+ if (!notebook->focus_tab || notebook->focus_tab->next)
+ gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_RIGHT);
+ }
if (notebook->need_timer)
{
@@ -1803,7 +1815,8 @@ gtk_notebook_draw_arrow (GtkNotebook *notebook, guint arrow)
static void
gtk_real_notebook_switch_page (GtkNotebook *notebook,
- GtkNotebookPage *page)
+ GtkNotebookPage *page,
+ gint page_num)
{
g_return_if_fail (notebook != NULL);
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
@@ -1817,7 +1830,8 @@ gtk_real_notebook_switch_page (GtkNotebook *notebook,
notebook->cur_page = page;
- if (notebook->focus_tab->data != (gpointer) notebook->cur_page)
+ if (!notebook->focus_tab ||
+ notebook->focus_tab->data != (gpointer) notebook->cur_page)
notebook->focus_tab =
g_list_find (notebook->children, notebook->cur_page);
@@ -2072,6 +2086,40 @@ gtk_notebook_draw_tab (GtkNotebook *notebook,
}
}
+static void
+gtk_notebook_set_focus_child (GtkContainer *container,
+ GtkWidget *child)
+{
+ GtkNotebook *notebook;
+
+ g_return_if_fail (container != NULL);
+ g_return_if_fail (GTK_IS_NOTEBOOK (container));
+
+ if (child)
+ {
+ g_return_if_fail (GTK_IS_WIDGET (child));
+
+ notebook = GTK_NOTEBOOK (container);
+
+ notebook->child_has_focus = TRUE;
+ if (!notebook->focus_tab)
+ {
+ GList *children;
+ GtkNotebookPage *page;
+
+ children = notebook->children;
+ while (children)
+ {
+ page = children->data;
+ if (page->child == child || page->tab_label == child)
+ notebook->focus_tab = children;
+ children = children->next;
+ }
+ }
+ }
+ parent_class->set_focus_child (container, child);
+}
+
static gint
gtk_notebook_focus_in (GtkWidget *widget,
GdkEventFocus *event)
@@ -2080,14 +2128,7 @@ gtk_notebook_focus_in (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
- if (GTK_CONTAINER (widget)->focus_child)
- {
- if (gtk_notebook_page_select (GTK_NOTEBOOK (widget)))
- return FALSE;
- else
- gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL);
- }
-
+ GTK_NOTEBOOK (widget)->child_has_focus = FALSE;
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
gtk_widget_draw_focus (widget);
@@ -2149,43 +2190,48 @@ gtk_notebook_focus_changed (GtkNotebook *notebook, GtkNotebookPage *old_page)
g_return_if_fail (notebook != NULL);
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
- g_return_if_fail (old_page != NULL);
widget = GTK_WIDGET (notebook);
- if (GTK_WIDGET_DRAWABLE (widget) && notebook->show_tabs &&
- notebook->focus_tab)
+ if (GTK_WIDGET_DRAWABLE (widget) && notebook->show_tabs)
{
- GtkNotebookPage *page;
GdkGC *gc;
- page = notebook->focus_tab->data;
-
- if (GTK_WIDGET_HAS_FOCUS (widget))
- gc = widget->style->black_gc;
- else if (page == notebook->cur_page)
- gc = widget->style->bg_gc[GTK_STATE_NORMAL];
- else
- gc = widget->style->bg_gc[GTK_STATE_ACTIVE];
+ if (notebook->focus_tab)
+ {
+ GtkNotebookPage *page;
- gdk_draw_rectangle (widget->window,
- gc, FALSE,
- page->tab_label->allocation.x - 1,
- page->tab_label->allocation.y - 1,
- page->tab_label->allocation.width + 1,
- page->tab_label->allocation.height + 1);
+ page = notebook->focus_tab->data;
- if (old_page == notebook->cur_page)
- gc = widget->style->bg_gc[GTK_STATE_NORMAL];
- else
- gc = widget->style->bg_gc[GTK_STATE_ACTIVE];
+ if (GTK_WIDGET_HAS_FOCUS (widget))
+ gc = widget->style->black_gc;
+ else if (page == notebook->cur_page)
+ gc = widget->style->bg_gc[GTK_STATE_NORMAL];
+ else
+ gc = widget->style->bg_gc[GTK_STATE_ACTIVE];
+
+ gdk_draw_rectangle (widget->window,
+ gc, FALSE,
+ page->tab_label->allocation.x - 1,
+ page->tab_label->allocation.y - 1,
+ page->tab_label->allocation.width + 1,
+ page->tab_label->allocation.height + 1);
+ }
- gdk_draw_rectangle (widget->window,
- gc, FALSE,
- old_page->tab_label->allocation.x - 1,
- old_page->tab_label->allocation.y - 1,
- old_page->tab_label->allocation.width + 1,
- old_page->tab_label->allocation.height + 1);
+ if (old_page)
+ {
+ if (old_page == notebook->cur_page)
+ gc = widget->style->bg_gc[GTK_STATE_NORMAL];
+ else
+ gc = widget->style->bg_gc[GTK_STATE_ACTIVE];
+
+ gdk_draw_rectangle (widget->window,
+ gc, FALSE,
+ old_page->tab_label->allocation.x - 1,
+ old_page->tab_label->allocation.y - 1,
+ old_page->tab_label->allocation.width + 1,
+ old_page->tab_label->allocation.height + 1);
+ }
}
}
@@ -2295,7 +2341,17 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook,
if (notebook->scrollable)
{
+ GList *focus_tab;
+
children = notebook->children;
+
+ if (notebook->focus_tab)
+ focus_tab = notebook->focus_tab;
+ else if (notebook->first_tab)
+ focus_tab = notebook->first_tab;
+ else
+ focus_tab = notebook->children;
+
switch (notebook->tab_pos)
{
case GTK_POS_TOP:
@@ -2309,7 +2365,7 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook,
if (tab_space > allocation->width - 2 * container->border_width - TAB_OVERLAP)
{
showarrow = TRUE;
- page = notebook->focus_tab->data;
+ page = focus_tab->data;
tab_space = (allocation->width - TAB_OVERLAP - page->requisition.width -
2 * (container->border_width + ARROW_SPACING + ARROW_SIZE));
@@ -2334,7 +2390,7 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook,
if (tab_space > (allocation->height - 2 * container->border_width - TAB_OVERLAP))
{
showarrow = TRUE;
- page = notebook->focus_tab->data;
+ page = focus_tab->data;
tab_space = (allocation->height -
ARROW_SIZE - ARROW_SPACING - TAB_OVERLAP -
2 * container->border_width - page->requisition.height);
@@ -2353,7 +2409,7 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook,
}
if (showarrow) /* first_tab <- focus_tab */
{
- children = notebook->focus_tab->prev;
+ children = focus_tab->prev;
while (children)
{
if (notebook->first_tab == children)
@@ -2362,17 +2418,17 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook,
}
if (!children)
- notebook->first_tab = notebook->focus_tab;
+ notebook->first_tab = focus_tab;
else
- gtk_notebook_calc_tabs (notebook, notebook->focus_tab->prev,
+ gtk_notebook_calc_tabs (notebook, focus_tab->prev,
&(notebook->first_tab), &tab_space,
STEP_PREV);
if (tab_space <= 0)
{
notebook->first_tab = notebook->first_tab->next;
if (!notebook->first_tab)
- notebook->first_tab = notebook->focus_tab;
- last_child = notebook->focus_tab->next;
+ notebook->first_tab = focus_tab;
+ last_child = focus_tab->next;
}
else /* focus_tab -> end */
{
@@ -2380,7 +2436,7 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook,
notebook->first_tab = notebook->children;
children = NULL;
- gtk_notebook_calc_tabs (notebook, notebook->focus_tab->next,
+ gtk_notebook_calc_tabs (notebook, focus_tab->next,
&children, &tab_space, STEP_NEXT);
if (tab_space <= 0)
@@ -2632,7 +2688,7 @@ gtk_notebook_focus (GtkContainer *container,
GtkNotebook *notebook;
GtkWidget *focus_child;
GtkNotebookPage *page = NULL;
- GtkNotebookPage *old_page;
+ GtkNotebookPage *old_page = NULL;
gint return_val;
g_return_val_if_fail (container != NULL, FALSE);
@@ -2668,16 +2724,13 @@ gtk_notebook_focus (GtkContainer *container,
return FALSE;
}
- old_page = notebook->focus_tab->data;
- return_val = FALSE;
+ if (notebook->focus_tab)
+ old_page = notebook->focus_tab->data;
- if (!GTK_WIDGET_HAS_FOCUS (container) && !focus_child)
- {
- gtk_widget_grab_focus (GTK_WIDGET (container));
- return TRUE;
- }
+ return_val = FALSE;
- if (focus_child && focus_child == old_page->child)
+ if (focus_child && old_page && focus_child == old_page->child &&
+ notebook->child_has_focus)
{
if (GTK_WIDGET_VISIBLE (old_page->child))
{
@@ -2699,20 +2752,34 @@ gtk_notebook_focus (GtkContainer *container,
case GTK_DIR_TAB_FORWARD:
case GTK_DIR_RIGHT:
case GTK_DIR_DOWN:
- if (!notebook->focus_tab->next)
- return FALSE;
+ if (!notebook->focus_tab)
+ notebook->focus_tab = notebook->children;
+ else
+ notebook->focus_tab = notebook->focus_tab->next;
+
+ if (!notebook->focus_tab)
+ {
+ gtk_notebook_focus_changed (notebook, old_page);
+ return FALSE;
+ }
- notebook->focus_tab = notebook->focus_tab->next;
page = notebook->focus_tab->data;
return_val = TRUE;
break;
case GTK_DIR_TAB_BACKWARD:
case GTK_DIR_LEFT:
case GTK_DIR_UP:
- if (!notebook->focus_tab->prev)
+ if (!notebook->focus_tab)
+ notebook->focus_tab = g_list_last (notebook->children);
+ else
+ notebook->focus_tab = notebook->focus_tab->prev;
+
+ if (!notebook->focus_tab)
+ {
+ gtk_notebook_focus_changed (notebook, old_page);
return FALSE;
+ }
- notebook->focus_tab = notebook->focus_tab->prev;
page = notebook->focus_tab->data;
return_val = TRUE;
break;
@@ -2720,6 +2787,9 @@ gtk_notebook_focus (GtkContainer *container,
if (return_val)
{
+ if (!GTK_WIDGET_HAS_FOCUS (container) )
+ gtk_widget_grab_focus (GTK_WIDGET (container));
+
if (GTK_WIDGET_MAPPED (page->tab_label))
gtk_notebook_focus_changed (notebook, old_page);
else
@@ -2779,7 +2849,7 @@ static void
gtk_notebook_switch_focus_tab (GtkNotebook *notebook,
GList *new_child)
{
- GtkNotebookPage *old_page;
+ GtkNotebookPage *old_page = NULL;
GtkNotebookPage *page;
g_return_if_fail (notebook != NULL);
@@ -2787,7 +2857,9 @@ gtk_notebook_switch_focus_tab (GtkNotebook *notebook,
if (notebook->focus_tab != new_child)
{
- old_page = notebook->focus_tab->data;
+ if (notebook->focus_tab)
+ old_page = notebook->focus_tab->data;
+
notebook->focus_tab = new_child;
page = notebook->focus_tab->data;
if (GTK_WIDGET_MAPPED (page->tab_label))
@@ -2834,6 +2906,7 @@ gtk_notebook_key_press (GtkWidget *widget,
direction = GTK_DIR_RIGHT;
break;
case GDK_Tab:
+ case GDK_ISO_Left_Tab:
if (event->state & GDK_SHIFT_MASK)
direction = GTK_DIR_TAB_BACKWARD;
else
diff --git a/gtk/gtknotebook.h b/gtk/gtknotebook.h
index fadd33e32..501a991aa 100644
--- a/gtk/gtknotebook.h
+++ b/gtk/gtknotebook.h
@@ -62,6 +62,7 @@ struct _GtkNotebook
guint click_child : 2;
guint button : 2;
guint need_timer : 1;
+ guint child_has_focus : 1;
};
struct _GtkNotebookClass
@@ -69,7 +70,8 @@ struct _GtkNotebookClass
GtkContainerClass parent_class;
void (* switch_page) (GtkNotebook *notebook,
- GtkNotebookPage *page);
+ GtkNotebookPage *page,
+ gint page_num);
};
struct _GtkNotebookPage