static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget, gpointer cb_data) { GtkPizzaAdjData *data = cb_data; widget->allocation.x += data->dx; widget->allocation.y += data->dy; if (GTK_WIDGET_NO_WINDOW (widget) && GTK_IS_CONTAINER (widget)) { gtk_container_forall (GTK_CONTAINER (widget), gtk_pizza_adjust_allocations_recurse, cb_data); } }
static void scroll_adjust(GtkWidget* widget, void* data) { const AdjustData* p = static_cast<AdjustData*>(data); widget->allocation.x += p->dx; widget->allocation.y += p->dy; if (widget->window == p->window) { // GtkFrame requires a queue_resize, otherwise parts of // the frame newly exposed by the scroll are not drawn. // To be safe, do it for all widgets. gtk_widget_queue_resize_no_redraw(widget); if (GTK_IS_CONTAINER(widget)) gtk_container_forall(GTK_CONTAINER(widget), scroll_adjust, data); } }
static void assign_tooltips_from_actions(GtkWidget* widget) { if(G_LIKELY(GTK_IS_MENU_ITEM(widget))) { if(GTK_IS_ACTIVATABLE(widget)) assign_tooltip_from_action(widget); widget = gtk_menu_item_get_submenu((GtkMenuItem*)widget); if(widget) assign_tooltips_from_actions(widget); } else if (GTK_IS_CONTAINER(widget)) { gtk_container_forall((GtkContainer*)widget, (GtkCallback)assign_tooltips_from_actions, NULL); } }
static void do_align_left_widgets (GtkWidget *first_level_child, GtkSizeGroup *size_group) { if (GTK_IS_HBOX (first_level_child) || GTK_IS_HBUTTON_BOX (first_level_child)) { GtkSizeGroup *size_group_copy = size_group; gtk_container_foreach (GTK_CONTAINER (first_level_child), (GtkCallback) do_align_left_widget, &size_group_copy); } else if (GTK_IS_CONTAINER (first_level_child)) { gtk_container_foreach (GTK_CONTAINER (first_level_child), (GtkCallback) do_align_left_widgets, size_group); } }
/** * eel_gtk_container_child_expose_event: * * @container: A GtkContainer widget. * @child: A child of @container or NULL; * @event: The expose event. * * Forward an expose event to a child if needed. It is valid to give a NULL @child. * In that case this function is a noop. Proper clipping is done to ensure that the @child * does indeed need to be forwarded the exposure event. Finally, the forwarding * only occurs if the child is a NO_WINDOW widget. Of course, it is valid to feed * non NO_WINDOW widgets to this function, in which case this function is a noop. */ void eel_gtk_container_child_expose_event (GtkContainer *container, GtkWidget *child, GdkEventExpose *event) { g_return_if_fail (GTK_IS_CONTAINER (container)); if (child == NULL) { return; } g_return_if_fail (GTK_IS_WIDGET (child)); gtk_container_propagate_expose (container, child, event); }
static gint get_n_labels_from_button (GtkWidget *button) { GtkWidget *child; gint n_labels; n_labels = 0; 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)) count_labels (GTK_CONTAINER (child), &n_labels); return n_labels; }
/* void willAppendChild (in nsIDOMNode child); */ NS_IMETHODIMP xgGtkElement::WillAppendChild (nsIDOMNode *child) { if (!GTK_IS_CONTAINER (mObject)) { return NS_ERROR_FAILURE; } nsCOMPtr<xgIGObjectHolder> wrappedChild (do_QueryInterface (child)); GObject *widget = NULL; if (!wrappedChild || NS_FAILED (wrappedChild->GetGObject (&widget)) || !GTK_IS_WIDGET (widget)) { return NS_ERROR_FAILURE; } gtk_container_add (GTK_CONTAINER (mObject), GTK_WIDGET (widget)); return NS_OK; }
static GtkWidget * find_mnemonic_widget (GtkWidget *widget, gint level) { gboolean can_focus; g_object_get (widget, "can-focus", &can_focus, NULL); if (GTK_WIDGET_GET_CLASS (widget)->activate_signal || can_focus || GTK_WIDGET_GET_CLASS (widget)->mnemonic_activate != GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->mnemonic_activate) { return widget; } if (GIMP_IS_SIZE_ENTRY (widget)) { GimpSizeEntry *entry = GIMP_SIZE_ENTRY (widget); return gimp_size_entry_get_help_widget (entry, entry->number_of_fields - 1); } else if (GTK_IS_CONTAINER (widget)) { GtkWidget *mnemonic_widget = NULL; GList *children; GList *list; children = gtk_container_get_children (GTK_CONTAINER (widget)); for (list = children; list; list = g_list_next (list)) { mnemonic_widget = find_mnemonic_widget (list->data, level + 1); if (mnemonic_widget) break; } g_list_free (children); return mnemonic_widget; } return NULL; }
void EvalCcRqMENUENABLE (CrossCallInfo *pcci) /* parent, zero based position of menu, onoff; no result. */ { GtkWidget *parent_menu, *sub_menu; printf("EvalCcRqMENUENABLE\n"); gint index = pcci->p2; if (pcci->p1 && GTK_IS_CONTAINER(pcci->p1)) { printf("We have a container. Checking the widget.\n"); parent_menu = GTK_WIDGET(pcci->p1); gtk_container_foreach(GTK_CONTAINER(parent_menu), pcci->p3 ? enable_menu_callback : disable_menu_callback, (gpointer) (&index)); } MakeReturn0Cci (pcci); }
// If you should ever need to change the font for the running application.. // Ugly but effective. void change_font(GtkWidget *widget, gpointer data) { PangoFontDescription *font_desc; gchar *font = (gchar*)data; const gchar *name; font_desc = pango_font_description_from_string(font); if (font_desc == NULL) exit(1); gtk_widget_modify_font(widget, font_desc); name = ghb_get_setting_key(widget); g_debug("changing font for widget %s\n", name); if (GTK_IS_CONTAINER(widget)) { gtk_container_foreach((GtkContainer*)widget, change_font, data); } }
static bool useEvent(GtkWidget *widget, GdkEventButton *event) { if(lastRejectedEvent && lastRejectedEvent==event) return false; if(!GTK_IS_CONTAINER(widget)) return true; // if widget is a notebook, accept if there is no hovered tab if (GTK_IS_NOTEBOOK(widget)) { return (!Tab::hasVisibleArrows(GTK_NOTEBOOK(widget)) && Tab::currentHoveredIndex(widget) == -1 && childrenUseEvent(widget, event, false)); } else { return childrenUseEvent(widget, event, false); } }
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; }
/* * SetStyleRecursively * * Set the widget's style to the style (data) and make sure * that all the children (if it's a container) are also set * to that particular style. */ void SetStyleRecursively (GtkWidget *widget, gpointer data) { GtkStyle *style; /* --- Get the style --- */ style = (GtkStyle *) data; /* --- Set the style of the widget --- */ gtk_widget_set_style (widget, style); /* --- If it may have children widgets --- */ if (GTK_IS_CONTAINER (widget)) { /* --- Set all the children's styles too. --- */ gtk_container_foreach (GTK_CONTAINER (widget), SetStyleRecursively, style); } }
static void gb_label_get_focus_targets (GtkWidget * widget, GList ** focus_targets) { if (GTK_WIDGET_CAN_FOCUS (widget) && GB_IS_GB_WIDGET (widget)) { *focus_targets = g_list_insert_sorted (*focus_targets, (gchar*) gtk_widget_get_name (widget), g_str_equal); } if (GTK_IS_CONTAINER (widget)) { gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) gb_label_get_focus_targets, focus_targets); } }
static void on_toggle_border_widths (GtkToggleButton *button, void *data) { gboolean has_border; int i; has_border = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); for (i = 0; i < TEST_WIDGET_LAST; ++i) { if (GTK_IS_CONTAINER (test_widgets[i])) { gtk_container_set_border_width (GTK_CONTAINER (test_widgets[i]), has_border ? 50 : 0); } } }
void balsa_mime_widget_image_resize_all(GtkWidget * widget, gpointer user_data) { if (GTK_IS_CONTAINER(widget)) gtk_container_foreach(GTK_CONTAINER(widget), balsa_mime_widget_image_resize_all, NULL); else if (GTK_IS_IMAGE(widget) && g_object_get_data(G_OBJECT(widget), "orig-width") && g_object_get_data(G_OBJECT(widget), "mime-body") && !GPOINTER_TO_INT(g_object_get_data (G_OBJECT(widget), "check_size_sched"))) { GtkWidget **widget_p = g_new(GtkWidget *, 1); g_object_set_data(G_OBJECT(widget), "check_size_sched", GINT_TO_POINTER(TRUE)); *widget_p = widget; g_object_add_weak_pointer(G_OBJECT(widget), (gpointer) widget_p); g_idle_add((GSourceFunc) img_check_size, widget_p); }
/** * eel_gtk_container_child_unmap: * * @container: A GtkContainer widget. * @child: A child of @container or NULL; * * Unmap a child if needed. This is usually called from the "GtkWidget::unmap" * method of the @container widget. If @child is NULL, then this function is a noop. */ void eel_gtk_container_child_unmap (GtkContainer *container, GtkWidget *child) { g_return_if_fail (GTK_IS_CONTAINER (container)); if (child == NULL) { return; } g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container)); if (gtk_widget_get_visible (child) && gtk_widget_get_mapped (child)) { gtk_widget_unmap (child); } }
void set_creation_container (hf_options_struct *hfo, GtkWidget *creation_container) { gboolean already_set=FALSE; if (hfo->creation_container) already_set = TRUE; if (!(creation_container && hfo)) return; // printf("HFO->CREATION_CONTAINER in SET_CREATION_CONTAINER: %d->%d\n",hfo,creation_container); if (GTK_WIDGET(creation_container)) if (GTK_IS_CONTAINER(creation_container)) hfo->creation_container = creation_container; else printf("SET_CREATION_CONTAINER: %d is not a container\n", creation_container); else printf("SET_CREATION_CONTAINER: %d is not a widget\n", creation_container); if (!already_set) gtk_box_pack_start(GTK_BOX(creation_container), hfo->fd_struct->filter_dialog, FALSE, FALSE, 0); // gtk_container_add(GTK_CONTAINER(creation_container), hfo->fd_struct->filter_dialog); }
static GList* test_list_descendants (GtkWidget *widget, GType widget_type) { GList *results = NULL; if (GTK_IS_CONTAINER (widget)) { GList *node, *list = gtk_container_get_children (GTK_CONTAINER (widget)); for (node = list; node; node = node->next) { if (!widget_type || g_type_is_a (G_OBJECT_TYPE (node->data), widget_type)) results = g_list_prepend (results, node->data); else results = g_list_concat (results, test_list_descendants (node->data, widget_type)); } g_list_free (list); } return results; }
static GtkWidget * find_menubar (GtkContainer *container) { GList *children; GList *node; GtkWidget *menubar = NULL; children = gtk_container_get_children (container); for (node = children; ! menubar && node; node = node->next) { if (GTK_IS_MENU_BAR (node->data)) { menubar = node->data; } else if (GTK_IS_CONTAINER (node->data)) { menubar = find_menubar (node->data); } } g_list_free (children); return menubar; }
/** * eel_gtk_container_child_remove: * * @container: A GtkContainer widget. * @child: A non NULL child of @container. * * Remove @child from @container. The @container is resized if needed. * This is usually called from the "GtkContainer::remove" method of the * @container. The child cannot be NULL. */ void eel_gtk_container_child_remove (GtkContainer *container, GtkWidget *child) { gboolean child_was_visible; g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_WIDGET (child)); g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container)); child_was_visible = gtk_widget_get_visible (child); gtk_widget_unparent (child); if (child_was_visible) { gtk_widget_queue_resize (GTK_WIDGET (container)); } }
static void brasero_file_chooser_find_pane (GtkWidget *child, gpointer footer) { if (GTK_IS_PANED (child)) { GList *children_vbox; GList *iter_vbox; GtkWidget *vbox; vbox = gtk_paned_get_child2 (GTK_PANED (child)); children_vbox = gtk_container_get_children (GTK_CONTAINER (vbox)); for (iter_vbox = children_vbox; iter_vbox; iter_vbox = iter_vbox->next) { if (GTK_IS_BOX (iter_vbox->data) && gtk_orientable_get_orientation (GTK_ORIENTABLE (iter_vbox->data)) == GTK_ORIENTATION_HORIZONTAL) { GtkPackType packing; gtk_box_query_child_packing (GTK_BOX (vbox), GTK_WIDGET (iter_vbox->data), NULL, NULL, NULL, &packing); if (packing == GTK_PACK_START) { GtkRequisition total_request, footer_request; gtk_widget_get_preferred_size (GTK_WIDGET (vbox), &total_request, NULL); gtk_widget_get_preferred_size (GTK_WIDGET (iter_vbox->data), &footer_request, NULL); *((gint *) footer) = total_request.height - footer_request.height; break; } } } g_list_free (children_vbox); } else if (GTK_IS_CONTAINER (child)) { gtk_container_foreach (GTK_CONTAINER (child), brasero_file_chooser_find_pane, footer); } }
static void set_vte(GtkWidget *widget) { if (VTE_IS_TERMINAL(widget)) { have_vte = TRUE; vte = VTE_TERMINAL(widget); } else if (GTK_IS_CONTAINER(widget)) { GList *children, *iter; children = gtk_container_get_children(GTK_CONTAINER(widget)); for (iter=children; !have_vte && iter; iter=g_list_next(iter)) set_vte(iter->data); g_list_free(children); } }
gboolean bst_choice_selectable (GtkWidget *widget) { gboolean selectable = FALSE; g_return_val_if_fail (GTK_IS_CONTAINER (widget), FALSE); if (GTK_IS_MENU (widget)) { GList *list, *children = gtk_container_children (GTK_CONTAINER (widget)); for (list = children; list; list = list->next) { GtkBin *bin = list->data; if (GTK_WIDGET_IS_SENSITIVE (bin) && GTK_WIDGET_VISIBLE (bin) && bin->child) { selectable = TRUE; break; } } g_list_free (children); } else if (GXK_IS_DIALOG (widget)) { GList *list, *children = gtk_container_children (GTK_CONTAINER (GXK_DIALOG (widget)->hbox)); for (list = children; list; list = list->next) { GtkBin *bin = list->data; if (GTK_IS_BUTTON (bin) && GTK_WIDGET_IS_SENSITIVE (bin) && GTK_WIDGET_VISIBLE (bin)) { selectable = TRUE; break; } } g_list_free (children); } return selectable; }
static GtkWidget * contacts_edit_add_focus_events (GtkWidget *widget, GtkWidget *ebox, GList *widgets) { if (!ebox) { GtkWidget *align = gtk_alignment_new (0.5, 0.5, 1, 1); ebox = gtk_event_box_new (); gtk_container_add (GTK_CONTAINER (align), widget); gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, 6, 6); gtk_container_add (GTK_CONTAINER (ebox), align); gtk_widget_show (align); gtk_widget_show (ebox); gtk_widget_set_name (ebox, gtk_widget_get_name (widget)); } if (!widget) return ebox; if (GTK_IS_CONTAINER (widget) && !GTK_IS_TEXT_VIEW (widget)) { GList *c, *children = gtk_container_get_children (GTK_CONTAINER (widget)); for (c = children; c; c = c->next) { contacts_edit_add_focus_events (GTK_WIDGET (c->data), ebox, widgets); } g_list_free (children); } else if (GTK_IS_WIDGET (widget)) { GList *w; g_signal_connect (G_OBJECT (widget), "focus-in-event", G_CALLBACK (contacts_edit_focus_in), ebox); g_signal_connect (G_OBJECT (widget), "focus-out-event", G_CALLBACK (contacts_edit_focus_out), ebox); for (w = widgets; w; w = w->next) { g_signal_connect (G_OBJECT (widget), "focus-in-event", G_CALLBACK (contacts_edit_focus_in), w->data); g_signal_connect (G_OBJECT (widget), "focus-out-event", G_CALLBACK (contacts_edit_focus_out), w->data); } } return ebox; }
/* locate vte anywhere at or below widget */ static gboolean holds_vte(GtkWidget *widget) { gboolean found = FALSE; if (VTE_IS_TERMINAL(widget)) found = TRUE; else if (GTK_IS_CONTAINER(widget)) { GList *children, *iter; children = gtk_container_get_children(GTK_CONTAINER(widget)); for (iter=children; !found && iter; iter=g_list_next(iter)) found = holds_vte(iter->data); g_list_free(children); } return found; }
/* Try to adjust some buttons to close the window on click */ void adjust_destroy (GtkWidget *widget, GtkWindow *win) { if (GTK_IS_BUTTON(widget) && \ gtk_button_get_use_stock (GTK_BUTTON(widget)) && \ (strncmp (gtk_button_get_label (GTK_BUTTON(widget)), "gtk-apply", 9) == 0 || \ strncmp (gtk_button_get_label (GTK_BUTTON(widget)), "gtk-cancel", 10) == 0 || \ strncmp (gtk_button_get_label (GTK_BUTTON(widget)), "gtk-close", 9) == 0)) { g_signal_connect_object (G_OBJECT(widget), "clicked", G_CALLBACK(gtk_widget_destroy), G_OBJECT(win), G_CONNECT_AFTER | G_CONNECT_SWAPPED); } else if (GTK_IS_CONTAINER(widget)) { gtk_container_foreach (widget, adjust_destroy, win); } }
//________________________________________________________________________________ void ComboBoxData::registerChild( GtkWidget* widget, bool recursive ) { // make sure widget is not already in map if( _hoverData.find( widget ) == _hoverData.end() ) { #if CARBON_DEBUG std::cerr << "Carbon::ComboBoxData::registerChild -" << " " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")" << std::endl; #endif // allocate new Hover data HoverData data; data._widget = widget; data._destroyId.connect( G_OBJECT(widget), "destroy", G_CALLBACK( childDestroyNotifyEvent ), this ); data._enterId.connect( G_OBJECT(widget), "enter-notify-event", G_CALLBACK( enterNotifyEvent ), this ); data._leaveId.connect( G_OBJECT(widget), "leave-notify-event", G_CALLBACK( leaveNotifyEvent ), this ); // and insert in map _hoverData.insert( std::make_pair( widget, data ) ); } /* also insert widget's children, recursively. that should take care of buttons in tabs and other fancy stuff that applications mght do */ if( recursive && GTK_IS_CONTAINER( widget ) ) { GList *children( gtk_container_get_children( GTK_CONTAINER(widget) ) ); for( GList* child = g_list_first(children); child; child = g_list_next(child) ) { registerChild( GTK_WIDGET( child->data ) ); } if( children ) g_list_free( children ); } }
gpointer ide_widget_find_child_typed (GtkWidget *widget, GType child_type) { struct { gpointer ret; GType type; } state; g_return_val_if_fail (GTK_IS_CONTAINER (widget), NULL); g_return_val_if_fail (g_type_is_a (child_type, GTK_TYPE_WIDGET), NULL); state.ret = NULL; state.type = child_type; gtk_container_foreach (GTK_CONTAINER (widget), ide_widget_find_child_typed_cb, &state); return state.ret; }
MidoratorEntry* midorator_entry_new(GtkWidget *parent) { GtkWidget *e = g_object_new(MIDORATOR_TYPE_ENTRY, NULL); gtk_entry_set_has_frame(GTK_ENTRY(e), false); if (parent) { gtk_widget_modify_base(e, GTK_STATE_NORMAL, &parent->style->bg[0]); gtk_widget_modify_base(e, GTK_STATE_ACTIVE, &parent->style->bg[0]); gtk_widget_modify_bg(e, GTK_STATE_NORMAL, &parent->style->bg[0]); gtk_widget_modify_bg(e, GTK_STATE_ACTIVE, &parent->style->bg[0]); } if (GTK_IS_BOX(parent)) { gtk_box_pack_start(GTK_BOX(parent), e, true, true, 0); gtk_widget_show(e); gtk_widget_grab_focus(e); gtk_box_reorder_child(GTK_BOX(parent), e, 0); } else if (GTK_IS_CONTAINER(parent)) { gtk_container_add(GTK_CONTAINER(parent), e); gtk_widget_show(e); } return MIDORATOR_ENTRY(e); //return (MidoratorEntry*)(e); }