static void gb_gnome_druid_insert_page_before (GtkWidget * menuitem, GnomeDruidPage *page) { GtkWidget *parent, *new_page; GnomeDruidPage *prev_page; GList *children, *elem; parent = GTK_WIDGET (page)->parent; g_return_if_fail (GNOME_IS_DRUID (parent)); children = gtk_container_get_children (GTK_CONTAINER (parent)); elem = g_list_find (children, page); g_return_if_fail (elem != NULL); new_page = gb_widget_new ("GnomeDruidPageStandard", parent); gtk_widget_show_all (new_page); if (elem->prev) prev_page = GNOME_DRUID_PAGE (elem->prev->data); else prev_page = NULL; g_list_free (children); gnome_druid_insert_page (GNOME_DRUID (parent), prev_page, GNOME_DRUID_PAGE (new_page)); gb_gnome_druid_show_page (parent, new_page); gnome_druid_set_page (GNOME_DRUID (parent), GNOME_DRUID_PAGE (new_page)); tree_add_widget (GTK_WIDGET (new_page)); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_gnome_app_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean statusbar, enable_layout_config; gb_window_set_standard_properties (widget, data, Title, Type, Position, Modal, DefaultWidth, DefaultHeight, Shrink, Grow, AutoShrink, IconName, FocusOnMap, Resizable, DestroyWithParent, Icon, Role, TypeHint, SkipTaskbar, SkipPager, Decorated, Gravity, Urgency); if (data->action == GB_APPLYING) { statusbar = gb_widget_input_bool (data, StatusBar); if (data->apply) { if (statusbar) { if (!GNOME_APP (widget)->statusbar) { gnome_app_set_statusbar (GNOME_APP (widget), gb_widget_new ("GnomeAppBar", widget)); gb_widget_set_child_name (GNOME_APP (widget)->statusbar, GladeChildGnomeAppBar); tree_add_widget (GNOME_APP (widget)->statusbar); } } else { if (GNOME_APP (widget)->statusbar) { /* This is not very clean, but there's no proper way to remove the statusbar. The statusbar has an hbox inserted above it which is added to the GnomeApp's vbox, so we remove the hbox. */ GtkWidget *hbox = GNOME_APP (widget)->statusbar->parent; gtk_container_remove (GTK_CONTAINER (hbox->parent), hbox); GNOME_APP (widget)->statusbar = NULL; } } } } enable_layout_config = gb_widget_input_bool (data, EnableLayoutConfig); if (data->apply) { gtk_object_set_data (GTK_OBJECT (widget), EnableLayoutConfig, GINT_TO_POINTER (enable_layout_config)); } }
static void gb_gnome_druid_add_finish_page (GtkWidget * menuitem, GnomeDruid *druid) { GtkWidget *new_page; new_page = gnome_druid_page_edge_new_aa (GNOME_EDGE_FINISH); gb_widget_create_from (new_page, "GnomeDruidPageFinish"); gtk_widget_show_all (new_page); gnome_druid_append_page (druid, GNOME_DRUID_PAGE (new_page)); gb_gnome_druid_show_page (GTK_WIDGET (druid), new_page); gnome_druid_set_page (druid, GNOME_DRUID_PAGE (new_page)); tree_add_widget (GTK_WIDGET (new_page)); }
static void gb_gnome_druid_insert_page_after (GtkWidget * menuitem, GnomeDruidPage *page) { GtkWidget *parent, *new_page; parent = GTK_WIDGET (page)->parent; g_return_if_fail (GNOME_IS_DRUID (parent)); new_page = gb_widget_new ("GnomeDruidPageStandard", parent); gtk_widget_show_all (new_page); gnome_druid_insert_page (GNOME_DRUID (parent), GNOME_DRUID_PAGE (page), GNOME_DRUID_PAGE (new_page)); gb_gnome_druid_show_page (parent, new_page); gnome_druid_set_page (GNOME_DRUID (parent), GNOME_DRUID_PAGE (new_page)); tree_add_widget (GTK_WIDGET (new_page)); }
/* This updates the box size to the given value, adding placeholders or deleting widgets as necessary. */ void gb_box_set_size (GtkWidget * widget, gint size) { GtkWidget *new_child; gint current_size = g_list_length (GTK_BOX (widget)->children); gint i; if (current_size < size) { /* This avoids any problems with redrawing the selection. */ editor_clear_selection (NULL); for (i = 0; i < size - current_size; i++) { if (GTK_IS_BUTTON_BOX (widget)) { new_child = gb_widget_new ("GtkButton", widget); GTK_WIDGET_SET_FLAGS (new_child, GTK_CAN_DEFAULT); gtk_box_pack_start (GTK_BOX (widget), new_child, TRUE, TRUE, 0); tree_add_widget (new_child); } else { new_child = editor_new_placeholder (); gtk_box_pack_start (GTK_BOX (widget), new_child, TRUE, TRUE, 0); } } } else if (current_size > size) { GList *children, *elem; GtkWidget *child; gchar *error = NULL; /* Get a list of children in the order they appear in the box, start at the end and move backwards until we find a widget that can be destroyed. If we can't find any, show a message box. */ children = gtk_container_get_children (GTK_CONTAINER (widget)); elem = g_list_last (children); while (elem) { child = elem->data; error = editor_can_delete_widget (child); if (!error) { gtk_container_remove (GTK_CONTAINER (widget), child); current_size--; if (current_size == size) break; } elem = elem->prev; } g_list_free (children); if (current_size > size) { glade_util_show_message_box (error ? error : _("Can't delete any children."), widget); } } }