static gboolean so_list_init (GnmDialogSOList *state, WBCGtk *wbcg, SheetObject *so) { GnmExprTop const *texpr; GtkBuilder *gui; gui = gnm_gtk_builder_load ("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); gnumeric_init_help_button ( go_gtk_builder_get_widget (gui, "help"), GNUMERIC_HELP_LINK_SO_LIST); /* a candidate for merging into attach guru */ gnumeric_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 (gnumeric_dialog_raise_if_exists (wbcg, COL_ROW_DIALOG_KEY)) return; gui = gnm_gtk_builder_new ("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); gnumeric_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); gnumeric_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_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); }
void dialog_new_view (WBCGtk *wbcg) { ViewState *state; GtkBuilder *gui; if (gnumeric_dialog_raise_if_exists (wbcg, VIEW_DIALOG_KEY)) return; gui = gnm_gtk_builder_new ("view.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; state = g_new (ViewState, 1); state->wbcg = wbcg; state->gui = gui; state->dialog = go_gtk_builder_get_widget (gui, "View"); state->location_elsewhere = GTK_RADIO_BUTTON (go_gtk_builder_get_widget (gui, "location_elsewhere")); state->location_display_name = GTK_ENTRY (go_gtk_builder_get_widget (gui, "location_display_name")); g_return_if_fail (state->dialog != NULL); { GdkScreen *this_screen = gtk_window_get_screen (wbcg_toplevel (wbcg)); GdkDisplay *this_display = gdk_screen_get_display (this_screen); int n_screens = gdk_display_get_n_screens (this_display); GtkBox *box = GTK_BOX (go_gtk_builder_get_widget (gui, "location_screens_vbox")); int i; for (i = 0; i < n_screens; i++) { /* Get this for every screen -- it might change. */ GSList *group = gtk_radio_button_get_group (state->location_elsewhere); GdkScreen *screen = gdk_display_get_screen (this_display, i); char *label = screen == this_screen ? (n_screens == 1 ? g_strdup (_("This screen")) : g_strdup_printf (_("Screen %d [This screen]"), i)) : g_strdup_printf (_("Screen %d"), i); GtkWidget *button = gtk_radio_button_new_with_label (group, label); g_free (label); if (screen == this_screen) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); g_object_set_data (G_OBJECT (button), "screen", screen); gtk_box_pack_start (box, button, TRUE, TRUE, 0); } } g_signal_connect (G_OBJECT (go_gtk_builder_get_widget (gui, "ok_button")), "clicked", G_CALLBACK (cb_view_ok_clicked), state); g_signal_connect (G_OBJECT (go_gtk_builder_get_widget (gui, "cancel_button")), "clicked", G_CALLBACK (cb_view_cancel_clicked), state); gnm_link_button_and_entry (GTK_WIDGET (state->location_elsewhere), GTK_WIDGET (state->location_display_name)); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->location_display_name)); gnumeric_init_help_button ( go_gtk_builder_get_widget (gui, "help_button"), GNUMERIC_HELP_LINK_VIEW); gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog), VIEW_DIALOG_KEY); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_view_destroy); gtk_widget_show_all (state->dialog); }
void dialog_search (WBCGtk *wbcg) { GtkBuilder *gui; GtkDialog *dialog; DialogState *dd; GtkGrid *grid; g_return_if_fail (wbcg != NULL); /* Only one guru per workbook. */ if (wbc_gtk_get_guru (wbcg)) return; gui = gnm_gtk_builder_load ("search.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; dialog = GTK_DIALOG (gtk_builder_get_object (gui, "search_dialog")); dd = g_new (DialogState, 1); dd->wbcg = wbcg; dd->gui = gui; dd->dialog = dialog; dd->matches = g_ptr_array_new (); dd->prev_button = go_gtk_builder_get_widget (gui, "prev_button"); dd->next_button = go_gtk_builder_get_widget (gui, "next_button"); dd->notebook = GTK_NOTEBOOK (gtk_builder_get_object (gui, "notebook")); dd->notebook_matches_page = gtk_notebook_page_num (dd->notebook, go_gtk_builder_get_widget (gui, "matches_tab")); dd->rangetext = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (dd->rangetext, 0, GNM_EE_MASK); grid = GTK_GRID (gtk_builder_get_object (gui, "normal-grid")); gtk_widget_set_hexpand (GTK_WIDGET (dd->rangetext), TRUE); gtk_grid_attach (grid, GTK_WIDGET (dd->rangetext), 1, 6, 1, 1); { char *selection_text = selection_to_string ( wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg)), TRUE); gnm_expr_entry_load_from_text (dd->rangetext, selection_text); g_free (selection_text); } dd->gentry = GTK_ENTRY (gtk_entry_new ()); gtk_widget_set_hexpand (GTK_WIDGET (dd->gentry), TRUE); gtk_grid_attach (grid, GTK_WIDGET (dd->gentry), 1, 0, 1, 1); gtk_widget_grab_focus (GTK_WIDGET (dd->gentry)); gnumeric_editable_enters (GTK_WINDOW (dialog), GTK_WIDGET (dd->gentry)); dd->matches_table = make_matches_table (dd); { GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (dd->matches_table)); gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (gui, "matches_vbox")), scrolled_window, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); } /* Set sensitivity of buttons. */ cursor_change (dd->matches_table, dd); #define SETW(w,f) gtk_toggle_button_set_active \ (GTK_TOGGLE_BUTTON (gtk_builder_get_object (gui, w)), f()) SETW("search_expr", gnm_conf_get_searchreplace_change_cell_expressions); SETW("search_other", gnm_conf_get_searchreplace_change_cell_other); SETW("search_string", gnm_conf_get_searchreplace_change_cell_strings); SETW("search_comments", gnm_conf_get_searchreplace_change_comments); SETW("search_expr_results", gnm_conf_get_searchreplace_search_results); SETW("ignore_case", gnm_conf_get_searchreplace_ignore_case); SETW("match_words", gnm_conf_get_searchreplace_whole_words_only); #undef SETW gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (gui, search_type_group[gnm_conf_get_searchreplace_regex ()])), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (gui, direction_group [gnm_conf_get_searchreplace_columnmajor () ? 1 : 0])), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (gui, scope_group[gnm_conf_get_searchreplace_scope ()])), TRUE); g_signal_connect (G_OBJECT (dd->matches_table), "cursor_changed", G_CALLBACK (cursor_change), dd); g_signal_connect (G_OBJECT (dd->matches_table), "select_cursor_row", G_CALLBACK (cb_next), dd); go_gtk_builder_signal_connect (gui, "search_button", "clicked", G_CALLBACK (search_clicked), dd); g_signal_connect (G_OBJECT (dd->prev_button), "clicked", G_CALLBACK (prev_clicked), dd); g_signal_connect (G_OBJECT (dd->next_button), "clicked", G_CALLBACK (next_clicked), dd); go_gtk_builder_signal_connect_swapped (gui, "close_button", "clicked", G_CALLBACK (gtk_widget_destroy), dd->dialog); g_signal_connect (G_OBJECT (gnm_expr_entry_get_entry (dd->rangetext)), "focus-in-event", G_CALLBACK (range_focused), dd); go_gtk_builder_signal_connect (gui, "scope_range", "toggled", G_CALLBACK (cb_focus_on_entry), dd->rangetext); wbc_gtk_attach_guru_with_unfocused_rs (wbcg, GTK_WIDGET (dialog), dd->rangetext); g_object_set_data_full (G_OBJECT (dialog), "state", dd, (GDestroyNotify) free_state); gnm_dialog_setup_destroy_handlers (dialog, wbcg, GNM_DIALOG_DESTROY_SHEET_REMOVED); gnumeric_init_help_button ( go_gtk_builder_get_widget (gui, "help_button"), GNUMERIC_HELP_LINK_SEARCH); gnumeric_restore_window_geometry (GTK_WINDOW (dialog), SEARCH_KEY); go_gtk_nonmodal_dialog (wbcg_toplevel (wbcg), GTK_WINDOW (dialog)); gtk_widget_show_all (GTK_WIDGET (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_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)); }
void dialog_row_height (WBCGtk *wbcg, gboolean use_default) { RowHeightState *state; g_return_if_fail (wbcg != NULL); if (gnumeric_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 (WORKBOOK_CONTROL (wbcg)); state->sheet = sv_sheet (state->sv); state->adjusting = FALSE; state->gui = gnm_glade_xml_new (GO_CMD_CONTEXT (wbcg), "row-height.glade", NULL, NULL); g_return_if_fail (state->gui != NULL); state->dialog = glade_xml_get_widget (state->gui, "dialog"); state->description = GTK_WIDGET (glade_xml_get_widget (state->gui, "description")); state->points = GTK_WIDGET (glade_xml_get_widget (state->gui, "pts-label")); state->spin = GTK_SPIN_BUTTON (glade_xml_get_widget (state->gui, "spin")); gtk_spin_button_get_adjustment (state->spin)->lower = GNM_ROW_MARGIN + GNM_ROW_MARGIN; g_signal_connect (G_OBJECT (state->spin), "value-changed", G_CALLBACK (cb_dialog_row_height_value_changed), state); state->default_check = GTK_WIDGET (glade_xml_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 = glade_xml_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 = glade_xml_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 = glade_xml_get_widget (state->gui, "cancel_button"); g_signal_connect (G_OBJECT (state->cancel_button), "clicked", G_CALLBACK (cb_dialog_row_height_cancel_clicked), state); gnumeric_init_help_button ( glade_xml_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); gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog), ROW_HEIGHT_DIALOG_KEY); gtk_widget_show (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_preferences (WBCGtk *wbcg, gchar const *page) { PrefState *state; GtkBuilder *gui; GtkWidget *w; gint i; GtkTreeViewColumn *column; GtkTreeSelection *selection; w = g_object_get_data (gnm_app_get_app (), PREF_DIALOG_KEY); if (w) { gtk_widget_show (w); gdk_window_raise (gtk_widget_get_window (w)); return; } gui = gnm_gtk_builder_load ("preferences.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; state = g_new0 (PrefState, 1); state->gui = gui; state->dialog = go_gtk_builder_get_widget (gui, "preferences"); state->notebook = (GtkNotebook*)go_gtk_builder_get_widget (gui, "notebook"); state->view = GTK_TREE_VIEW(go_gtk_builder_get_widget (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->view, GTK_TREE_MODEL(state->store)); selection = gtk_tree_view_get_selection (state->view); gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); column = gtk_tree_view_column_new_with_attributes ("", gtk_cell_renderer_pixbuf_new (), "pixbuf", ITEM_ICON, NULL); gtk_tree_view_append_column (state->view, column); column = gtk_tree_view_column_new_with_attributes ("", gtk_cell_renderer_text_new (), "text", ITEM_NAME, NULL); gtk_tree_view_append_column (state->view, column); gtk_tree_view_set_expander_column (state->view, column); g_signal_connect (selection, "changed", G_CALLBACK (cb_dialog_pref_selection_changed), state); g_signal_connect_swapped (G_OBJECT (go_gtk_builder_get_widget (gui, "close_button")), "clicked", G_CALLBACK (cb_close_clicked), state); gnumeric_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_PREFERENCES); g_signal_connect_swapped (G_OBJECT (state->dialog), "destroy", G_CALLBACK(cb_preferences_destroy), state); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify)g_free); g_object_set_data (gnm_app_get_app (), PREF_DIALOG_KEY, state->dialog); state->app_wb_removed_sig = g_signal_connect_swapped (gnm_app_get_app (), "workbook_removed", G_CALLBACK (cb_workbook_removed), state); for (i = 0; page_info[i].page_initializer; i++) { const page_info_t *this_page = &page_info[i]; GtkWidget *page_widget = this_page->page_initializer (state, NULL, state->notebook, i); gtk_notebook_append_page (state->notebook, page_widget, NULL); dialog_pref_add_item (state, this_page->page_name, this_page->icon_name, i, this_page->parent_path); } gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (state->store), ITEM_NAME, GTK_SORT_ASCENDING); go_gtk_nonmodal_dialog (wbcg_toplevel (wbcg), GTK_WINDOW (state->dialog)); gtk_widget_show (GTK_WIDGET (state->dialog)); dialog_pref_select_page (state, page); }
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); }
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); }
void dialog_search (WBCGtk *wbcg) { GtkBuilder *gui; GtkDialog *dialog; DialogState *dd; GtkTable *table; char *f; g_return_if_fail (wbcg != NULL); #ifdef USE_GURU /* Only one guru per workbook. */ if (wbc_gtk_get_guru (wbcg)) return; #endif f = g_build_filename (gnm_sys_data_dir (), "ui", "search.ui", NULL); gui = go_gtk_builder_new (f, NULL, GO_CMD_CONTEXT (wbcg)); g_free (f); if (gui == NULL) return; dialog = GTK_DIALOG (gtk_builder_get_object (gui, "search_dialog")); dd = g_new (DialogState, 1); dd->wbcg = wbcg; dd->gui = gui; dd->dialog = dialog; dd->matches = g_ptr_array_new (); dd->prev_button = go_gtk_builder_get_widget (gui, "prev_button"); dd->next_button = go_gtk_builder_get_widget (gui, "next_button"); dd->notebook = GTK_NOTEBOOK (gtk_builder_get_object (gui, "notebook")); dd->notebook_matches_page = gtk_notebook_page_num (dd->notebook, go_gtk_builder_get_widget (gui, "matches_tab")); dd->rangetext = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (dd->rangetext, 0, GNM_EE_MASK); table = GTK_TABLE (gtk_builder_get_object (gui, "page1-table")); gtk_table_attach (table, GTK_WIDGET (dd->rangetext), 1, 2, 6, 7, GTK_EXPAND | GTK_FILL, 0, 0, 0); { char *selection_text = selection_to_string ( wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg)), TRUE); gnm_expr_entry_load_from_text (dd->rangetext, selection_text); g_free (selection_text); } dd->gentry = GTK_ENTRY (gtk_entry_new ()); gtk_table_attach (table, GTK_WIDGET (dd->gentry), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_widget_grab_focus (GTK_WIDGET (dd->gentry)); gnumeric_editable_enters (GTK_WINDOW (dialog), GTK_WIDGET (dd->gentry)); dd->matches_table = make_matches_table (dd); { GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (dd->matches_table)); gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (gui, "matches_vbox")), scrolled_window, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); } /* Set sensitivity of buttons. */ cursor_change (dd->matches_table, dd); g_signal_connect (G_OBJECT (dd->matches_table), "cursor_changed", G_CALLBACK (cursor_change), dd); g_signal_connect (G_OBJECT (dd->matches_table), "select_cursor_row", G_CALLBACK (cb_next), dd); go_gtk_builder_signal_connect (gui, "search_button", "clicked", G_CALLBACK (search_clicked), dd); g_signal_connect (G_OBJECT (dd->prev_button), "clicked", G_CALLBACK (prev_clicked), dd); g_signal_connect (G_OBJECT (dd->next_button), "clicked", G_CALLBACK (next_clicked), dd); go_gtk_builder_signal_connect_swapped (gui, "close_button", "clicked", G_CALLBACK (gtk_widget_destroy), dd->dialog); g_signal_connect (G_OBJECT (gnm_expr_entry_get_entry (dd->rangetext)), "focus-in-event", G_CALLBACK (range_focused), dd); go_gtk_builder_signal_connect (gui, "scope_range", "toggled", G_CALLBACK (cb_focus_on_entry), dd->rangetext); #ifdef USE_GURU wbc_gtk_attach_guru_with_unfocused_rs (wbcg, GTK_WIDGET (dialog), dd->rangetext); #endif g_object_set_data_full (G_OBJECT (dialog), "state", dd, (GDestroyNotify) free_state); gnm_dialog_setup_destroy_handlers (dialog, wbcg, GNM_DIALOG_DESTROY_SHEET_REMOVED); gnumeric_init_help_button ( go_gtk_builder_get_widget (gui, "help_button"), GNUMERIC_HELP_LINK_SEARCH); gnumeric_restore_window_geometry (GTK_WINDOW (dialog), SEARCH_KEY); go_gtk_nonmodal_dialog (wbcg_toplevel (wbcg), GTK_WINDOW (dialog)); gtk_widget_show_all (GTK_WIDGET (dialog)); }