static GtkWidget* get_label_from_notebook_page (GailNotebookPage *page) { GtkWidget *child; GtkNotebook *notebook; notebook = page->notebook; if (!notebook) return NULL; if (!gtk_notebook_get_show_tabs (notebook)) return NULL; child = gtk_notebook_get_nth_page (notebook, page->index); if (child == NULL) return NULL; g_return_val_if_fail (GTK_IS_WIDGET (child), NULL); child = gtk_notebook_get_tab_label (notebook, child); if (GTK_IS_LABEL (child)) return child; if (GTK_IS_CONTAINER (child)) child = find_label_child (GTK_CONTAINER (child)); return child; }
static GtkWidget* find_label_child (GtkContainer *container) { GList *children, *tmp_list; GtkWidget *child; children = gtk_container_get_children (container); child = NULL; for (tmp_list = children; tmp_list != NULL; tmp_list = tmp_list->next) { if (GTK_IS_LABEL (tmp_list->data)) { child = GTK_WIDGET (tmp_list->data); break; } else if (GTK_IS_CONTAINER (tmp_list->data)) { child = find_label_child (GTK_CONTAINER (tmp_list->data)); if (child) break; } } g_list_free (children); return child; }
static GtkWidget * get_label_from_button (GtkWidget *button) { GtkWidget *child; child = gtk_bin_get_child (GTK_BIN (button)); if (GTK_IS_CONTAINER (child)) child = find_label_child (GTK_CONTAINER (child)); else if (!GTK_IS_LABEL (child)) child = NULL; return child; }
static GtkWidget * get_label_from_button (GtkWidget *button) { GtkWidget *child; child = gtk_bin_get_child (GTK_BIN (button)); G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (GTK_IS_ALIGNMENT (child)) child = gtk_bin_get_child (GTK_BIN (child)); G_GNUC_END_IGNORE_DEPRECATIONS if (GTK_IS_CONTAINER (child)) child = find_label_child (GTK_CONTAINER (child)); else if (!GTK_IS_LABEL (child)) child = NULL; return child; }
static GtkWidget* get_label_from_button (GtkWidget *button, gint index, gboolean allow_many) { GtkWidget *child; if (index > 0 && !allow_many) g_warning ("Inconsistent values passed to get_label_from_button"); child = gtk_bin_get_child (GTK_BIN (button)); if (GTK_IS_ALIGNMENT (child)) child = gtk_bin_get_child (GTK_BIN (child)); if (GTK_IS_CONTAINER (child)) child = find_label_child (GTK_CONTAINER (child), &index, allow_many); else if (!GTK_IS_LABEL (child)) child = NULL; return child; }
static GtkWidget * get_label_from_notebook_page (GtkNotebookPageAccessible *page) { GtkWidget *child; GtkNotebook *notebook; notebook = GTK_NOTEBOOK (gtk_accessible_get_widget (page->notebook)); if (!notebook) return NULL; if (!gtk_notebook_get_show_tabs (notebook)) return NULL; child = gtk_notebook_get_tab_label (notebook, page->child); if (GTK_IS_LABEL (child)) return child; if (GTK_IS_CONTAINER (child)) child = find_label_child (GTK_CONTAINER (child)); return child; }
static GtkWidget* find_label_child (GtkContainer *container, gint *index, gboolean allow_many) { GList *children, *tmp_list; GtkWidget *child; children = gtk_container_get_children (container); child = NULL; for (tmp_list = children; tmp_list != NULL; tmp_list = tmp_list->next) { if (GTK_IS_LABEL (tmp_list->data)) { if (!allow_many) { if (child) { child = NULL; break; } child = GTK_WIDGET (tmp_list->data); } else { if (*index == 0) { child = GTK_WIDGET (tmp_list->data); break; } (*index)--; } } /* * Label for button which are GtkTreeView column headers are in a * GtkHBox in a GtkAlignment. */ else if (GTK_IS_ALIGNMENT (tmp_list->data)) { GtkWidget *widget; widget = gtk_bin_get_child (GTK_BIN (tmp_list->data)); if (GTK_IS_LABEL (widget)) { if (!allow_many) { if (child) { child = NULL; break; } child = widget; } else { if (*index == 0) { child = widget; break; } (*index)--; } } } else if (GTK_IS_CONTAINER (tmp_list->data)) { child = find_label_child (GTK_CONTAINER (tmp_list->data), index, allow_many); if (child) break; } } g_list_free (children); return child; }