Use accessor functions to access GtkNotebook

This commit is contained in:
Javier Jardón 2010-07-02 22:39:02 +02:00
parent c6b6ab0599
commit d562611660
4 changed files with 23 additions and 36 deletions

View File

@ -132,13 +132,7 @@ gail_get_accessible_for_widget (GtkWidget *widget,
gint page_num = -1;
notebook = GTK_NOTEBOOK (widget);
/*
* Report the currently focused tab rather than the currently selected tab
*/
if (notebook->focus_tab)
{
page_num = g_list_index (notebook->children, notebook->focus_tab->data);
}
page_num = gtk_notebook_get_current_page (notebook);
if (page_num != -1)
{
obj = gtk_widget_get_accessible (widget);
@ -488,7 +482,6 @@ gail_switch_page_watcher (GSignalInvocationHint *ihint,
{
GObject *object;
GtkWidget *widget;
GtkNotebook *notebook;
object = g_value_get_object (param_values + 0);
g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE);
@ -498,8 +491,7 @@ gail_switch_page_watcher (GSignalInvocationHint *ihint,
if (!GTK_IS_NOTEBOOK (widget))
return TRUE;
notebook = GTK_NOTEBOOK (widget);
if (!notebook->focus_tab)
if (gtk_notebook_get_current_page (GTK_NOTEBOOK (widget)) == -1)
return TRUE;
gail_focus_notify_when_idle (widget);

View File

@ -124,8 +124,8 @@ gail_notebook_ref_child (AtkObject *obj,
gail_notebook = GAIL_NOTEBOOK (obj);
gtk_notebook = GTK_NOTEBOOK (widget);
if (gail_notebook->page_count < g_list_length (gtk_notebook->children))
if (gail_notebook->page_count < gtk_notebook_get_n_pages (gtk_notebook))
check_cache (gail_notebook, gtk_notebook);
accessible = find_child_in_list (gail_notebook->page_cache, i);
@ -163,16 +163,13 @@ gail_notebook_real_initialize (AtkObject *obj,
notebook = GAIL_NOTEBOOK (obj);
gtk_notebook = GTK_NOTEBOOK (data);
for (i = 0; i < g_list_length (gtk_notebook->children); i++)
for (i = 0; i < gtk_notebook_get_n_pages (gtk_notebook); i++)
{
create_notebook_page_accessible (notebook, gtk_notebook, i, FALSE, NULL);
}
notebook->page_count = i;
notebook->selected_page = gtk_notebook_get_current_page (gtk_notebook);
if (gtk_notebook->focus_tab && gtk_notebook->focus_tab->data)
{
notebook->focus_tab_page = g_list_index (gtk_notebook->children, gtk_notebook->focus_tab->data);
}
g_signal_connect (gtk_notebook,
"focus",
G_CALLBACK (gail_notebook_focus_cb),
@ -209,7 +206,7 @@ gail_notebook_real_notify_gtk (GObject *obj,
gail_notebook = GAIL_NOTEBOOK (atk_obj);
gtk_notebook = GTK_NOTEBOOK (widget);
if (gail_notebook->page_count < g_list_length (gtk_notebook->children))
if (gail_notebook->page_count < gtk_notebook_get_n_pages (gtk_notebook))
check_cache (gail_notebook, gtk_notebook);
/*
* Notify SELECTED state change for old and new page
@ -217,13 +214,9 @@ gail_notebook_real_notify_gtk (GObject *obj,
old_page_num = gail_notebook->selected_page;
page_num = gtk_notebook_get_current_page (gtk_notebook);
gail_notebook->selected_page = page_num;
gail_notebook->focus_tab_page = page_num;
old_focus_page_num = gail_notebook->focus_tab_page;
if (gtk_notebook->focus_tab && gtk_notebook->focus_tab->data)
{
focus_page_num = g_list_index (gtk_notebook->children, gtk_notebook->focus_tab->data);
gail_notebook->focus_tab_page = focus_page_num;
}
if (page_num != old_page_num)
{
AtkObject *obj;
@ -438,7 +431,7 @@ check_cache (GailNotebook *gail_notebook,
GList *gail_list;
gint i;
gtk_list = notebook->children;
gtk_list = gtk_container_get_children (GTK_CONTAINER (notebook));
gail_list = gail_notebook->page_cache;
i = 0;
@ -459,6 +452,8 @@ check_cache (GailNotebook *gail_notebook,
i++;
gtk_list = gtk_list->next;
}
g_list_free (gtk_list);
gail_notebook->page_count = i;
}
@ -572,11 +567,11 @@ gail_notebook_check_focus_tab (gpointer data)
gail_notebook->idle_focus_id = 0;
if (!gtk_notebook->focus_tab)
focus_page_num = gtk_notebook_get_current_page (gtk_notebook);
if (focus_page_num == -1)
return FALSE;
old_focus_page_num = gail_notebook->focus_tab_page;
focus_page_num = g_list_index (gtk_notebook->children, gtk_notebook->focus_tab->data);
gail_notebook->focus_tab_page = focus_page_num;
if (old_focus_page_num != focus_page_num)
{

View File

@ -172,8 +172,8 @@ gail_notebook_page_new (GtkNotebook *notebook,
GailNotebookPage *page;
GtkWidget *child;
GtkWidget *label;
GList *list;
GtkWidget *widget_page;
g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
child = gtk_notebook_get_nth_page (notebook, pagenum);
@ -188,8 +188,8 @@ gail_notebook_page_new (GtkNotebook *notebook,
page->notebook = notebook;
g_object_add_weak_pointer (G_OBJECT (page->notebook), (gpointer *)&page->notebook);
page->index = pagenum;
list = g_list_nth (notebook->children, pagenum);
page->page = list->data;
widget_page = gtk_notebook_get_nth_page (notebook, pagenum);
page->page = widget_page;
page->textutil = NULL;
atk_object = ATK_OBJECT (page);

View File

@ -6789,7 +6789,7 @@ static void
rotate_notebook (GtkButton *button,
GtkNotebook *notebook)
{
gtk_notebook_set_tab_pos (notebook, (notebook->tab_pos + 1) % 4);
gtk_notebook_set_tab_pos (notebook, (gtk_notebook_get_tab_pos (notebook) + 1) % 4);
}
static void
@ -6844,14 +6844,14 @@ notebook_type_changed (GtkWidget *optionmenu,
gtk_notebook_set_show_tabs (notebook, TRUE);
gtk_notebook_set_show_border (notebook, TRUE);
gtk_notebook_set_scrollable (notebook, TRUE);
if (g_list_length (notebook->children) == 5)
if (gtk_notebook_get_n_pages (notebook) == 5)
create_pages (notebook, 6, 15);
return;
break;
}
if (g_list_length (notebook->children) == 15)
if (gtk_notebook_get_n_pages (notebook) == 15)
for (i = 0; i < 10; i++)
gtk_notebook_remove_page (notebook, 5);
}