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)); }
static void on_vbbox_dialog_ok (GtkWidget * widget, GbWidgetNewData * data) { GtkWidget *new_widget, *spinbutton, *window, *new_child; gint rows, i; window = gtk_widget_get_toplevel (widget); /* Only call callback if placeholder/fixed widget is still there */ if (gb_widget_can_finish_new (data)) { spinbutton = gtk_object_get_data (GTK_OBJECT (window), "rows"); g_return_if_fail (spinbutton != NULL); rows = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spinbutton)); new_widget = gtk_vbutton_box_new (); for (i = 0; i < rows; i++) { new_child = gb_widget_new ("GtkButton", new_widget); GTK_WIDGET_SET_FLAGS (new_child, GTK_CAN_DEFAULT); gtk_container_add (GTK_CONTAINER (new_widget), new_child); } gb_widget_initialize (new_widget, data); (*data->callback) (new_widget, data); } gtk_widget_destroy (window); }
static GtkWidget * new_label (GtkWidget * parent) { GtkWidget *label; label = gb_widget_new ("GtkLabel", parent); g_return_val_if_fail (label != NULL, NULL); gb_widget_set_child_name (label,CListTitle); return label; }
/* * 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_app_setup_initial_app (GtkWidget *widget) { GtkWidget *placeholder, *toolbar; /* We create a standard menubar and toolbar which the user can edit or simply delete anything they don't want. */ glade_gnome_setup_initial_menus (widget); /* We need to get rid of the accelerators, since they aren't used, and they would override our default accelerators. */ gtk_window_remove_accel_group (GTK_WINDOW (widget), GNOME_APP (widget)->accel_group); /* FIXME: GnomeLibs bug workaround. It sets the initial border width to -2, which causes us lots of problems. */ #if 0 gtk_container_set_border_width (GTK_CONTAINER (GNOME_APP (widget)->menubar), 0); #endif gb_widget_create_from (GNOME_APP (widget)->menubar, "GtkMenubar"); gb_widget_create_from (GNOME_APP (widget)->menubar->parent, "BonoboDockItem"); /* Toolbar */ toolbar = gtk_toolbar_new (); gnome_app_set_toolbar (GNOME_APP (widget), GTK_TOOLBAR (toolbar)); gb_widget_create_from (toolbar, "GtkToolbar"); gb_widget_create_from (toolbar->parent, "BonoboDockItem"); gb_gnome_app_add_toolbar_button (GTK_TOOLBAR (toolbar), GTK_STOCK_NEW, _("New File")); gb_gnome_app_add_toolbar_button (GTK_TOOLBAR (toolbar), GTK_STOCK_OPEN, _("Open File")); gb_gnome_app_add_toolbar_button (GTK_TOOLBAR (toolbar), GTK_STOCK_SAVE, _("Save File")); /* Statusbar */ gnome_app_set_statusbar (GNOME_APP (widget), gb_widget_new ("GnomeAppBar", widget)); gb_widget_set_child_name (GNOME_APP (widget)->statusbar, GladeChildGnomeAppBar); /* We need to size the placeholders or the dialog is very small. */ placeholder = editor_new_placeholder (); gtk_widget_set_usize (placeholder, 300, 200); gnome_app_set_contents (GNOME_APP (widget), placeholder); }
static void on_druid_dialog_ok (GtkWidget * widget, GbWidgetNewData * data) { GtkWidget *new_widget, *spinbutton, *window, *page; gint pages, i; window = gtk_widget_get_toplevel (widget); /* Only call callback if placeholder/fixed widget is still there */ if (gb_widget_can_finish_new (data)) { spinbutton = gtk_object_get_data (GTK_OBJECT (window), "pages"); g_return_if_fail (spinbutton != NULL); pages = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spinbutton)); new_widget = gnome_druid_new (); page = gnome_druid_page_edge_new_aa (GNOME_EDGE_START); gb_widget_create_from (page, "GnomeDruidPageStart"); gnome_druid_append_page (GNOME_DRUID (new_widget), GNOME_DRUID_PAGE (page)); gnome_druid_set_page (GNOME_DRUID (new_widget), GNOME_DRUID_PAGE (page)); for (i = 0; i < pages - 2; i++) { page = gb_widget_new ("GnomeDruidPageStandard", new_widget); gnome_druid_append_page (GNOME_DRUID (new_widget), GNOME_DRUID_PAGE (page)); } if (pages >= 2) { page = gnome_druid_page_edge_new_aa (GNOME_EDGE_FINISH); gb_widget_create_from (page, "GnomeDruidPageFinish"); gnome_druid_append_page (GNOME_DRUID (new_widget), GNOME_DRUID_PAGE (page)); } gtk_widget_show_all (new_widget); gb_widget_initialize (new_widget, data); (*data->callback) (new_widget, data); } gtk_widget_destroy (window); }
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)); }
static void gb_bonobo_dock_item_add_item (BonoboDockItem * existing_dock_item, gboolean after) { BonoboDock *dock; BonoboDockBand *dock_band; GtkWidget *dock_item, *placeholder; BonoboDockPlacement placement; gint band_num, position, offset; if (!gb_bonobo_dock_item_find_position (BONOBO_DOCK_ITEM (existing_dock_item), &placement, &band_num, &position, &offset)) { g_warning ("Dock band not found"); return; } dock_band = BONOBO_DOCK_BAND (GTK_WIDGET (existing_dock_item)->parent); dock = BONOBO_DOCK (GTK_WIDGET (dock_band)->parent); /* Create the new dock item. */ dock_item = gb_widget_new ("BonoboDockItem", NULL); placeholder = editor_new_placeholder (); gtk_container_add (GTK_CONTAINER (dock_item), placeholder); /* Now add it at the required position. */ if (after) position++; bonobo_dock_add_item (dock, BONOBO_DOCK_ITEM (dock_item), placement, band_num, position, 0, FALSE); gtk_widget_show (dock_item); /* Show the properties of the new dock item. */ gb_widget_show_properties (dock_item); }
static void gb_gnome_app_add_toolbar_button (GtkToolbar *toolbar, const gchar *stock_id, const gchar *tooltip) { GtkWidget *button; GladeWidgetData *wdata; button = gb_widget_new ("GtkToolButton", NULL); gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (button), stock_id); gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (button), NULL); gtk_tool_button_set_label (GTK_TOOL_BUTTON (button), NULL); gtk_object_set_data_full (GTK_OBJECT (button), GladeToolButtonStockIDKey, g_strdup (stock_id), g_free); wdata = gtk_object_get_data (GTK_OBJECT (button), GB_WIDGET_DATA_KEY); wdata->tooltip = g_strdup (tooltip); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (button), -1); }
static void gb_menu_bar_on_edit_menu (GtkWidget *button, gpointer data) { GtkWidget *option, *menued, *menu; option = property_get_widget (); g_return_if_fail (GTK_IS_OPTION_MENU (option)); /* * we need to remove the menu from the option menu otherwise there * will be a separator where the selected menu is */ g_object_set_data (G_OBJECT (option), History, GINT_TO_POINTER (gtk_option_menu_get_history (GTK_OPTION_MENU (option)))); menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (option)); if (!menu) menu = gb_widget_new ("GtkMenu", option); g_object_ref (menu); gtk_option_menu_set_menu (GTK_OPTION_MENU (option), gtk_menu_new ()); menued = glade_menu_editor_new (current_project, GTK_MENU_SHELL (menu)); g_signal_connect (menued, "destroy", G_CALLBACK (set_menu), option); /* I think this was hidden as it doesn't call set_menu() to reset the history. */ gtk_widget_hide (GLADE_MENU_EDITOR (menued)->apply_button); dialogize (menued, button); gtk_widget_show (GTK_WIDGET (menued)); gtk_option_menu_set_menu (GTK_OPTION_MENU (option), menu); g_object_unref (menu); }
/* 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); } } }