static gboolean data_table_init (GnmDialogDataTable *state, WBCGtk *wbcg) { state->gui = gnm_gtk_builder_load ("data-table.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (state->gui == NULL) return TRUE; state->dialog = go_gtk_builder_get_widget (state->gui, "DataTable"); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); state->row_entry = init_entry (state, 0); state->col_entry = init_entry (state, 1); g_signal_connect (G_OBJECT (state->dialog), "response", G_CALLBACK (cb_data_table_response), state); gnm_init_help_button ( go_gtk_builder_get_widget (state->gui, "help"), GNUMERIC_HELP_LINK_DATA_TABLE); /* a candidate for merging into attach guru */ gnm_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog), DIALOG_DATA_TABLE_KEY); go_gtk_nonmodal_dialog (wbcg_toplevel (state->wbcg), GTK_WINDOW (state->dialog)); wbc_gtk_attach_guru (state->wbcg, state->dialog); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify)cb_data_table_destroy); gtk_widget_show_all (GTK_WIDGET (state->dialog)); return FALSE; }
static gboolean so_list_init (GnmDialogSOList *state, WBCGtk *wbcg, SheetObject *so) { GnmExprTop const *texpr; GtkBuilder *gui; gui = gnm_gtk_builder_load ("res:ui/so-list.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return TRUE; state->wbcg = wbcg; state->so = so; state->dialog = go_gtk_builder_get_widget (gui, "SOList"); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); texpr = sheet_widget_list_base_get_content_link (so); state->content_entry = init_entry (state, gui, 1, 4, texpr); if (texpr) gnm_expr_top_unref (texpr); texpr = sheet_widget_list_base_get_result_link (so); state->link_entry = init_entry (state, gui, 1, 0, texpr); if (texpr) gnm_expr_top_unref (texpr); state->as_index_radio = go_gtk_builder_get_widget (gui, "as-index-radio"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->as_index_radio), sheet_widget_list_base_result_type_is_index (so)); g_signal_connect (G_OBJECT (state->dialog), "response", G_CALLBACK (cb_so_list_response), state); gnm_init_help_button ( go_gtk_builder_get_widget (gui, "help"), GNUMERIC_HELP_LINK_SO_LIST); /* a candidate for merging into attach guru */ gnm_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog), DIALOG_SO_LIST_KEY); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, g_free); go_gtk_nonmodal_dialog (wbcg_toplevel (state->wbcg), GTK_WINDOW (state->dialog)); wbc_gtk_attach_guru (state->wbcg, state->dialog); gtk_widget_show_all (GTK_WIDGET (state->dialog)); g_object_unref (gui); return FALSE; }
void dialog_col_row (WBCGtk *wbcg, char const *operation, ColRowCallback_t callback, gpointer data) { GtkBuilder *gui; ColRowState *state; g_return_if_fail (wbcg != NULL); if (gnm_dialog_raise_if_exists (wbcg, COL_ROW_DIALOG_KEY)) return; gui = gnm_gtk_builder_load ("colrow.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; state = g_new (ColRowState, 1); state->wbcg = wbcg; state->callback = callback; state->data = data; state->gui = gui; state->dialog = go_gtk_builder_get_widget (state->gui, "dialog"); state->ok_button = go_gtk_builder_get_widget (state->gui, "ok_button"); g_signal_connect (G_OBJECT (state->ok_button), "clicked", G_CALLBACK (cb_dialog_col_row_ok_clicked), state); state->cancel_button = go_gtk_builder_get_widget (state->gui, "cancel_button"); g_signal_connect (G_OBJECT (state->cancel_button), "clicked", G_CALLBACK (cb_dialog_col_row_cancel_clicked), state); gnm_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_GROUP_UNGROUP); gtk_window_set_title (GTK_WINDOW (state->dialog), operation); wbc_gtk_attach_guru (state->wbcg, state->dialog); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_dialog_col_row_destroy); gnm_keyed_dialog (wbcg, GTK_WINDOW (state->dialog), COL_ROW_DIALOG_KEY); gtk_widget_show (state->dialog); }
static gboolean data_table_init (GnmDialogDataTable *state, WBCGtk *wbcg) { GtkTable *table; state->gui = gnm_glade_xml_new (GO_CMD_CONTEXT (wbcg), "data-table.glade", NULL, NULL); if (state->gui == NULL) return TRUE; state->dialog = glade_xml_get_widget (state->gui, "DataTable"); table = GTK_TABLE (glade_xml_get_widget (state->gui, "table")); state->row_entry = init_entry (state, "row-entry"); state->col_entry = init_entry (state, "col-entry"); g_signal_connect (G_OBJECT (state->dialog), "response", G_CALLBACK (cb_data_table_response), state); gnumeric_init_help_button ( glade_xml_get_widget (state->gui, "help"), GNUMERIC_HELP_LINK_DATA_TABLE); /* a candidate for merging into attach guru */ gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog), DIALOG_DATA_TABLE_KEY); go_gtk_nonmodal_dialog (wbcg_toplevel (state->wbcg), GTK_WINDOW (state->dialog)); wbc_gtk_attach_guru (state->wbcg, state->dialog); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify)cb_data_table_destroy); gtk_widget_show_all (GTK_WIDGET (state->dialog)); return FALSE; }
void dialog_sheet_order (WBCGtk *wbcg) { SheetManager *state; GtkBuilder *gui; GtkGrid *grid; GOColorGroup *cg; Workbook *wb; GtkWidget *widget; GdkPixbuf *icon; g_return_if_fail (wbcg != NULL); widget = GTK_WIDGET (wbcg_toplevel (wbcg)); gui = gnm_gtk_builder_load ("res:ui/sheet-order.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; wb = wb_control_get_workbook (GNM_WBC (wbcg)); if (g_object_get_data (G_OBJECT (wb), SHEET_ORDER_KEY)) { GtkWidget *dialog = gtk_message_dialog_new (wbcg_toplevel (wbcg), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, _("Another view is already managing sheets")); go_gtk_dialog_run (GTK_DIALOG (dialog), wbcg_toplevel (wbcg)); return; } g_object_set_data (G_OBJECT (wb), SHEET_ORDER_KEY, (gpointer) gui); state = g_new0 (SheetManager, 1); state->gui = gui; state->wbcg = wbcg; state->dialog = go_gtk_builder_get_widget (gui, "sheet-order-dialog"); state->warning = go_gtk_builder_get_widget (gui, "warning"); state->up_btn = go_gtk_builder_get_widget (gui, "up_button"); state->down_btn = go_gtk_builder_get_widget (gui, "down_button"); state->add_btn = go_gtk_builder_get_widget (gui, "add_button"); state->append_btn = go_gtk_builder_get_widget (gui, "append_button"); state->duplicate_btn = go_gtk_builder_get_widget (gui, "duplicate_button"); state->delete_btn = go_gtk_builder_get_widget (gui, "delete_button"); state->apply_names_btn = go_gtk_builder_get_widget (gui, "ok_button"); state->sort_asc_btn = go_gtk_builder_get_widget (gui, "sort-asc-button"); state->sort_desc_btn = go_gtk_builder_get_widget (gui, "sort-desc-button"); state->undo_btn = go_gtk_builder_get_widget (gui, "undo-button"); state->cancel_btn = go_gtk_builder_get_widget (gui, "cancel_button"); state->advanced_check = go_gtk_builder_get_widget (gui, "advanced-check"); state->initial_colors_set = FALSE; state->image_padlock = go_gtk_widget_render_icon_pixbuf (widget, "gnumeric-protection-yes", GTK_ICON_SIZE_MENU); state->image_padlock_no = go_gtk_widget_render_icon_pixbuf (widget, "gnumeric-protection-no", GTK_ICON_SIZE_MENU); state->image_visible = go_gtk_widget_render_icon_pixbuf (widget, "gnumeric-visible", GTK_ICON_SIZE_MENU); state->image_ltr = go_gtk_widget_render_icon_pixbuf (widget, "format-text-direction-ltr", GTK_ICON_SIZE_MENU); state->image_rtl = go_gtk_widget_render_icon_pixbuf (widget, "format-text-direction-rtl", GTK_ICON_SIZE_MENU); /* Listen for changes in the sheet order. */ state->sheet_order_changed_listener = g_signal_connect (G_OBJECT (wb), "sheet_order_changed", G_CALLBACK (cb_sheet_order_changed), state); state->sheet_added_listener = g_signal_connect (G_OBJECT (wb), "sheet_added", G_CALLBACK (cb_sheet_added), state); state->sheet_deleted_listener = g_signal_connect (G_OBJECT (wb), "sheet_deleted", G_CALLBACK (cb_sheet_deleted), state); grid = GTK_GRID (go_gtk_builder_get_widget (gui,"main-grid")); cg = go_color_group_fetch ("back_color_group", wb_control_view (GNM_WBC (wbcg))); icon = go_gtk_widget_render_icon_pixbuf (widget, "gnumeric-bucket", GTK_ICON_SIZE_LARGE_TOOLBAR); state->ccombo_back = go_combo_color_new (icon, _("Default"), 0, cg); g_object_unref (icon); g_object_unref (cg); go_combo_color_set_instant_apply ( GO_COMBO_COLOR (state->ccombo_back), TRUE); gtk_grid_attach (grid, state->ccombo_back, 1, 4, 1, 1); gtk_widget_set_sensitive (state->ccombo_back, FALSE); cg = go_color_group_fetch ("fore_color_group", wb_control_view (GNM_WBC (wbcg))); icon = go_gtk_widget_render_icon_pixbuf (widget, "font", GTK_ICON_SIZE_LARGE_TOOLBAR); state->ccombo_fore = go_combo_color_new (icon, _("Default"), 0, cg); g_object_unref (icon); g_object_unref (cg); go_combo_color_set_instant_apply ( GO_COMBO_COLOR (state->ccombo_fore), TRUE); gtk_grid_attach (grid, state->ccombo_fore, 2, 4, 1, 1); gtk_widget_set_sensitive (state->ccombo_fore, FALSE); create_sheet_list (state); populate_sheet_list (state); #define CONNECT(o,s,c) g_signal_connect(G_OBJECT(o),s,G_CALLBACK(c),state) CONNECT (state->up_btn, "clicked", cb_up); CONNECT (state->down_btn, "clicked", cb_down); CONNECT (state->sort_asc_btn, "clicked", cb_asc); CONNECT (state->sort_desc_btn, "clicked", cb_desc); CONNECT (state->add_btn, "clicked", cb_add_clicked); CONNECT (state->append_btn, "clicked", cb_append_clicked); CONNECT (state->duplicate_btn, "clicked", cb_duplicate_clicked); CONNECT (state->delete_btn, "clicked", cb_delete_clicked); CONNECT (state->apply_names_btn, "clicked", cb_apply_names_clicked); CONNECT (state->cancel_btn, "clicked", cb_cancel_clicked); CONNECT (state->undo_btn, "clicked", cb_undo_clicked); CONNECT (state->advanced_check, "toggled", cb_adv_check_toggled); CONNECT (state->ccombo_back, "color_changed", cb_color_changed_back); CONNECT (state->ccombo_fore, "color_changed", cb_color_changed_fore); CONNECT (state->model, "rows-reordered", cb_dialog_order_changed); state->model_row_insertion_listener = CONNECT (state->model, "row-inserted", cb_dialog_order_changed_by_insertion); #undef CONNECT cb_adv_check_toggled (NULL, state); gnm_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_SHEET_MANAGER); gtk_widget_set_sensitive (state->undo_btn, wb->undo_commands != NULL); gtk_widget_set_sensitive (state->apply_names_btn, FALSE); /* a candidate for merging into attach guru */ wbc_gtk_attach_guru (state->wbcg, GTK_WIDGET (state->dialog)); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_sheet_order_destroy); g_signal_connect (G_OBJECT (state->dialog), "destroy", G_CALLBACK (destroy_cb), NULL); gnm_restore_window_geometry (GTK_WINDOW (state->dialog), SHEET_ORDER_KEY); go_gtk_nonmodal_dialog (wbcg_toplevel (state->wbcg), GTK_WINDOW (state->dialog)); gtk_widget_show_all (GTK_WIDGET (state->dialog)); }
void dialog_delete_cells (WBCGtk *wbcg) { DeleteCellState *state; WorkbookControl *wbc = GNM_WBC (wbcg); SheetView *sv = wb_control_cur_sheet_view (wbc); Sheet *sheet = sv_sheet (sv); GnmRange const *sel; GtkBuilder *gui; GtkWidget *w; int cols, rows; g_return_if_fail (wbcg != NULL); if (!(sel = selection_first_range (sv, GO_CMD_CONTEXT (wbc), _("Delete")))) return; cols = sel->end.col - sel->start.col + 1; rows = sel->end.row - sel->start.row + 1; if (range_is_full (sel, sheet, FALSE)) { cmd_delete_cols (wbc, sheet, sel->start.col, cols); return; } if (range_is_full (sel, sheet, TRUE)) { cmd_delete_rows (wbc, sheet, sel->start.row, rows); return; } if (gnm_dialog_raise_if_exists (wbcg, DELETE_CELL_DIALOG_KEY)) return; gui = gnm_gtk_builder_load ("res:ui/delete-cells.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; state = g_new (DeleteCellState, 1); state->wbcg = wbcg; state->sel = sel; state->gui = gui; state->sheet = sv_sheet (sv); state->dialog = go_gtk_builder_get_widget (state->gui, "Delete_cells"); if (state->dialog == NULL) { go_gtk_notice_dialog (wbcg_toplevel (wbcg), GTK_MESSAGE_ERROR, _("Could not create the Delete Cell dialog.")); g_free (state); return ; } w = go_gtk_builder_get_widget (state->gui, "okbutton"); g_signal_connect_swapped (G_OBJECT (w), "clicked", G_CALLBACK (cb_delete_cell_ok_clicked), state); w = go_gtk_builder_get_widget (state->gui, "cancelbutton"); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (cb_delete_cell_cancel_clicked), state); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); gnm_init_help_button ( go_gtk_builder_get_widget (state->gui, "helpbutton"), GNUMERIC_HELP_LINK_DELETE_CELLS); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (go_gtk_builder_get_widget (state->gui, cols < rows ? "radio_0" : "radio_1")), TRUE); wbc_gtk_attach_guru (state->wbcg, state->dialog); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_delete_cell_destroy); gnm_keyed_dialog (wbcg, GTK_WINDOW (state->dialog), DELETE_CELL_DIALOG_KEY); gtk_widget_show (state->dialog); }
void dialog_so_styled (WBCGtk *wbcg, GObject *so, GOStyle *default_style, char const *title, so_styled_t extent) { DialogSOStyled *state; GtkWidget *dialog, *help, *editor; GOStyle *style; /* Only pop up one copy per workbook */ if (gnm_dialog_raise_if_exists (wbcg, GNM_SO_STYLED_KEY)) { g_object_unref (default_style); return; } state = g_new0 (DialogSOStyled, 1); state->so = G_OBJECT (so); state->wbcg = wbcg; state->orig_props = go_object_properties_collect (so); force_new_style (state->so); dialog = gtk_dialog_new_with_buttons (title, wbcg_toplevel (state->wbcg), GTK_DIALOG_DESTROY_WITH_PARENT, NULL, NULL); state->extent = extent; gnm_dialog_setup_destroy_handlers (GTK_DIALOG (dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); help = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_HELP, GTK_RESPONSE_HELP); gnm_init_help_button (help, "sect-graphics-drawings"); gtk_dialog_add_buttons (GTK_DIALOG (dialog), GNM_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GNM_STOCK_OK, GTK_RESPONSE_OK, NULL); g_object_get (so, "style", &style, NULL); editor = go_style_get_editor (style, default_style, GO_CMD_CONTEXT (wbcg), G_OBJECT (so)); g_object_unref (style); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), editor, TRUE, TRUE, TRUE); g_object_unref (default_style); if (extent & SO_STYLED_TEXT) { GtkWidget *text_w = dialog_so_styled_text_widget (state); gtk_widget_show_all (text_w); if (GTK_IS_NOTEBOOK (editor)) gtk_notebook_append_page (GTK_NOTEBOOK (editor), text_w, gtk_label_new (_("Content"))); else gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), text_w, TRUE, TRUE, TRUE); } if (extent & SO_STYLED_LINE) { GtkWidget *w = dialog_so_styled_line_widget (state, "end-arrow"); gtk_widget_show_all (w); if (GTK_IS_NOTEBOOK (editor)) gtk_notebook_append_page (GTK_NOTEBOOK (editor), w, gtk_label_new (_("Head"))); else gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), w, TRUE, TRUE, TRUE); } if (extent & SO_STYLED_LINE) { GtkWidget *w = dialog_so_styled_line_widget (state, "start-arrow"); gtk_widget_show_all (w); if (GTK_IS_NOTEBOOK (editor)) gtk_notebook_append_page (GTK_NOTEBOOK (editor), w, gtk_label_new (_("Tail"))); else gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), w, TRUE, TRUE, TRUE); } g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (cb_dialog_so_styled_response), state); gnm_keyed_dialog (state->wbcg, GTK_WINDOW (dialog), GNM_SO_STYLED_KEY); g_object_set_data_full (G_OBJECT (dialog), "state", state, (GDestroyNotify) dialog_so_styled_free); go_gtk_nonmodal_dialog (wbcg_toplevel (state->wbcg), GTK_WINDOW (dialog)); wbc_gtk_attach_guru (state->wbcg, dialog); gtk_widget_show (dialog); }
void dialog_tabulate (WBCGtk *wbcg, Sheet *sheet) { GtkBuilder *gui; GtkDialog *dialog; DialogState *dd; int i; g_return_if_fail (wbcg != NULL); /* Only one guru per workbook. */ if (wbc_gtk_get_guru (wbcg)) return; if (gnm_dialog_raise_if_exists (wbcg, TABULATE_KEY)) return; gui = gnm_gtk_builder_load ("tabulate.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; dialog = GTK_DIALOG (go_gtk_builder_get_widget (gui, "tabulate_dialog")); dd = g_new (DialogState, 1); dd->wbcg = wbcg; dd->gui = gui; dd->dialog = dialog; dd->sheet = sheet; dd->grid = GTK_GRID (go_gtk_builder_get_widget (gui, "main-grid")); /* we might get the 4 below from the positon of some of the widgets inside the grid */ for (i = 1; i < 4; i++) { GnmExprEntry *ge = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (ge, GNM_EE_SINGLE_RANGE | GNM_EE_SHEET_OPTIONAL, GNM_EE_MASK); gtk_grid_attach (dd->grid, GTK_WIDGET (ge), COL_CELL, i + 1, 1, 1); gtk_widget_set_margin_left (GTK_WIDGET (ge), 18); gtk_widget_show (GTK_WIDGET (ge)); } dd->resultrangetext = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (dd->resultrangetext, GNM_EE_SINGLE_RANGE | GNM_EE_SHEET_OPTIONAL, GNM_EE_MASK); gtk_grid_attach (dd->grid, GTK_WIDGET (dd->resultrangetext), 0, 6, 4, 1); gtk_widget_set_margin_left (GTK_WIDGET (dd->resultrangetext), 18); gtk_widget_show (GTK_WIDGET (dd->resultrangetext)); g_signal_connect (G_OBJECT (go_gtk_builder_get_widget (gui, "ok_button")), "clicked", G_CALLBACK (tabulate_ok_clicked), dd); g_signal_connect (G_OBJECT (go_gtk_builder_get_widget (gui, "cancel_button")), "clicked", G_CALLBACK (cancel_clicked), dd); /* FIXME: Add correct helpfile address */ gnm_init_help_button ( go_gtk_builder_get_widget (gui, "help_button"), GNUMERIC_HELP_LINK_TABULATE); g_object_set_data_full (G_OBJECT (dialog), "state", dd, (GDestroyNotify) cb_dialog_destroy); gnm_dialog_setup_destroy_handlers (dialog, wbcg, GNM_DIALOG_DESTROY_SHEET_REMOVED); gtk_widget_show_all (gtk_dialog_get_content_area (dialog)); wbc_gtk_attach_guru (wbcg, GTK_WIDGET (dialog)); non_model_dialog (wbcg, dialog, TABULATE_KEY); }
void dialog_row_height (WBCGtk *wbcg, gboolean use_default) { RowHeightState *state; g_return_if_fail (wbcg != NULL); if (gnm_dialog_raise_if_exists (wbcg, ROW_HEIGHT_DIALOG_KEY)) return; state = g_new (RowHeightState, 1); state->wbcg = wbcg; state->sv = wb_control_cur_sheet_view (GNM_WBC (wbcg)); state->sheet = sv_sheet (state->sv); state->adjusting = FALSE; state->gui = gnm_gtk_builder_load ("row-height.ui", NULL, GO_CMD_CONTEXT (wbcg)); g_return_if_fail (state->gui != NULL); state->dialog = go_gtk_builder_get_widget (state->gui, "dialog"); state->description = GTK_WIDGET (go_gtk_builder_get_widget (state->gui, "description")); state->points = GTK_WIDGET (go_gtk_builder_get_widget (state->gui, "pts-label")); state->spin = GTK_SPIN_BUTTON (go_gtk_builder_get_widget (state->gui, "spin")); gtk_adjustment_set_lower (gtk_spin_button_get_adjustment (state->spin), GNM_ROW_MARGIN + GNM_ROW_MARGIN + 1); g_signal_connect (G_OBJECT (state->spin), "value-changed", G_CALLBACK (cb_dialog_row_height_value_changed), state); state->default_check = GTK_WIDGET (go_gtk_builder_get_widget (state->gui, "default_check")); g_signal_connect (G_OBJECT (state->default_check), "clicked", G_CALLBACK (cb_dialog_row_height_default_check_toggled), state); state->ok_button = go_gtk_builder_get_widget (state->gui, "ok_button"); g_signal_connect (G_OBJECT (state->ok_button), "clicked", G_CALLBACK (cb_dialog_row_height_ok_clicked), state); state->apply_button = go_gtk_builder_get_widget (state->gui, "apply_button"); g_signal_connect (G_OBJECT (state->apply_button), "clicked", G_CALLBACK (cb_dialog_row_height_apply_clicked), state); state->cancel_button = go_gtk_builder_get_widget (state->gui, "cancel_button"); g_signal_connect (G_OBJECT (state->cancel_button), "clicked", G_CALLBACK (cb_dialog_row_height_cancel_clicked), state); gnm_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_ROW_HEIGHT); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_dialog_row_height_destroy); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); dialog_row_height_set_mode (use_default, state); dialog_row_height_load_value (state); wbc_gtk_attach_guru (state->wbcg, state->dialog); gnm_keyed_dialog (wbcg, GTK_WINDOW (state->dialog), ROW_HEIGHT_DIALOG_KEY); gtk_widget_show (state->dialog); }
void dialog_cell_comment (WBCGtk *wbcg, Sheet *sheet, GnmCellPos const *pos) { CommentState *state; GtkWidget *box, *check, *old_author, *new_author; GnmComment *comment; GtkBuilder *gui; char *title, *cell_name; char const*real_user; GnmCellRef ref; GnmParsePos pp; GnmConventionsOut out; g_return_if_fail (wbcg != NULL); g_return_if_fail (sheet != NULL); g_return_if_fail (pos != NULL); if (gnumeric_dialog_raise_if_exists (wbcg, COMMENT_DIALOG_KEY)) return; gui = gnm_gtk_builder_new ("cell-comment.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; state = g_new (CommentState, 1); state->wbcg = wbcg; state->sheet = sheet; state->pos = pos; state->gui = gui; state->dialog = go_gtk_builder_get_widget (state->gui, "comment_dialog"); g_return_if_fail (state->dialog != NULL); box = go_gtk_builder_get_widget (state->gui, "dialog-vbox"); g_return_if_fail (box != NULL); state->gtv = gnm_text_view_new (); gtk_widget_show_all (GTK_WIDGET (state->gtv)); gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (state->gtv), TRUE, TRUE, TRUE); g_object_set (state->gtv, "wrap", GTK_WRAP_WORD, NULL); gnm_cellref_init (&ref, sheet, pos->col, pos->row, FALSE); out.accum = g_string_new (NULL); parse_pos_init_sheet (&pp, sheet); out.pp = &pp; out.convs = sheet->convs; cellref_as_string (&out, &ref, FALSE); cell_name = g_string_free (out.accum, FALSE); old_author = go_gtk_builder_get_widget (state->gui, "old-author-entry"); new_author = go_gtk_builder_get_widget (state->gui, "new-author-entry"); real_user = g_get_real_name (); if ((real_user != NULL) && g_utf8_validate (real_user, -1, NULL)) { gtk_entry_set_text (GTK_ENTRY (new_author), real_user); gtk_editable_select_region (GTK_EDITABLE (new_author), 0, -1); } comment = sheet_get_comment (sheet, pos); if (comment) { char const *text; PangoAttrList *attr; g_object_get (G_OBJECT (comment), "text", &text, "markup", &attr, NULL); g_object_set (state->gtv, "text", text, "attributes", attr, NULL); if (attr != NULL) pango_attr_list_unref (attr); text = cell_comment_author_get (comment); if (text != NULL) gtk_label_set_text (GTK_LABEL (old_author), text); title = g_strdup_printf (_("Edit Cell Comment (%s)"), cell_name); } else { title = g_strdup_printf (_("New Cell Comment (%s)"), cell_name); gtk_widget_hide (old_author); gtk_widget_hide (go_gtk_builder_get_widget (state->gui, "old-author-label")); } gtk_window_set_title (GTK_WINDOW (state->dialog), title); g_free (title); state->ok_button = go_gtk_builder_get_widget (state->gui, "ok_button"); g_signal_connect (G_OBJECT (state->ok_button), "clicked", G_CALLBACK (cb_cell_comment_ok_clicked), state); state->cancel_button = go_gtk_builder_get_widget (state->gui, "cancel_button"); g_signal_connect (G_OBJECT (state->cancel_button), "clicked", G_CALLBACK (cb_cell_comment_cancel_clicked), state); check = go_gtk_builder_get_widget (state->gui, "wrap-check"); g_signal_connect (G_OBJECT (check), "toggled", G_CALLBACK (cb_wrap_toggled), state->gtv); cb_wrap_toggled (GTK_TOGGLE_BUTTON (check), G_OBJECT (state->gtv)); gnumeric_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_CELL_COMMENT); wbc_gtk_attach_guru (state->wbcg, state->dialog); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_dialog_cell_comment_destroy); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog), COMMENT_DIALOG_KEY); gtk_widget_show (state->dialog); }
/** * dialog_init: * @state: * * Create the dialog (guru). * **/ static gboolean dialog_goto_init (GotoState *state) { GtkTable *table; GtkWidget *scrolled; GtkTreeViewColumn *column; table = GTK_TABLE (go_gtk_builder_get_widget (state->gui, "names")); state->goto_text = GTK_ENTRY (gtk_entry_new ()); gtk_table_attach (table, GTK_WIDGET (state->goto_text), 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0); g_signal_connect_after (G_OBJECT (state->goto_text), "changed", G_CALLBACK (cb_dialog_goto_update_sensitivity), state); state->spin_rows = GTK_SPIN_BUTTON (go_gtk_builder_get_widget (state->gui, "spin-rows")); state->spin_cols = GTK_SPIN_BUTTON (go_gtk_builder_get_widget (state->gui, "spin-columns")); /* Set-up treeview */ scrolled = go_gtk_builder_get_widget (state->gui, "scrolled"); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_ETCHED_IN); state->model = gtk_tree_store_new (NUM_COLMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER); state->treeview = GTK_TREE_VIEW ( gtk_tree_view_new_with_model (GTK_TREE_MODEL (state->model))); state->selection = gtk_tree_view_get_selection (state->treeview); gtk_tree_selection_set_mode (state->selection, GTK_SELECTION_BROWSE); g_signal_connect (state->selection, "changed", G_CALLBACK (cb_dialog_goto_selection_changed), state); column = gtk_tree_view_column_new_with_attributes (_("Sheet"), gtk_cell_renderer_text_new (), "text", SHEET_NAME, NULL); gtk_tree_view_column_set_sort_column_id (column, SHEET_NAME); gtk_tree_view_append_column (state->treeview, column); column = gtk_tree_view_column_new_with_attributes (_("Cell"), gtk_cell_renderer_text_new (), "text", ITEM_NAME, NULL); gtk_tree_view_column_set_sort_column_id (column, ITEM_NAME); gtk_tree_view_append_column (state->treeview, column); gtk_tree_view_set_headers_visible (state->treeview, TRUE); gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (state->treeview)); dialog_goto_load_names (state); /* Finished set-up of treeview */ /* Listen for sheet changes */ state->sheet_order_changed_listener = g_signal_connect (G_OBJECT (state->wb), "sheet_order_changed", G_CALLBACK (cb_sheet_order_changed), state); state->sheet_added_listener = g_signal_connect (G_OBJECT (state->wb), "sheet_added", G_CALLBACK (cb_sheet_added), state); state->sheet_deleted_listener = g_signal_connect (G_OBJECT (state->wb), "sheet_deleted", G_CALLBACK (cb_sheet_deleted), state); state->close_button = go_gtk_builder_get_widget (state->gui, "close_button"); g_signal_connect (G_OBJECT (state->close_button), "clicked", G_CALLBACK (cb_dialog_goto_close_clicked), state); state->go_button = go_gtk_builder_get_widget (state->gui, "go_button"); g_signal_connect (G_OBJECT (state->go_button), "clicked", G_CALLBACK (cb_dialog_goto_go_clicked), state); gtk_window_set_default (GTK_WINDOW (state->dialog), state->go_button); gnumeric_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_GOTO_CELL); dialog_goto_load_selection (state); wbc_gtk_attach_guru (state->wbcg, state->dialog); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_dialog_goto_free); return FALSE; }
void dialog_zoom (WBCGtk *wbcg, Sheet *sheet) { ZoomState *state; GSList *l, *sheets; int i, row, cur_row; gboolean is_custom = TRUE; GtkRadioButton *radio; GtkWidget *focus_target; GladeXML *gui; GtkTreeViewColumn *column; g_return_if_fail (wbcg != NULL); g_return_if_fail (sheet != NULL); if (gnumeric_dialog_raise_if_exists (wbcg, ZOOM_DIALOG_KEY)) return; gui = gnm_glade_xml_new (GO_CMD_CONTEXT (wbcg), "dialog-zoom.glade", NULL, NULL); if (gui == NULL) return; state = g_new (ZoomState, 1); state->wbcg = wbcg; state->gui = gui; state->dialog = glade_xml_get_widget (state->gui, "Zoom"); g_return_if_fail (state->dialog != NULL); /* Get the list of sheets */ state->sheet_list_model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); state->sheet_list = GTK_TREE_VIEW (glade_xml_get_widget (state->gui, "sheet_list")); gtk_tree_view_set_headers_visible (state->sheet_list, FALSE); gtk_tree_view_set_model (state->sheet_list, GTK_TREE_MODEL (state->sheet_list_model)); state->sheet_list_selection = gtk_tree_view_get_selection (state->sheet_list); gtk_tree_selection_set_mode (state->sheet_list_selection, GTK_SELECTION_MULTIPLE); column = gtk_tree_view_column_new_with_attributes (_("Name"), gtk_cell_renderer_text_new (), "text", 0, NULL); gtk_tree_view_column_set_sort_column_id (column, COL_SHEET_NAME); gtk_tree_view_append_column (GTK_TREE_VIEW (state->sheet_list), column); sheets = workbook_sheets (wb_control_get_workbook (WORKBOOK_CONTROL (wbcg))); cur_row = row = 0; for (l = sheets; l; l = l->next) { GtkTreeIter iter; Sheet *this_sheet = l->data; gtk_list_store_append (state->sheet_list_model, &iter); gtk_list_store_set (state->sheet_list_model, &iter, COL_SHEET_NAME, this_sheet->name_unquoted, COL_SHEET_PTR, this_sheet, -1); if (this_sheet == sheet) cur_row = row; row++; } g_slist_free (sheets); { GtkTreePath *path = gtk_tree_path_new_from_indices (cur_row, -1); gtk_tree_view_set_cursor (state->sheet_list, path, NULL, FALSE); gtk_tree_path_free (path); } state->zoom = GTK_SPIN_BUTTON (glade_xml_get_widget (state->gui, "zoom")); g_return_if_fail (state->zoom != NULL); state->custom = GTK_RADIO_BUTTON (glade_xml_get_widget (state->gui, "radio_custom")); g_return_if_fail (state->custom != NULL); focus_target = GTK_WIDGET (state->custom); g_signal_connect (G_OBJECT (state->custom), "clicked", G_CALLBACK (focus_to_custom), (gpointer) state); g_signal_connect (G_OBJECT (state->zoom), "focus_in_event", G_CALLBACK (custom_selected), state); for (i = 0; buttons[i].name != NULL; i++) { radio = GTK_RADIO_BUTTON (glade_xml_get_widget (state->gui, buttons[i].name)); g_return_if_fail (radio != NULL); g_object_set_data (G_OBJECT (radio), ZOOM_DIALOG_FACTOR_KEY, GINT_TO_POINTER(buttons[i].factor)); g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (radio_toggled), state); if (((int)(sheet->last_zoom_factor_used * 100. + .5)) == buttons[i].factor) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); is_custom = FALSE; focus_target = GTK_WIDGET (radio); } } if (is_custom) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->custom), TRUE); gtk_spin_button_set_value (state->zoom, (int)(sheet->last_zoom_factor_used * 100. + .5)); } state->ok_button = glade_xml_get_widget (state->gui, "ok_button"); g_signal_connect (G_OBJECT (state->ok_button), "clicked", G_CALLBACK (cb_zoom_ok_clicked), state); state->cancel_button = glade_xml_get_widget (state->gui, "cancel_button"); g_signal_connect (G_OBJECT (state->cancel_button), "clicked", G_CALLBACK (cb_zoom_cancel_clicked), state); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (&state->zoom->entry)); gnumeric_init_help_button ( glade_xml_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_ZOOM); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), wbcg, GNM_DIALOG_DESTROY_SHEET_REMOVED); gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog), ZOOM_DIALOG_KEY); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_zoom_destroy); wbc_gtk_attach_guru (state->wbcg, state->dialog); gtk_widget_show (state->dialog); gtk_widget_grab_focus (focus_target); }
/** * dialog_init: * @state: * * Create the dialog (guru). * **/ static gboolean dialog_init (SolverState *state) { GtkGrid *grid; GnmSolverParameters *param; GtkCellRenderer *renderer; GtkListStore *store; GtkTreeViewColumn *column; GSList *cl; GnmCell *target_cell; GnmValue const *input; int i; param = state->sheet->solver_parameters; state->gui = gnm_gtk_builder_load ("solver.ui", NULL, GO_CMD_CONTEXT (state->wbcg)); if (state->gui == NULL) return TRUE; state->dialog = go_gtk_builder_get_widget (state->gui, "Solver"); if (state->dialog == NULL) return TRUE; state->notebook = go_gtk_builder_get_widget (state->gui, "solver_notebook"); /* buttons */ state->solve_button = go_gtk_builder_get_widget (state->gui, "solvebutton"); g_signal_connect (G_OBJECT (state->solve_button), "clicked", G_CALLBACK (cb_dialog_solve_clicked), state); state->close_button = go_gtk_builder_get_widget (state->gui, "closebutton"); g_signal_connect (G_OBJECT (state->close_button), "clicked", G_CALLBACK (cb_dialog_close_clicked), state); state->help_button = go_gtk_builder_get_widget (state->gui, "helpbutton"); gnm_init_help_button (state->help_button, GNUMERIC_HELP_LINK_SOLVER); state->add_button = go_gtk_builder_get_widget (state->gui, "addbutton"); gtk_button_set_alignment (GTK_BUTTON (state->add_button), 0.5, .5); g_signal_connect_swapped (G_OBJECT (state->add_button), "clicked", G_CALLBACK (cb_dialog_add_clicked), state); state->change_button = go_gtk_builder_get_widget (state->gui, "changebutton"); g_signal_connect (G_OBJECT (state->change_button), "clicked", G_CALLBACK (cb_dialog_change_clicked), state); state->delete_button = go_gtk_builder_get_widget (state->gui, "deletebutton"); gtk_button_set_alignment (GTK_BUTTON (state->delete_button), 0.5, .5); g_signal_connect (G_OBJECT (state->delete_button), "clicked", G_CALLBACK (cb_dialog_delete_clicked), state); state->stop_button = go_gtk_builder_get_widget (state->gui, "stopbutton"); g_signal_connect_swapped (G_OBJECT (state->stop_button), "clicked", G_CALLBACK (cb_stop_solver), state); /* target_entry */ grid = GTK_GRID (go_gtk_builder_get_widget (state->gui, "parameter-grid")); state->target_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->target_entry, GNM_EE_SINGLE_RANGE | GNM_EE_FORCE_ABS_REF | GNM_EE_SHEET_OPTIONAL, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->target_entry), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->target_entry), 1, 0, 2, 1); gnm_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->target_entry)); gtk_widget_show (GTK_WIDGET (state->target_entry)); g_signal_connect_after (G_OBJECT (state->target_entry), "changed", G_CALLBACK (dialog_set_main_button_sensitivity), state); /* change_cell_entry */ state->change_cell_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->change_cell_entry, GNM_EE_SINGLE_RANGE | GNM_EE_FORCE_ABS_REF | GNM_EE_SHEET_OPTIONAL, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->change_cell_entry), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->change_cell_entry), 1, 2, 2, 1); gnm_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->change_cell_entry)); gtk_widget_show (GTK_WIDGET (state->change_cell_entry)); g_signal_connect_after (G_OBJECT (state->change_cell_entry), "changed", G_CALLBACK (dialog_set_main_button_sensitivity), state); /* Algorithm */ state->algorithm_combo = GTK_COMBO_BOX (go_gtk_builder_get_widget (state->gui, "algorithm_combo")); renderer = (GtkCellRenderer*) gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (state->algorithm_combo), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (state->algorithm_combo), renderer, "text", 0, NULL); fill_algorithm_combo (state, param->options.model_type); for (i = 0; model_type_group[i]; i++) { const char *bname = model_type_group[i]; GtkWidget *w = go_gtk_builder_get_widget(state->gui, bname); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), param->options.model_type == (GnmSolverModelType)i); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (cb_dialog_model_type_clicked), state); } /* Options */ state->max_iter_entry = go_gtk_builder_get_widget (state->gui, "max_iter_entry"); gtk_spin_button_set_value (GTK_SPIN_BUTTON (state->max_iter_entry), param->options.max_iter); state->max_time_entry = go_gtk_builder_get_widget (state->gui, "max_time_entry"); gtk_spin_button_set_value (GTK_SPIN_BUTTON (state->max_time_entry), param->options.max_time_sec); state->gradient_order_entry = go_gtk_builder_get_widget (state->gui, "gradient_order_entry"); gtk_spin_button_set_value (GTK_SPIN_BUTTON (state->gradient_order_entry), param->options.gradient_order); /* lhs_entry */ grid = GTK_GRID (go_gtk_builder_get_widget (state->gui, "constraints-grid")); state->lhs.entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->lhs.entry, GNM_EE_SINGLE_RANGE | GNM_EE_FORCE_ABS_REF | GNM_EE_SHEET_OPTIONAL, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->lhs.entry), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->lhs.entry), 0, 4, 1, 1); state->lhs.label = go_gtk_builder_get_widget (state->gui, "lhs_label"); gtk_label_set_mnemonic_widget (GTK_LABEL (state->lhs.label), GTK_WIDGET (state->lhs.entry)); gtk_widget_show (GTK_WIDGET (state->lhs.entry)); g_signal_connect_after (G_OBJECT (state->lhs.entry), "changed", G_CALLBACK (dialog_set_sec_button_sensitivity), state); g_signal_connect_swapped ( gnm_expr_entry_get_entry (GNM_EXPR_ENTRY (state->lhs.entry)), "activate", G_CALLBACK (cb_dialog_add_clicked), state); /* rhs_entry */ state->rhs.entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->rhs.entry, GNM_EE_SINGLE_RANGE | GNM_EE_FORCE_ABS_REF | GNM_EE_SHEET_OPTIONAL | GNM_EE_CONSTANT_ALLOWED, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->rhs.entry), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->rhs.entry), 2, 4, 1, 1); gtk_widget_show (GTK_WIDGET (state->rhs.entry)); state->rhs.label = go_gtk_builder_get_widget (state->gui, "rhs_label"); gtk_label_set_mnemonic_widget ( GTK_LABEL (state->rhs.label), GTK_WIDGET (state->rhs.entry)); g_signal_connect_after (G_OBJECT (state->rhs.entry), "changed", G_CALLBACK (dialog_set_sec_button_sensitivity), state); g_signal_connect_swapped ( gnm_expr_entry_get_entry (GNM_EXPR_ENTRY (state->rhs.entry)), "activate", G_CALLBACK (cb_dialog_add_clicked), state); /* type_menu */ state->type_combo = GTK_COMBO_BOX (go_gtk_builder_get_widget (state->gui, "type_menu")); gtk_combo_box_set_active (state->type_combo, 0); g_signal_connect (state->type_combo, "changed", G_CALLBACK (dialog_set_sec_button_sensitivity), state); /* constraint_list */ state->constraint_list = GTK_TREE_VIEW (go_gtk_builder_get_widget (state->gui, "constraint_list")); state->constr = NULL; g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (state->constraint_list)), "changed", G_CALLBACK (constraint_select_click), state); gtk_tree_view_set_reorderable (state->constraint_list, TRUE); store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); gtk_tree_view_set_model (state->constraint_list, GTK_TREE_MODEL(store)); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ( _("Subject to the Constraints:"), renderer, "text", 0, NULL); gtk_tree_view_column_set_expand (column, TRUE); gtk_tree_view_append_column (state->constraint_list, column); { GtkWidget *w = GTK_WIDGET (state->constraint_list); int width, height, vsep; PangoLayout *layout = gtk_widget_create_pango_layout (w, "Mg19"); gtk_widget_style_get (w, "vertical_separator", &vsep, NULL); pango_layout_get_pixel_size (layout, &width, &height); gtk_widget_set_size_request (w, -1, (2 * height + vsep) * (4 + 1)); g_object_unref (layout); } /* Loading the old solver specs... from param */ for (cl = param->constraints; cl; cl = cl->next) { GnmSolverConstraint const *c = cl->data; GtkTreeIter iter; char *str; gtk_list_store_append (store, &iter); str = gnm_solver_constraint_as_str (c, state->sheet); gtk_list_store_set (store, &iter, 0, str, 1, c, -1); g_free (str); } g_object_unref (store); INIT_BOOL_ENTRY ("autoscale_button", options.automatic_scaling); INIT_BOOL_ENTRY ("non_neg_button", options.assume_non_negative); INIT_BOOL_ENTRY ("all_int_button", options.assume_discrete); INIT_BOOL_ENTRY ("program", options.program_report); INIT_BOOL_ENTRY ("sensitivity", options.sensitivity_report); input = gnm_solver_param_get_input (param); if (input != NULL) gnm_expr_entry_load_from_text (state->change_cell_entry, value_peek_string (input)); target_cell = gnm_solver_param_get_target_cell (param); if (target_cell) gnm_expr_entry_load_from_text (state->target_entry, cell_name (target_cell)); else { SheetView *sv = wb_control_cur_sheet_view (GNM_WBC (state->wbcg)); if (sv) { GnmRange first = {sv->edit_pos, sv->edit_pos}; gnm_expr_entry_load_from_range (state->target_entry, state->sheet, &first); } } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON ( go_gtk_builder_get_widget(state->gui, "max_button")), param->problem_type == GNM_SOLVER_MAXIMIZE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON ( go_gtk_builder_get_widget(state->gui, "min_button")), param->problem_type == GNM_SOLVER_MINIMIZE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON ( go_gtk_builder_get_widget(state->gui, "no_scenario")), ! param->options.add_scenario); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON ( go_gtk_builder_get_widget(state->gui, "optimal_scenario")), param->options.add_scenario); state->scenario_name_entry = go_gtk_builder_get_widget (state->gui, "scenario_name_entry"); gtk_entry_set_text (GTK_ENTRY (state->scenario_name_entry), param->options.scenario_name); state->run.status_widget = go_gtk_builder_get_widget (state->gui, "solver_status_label"); state->run.problem_status_widget = go_gtk_builder_get_widget (state->gui, "problem_status_label"); state->run.objective_value_widget = go_gtk_builder_get_widget (state->gui, "objective_value_label"); state->run.timer_widget = go_gtk_builder_get_widget (state->gui, "elapsed_time_label"); state->run.spinner = go_gtk_builder_get_widget (state->gui, "run_spinner"); /* Done */ gnm_expr_entry_grab_focus (state->target_entry, FALSE); wbcg_set_entry (state->wbcg, state->target_entry); dialog_set_main_button_sensitivity (NULL, state); dialog_set_sec_button_sensitivity (NULL, state); /* dialog */ wbc_gtk_attach_guru (state->wbcg, state->dialog); g_signal_connect_swapped (G_OBJECT (state->dialog), "destroy", G_CALLBACK (cb_dialog_solver_destroy), state); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify)unref_state); return FALSE; }
void dialog_merge (WBCGtk *wbcg) { MergeState *state; GtkBuilder *gui; GtkGrid *grid; GtkWidget *scrolled; GtkTreeViewColumn *column; GtkTreeSelection *selection; GnmRange const *r; g_return_if_fail (wbcg != NULL); if (gnumeric_dialog_raise_if_exists (wbcg, MERGE_KEY)) return; gui = gnm_gtk_builder_load ("merge.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; state = g_new0 (MergeState, 1); state->gui = gui; state->wbcg = wbcg; state->sheet = wb_control_cur_sheet (WORKBOOK_CONTROL (state->wbcg)); state->dialog = go_gtk_builder_get_widget (gui, "Merge"); state->warning_dialog = NULL; state->add_btn = go_gtk_builder_get_widget (gui, "add_button"); state->delete_btn = go_gtk_builder_get_widget (gui, "remove_button"); state->merge_btn = go_gtk_builder_get_widget (gui, "merge_button"); state->change_btn = go_gtk_builder_get_widget (gui, "change_button"); state->cancel_btn = go_gtk_builder_get_widget (gui, "cancel_button"); gtk_widget_set_size_request (state->delete_btn, 100, -1); gtk_button_set_alignment (GTK_BUTTON (state->add_btn), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->delete_btn), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->change_btn), 0., .5); grid = GTK_GRID (go_gtk_builder_get_widget (gui, "main-grid")); state->zone = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (state->zone, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->zone)); gtk_label_set_mnemonic_widget (GTK_LABEL (go_gtk_builder_get_widget (gui, "var1-label")), GTK_WIDGET (state->zone)); gtk_widget_set_hexpand (GTK_WIDGET (state->zone), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->zone), 1, 0, 2, 1); r = selection_first_range ( wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg)), NULL, NULL); if (r != NULL) gnm_expr_entry_load_from_range (state->zone, state->sheet, r); state->data = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (state->data, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->data), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->data), 0, 5, 1, 1); state->field = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (state->field, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->field), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->field), 1, 5, 1, 1); scrolled = go_gtk_builder_get_widget (state->gui, "scrolled"); state->model = gtk_list_store_new (NUM_COLMNS, G_TYPE_STRING, G_TYPE_STRING); state->list = GTK_TREE_VIEW (gtk_tree_view_new_with_model (GTK_TREE_MODEL (state->model))); selection = gtk_tree_view_get_selection (state->list); gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); column = gtk_tree_view_column_new_with_attributes (_("Input Data"), gtk_cell_renderer_text_new (), "text", DATA_RANGE, NULL); gtk_tree_view_column_set_sort_column_id (column, DATA_RANGE); gtk_tree_view_column_set_min_width (column, 150); gtk_tree_view_append_column (state->list, column); column = gtk_tree_view_column_new_with_attributes (_("Merge Field"), gtk_cell_renderer_text_new (), "text", FIELD_LOCATION, NULL); gtk_tree_view_column_set_sort_column_id (column, FIELD_LOCATION); gtk_tree_view_column_set_min_width (column, 100); gtk_tree_view_append_column (state->list, column); gtk_tree_view_set_headers_clickable (state->list, TRUE); gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (state->list)); cb_merge_update_buttons (NULL, state); g_signal_connect (selection, "changed", G_CALLBACK (cb_merge_selection_changed), state); g_signal_connect_after (G_OBJECT (state->zone), "changed", G_CALLBACK (cb_merge_update_buttons), state); g_signal_connect_after (G_OBJECT (state->data), "changed", G_CALLBACK (cb_merge_update_buttons), state); g_signal_connect_after (G_OBJECT (state->field), "changed", G_CALLBACK (cb_merge_update_buttons), state); g_signal_connect (G_OBJECT (state->add_btn), "clicked", G_CALLBACK (cb_merge_add_clicked), state); g_signal_connect (G_OBJECT (state->change_btn), "clicked", G_CALLBACK (cb_merge_change_clicked), state); g_signal_connect (G_OBJECT (state->delete_btn), "clicked", G_CALLBACK (cb_merge_delete_clicked), state); g_signal_connect (G_OBJECT (state->merge_btn), "clicked", G_CALLBACK (cb_merge_merge_clicked), state); g_signal_connect (G_OBJECT (state->cancel_btn), "clicked", G_CALLBACK (cb_merge_cancel_clicked), state); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); gnumeric_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_DATA_MERGE); gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog), MERGE_KEY); /* a candidate for merging into attach guru */ g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_merge_destroy); go_gtk_nonmodal_dialog (wbcg_toplevel (state->wbcg), GTK_WINDOW (state->dialog)); wbc_gtk_attach_guru (state->wbcg, GTK_WIDGET (state->dialog)); gtk_widget_show_all (GTK_WIDGET (state->dialog)); }
/** * dialog_init: * @state: * * Create the dialog (guru). * **/ static gboolean dialog_init (GoalSeekState *state) { GtkTable *table; state->dialog = glade_xml_get_widget (state->gui, "GoalSeek"); if (state->dialog == NULL) return TRUE; state->close_button = glade_xml_get_widget (state->gui, "closebutton"); g_signal_connect (G_OBJECT (state->close_button), "clicked", G_CALLBACK (cb_dialog_close_clicked), state); state->cancel_button = glade_xml_get_widget (state->gui, "cancelbutton"); g_signal_connect (G_OBJECT (state->cancel_button), "clicked", G_CALLBACK (cb_dialog_cancel_clicked), state); state->apply_button = glade_xml_get_widget (state->gui, "applybutton"); g_signal_connect (G_OBJECT (state->apply_button), "clicked", G_CALLBACK (cb_dialog_apply_clicked), state); gnumeric_init_help_button ( glade_xml_get_widget (state->gui, "helpbutton"), GNUMERIC_HELP_LINK_GOAL_SEEK); state->to_value_entry = glade_xml_get_widget (state->gui, "to_value_entry"); state->at_least_entry = glade_xml_get_widget (state->gui, "at_least-entry"); state->at_most_entry = glade_xml_get_widget (state->gui, "at_most-entry"); state->target_value_label = glade_xml_get_widget (state->gui, "target-value"); gtk_label_set_justify (GTK_LABEL (state->target_value_label), GTK_JUSTIFY_RIGHT); state->current_value_label = glade_xml_get_widget (state->gui, "current-value"); gtk_label_set_justify (GTK_LABEL (state->current_value_label), GTK_JUSTIFY_RIGHT); state->solution_label = glade_xml_get_widget (state->gui, "solution"); gtk_label_set_justify (GTK_LABEL (state->solution_label), GTK_JUSTIFY_RIGHT); state->result_label = glade_xml_get_widget (state->gui, "result-label"); state->result_table = glade_xml_get_widget (state->gui, "result-table"); table = GTK_TABLE (glade_xml_get_widget (state->gui, "goal-table")); state->set_cell_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->set_cell_entry, GNM_EE_SINGLE_RANGE | GNM_EE_FORCE_ABS_REF, GNM_EE_MASK); gtk_table_attach (table, GTK_WIDGET (state->set_cell_entry), 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->set_cell_entry)); dialog_preload_selection (state, state->set_cell_entry); gtk_widget_show (GTK_WIDGET (state->set_cell_entry)); state->change_cell_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->change_cell_entry, GNM_EE_SINGLE_RANGE | GNM_EE_FORCE_ABS_REF, GNM_EE_MASK); gtk_table_attach (table, GTK_WIDGET (state->change_cell_entry), 2, 3, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 0); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->change_cell_entry)); dialog_preload_selection (state, state->change_cell_entry); gtk_widget_show (GTK_WIDGET (state->change_cell_entry)); g_signal_connect (G_OBJECT (state->dialog), "realize", G_CALLBACK (dialog_realized), state); state->old_value = NULL; state->old_cell = NULL; wbc_gtk_attach_guru (state->wbcg, state->dialog); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_dialog_destroy); gnm_expr_entry_grab_focus (state->set_cell_entry, FALSE); return FALSE; }
void dialog_data_slicer (WBCGtk *wbcg, gboolean create) { static GtkTargetEntry row_targets[] = { { (char *)"GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP, 0 } }; DialogDataSlicer *state; GtkBuilder *gui; GtkWidget *w; g_return_if_fail (wbcg != NULL); if (gnm_dialog_raise_if_exists (wbcg, DIALOG_KEY)) return; gui = gnm_gtk_builder_load ("data-slicer.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (NULL == gui) return; state = g_new0 (DialogDataSlicer, 1); state->wbcg = wbcg; state->sv = wb_control_cur_sheet_view (GNM_WBC (wbcg)); state->dialog = go_gtk_builder_get_widget (gui, "dialog_data_slicer"); state->notebook = go_gtk_builder_get_widget (gui, "notebook"); state->slicer = create ? NULL : sv_editpos_in_slicer (state->sv); state->cache = NULL; state->source = NULL; if (NULL == state->slicer) { state->slicer = g_object_new (GNM_SHEET_SLICER_TYPE, NULL); } else { g_object_ref (state->slicer); g_object_get (G_OBJECT (state->slicer), "cache", &state->cache, NULL); if (NULL != state->cache && NULL != (state->source = go_data_cache_get_source (state->cache))) g_object_ref (state->source); } state->source_expr = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->source_expr, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); g_signal_connect_swapped (G_OBJECT (state->source_expr), "changed", G_CALLBACK (cb_source_expr_changed), state); w = go_gtk_builder_get_widget (gui, "source_vbox"); gtk_box_pack_start (GTK_BOX (w), GTK_WIDGET (state->source_expr), FALSE, FALSE, 0); gtk_widget_show (GTK_WIDGET (state->source_expr)); w = go_gtk_builder_get_widget (gui, "ok_button"); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (cb_dialog_data_slicer_ok), state); w = go_gtk_builder_get_widget (gui, "cancel_button"); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (cb_dialog_data_slicer_cancel), state); state->treeview = GTK_TREE_VIEW (go_gtk_builder_get_widget (gui, "field_tree")); gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (state->treeview), GDK_BUTTON1_MASK, row_targets, G_N_ELEMENTS (row_targets), GDK_ACTION_MOVE); gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (state->treeview), row_targets, G_N_ELEMENTS (row_targets), GDK_ACTION_MOVE); state->selection = gtk_tree_view_get_selection (state->treeview); gtk_tree_selection_set_mode (state->selection, GTK_SELECTION_SINGLE); g_signal_connect (state->selection, "changed", G_CALLBACK (cb_dialog_data_slicer_selection_changed), state); gtk_tree_view_append_column (state->treeview, gtk_tree_view_column_new_with_attributes ("", gtk_cell_renderer_text_new (), "text", FIELD_NAME, NULL)); cb_dialog_data_slicer_create_model (state); g_signal_connect (state->treeview, "realize", G_CALLBACK (gtk_tree_view_expand_all), NULL); gtk_notebook_set_current_page (GTK_NOTEBOOK (state->notebook), create ? 0 : 1); /* a candidate for merging into attach guru */ gnm_init_help_button (go_gtk_builder_get_widget (gui, "help_button"), GNUMERIC_HELP_LINK_DATA_SLICER); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify)cb_dialog_data_slicer_destroy); wbc_gtk_attach_guru (state->wbcg, state->dialog); gnm_keyed_dialog (wbcg, GTK_WINDOW (state->dialog), DIALOG_KEY); gtk_widget_show (state->dialog); g_object_unref (gui); }
static void attr_dialog_impl (AttrState *state) { GtkWidget *dialog = go_gtk_builder_get_widget (state->gui, "WorkbookAttr"); GtkTreeViewColumn *column; GtkTreeSelection *selection; int i; g_return_if_fail (dialog != NULL); /* Initialize */ state->dialog = dialog; state->notebook = go_gtk_builder_get_widget (state->gui, "notebook"); state->destroying = FALSE; state->tview = GTK_TREE_VIEW(go_gtk_builder_get_widget (state->gui, "itemlist")); state->store = gtk_tree_store_new (NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); gtk_tree_view_set_model (state->tview, GTK_TREE_MODEL(state->store)); g_object_unref (state->store); selection = gtk_tree_view_get_selection (state->tview); gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); column = gtk_tree_view_column_new_with_attributes ("", gtk_cell_renderer_pixbuf_new (), "pixbuf", ITEM_ICON, NULL); gtk_tree_view_append_column (state->tview, column); column = gtk_tree_view_column_new_with_attributes ("", gtk_cell_renderer_text_new (), "text", ITEM_NAME, NULL); gtk_tree_view_append_column (state->tview, column); gtk_tree_view_set_expander_column (state->tview, column); g_signal_connect (selection, "changed", G_CALLBACK (cb_attr_dialog_selection_changed), state); for (i = 0; page_info[i].page > -1; i++) { const page_info_t *this_page = &page_info[i]; this_page->page_initializer (state); attr_dialog_add_item (state, this_page->page_name, this_page->icon_name, this_page->page, this_page->parent_path); } gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (state->store), ITEM_NAME, GTK_SORT_ASCENDING); g_signal_connect (G_OBJECT (go_gtk_builder_get_widget (state->gui, "close_button")), "clicked", G_CALLBACK (cb_attr_dialog_dialog_close), state); gnm_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_WORKBOOK_ATTRIBUTE); /* a candidate for merging into attach guru */ g_object_set_data_full (G_OBJECT (dialog), "state", state, (GDestroyNotify) cb_attr_dialog_dialog_destroy); wbc_gtk_attach_guru (state->wbcg, state->dialog); gnm_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog), WORKBOOK_ATTRIBUTE_KEY); gtk_widget_show (state->dialog); }
void dialog_so_size (WBCGtk *wbcg, GObject *so) { GtkBuilder *gui; SOSizeState *state; int width, height; g_return_if_fail (wbcg != NULL); if (gnumeric_dialog_raise_if_exists (wbcg, SO_SIZE_DIALOG_KEY)) return; gui = gnm_gtk_builder_load ("sheetobject-size.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; state = g_new (SOSizeState, 1); state->wbcg = wbcg; state->sv = wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg)); state->sheet = sv_sheet (state->sv); state->scg = wbcg_get_nth_scg (wbcg, state->sheet->index_in_wb); state->gui = gui; state->dialog = go_gtk_builder_get_widget (state->gui, "object-size"); state->so = SHEET_OBJECT (so); g_object_ref (so); state->nameentry = GTK_ENTRY (go_gtk_builder_get_widget (state->gui, "name-entry")); state->old_anchor = NULL; state->old_name = NULL; g_object_get (so, "name", &state->old_name, NULL); if (state->old_name == NULL) state->old_name = g_strdup (""); gtk_entry_set_text (state->nameentry, state->old_name); state->so_name_changed = FALSE; g_signal_connect (G_OBJECT (state->nameentry), "focus-out-event", G_CALLBACK (cb_dialog_so_size_name_changed), state); state->so_print_check_changed = FALSE; state->wpoints = GTK_WIDGET (go_gtk_builder_get_widget (state->gui, "w-pts-label")); state->wspin = GTK_SPIN_BUTTON (go_gtk_builder_get_widget (state->gui, "w-spin")); state->hpoints = GTK_WIDGET (go_gtk_builder_get_widget (state->gui, "h-pts-label")); state->hspin = GTK_SPIN_BUTTON (go_gtk_builder_get_widget (state->gui, "h-spin")); state->xpoints = GTK_WIDGET (go_gtk_builder_get_widget (state->gui, "x-pts-label")); state->xspin = GTK_SPIN_BUTTON (go_gtk_builder_get_widget (state->gui, "x-spin")); state->ypoints = GTK_WIDGET (go_gtk_builder_get_widget (state->gui, "y-pts-label")); state->yspin = GTK_SPIN_BUTTON (go_gtk_builder_get_widget (state->gui, "y-spin")); state->print_check = GTK_WIDGET (go_gtk_builder_get_widget (state->gui, "print-check")); dialog_so_size_load (state); state->active_anchor = sheet_object_anchor_dup (sheet_object_get_anchor (state->so)); width = state->coords[2] - state->coords[0]; height = state->coords[3] - state->coords[1]; gtk_spin_button_set_value (state->wspin, (width < 0) ? - width : width); gtk_spin_button_set_value (state->hspin, (height < 0) ? - height : height); gtk_spin_button_set_value (state->xspin, 0.); gtk_spin_button_set_value (state->yspin, 0.); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->print_check), !(state->so->flags & SHEET_OBJECT_PRINT)); g_signal_connect (G_OBJECT (state->wspin), "value-changed", G_CALLBACK (cb_dialog_so_size_value_changed_update_points), state->wpoints); g_signal_connect (G_OBJECT (state->hspin), "value-changed", G_CALLBACK (cb_dialog_so_size_value_changed_update_points), state->hpoints); g_signal_connect (G_OBJECT (state->xspin), "value-changed", G_CALLBACK (cb_dialog_so_size_value_changed_update_points), state->xpoints); g_signal_connect (G_OBJECT (state->yspin), "value-changed", G_CALLBACK (cb_dialog_so_size_value_changed_update_points), state->ypoints); g_signal_connect (G_OBJECT (state->print_check), "toggled", G_CALLBACK (cb_dialog_so_size_print_check_toggled), state); cb_dialog_so_size_value_changed_update_points (state->wspin, GTK_LABEL (state->wpoints)); cb_dialog_so_size_value_changed_update_points (state->hspin, GTK_LABEL (state->hpoints)); cb_dialog_so_size_value_changed_update_points (state->xspin, GTK_LABEL (state->xpoints)); cb_dialog_so_size_value_changed_update_points (state->yspin, GTK_LABEL (state->ypoints)); g_signal_connect (G_OBJECT (state->wspin), "value-changed", G_CALLBACK (cb_dialog_so_size_value_changed), state); g_signal_connect (G_OBJECT (state->hspin), "value-changed", G_CALLBACK (cb_dialog_so_size_value_changed), state); g_signal_connect (G_OBJECT (state->xspin), "value-changed", G_CALLBACK (cb_dialog_so_size_value_changed), state); g_signal_connect (G_OBJECT (state->yspin), "value-changed", G_CALLBACK (cb_dialog_so_size_value_changed), state); state->ok_button = go_gtk_builder_get_widget (state->gui, "ok_button"); g_signal_connect (G_OBJECT (state->ok_button), "clicked", G_CALLBACK (cb_dialog_so_size_ok_clicked), state); state->apply_button = go_gtk_builder_get_widget (state->gui, "apply_button"); g_signal_connect (G_OBJECT (state->apply_button), "clicked", G_CALLBACK (cb_dialog_so_size_apply_clicked), state); state->cancel_button = go_gtk_builder_get_widget (state->gui, "cancel_button"); g_signal_connect (G_OBJECT (state->cancel_button), "clicked", G_CALLBACK (cb_dialog_so_size_cancel_clicked), state); gnumeric_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_SO_SIZE); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); wbc_gtk_attach_guru (state->wbcg, state->dialog); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_dialog_so_size_destroy); gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog), SO_SIZE_DIALOG_KEY); dialog_so_size_button_sensitivity (state); gtk_widget_show (state->dialog); }
static void dialog_init (SortFlowState *state) { GtkTable *table; GtkWidget *scrolled; GtkTreeViewColumn *column; GtkCellRenderer *renderer; gboolean col_rb; GnmRange const *range; table = GTK_TABLE (go_gtk_builder_get_widget (state->gui, "cell_sort_options_table")); /* setup range entry */ state->range_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->range_entry, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_table_attach (table, GTK_WIDGET (state->range_entry), 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->range_entry)); gnm_expr_entry_set_update_policy (state->range_entry, GTK_UPDATE_DISCONTINUOUS); gtk_widget_show (GTK_WIDGET (state->range_entry)); g_signal_connect_swapped (G_OBJECT (state->range_entry), "changed", G_CALLBACK (cb_update_to_new_range), state); state->locale_selector = GO_LOCALE_SEL (go_locale_sel_new ()); gtk_widget_show_all (GTK_WIDGET (state->locale_selector)); gtk_table_attach (table, GTK_WIDGET (state->locale_selector), 2, 3, 5, 6, GTK_EXPAND | GTK_FILL, 0, 0, 0); table = GTK_TABLE (go_gtk_builder_get_widget (state->gui, "cell_sort_spec_table")); /* setup add entry */ state->add_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->add_entry, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_table_attach (table, GTK_WIDGET (state->add_entry), 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->add_entry)); gtk_widget_show (GTK_WIDGET (state->add_entry)); /* Set-up tree view */ scrolled = go_gtk_builder_get_widget (state->gui, "scrolled_cell_sort_list"); state->model = gtk_list_store_new (NUM_COLMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_INT); state->treeview = GTK_TREE_VIEW ( gtk_tree_view_new_with_model (GTK_TREE_MODEL (state->model))); state->selection = gtk_tree_view_get_selection (state->treeview); gtk_tree_selection_set_mode (state->selection, GTK_SELECTION_BROWSE); g_signal_connect_swapped (state->selection, "changed", G_CALLBACK (cb_sort_selection_changed), state); state->header_column = gtk_tree_view_column_new_with_attributes (_("Header"), gtk_cell_renderer_text_new (), "text", ITEM_HEADER, NULL); gtk_tree_view_append_column (state->treeview, state->header_column); column = gtk_tree_view_column_new_with_attributes (_("Row/Column"), gtk_cell_renderer_text_new (), "text", ITEM_NAME, NULL); gtk_tree_view_append_column (state->treeview, column); renderer = gnumeric_cell_renderer_toggle_new (); g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (cb_toggled_descending), state); column = gtk_tree_view_column_new_with_attributes ("", renderer, "active", ITEM_DESCENDING, "pixbuf", ITEM_DESCENDING_IMAGE, NULL); gtk_tree_view_append_column (state->treeview, column); renderer = gtk_cell_renderer_toggle_new (); g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (cb_toggled_case_sensitive), state); column = gtk_tree_view_column_new_with_attributes (_("Case Sensitive"), renderer, "active", ITEM_CASE_SENSITIVE, NULL); gtk_tree_view_append_column (state->treeview, column); gtk_tree_view_columns_autosize (state->treeview); g_signal_connect (G_OBJECT (state->treeview), "key_press_event", G_CALLBACK (cb_treeview_keypress), state); g_signal_connect (G_OBJECT (state->treeview), "button_press_event", G_CALLBACK (cb_treeview_button_press), state); #if 0 /* We are currently not supporting `by-value' vs not. */ renderer = gtk_cell_renderer_toggle_new (); g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (cb_toggled_sort_by_value), state); column = gtk_tree_view_column_new_with_attributes (_("By Value"), renderer, "active", ITEM_SORT_BY_VALUE, NULL); gtk_tree_view_append_column (state->treeview, column); #endif gtk_tree_view_set_reorderable (state->treeview,TRUE); gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (state->treeview)); gtk_widget_show (GTK_WIDGET (state->treeview)); /* Set-up other widgets */ state->cell_sort_row_rb = go_gtk_builder_get_widget (state->gui, "cell_sort_row_rb"); state->cell_sort_col_rb = go_gtk_builder_get_widget (state->gui, "cell_sort_col_rb"); g_signal_connect_swapped (G_OBJECT (state->cell_sort_row_rb), "toggled", G_CALLBACK (cb_update_to_new_range), state); state->cell_sort_header_check = go_gtk_builder_get_widget (state->gui, "cell_sort_header_check"); g_signal_connect_swapped (G_OBJECT (state->cell_sort_header_check), "toggled", G_CALLBACK (cb_sort_header_check), state); state->retain_format_check = go_gtk_builder_get_widget (state->gui, "retain_format_button"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->retain_format_check), gnm_conf_get_core_sort_default_retain_formats ()); /* Set-up buttons */ state->up_button = go_gtk_builder_get_widget (state->gui, "up_button"); g_signal_connect_swapped (G_OBJECT (state->up_button), "clicked", G_CALLBACK (cb_up), state); state->down_button = go_gtk_builder_get_widget (state->gui, "down_button"); g_signal_connect_swapped (G_OBJECT (state->down_button), "clicked", G_CALLBACK (cb_down), state); state->add_button = go_gtk_builder_get_widget (state->gui, "add_button"); g_signal_connect_swapped (G_OBJECT (state->add_button), "clicked", G_CALLBACK (cb_add_clicked), state); gtk_widget_set_sensitive (state->add_button, TRUE); state->delete_button = go_gtk_builder_get_widget (state->gui, "delete_button"); g_signal_connect (G_OBJECT (state->delete_button), "clicked", G_CALLBACK (cb_delete_clicked), state); gtk_widget_set_sensitive (state->delete_button, FALSE); state->clear_button = go_gtk_builder_get_widget (state->gui, "clear_button"); g_signal_connect_swapped (G_OBJECT (state->clear_button), "clicked", G_CALLBACK (cb_clear_clicked), state); gtk_widget_set_sensitive (state->clear_button, FALSE); gtk_button_set_alignment (GTK_BUTTON (state->up_button), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->down_button), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->add_button), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->delete_button), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->clear_button), 0., .5); gnumeric_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_CELL_SORT); state->ok_button = go_gtk_builder_get_widget (state->gui, "ok_button"); g_signal_connect_swapped (G_OBJECT (state->ok_button), "clicked", G_CALLBACK (cb_dialog_ok_clicked), state); state->cancel_button = go_gtk_builder_get_widget (state->gui, "cancel_button"); g_signal_connect (G_OBJECT (state->cancel_button), "clicked", G_CALLBACK (cb_dialog_cancel_clicked), state); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); /* Finish dialog signals */ wbc_gtk_attach_guru (state->wbcg, state->dialog); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_dialog_destroy); range = dialog_load_selection (state, &col_rb); cb_sort_selection_changed (state); gnm_expr_entry_grab_focus(GNM_EXPR_ENTRY (state->add_entry), TRUE); }