void RenderThemeGtk::refreshComboBoxChildren() const { gtkComboBox(); // Ensure that we've initialized the combo box. // Some themes look at widget ancestry to determine how to render widgets, so // get the GtkButton that is the actual child of the combo box. gtk_container_forall(GTK_CONTAINER(m_gtkComboBox), getGtkComboBoxButton, &m_gtkComboBoxButton); ASSERT(m_gtkComboBoxButton); setupWidget(m_gtkComboBoxButton); g_object_add_weak_pointer(G_OBJECT(m_gtkComboBoxButton), reinterpret_cast<gpointer*>(&m_gtkComboBoxButton)); ComboBoxWidgetPieces pieces = { 0, 0 }; GtkWidget* buttonChild = gtk_bin_get_child(GTK_BIN(gtkComboBoxButton())); if (GTK_IS_HBOX(buttonChild)) gtk_container_forall(GTK_CONTAINER(buttonChild), getGtkComboBoxPieces, &pieces); else if (GTK_IS_ARROW(buttonChild)) pieces.arrow = buttonChild; ASSERT(pieces.arrow); m_gtkComboBoxArrow = pieces.arrow; setupWidget(m_gtkComboBoxArrow); // When the style changes, the combo box may destroy its children. g_object_add_weak_pointer(G_OBJECT(m_gtkComboBoxArrow), reinterpret_cast<gpointer*>(&m_gtkComboBoxArrow)); m_gtkComboBoxSeparator = pieces.separator; if (m_gtkComboBoxSeparator) { setupWidget(m_gtkComboBoxSeparator); // When the style changes, the combo box may destroy its children. g_object_add_weak_pointer(G_OBJECT(m_gtkComboBoxSeparator), reinterpret_cast<gpointer*>(&m_gtkComboBoxSeparator)); } }
/* * A DownArrow in a GtkToggltButton whose parent is not a ColorCombo * has press as default action. */ static gboolean gail_button_is_default_press (GtkWidget *widget) { GtkArrowType arrow_type; GtkWidget *child; GtkWidget *parent; gboolean ret = FALSE; const gchar *parent_type_name; child = gtk_bin_get_child (GTK_BIN (widget)); if (GTK_IS_ARROW (child)) { g_object_get (child, "arrow_type", &arrow_type, NULL); if (arrow_type == GTK_ARROW_DOWN) { parent = gtk_widget_get_parent (widget); if (parent) { parent_type_name = g_type_name (G_OBJECT_TYPE (parent)); if (g_strcmp0 (parent_type_name, "ColorCombo")) return TRUE; } } } return ret; }
static void get_combo_box_arrow (GtkWidget *widget, gpointer data) { GtkWidget **p_child = data; if (GTK_IS_ARROW (widget)) *p_child = widget; }
static void getGtkComboBoxPieces(GtkWidget* widget, gpointer data) { if (GTK_IS_ARROW(widget)) { static_cast<ComboBoxWidgetPieces*>(data)->arrow = widget; return; } if (GTK_IS_SEPARATOR(widget)) static_cast<ComboBoxWidgetPieces*>(data)->separator = widget; }
AtkObject* gail_arrow_new (GtkWidget *widget) { GObject *object; AtkObject *accessible; g_return_val_if_fail (GTK_IS_ARROW (widget), NULL); object = g_object_new (GAIL_TYPE_ARROW, NULL); accessible = ATK_OBJECT (object); atk_object_initialize (accessible, widget); accessible->role = ATK_ROLE_ICON; return accessible; }
static void moz_gtk_get_combo_box_button_inner_widgets(GtkWidget *widget, gpointer client_data) { if (GTK_IS_SEPARATOR(widget)) { gParts->comboBoxSeparatorWidget = widget; g_object_add_weak_pointer(G_OBJECT(widget), (gpointer) &gParts->comboBoxSeparatorWidget); } else if (GTK_IS_ARROW(widget)) { gParts->comboBoxArrowWidget = widget; g_object_add_weak_pointer(G_OBJECT(widget), (gpointer) &gParts->comboBoxArrowWidget); } else return; gtk_widget_realize(widget); g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE)); }
static gint ensure_combo_box_widgets() { GtkWidget* buttonChild; if (gParts->comboBoxButtonWidget && gParts->comboBoxArrowWidget) return MOZ_GTK_SUCCESS; /* Create a ComboBox if needed */ if (!gParts->comboBoxWidget) { gParts->comboBoxWidget = gtk_combo_box_new(); setup_widget_prototype(gParts->comboBoxWidget); } /* Get its inner Button */ gtk_container_forall(GTK_CONTAINER(gParts->comboBoxWidget), moz_gtk_get_combo_box_inner_button, NULL); if (gParts->comboBoxButtonWidget) { /* Get the widgets inside the Button */ buttonChild = gtk_bin_get_child(GTK_BIN(gParts->comboBoxButtonWidget)); if (GTK_IS_HBOX(buttonChild)) { /* appears-as-list = FALSE, cell-view = TRUE; the button * contains an hbox. This hbox is there because the ComboBox * needs to place a cell renderer, a separator, and an arrow in * the button when appears-as-list is FALSE. */ gtk_container_forall(GTK_CONTAINER(buttonChild), moz_gtk_get_combo_box_button_inner_widgets, NULL); } else if(GTK_IS_ARROW(buttonChild)) { /* appears-as-list = TRUE, or cell-view = FALSE; * the button only contains an arrow */ gParts->comboBoxArrowWidget = buttonChild; g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer) &gParts->comboBoxArrowWidget); gtk_widget_realize(gParts->comboBoxArrowWidget); g_object_set_data(G_OBJECT(gParts->comboBoxArrowWidget), "transparent-bg-hint", GINT_TO_POINTER(TRUE)); } } else { /* Shouldn't be reached with current internal gtk implementation; we * use a generic toggle button as last resort fallback to avoid * crashing. */ ensure_toggle_button_widget(); gParts->comboBoxButtonWidget = gParts->toggleButtonWidget; } if (!gParts->comboBoxArrowWidget) { /* Shouldn't be reached with current internal gtk implementation; * we gParts->buttonArrowWidget as last resort fallback to avoid * crashing. */ ensure_button_arrow_widget(); gParts->comboBoxArrowWidget = gParts->buttonArrowWidget; } /* We don't test the validity of gParts->comboBoxSeparatorWidget since there * is none when "appears-as-list" = TRUE or "cell-view" = FALSE; if it * is invalid we just won't paint it. */ return MOZ_GTK_SUCCESS; }