1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
4 * wbcg-actions.c: The callbacks and tables for all the menus and stock toolbars
6 * Copyright (C) 2003-2006 Jody Goldberg (jody@gnome.org)
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) version 3.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
24 #include <gnumeric-config.h>
27 #include "libgnumeric.h"
28 #include "application.h"
29 #include "gnm-commands-slicer.h"
31 #include "clipboard.h"
32 #include "selection.h"
38 #include "gnm-format.h"
41 #include "sheet-merge.h"
42 #include "sheet-filter.h"
43 #include "sheet-utils.h"
44 #include "sheet-style.h"
45 #include "style-border.h"
46 #include "style-color.h"
47 #include "tools/filter.h"
48 #include "sheet-control-gui-priv.h"
49 #include "sheet-view.h"
52 #include "workbook-view.h"
53 #include "wbc-gtk-impl.h"
54 #include "workbook-cmd-format.h"
55 #include "dialogs/dialogs.h"
56 #include "sheet-object-image.h"
57 #include "sheet-object-widget.h"
58 #include "gnm-so-filled.h"
59 #include "gnm-so-line.h"
60 #include "sheet-object-graph.h"
61 #include "sheet-object-component.h"
64 #include "gnumeric-conf.h"
67 #include "print-info.h"
68 #include "gnm-pane-impl.h"
70 #include "widgets/gnm-fontbutton.h"
72 #include <goffice/goffice.h>
73 #include <goffice/component/goffice-component.h>
76 #include <glib/gi18n-lib.h>
77 #include <gsf/gsf-input.h>
79 #include <glib/gstdio.h>
83 cb_cleanup_sendto (gpointer path
)
85 char *dir
= g_path_get_dirname (path
);
88 g_free (path
); /* the attachment */
91 g_free (dir
); /* the tempdir */
97 static GNM_ACTION_DEF (cb_file_new
)
99 GdkScreen
*screen
= gtk_window_get_screen (wbcg_toplevel (wbcg
));
100 Workbook
*wb
= workbook_new_with_sheets
101 (gnm_conf_get_core_workbook_n_sheet ());
102 WBCGtk
*new_wbcg
= wbc_gtk_new (NULL
, wb
, screen
, NULL
);
103 wbcg_copy_toolbar_visibility (new_wbcg
, wbcg
);
106 static GNM_ACTION_DEF (cb_file_open
) { gui_file_open (wbcg
, GNM_FILE_OPEN_STYLE_OPEN
, NULL
); }
107 static GNM_ACTION_DEF (cb_file_save
) { gui_file_save (wbcg
, wb_control_view (GNM_WBC (wbcg
))); }
108 static GNM_ACTION_DEF (cb_file_save_as
) { gui_file_save_as
109 (wbcg
, wb_control_view (GNM_WBC (wbcg
)),
110 GNM_FILE_SAVE_AS_STYLE_SAVE
, NULL
); }
112 static GNM_ACTION_DEF (cb_file_sendto
) {
113 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
114 WorkbookView
*wbv
= wb_control_view (wbc
);
115 GOCmdContext
*gcc
= GO_CMD_CONTEXT (wbcg
);
116 gboolean problem
= FALSE
;
117 GOIOContext
*io_context
;
121 wb
= wb_control_get_workbook (wbc
);
123 fs
= workbook_get_file_saver (wb
);
125 fs
= go_file_saver_get_default ();
127 io_context
= go_io_context_new (gcc
);
129 char *template, *full_name
, *uri
;
130 char *basename
= g_path_get_basename (go_doc_get_uri (GO_DOC (wb
)));
132 template = g_build_filename (g_get_tmp_dir (),
133 ".gnm-sendto-XXXXXX", NULL
);
134 problem
= (g_mkdtemp_full (template, 0600) == NULL
);
141 full_name
= g_build_filename (template, basename
, NULL
);
143 uri
= go_filename_to_uri (full_name
);
145 workbook_view_save_to_uri (wbv
, fs
, uri
, io_context
);
147 if (go_io_error_occurred (io_context
) ||
148 go_io_warning_occurred (io_context
))
149 go_io_error_display (io_context
);
151 if (go_io_error_occurred (io_context
)) {
154 /* mutt does not handle urls with no destination
155 * so pick something to arbitrary */
157 GdkScreen
*screen
= gtk_window_get_screen (wbcg_toplevel (wbcg
));
158 char *url
, *tmp
= go_url_encode (full_name
, 0);
159 url
= g_strdup_printf ("mailto:someone?attach=%s", tmp
);
162 err
= go_gtk_url_show (url
, screen
);
165 go_cmd_context_error (GO_CMD_CONTEXT (io_context
), err
);
167 go_io_error_display (io_context
);
175 cb_cleanup_sendto (full_name
);
178 * We wait a while before we clean up to ensure the file is
179 * loaded by the mailer.
181 g_timeout_add (1000 * 10, cb_cleanup_sendto
, full_name
);
184 go_cmd_context_error_export (GO_CMD_CONTEXT (io_context
),
185 _("Default file saver is not available."));
186 go_io_error_display (io_context
);
191 g_object_unref (io_context
);
194 /* What do we do with "problem"? */
197 static GNM_ACTION_DEF (cb_file_page_setup
)
199 dialog_printer_setup (wbcg
, wbcg_cur_sheet (wbcg
));
202 static GNM_ACTION_DEF (cb_file_print_area_set
)
204 Sheet
*sheet
= wbcg_cur_sheet (wbcg
);
205 SheetView
*sv
= sheet_get_view (sheet
, wb_control_view (GNM_WBC (wbcg
)));
209 GnmRange
const *r
= selection_first_range (sv
,
210 GO_CMD_CONTEXT (wbcg
), _("Set Print Area"));
212 parse_pos_init_sheet (&pp
, sheet
);
213 selection
= undo_range_name (sheet
, r
);
214 message
= g_strdup_printf (_("Set Print Area to %s"), selection
);
215 cmd_define_name (GNM_WBC (wbcg
), "Print_Area", &pp
,
216 gnm_expr_top_new_constant
217 (value_new_cellrange_r (NULL
, r
)),
224 static GNM_ACTION_DEF (cb_file_print_area_clear
)
227 Sheet
*sheet
= wbcg_cur_sheet (wbcg
);
229 parse_pos_init_sheet (&pp
, sheet
);
230 cmd_define_name (GNM_WBC (wbcg
), "Print_Area", &pp
,
231 gnm_expr_top_new_constant
232 (value_new_error_REF (NULL
)),
233 _("Clear Print Area"));
236 static GNM_ACTION_DEF (cb_file_print_area_show
)
238 Sheet
*sheet
= wbcg_cur_sheet (wbcg
);
239 GnmRange
*r
= sheet_get_nominal_printarea (sheet
);
242 SheetView
*sv
= sheet_get_view (sheet
,
243 wb_control_view (GNM_WBC (wbcg
)));
244 wb_control_sheet_focus (GNM_WBC (wbcg
), sheet
);
245 sv_selection_reset (sv
);
246 sv_selection_add_range (sv
, r
);
247 sv_make_cell_visible (sv
, r
->start
.col
, r
->start
.row
, FALSE
);
252 static GNM_ACTION_DEF (cb_file_print_area_toggle_col
)
254 cmd_page_break_toggle (GNM_WBC (wbcg
),
255 wbcg_cur_sheet (wbcg
),
258 static GNM_ACTION_DEF (cb_file_print_area_toggle_row
)
260 cmd_page_break_toggle (GNM_WBC (wbcg
),
261 wbcg_cur_sheet (wbcg
),
265 static GNM_ACTION_DEF (cb_file_print_area_clear_pagebreaks
)
267 cmd_page_breaks_clear (GNM_WBC (wbcg
), wbcg_cur_sheet (wbcg
));
270 static GNM_ACTION_DEF (cb_file_print
)
272 gnm_print_sheet (GNM_WBC (wbcg
),
273 wbcg_cur_sheet (wbcg
), FALSE
, GNM_PRINT_SAVED_INFO
, NULL
);
276 static GNM_ACTION_DEF (cb_file_print_preview
)
278 gnm_print_sheet (GNM_WBC (wbcg
),
279 wbcg_cur_sheet (wbcg
), TRUE
, GNM_PRINT_ACTIVE_SHEET
, NULL
);
282 static GNM_ACTION_DEF (cb_doc_meta_data
) { dialog_doc_metadata_new (wbcg
, 0); }
283 static GNM_ACTION_DEF (cb_file_preferences
) { dialog_preferences (wbcg
, NULL
); }
284 static GNM_ACTION_DEF (cb_file_history_full
) { dialog_recent_used (wbcg
); }
285 static GNM_ACTION_DEF (cb_file_close
) { wbc_gtk_close (wbcg
); }
287 static GNM_ACTION_DEF (cb_file_quit
)
289 /* If we are still loading initial files, short circuit */
290 if (!initial_workbook_open_complete
) {
291 initial_workbook_open_complete
= TRUE
;
295 /* If we were editing when the quit request came in abort the edit. */
296 wbcg_edit_finish (wbcg
, WBC_EDIT_REJECT
, NULL
);
301 /****************************************************************************/
303 static GNM_ACTION_DEF (cb_edit_clear_all
)
305 cmd_selection_clear (GNM_WBC (wbcg
),
306 CLEAR_VALUES
| CLEAR_FORMATS
| CLEAR_OBJECTS
| CLEAR_COMMENTS
);
309 static GNM_ACTION_DEF (cb_edit_clear_formats
)
310 { cmd_selection_clear (GNM_WBC (wbcg
), CLEAR_FORMATS
); }
311 static GNM_ACTION_DEF (cb_edit_clear_comments
)
312 { cmd_selection_clear (GNM_WBC (wbcg
), CLEAR_COMMENTS
); }
313 static GNM_ACTION_DEF (cb_edit_clear_content
)
314 { cmd_selection_clear (GNM_WBC (wbcg
), CLEAR_VALUES
); }
315 static GNM_ACTION_DEF (cb_edit_clear_all_filtered
)
317 cmd_selection_clear (GNM_WBC (wbcg
),
318 CLEAR_VALUES
| CLEAR_FORMATS
| CLEAR_OBJECTS
| CLEAR_COMMENTS
| CLEAR_FILTERED_ONLY
);
321 static GNM_ACTION_DEF (cb_edit_clear_formats_filtered
)
322 { cmd_selection_clear (GNM_WBC (wbcg
), CLEAR_FORMATS
| CLEAR_FILTERED_ONLY
); }
323 static GNM_ACTION_DEF (cb_edit_clear_comments_filtered
)
324 { cmd_selection_clear (GNM_WBC (wbcg
), CLEAR_COMMENTS
| CLEAR_FILTERED_ONLY
); }
325 static GNM_ACTION_DEF (cb_edit_clear_content_filtered
)
326 { cmd_selection_clear (GNM_WBC (wbcg
), CLEAR_VALUES
| CLEAR_FILTERED_ONLY
); }
328 static GNM_ACTION_DEF (cb_edit_delete_rows
)
330 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
331 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
332 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
336 if (!(sel
= selection_first_range (sv
, GO_CMD_CONTEXT (wbc
), _("Delete"))))
338 rows
= range_height (sel
);
340 cmd_delete_rows (wbc
, sheet
, sel
->start
.row
, rows
);
342 static GNM_ACTION_DEF (cb_edit_delete_columns
)
344 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
345 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
346 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
350 if (!(sel
= selection_first_range (sv
, GO_CMD_CONTEXT (wbc
), _("Delete"))))
352 cols
= range_width (sel
);
354 cmd_delete_cols (wbc
, sheet
, sel
->start
.col
, cols
);
357 static GNM_ACTION_DEF (cb_edit_delete_cells
)
359 dialog_delete_cells (wbcg
);
361 static GNM_ACTION_DEF (cb_edit_delete_links
)
363 SheetControlGUI
*scg
= wbcg_cur_scg (wbcg
);
364 GnmStyle
*style
= gnm_style_new ();
369 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
370 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
372 for (l
= scg_view (scg
)->selections
; l
!= NULL
; l
= l
->next
) {
373 GnmRange
const *r
= l
->data
;
374 GnmStyleList
*styles
;
376 styles
= sheet_style_collect_hlinks (sheet
, r
);
377 n_links
+= g_slist_length (styles
);
378 style_list_free (styles
);
380 format
= ngettext ("Remove %d Link", "Remove %d Links", n_links
);
381 name
= g_strdup_printf (format
, n_links
);
382 gnm_style_set_hlink (style
, NULL
);
383 cmd_selection_format (wbc
, style
, NULL
, name
);
387 static GNM_ACTION_DEF (cb_edit_select_all
)
389 scg_select_all (wbcg_cur_scg (wbcg
));
391 static GNM_ACTION_DEF (cb_edit_select_row
)
393 sv_select_cur_row (wb_control_cur_sheet_view (GNM_WBC (wbcg
)));
395 static GNM_ACTION_DEF (cb_edit_select_col
)
397 sv_select_cur_col (wb_control_cur_sheet_view (GNM_WBC (wbcg
)));
399 static GNM_ACTION_DEF (cb_edit_select_array
)
401 sv_select_cur_array (wb_control_cur_sheet_view (GNM_WBC (wbcg
)));
403 static GNM_ACTION_DEF (cb_edit_select_depends
)
405 sv_select_cur_depends (wb_control_cur_sheet_view (GNM_WBC (wbcg
)));
407 static GNM_ACTION_DEF (cb_edit_select_inputs
)
409 sv_select_cur_inputs (wb_control_cur_sheet_view (GNM_WBC (wbcg
)));
411 static GNM_ACTION_DEF (cb_edit_select_object
)
413 scg_object_select_next (wbcg_cur_scg (wbcg
), FALSE
);
416 static GNM_ACTION_DEF (cb_edit_cut
)
418 if (!wbcg_is_editing (wbcg
)) {
419 SheetControlGUI
*scg
= wbcg_cur_scg (wbcg
);
420 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
421 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
422 if (scg
!= NULL
&& scg
->selected_objects
!= NULL
)
423 gnm_app_clipboard_cut_copy_obj (wbc
, TRUE
, sv
,
424 go_hash_keys (scg
->selected_objects
));
426 sv_selection_cut (sv
, wbc
);
428 gtk_editable_cut_clipboard (GTK_EDITABLE (wbcg_get_entry (wbcg
)));
431 static GNM_ACTION_DEF (cb_edit_copy
)
433 if (!wbcg_is_editing (wbcg
)) {
434 SheetControlGUI
*scg
= wbcg_cur_scg (wbcg
);
435 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
436 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
437 if (scg
!= NULL
&& scg
->selected_objects
!= NULL
)
438 gnm_app_clipboard_cut_copy_obj (wbc
, FALSE
, sv
,
439 go_hash_keys (scg
->selected_objects
));
441 sv_selection_copy (sv
, wbc
);
443 gtk_editable_copy_clipboard (GTK_EDITABLE (wbcg_get_entry (wbcg
)));
446 static GNM_ACTION_DEF (cb_edit_paste
)
448 if (!wbcg_is_editing (wbcg
)) {
449 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
450 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
451 cmd_paste_to_selection (wbc
, sv
, PASTE_DEFAULT
);
453 gtk_editable_paste_clipboard (GTK_EDITABLE (wbcg_get_entry (wbcg
)));
456 static GNM_ACTION_DEF (cb_edit_paste_special
)
458 dialog_paste_special (wbcg
);
461 static GNM_ACTION_DEF (cb_sheet_remove
)
463 SheetControlGUI
*scg
= wbcg_cur_scg (wbcg
);
465 scg_delete_sheet_if_possible (scg
);
469 common_cell_goto (WBCGtk
*wbcg
, Sheet
*sheet
, GnmCellPos
const *pos
)
474 if (!sheet_is_visible (sheet
))
477 wbv
= wb_control_view (GNM_WBC (wbcg
));
478 sv
= sheet_get_view (sheet
, wbv
);
479 wb_view_sheet_focus (wbv
, sheet
);
480 sv_selection_set (sv
, pos
,
483 sv_make_cell_visible (sv
, pos
->col
, pos
->row
, FALSE
);
487 cb_edit_search_replace_query (GnmSearchReplaceQuery q
, GnmSearchReplace
*sr
, ...)
491 WBCGtk
*wbcg
= sr
->user_data
;
497 GnmCell
*cell
= va_arg (pvar
, GnmCell
*);
498 char const *old_text
= va_arg (pvar
, char const *);
499 char const *new_text
= va_arg (pvar
, char const *);
500 char *err
= g_strdup_printf
501 (_("In cell %s, the current contents\n"
503 "would have been replaced by\n"
505 "which is invalid.\n\n"
506 "The replace has been aborted "
507 "and nothing has been changed."),
512 go_gtk_notice_dialog (wbcg_toplevel (wbcg
), GTK_MESSAGE_ERROR
,
515 res
= GTK_RESPONSE_NO
;
519 case GNM_SRQ_QUERY
: {
520 GnmCell
*cell
= va_arg (pvar
, GnmCell
*);
521 char const *old_text
= va_arg (pvar
, char const *);
522 char const *new_text
= va_arg (pvar
, char const *);
523 Sheet
*sheet
= cell
->base
.sheet
;
524 char *pos_name
= g_strconcat (sheet
->name_unquoted
, "!",
525 cell_name (cell
), NULL
);
527 common_cell_goto (wbcg
, sheet
, &cell
->pos
);
529 res
= dialog_search_replace_query (wbcg
, sr
, pos_name
,
535 case GNM_SRQ_QUERY_COMMENT
: {
536 Sheet
*sheet
= va_arg (pvar
, Sheet
*);
537 GnmCellPos
*cp
= va_arg (pvar
, GnmCellPos
*);
538 char const *old_text
= va_arg (pvar
, char const *);
539 char const *new_text
= va_arg (pvar
, char const *);
540 char *pos_name
= g_strdup_printf (_("Comment in cell %s!%s"),
541 sheet
->name_unquoted
,
542 cellpos_as_string (cp
));
543 common_cell_goto (wbcg
, sheet
, cp
);
545 res
= dialog_search_replace_query (wbcg
, sr
, pos_name
,
552 /* Shouldn't really happen. */
553 res
= GTK_RESPONSE_CANCEL
;
561 cb_edit_search_replace_action (WBCGtk
*wbcg
,
562 GnmSearchReplace
*sr
)
564 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
566 sr
->query_func
= cb_edit_search_replace_query
;
567 sr
->user_data
= wbcg
;
569 return cmd_search_replace (wbc
, sr
);
573 static GNM_ACTION_DEF (cb_edit_search_replace
) { dialog_search_replace (wbcg
, cb_edit_search_replace_action
); }
574 static GNM_ACTION_DEF (cb_edit_search
) { dialog_search (wbcg
); }
576 static GNM_ACTION_DEF (cb_edit_fill_autofill
)
578 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
579 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
580 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
582 GnmRange
const *total
= selection_first_range (sv
, GO_CMD_CONTEXT (wbc
), _("Autofill"));
584 GnmRange src
= *total
;
586 GSList
*merges
, *ptr
;
588 if (sheet_range_trim (sheet
, &src
, TRUE
, TRUE
))
589 return; /* Region totally empty */
591 /* trim is a bit overzealous, it forgets about merges */
594 merges
= gnm_sheet_merge_get_overlap (sheet
, &src
);
595 for (ptr
= merges
; ptr
!= NULL
; ptr
= ptr
->next
) {
596 GnmRange
const *r
= ptr
->data
;
597 if (src
.end
.col
< r
->end
.col
) {
598 src
.end
.col
= r
->end
.col
;
601 if (src
.end
.row
< r
->end
.row
) {
602 src
.end
.row
= r
->end
.row
;
608 /* Make it autofill in only one direction */
609 if ((total
->end
.col
- src
.end
.col
) >=
610 (total
->end
.row
- src
.end
.row
))
611 src
.end
.row
= total
->end
.row
;
613 src
.end
.col
= total
->end
.col
;
615 cmd_autofill (wbc
, sheet
, FALSE
,
616 total
->start
.col
, total
->start
.row
,
617 src
.end
.col
- total
->start
.col
+ 1,
618 src
.end
.row
- total
->start
.row
+ 1,
619 total
->end
.col
, total
->end
.row
,
624 static GNM_ACTION_DEF (cb_edit_fill_series
)
626 dialog_fill_series (wbcg
);
629 static GNM_ACTION_DEF (cb_edit_goto_top
)
631 wb_control_navigate_to_cell (GNM_WBC (wbcg
), navigator_top
);
633 static GNM_ACTION_DEF (cb_edit_goto_bottom
)
635 wb_control_navigate_to_cell (GNM_WBC (wbcg
), navigator_bottom
);
637 static GNM_ACTION_DEF (cb_edit_goto_first
)
639 wb_control_navigate_to_cell (GNM_WBC (wbcg
), navigator_first
);
641 static GNM_ACTION_DEF (cb_edit_goto_last
)
643 wb_control_navigate_to_cell (GNM_WBC (wbcg
), navigator_last
);
645 static GNM_ACTION_DEF (cb_edit_goto
)
647 dialog_goto_cell (wbcg
);
649 static GNM_ACTION_DEF (cb_edit_goto_cell_indicator
)
651 if (GNM_IS_WBC_GTK (wbcg
))
652 wbcg_focus_current_cell_indicator (WBC_GTK (wbcg
));
655 static GNM_ACTION_DEF (cb_edit_recalc
)
658 * f9 - do any necessary calculations across all sheets
659 * shift-f9 - do any necessary calcs on current sheet only
660 * ctrl-alt-f9 - force a full recalc across all sheets
661 * ctrl-alt-shift-f9 - a full-monty super recalc
663 workbook_recalc_all (wb_control_get_workbook (GNM_WBC (wbcg
)));
666 static GNM_ACTION_DEF (cb_repeat
) { command_repeat (GNM_WBC (wbcg
)); }
668 /****************************************************************************/
670 static GNM_ACTION_DEF (cb_direction
)
672 Sheet
*sheet
= wb_control_cur_sheet (GNM_WBC (wbcg
));
673 cmd_toggle_rtl (GNM_WBC (wbcg
), sheet
);
676 static GNM_ACTION_DEF (cb_view_zoom_in
)
678 Sheet
*sheet
= wb_control_cur_sheet (GNM_WBC (wbcg
));
679 int zoom
= (int)(sheet
->last_zoom_factor_used
* 100. + .5) - 10;
680 if ((zoom
% 15) != 0)
681 zoom
= 15 * (int)(zoom
/15);
684 cmd_zoom (GNM_WBC (wbcg
), g_slist_append (NULL
, sheet
),
685 (double) (zoom
+ 10) / 100);
687 static GNM_ACTION_DEF (cb_view_zoom_out
)
689 Sheet
*sheet
= wb_control_cur_sheet (GNM_WBC (wbcg
));
690 int zoom
= (int)(sheet
->last_zoom_factor_used
* 100. + .5) - 10;
691 if ((zoom
% 15) != 0)
692 zoom
= 15 * (int)(zoom
/15);
696 cmd_zoom (GNM_WBC (wbcg
), g_slist_append (NULL
, sheet
),
697 (double) (zoom
+ 10) / 100);
700 static GNM_ACTION_DEF (cb_view_fullscreen
)
702 if (wbcg
->is_fullscreen
)
703 gtk_window_unfullscreen (wbcg_toplevel (wbcg
));
705 gtk_window_fullscreen (wbcg_toplevel (wbcg
));
708 static GNM_ACTION_DEF (cb_view_zoom
) { dialog_zoom (wbcg
, wbcg_cur_sheet (wbcg
)); }
709 static GNM_ACTION_DEF (cb_view_new
) { dialog_new_view (wbcg
); }
710 static GNM_ACTION_DEF (cb_view_freeze_panes
)
712 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
713 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
714 SheetControlGUI
*scg
= wbcg_cur_scg (wbcg
);
717 if (scg
->active_panes
== 1) {
718 gboolean center
= FALSE
;
719 GnmPane
const *pane
= scg_pane (scg
, 0);
720 GnmCellPos frozen_tl
, unfrozen_tl
;
722 frozen_tl
= pane
->first
;
723 unfrozen_tl
= sv
->edit_pos
;
725 if (unfrozen_tl
.row
== 0 && unfrozen_tl
.col
== 0) {
726 GnmRange
const *first
= selection_first_range (sv
, NULL
, NULL
);
727 Sheet
*sheet
= sv_sheet (sv
);
728 gboolean full_rows
= range_is_full (first
, sheet
, TRUE
);
729 gboolean full_cols
= range_is_full (first
, sheet
, FALSE
);
730 if (!full_rows
|| !full_cols
) {
731 if (!full_rows
&& !full_cols
) {
732 unfrozen_tl
.row
= first
->end
.row
+ 1;
733 unfrozen_tl
.col
= first
->end
.col
+ 1;
734 } else if (full_rows
) {
735 unfrozen_tl
.row
= first
->end
.row
+ 1;
739 unfrozen_tl
.col
= first
->end
.col
+ 1;
744 /* If edit pos is out of visible range */
745 if (unfrozen_tl
.col
< pane
->first
.col
||
746 unfrozen_tl
.col
> pane
->last_visible
.col
||
747 unfrozen_tl
.row
< pane
->first
.row
||
748 unfrozen_tl
.row
> pane
->last_visible
.row
)
751 if (unfrozen_tl
.col
== pane
->first
.col
) {
752 /* or edit pos is in top left visible cell */
753 if (unfrozen_tl
.row
== pane
->first
.row
)
756 unfrozen_tl
.col
= frozen_tl
.col
= 0;
757 } else if (unfrozen_tl
.row
== pane
->first
.row
)
758 unfrozen_tl
.row
= frozen_tl
.row
= 0;
761 unfrozen_tl
.col
= (pane
->first
.col
+
762 pane
->last_visible
.col
) / 2;
763 unfrozen_tl
.row
= (pane
->first
.row
+
764 pane
->last_visible
.row
) / 2;
767 g_return_if_fail (unfrozen_tl
.col
> frozen_tl
.col
||
768 unfrozen_tl
.row
> frozen_tl
.row
);
770 sv_freeze_panes (sv
, &frozen_tl
, &unfrozen_tl
);
772 sv_freeze_panes (sv
, NULL
, NULL
);
775 /****************************************************************************/
778 insert_date_time_common (WBCGtk
*wbcg
, gboolean do_date
, gboolean do_time
)
780 if (wbcg_edit_start (wbcg
, FALSE
, FALSE
)) {
781 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
782 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
783 Sheet
*sheet
= sv_sheet (sv
);
784 GnmCell
const *cell
= sheet_cell_fetch (sheet
,
787 GODateConventions
const *date_conv
=
788 workbook_date_conv (sheet
->workbook
);
789 GnmValue
*v
= value_new_float
790 (go_date_timet_to_serial_raw (time (NULL
), date_conv
));
796 GOFormat
*fmt
= gnm_format_for_date_editing (cell
);
797 dtxt
= format_value (fmt
, v
, -1, date_conv
);
798 go_format_unref (fmt
);
802 GOFormat
const *fmt
= go_format_default_time ();
803 ttxt
= format_value (fmt
, v
, -1, date_conv
);
806 if (do_date
&& do_time
) {
807 txt
= g_strconcat (dtxt
, " ", ttxt
, NULL
);
815 wb_control_edit_line_set (wbc
, txt
);
824 static GNM_ACTION_DEF (cb_insert_current_date_time
)
826 insert_date_time_common (wbcg
, TRUE
, TRUE
);
828 static GNM_ACTION_DEF (cb_insert_current_date
)
830 insert_date_time_common (wbcg
, TRUE
, FALSE
);
833 static GNM_ACTION_DEF (cb_insert_current_time
)
835 insert_date_time_common (wbcg
, FALSE
, TRUE
);
838 static GNM_ACTION_DEF (cb_define_name
)
840 dialog_define_names (wbcg
);
842 static GNM_ACTION_DEF (cb_paste_names
)
844 dialog_paste_names (wbcg
);
847 static GNM_ACTION_DEF (cb_insert_rows
)
849 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
850 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
851 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
854 /* TODO : No need to check simplicty. XL applies for each non-discrete
855 * selected region, (use selection_apply). Arrays and Merged regions
858 if (!(sel
= selection_first_range (sv
, GO_CMD_CONTEXT (wbc
), _("Insert rows"))))
860 cmd_insert_rows (wbc
, sheet
, sel
->start
.row
, range_height (sel
));
863 static GNM_ACTION_DEF (cb_insert_cols
)
865 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
866 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
867 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
870 /* TODO : No need to check simplicty. XL applies for each non-discrete
871 * selected region, (use selection_apply). Arrays and Merged regions
874 if (!(sel
= selection_first_range (sv
, GO_CMD_CONTEXT (wbc
),
875 _("Insert columns"))))
877 cmd_insert_cols (wbc
, sheet
, sel
->start
.col
, range_width (sel
));
880 static GNM_ACTION_DEF (cb_insert_cells
) { dialog_insert_cells (wbcg
); }
882 static GNM_ACTION_DEF (cb_insert_comment
)
884 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
885 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
886 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
887 dialog_cell_comment (wbcg
, sheet
, &sv
->edit_pos
);
890 /****************************************************************************/
892 static GNM_ACTION_DEF (cb_sheet_name
)
894 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
895 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
896 dialog_sheet_rename (wbcg
, sheet
);
899 static GNM_ACTION_DEF (cb_sheet_order
) { dialog_sheet_order (wbcg
); }
900 static GNM_ACTION_DEF (cb_sheet_resize
) { dialog_sheet_resize (wbcg
); }
901 static GNM_ACTION_DEF (cb_format_cells
) { dialog_cell_format (wbcg
, FD_CURRENT
, 0); }
902 static GNM_ACTION_DEF (cb_format_cells_cond
) { dialog_cell_format_cond (wbcg
); }
903 static GNM_ACTION_DEF (cb_autoformat
) { dialog_autoformat (wbcg
); }
904 static GNM_ACTION_DEF (cb_workbook_attr
) { dialog_workbook_attr (wbcg
); }
905 static GNM_ACTION_DEF (cb_tools_plugins
) { dialog_plugin_manager (wbcg
); }
906 static GNM_ACTION_DEF (cb_tools_autocorrect
) { dialog_preferences (wbcg
, "Auto Correct"); }
907 static GNM_ACTION_DEF (cb_tools_auto_save
) { dialog_autosave (wbcg
); }
908 static GNM_ACTION_DEF (cb_tools_goal_seek
) { dialog_goal_seek (wbcg
, wbcg_cur_sheet (wbcg
)); }
909 static GNM_ACTION_DEF (cb_tools_tabulate
) { dialog_tabulate (wbcg
, wbcg_cur_sheet (wbcg
)); }
910 static GNM_ACTION_DEF (cb_tools_merge
) { dialog_merge (wbcg
); }
912 static GNM_ACTION_DEF (cb_tools_solver
) { dialog_solver (wbcg
, wbcg_cur_sheet (wbcg
)); }
914 static GNM_ACTION_DEF (cb_tools_scenario_add
) { dialog_scenario_add (wbcg
); }
915 static GNM_ACTION_DEF (cb_tools_scenarios
) { dialog_scenarios (wbcg
); }
916 static GNM_ACTION_DEF (cb_tools_simulation
) { dialog_simulation (wbcg
, wbcg_cur_sheet (wbcg
)); }
917 static GNM_ACTION_DEF (cb_tools_compare
) { dialog_sheet_compare (wbcg
); }
918 static GNM_ACTION_DEF (cb_tools_anova_one_factor
) { dialog_anova_single_factor_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
919 static GNM_ACTION_DEF (cb_tools_anova_two_factor
) { dialog_anova_two_factor_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
920 static GNM_ACTION_DEF (cb_tools_chi_square_independence
) { dialog_chi_square_tool (wbcg
, wbcg_cur_sheet (wbcg
), TRUE
); }
921 static GNM_ACTION_DEF (cb_tools_chi_square_homogeneity
) { dialog_chi_square_tool (wbcg
, wbcg_cur_sheet (wbcg
), FALSE
); }
922 static GNM_ACTION_DEF (cb_tools_correlation
) { dialog_correlation_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
923 static GNM_ACTION_DEF (cb_tools_covariance
) { dialog_covariance_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
924 static GNM_ACTION_DEF (cb_tools_desc_statistics
) { dialog_descriptive_stat_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
925 static GNM_ACTION_DEF (cb_tools_exp_smoothing
) { dialog_exp_smoothing_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
926 static GNM_ACTION_DEF (cb_tools_average
) { dialog_average_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
927 static GNM_ACTION_DEF (cb_tools_fourier
) { dialog_fourier_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
928 static GNM_ACTION_DEF (cb_tools_frequency
) { dialog_frequency_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
929 static GNM_ACTION_DEF (cb_tools_histogram
) { dialog_histogram_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
930 static GNM_ACTION_DEF (cb_tools_kaplan_meier
) { dialog_kaplan_meier_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
931 static GNM_ACTION_DEF (cb_tools_normality_tests
){ dialog_normality_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
932 static GNM_ACTION_DEF (cb_tools_one_mean_test
) { dialog_one_mean_test_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
933 static GNM_ACTION_DEF (cb_tools_principal_components
) { dialog_principal_components_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
934 static GNM_ACTION_DEF (cb_tools_ranking
) { dialog_ranking_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
935 static GNM_ACTION_DEF (cb_tools_regression
) { dialog_regression_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
936 static GNM_ACTION_DEF (cb_tools_sampling
) { dialog_sampling_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
937 static GNM_ACTION_DEF (cb_tools_sign_test_one_median
) { dialog_sign_test_tool (wbcg
, wbcg_cur_sheet (wbcg
), SIGNTEST
); }
938 static GNM_ACTION_DEF (cb_tools_sign_test_two_medians
) { dialog_sign_test_two_tool (wbcg
, wbcg_cur_sheet (wbcg
), SIGNTEST
); }
939 static GNM_ACTION_DEF (cb_tools_wilcoxon_signed_rank_one_median
) { dialog_sign_test_tool (wbcg
, wbcg_cur_sheet (wbcg
), SIGNTEST_WILCOXON
); }
940 static GNM_ACTION_DEF (cb_tools_wilcoxon_signed_rank_two_medians
) { dialog_sign_test_two_tool (wbcg
, wbcg_cur_sheet (wbcg
), SIGNTEST_WILCOXON
); }
941 static GNM_ACTION_DEF (cb_tools_wilcoxon_mann_whitney
) { dialog_wilcoxon_m_w_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
942 static GNM_ACTION_DEF (cb_tools_ttest_paired
) { dialog_ttest_tool (wbcg
, wbcg_cur_sheet (wbcg
), TTEST_PAIRED
); }
943 static GNM_ACTION_DEF (cb_tools_ttest_equal_var
) { dialog_ttest_tool (wbcg
, wbcg_cur_sheet (wbcg
), TTEST_UNPAIRED_EQUALVARIANCES
); }
944 static GNM_ACTION_DEF (cb_tools_ttest_unequal_var
) { dialog_ttest_tool (wbcg
, wbcg_cur_sheet (wbcg
), TTEST_UNPAIRED_UNEQUALVARIANCES
); }
945 static GNM_ACTION_DEF (cb_tools_ztest
) { dialog_ttest_tool (wbcg
, wbcg_cur_sheet (wbcg
), TTEST_ZTEST
); }
946 static GNM_ACTION_DEF (cb_tools_ftest
) { dialog_ftest_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
947 static GNM_ACTION_DEF (cb_tools_random_generator_uncorrelated
) { dialog_random_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
948 static GNM_ACTION_DEF (cb_tools_random_generator_correlated
) { dialog_random_cor_tool (wbcg
, wbcg_cur_sheet (wbcg
)); }
949 static GNM_ACTION_DEF (cb_data_sort
) { dialog_cell_sort (wbcg
); }
950 static GNM_ACTION_DEF (cb_data_shuffle
) { dialog_shuffle (wbcg
); }
951 static GNM_ACTION_DEF (cb_data_import_text
) { gui_file_open
952 (wbcg
, GNM_FILE_OPEN_STYLE_IMPORT
, "Gnumeric_stf:stf_assistant"); }
953 static GNM_ACTION_DEF (cb_data_import_other
) { gui_file_open
954 (wbcg
, GNM_FILE_OPEN_STYLE_IMPORT
, NULL
); }
956 static GNM_ACTION_DEF (cb_auto_filter
) { cmd_autofilter_add_remove (GNM_WBC (wbcg
)); }
957 static GNM_ACTION_DEF (cb_show_all
) { filter_show_all (GNM_WBC (wbcg
)); }
958 static GNM_ACTION_DEF (cb_data_filter
) { dialog_advanced_filter (wbcg
); }
959 static GNM_ACTION_DEF (cb_data_validate
) { dialog_cell_format (wbcg
, FD_VALIDATION
,
960 (1 << FD_VALIDATION
) | (1 << FD_INPUT_MSG
)); }
961 static GNM_ACTION_DEF (cb_data_text_to_columns
) { stf_text_to_columns (GNM_WBC (wbcg
), GO_CMD_CONTEXT (wbcg
)); }
962 static GNM_ACTION_DEF (cb_data_consolidate
) { dialog_consolidate (wbcg
); }
963 static GNM_ACTION_DEF (cb_data_table
) { dialog_data_table (wbcg
); }
964 static GNM_ACTION_DEF (cb_data_slicer_create
) { dialog_data_slicer (wbcg
, TRUE
); }
965 static GNM_ACTION_DEF (cb_data_slicer_refresh
) { cmd_slicer_refresh (GNM_WBC (wbcg
)); }
966 static GNM_ACTION_DEF (cb_data_slicer_edit
) { dialog_data_slicer (wbcg
, FALSE
); }
967 static GNM_ACTION_DEF (cb_data_export
) { gui_file_save_as
968 (wbcg
, wb_control_view (GNM_WBC (wbcg
)),
969 GNM_FILE_SAVE_AS_STYLE_EXPORT
, NULL
); }
970 static GNM_ACTION_DEF (cb_data_export_text
) { gui_file_save_as
971 (wbcg
, wb_control_view (GNM_WBC (wbcg
)),
972 GNM_FILE_SAVE_AS_STYLE_EXPORT
, "Gnumeric_stf:stf_assistant"); }
973 static GNM_ACTION_DEF (cb_data_export_csv
) { gui_file_save_as
974 (wbcg
, wb_control_view (GNM_WBC (wbcg
)),
975 GNM_FILE_SAVE_AS_STYLE_EXPORT
, "Gnumeric_stf:stf_csv"); }
976 static GNM_ACTION_DEF (cb_data_export_repeat
) { gui_file_export_repeat (wbcg
); }
979 hide_show_detail_real (WBCGtk
*wbcg
, gboolean is_cols
, gboolean show
)
981 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
982 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
983 char const *operation
= show
? _("Show Detail") : _("Hide Detail");
984 GnmRange
const *r
= selection_first_range (sv
, GO_CMD_CONTEXT (wbc
),
987 /* This operation can only be performed on a whole existing group */
988 if (sheet_colrow_can_group (sv_sheet (sv
), r
, is_cols
)) {
989 go_cmd_context_error_invalid (GO_CMD_CONTEXT (wbc
), operation
,
990 _("can only be performed on an existing group"));
994 cmd_selection_colrow_hide (wbc
, is_cols
, show
);
998 hide_show_detail (WBCGtk
*wbcg
, gboolean show
)
1000 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1001 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
1002 Sheet
const *sheet
= sv_sheet (sv
);
1003 char const *operation
= show
? _("Show Detail") : _("Hide Detail");
1004 GnmRange
const *r
= selection_first_range (sv
,
1005 GO_CMD_CONTEXT (wbc
), operation
);
1008 /* We only operate on a single selection */
1012 /* Do we need to ask the user what he/she wants to group/ungroup? */
1013 if (range_is_full (r
, sheet
, TRUE
) ^ range_is_full (r
, sheet
, FALSE
))
1014 is_cols
= !range_is_full (r
, sheet
, TRUE
);
1016 dialog_col_row (wbcg
, operation
,
1017 (ColRowCallback_t
) hide_show_detail_real
,
1018 GINT_TO_POINTER (show
));
1022 hide_show_detail_real (wbcg
, is_cols
, show
);
1026 group_ungroup_colrow (WBCGtk
*wbcg
, gboolean group
)
1028 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1029 SheetView
*sv
= wb_control_cur_sheet_view (wbc
);
1030 Sheet
const *sheet
= sv_sheet (sv
);
1031 char const *operation
= group
? _("Group") : _("Ungroup");
1032 GnmRange
const *r
= selection_first_range (sv
,
1033 GO_CMD_CONTEXT (wbc
), operation
);
1036 /* We only operate on a single selection */
1040 /* Do we need to ask the user what he/she wants to group/ungroup? */
1041 if (range_is_full (r
, sheet
, TRUE
) ^ range_is_full (r
, sheet
, FALSE
))
1042 is_cols
= !range_is_full (r
, sheet
, TRUE
);
1044 dialog_col_row (wbcg
, operation
,
1045 (ColRowCallback_t
) cmd_selection_group
,
1046 GINT_TO_POINTER (group
));
1050 cmd_selection_group (wbc
, is_cols
, group
);
1053 static GNM_ACTION_DEF (cb_data_hide_detail
) { hide_show_detail (wbcg
, FALSE
); }
1054 static GNM_ACTION_DEF (cb_data_show_detail
) { hide_show_detail (wbcg
, TRUE
); }
1055 static GNM_ACTION_DEF (cb_data_group
) { group_ungroup_colrow (wbcg
, TRUE
); }
1056 static GNM_ACTION_DEF (cb_data_ungroup
) { group_ungroup_colrow (wbcg
, FALSE
); }
1058 static GNM_ACTION_DEF (cb_help_function
) { dialog_function_select_help (wbcg
); }
1059 static GNM_ACTION_DEF (cb_help_docs
)
1061 char *argv
[] = { NULL
, NULL
, NULL
};
1065 argv
[0] = (char *)"yelp";
1066 argv
[1] = (char *)"help:gnumeric";
1067 g_spawn_async (NULL
, argv
, NULL
,
1068 G_SPAWN_SEARCH_PATH
| G_SPAWN_STDOUT_TO_DEV_NULL
1069 | G_SPAWN_STDERR_TO_DEV_NULL
,
1070 NULL
, NULL
, NULL
, &err
);
1072 /* TODO : Should really start in same directory as the gspawn-* helpers
1073 * are installed in case they are not in the path */
1074 argv
[0] = (char *)"hh";
1075 argv
[1] = g_build_filename (gnm_sys_data_dir (), "doc", "C",
1076 "gnumeric.chm", NULL
);
1077 g_spawn_async (NULL
, argv
, NULL
,
1078 G_SPAWN_SEARCH_PATH
| G_SPAWN_STDOUT_TO_DEV_NULL
1079 | G_SPAWN_STDERR_TO_DEV_NULL
,
1080 NULL
, NULL
, NULL
, &err
);
1084 GOErrorInfo
*ei
= go_error_info_new_printf
1085 (_("Unable to start the help browser (%s).\n"
1086 "The system error message is: \n\n%s"),
1087 argv
[0], err
->message
);
1088 go_cmd_context_error_info (GO_CMD_CONTEXT (wbcg
), ei
);
1095 show_url (WBCGtk
*wbcg
, const char *url
)
1100 screen
= gtk_window_get_screen (wbcg_toplevel (wbcg
));
1101 err
= go_gtk_url_show (url
, screen
);
1103 go_cmd_context_error (GO_CMD_CONTEXT (wbcg
), err
);
1109 static GNM_ACTION_DEF (cb_help_web
)
1111 show_url (wbcg
, "http://www.gnumeric.org/");
1114 static GNM_ACTION_DEF (cb_help_irc
)
1116 show_url (wbcg
, "irc://irc.gnome.org/gnumeric");
1119 static GNM_ACTION_DEF (cb_help_bug
)
1121 show_url (wbcg
, "http://bugzilla.gnome.org/enter_bug.cgi?product=Gnumeric");
1124 static GNM_ACTION_DEF (cb_help_about
) { dialog_about (wbcg
); }
1126 static GNM_ACTION_DEF (cb_autosum
)
1131 if (wbcg_is_editing (wbcg
))
1134 entry
= wbcg_get_entry (wbcg
);
1135 txt
= gtk_entry_get_text (entry
);
1136 if (strncmp (txt
, "=sum(", 5)) {
1137 if (!wbcg_edit_start (wbcg
, TRUE
, TRUE
))
1138 return; /* attempt to edit failed */
1139 gtk_entry_set_text (entry
, "=sum()");
1140 gtk_editable_set_position (GTK_EDITABLE (entry
), 5);
1142 if (!wbcg_edit_start (wbcg
, FALSE
, TRUE
))
1143 return; /* attempt to edit failed */
1146 * FIXME : This is crap!
1147 * When the function druid is more complete use that.
1149 gtk_editable_set_position (GTK_EDITABLE (entry
),
1150 gtk_entry_get_text_length (entry
)-1);
1154 static GNM_ACTION_DEF (cb_insert_image
)
1156 char *uri
= go_gtk_select_image (wbcg_toplevel (wbcg
), NULL
);
1160 GsfInput
*input
= go_file_open (uri
, &err
);
1162 if (input
!= NULL
) {
1163 unsigned len
= gsf_input_size (input
);
1164 guint8
const *data
= gsf_input_read (input
, len
, NULL
);
1165 SheetObjectImage
*soi
= g_object_new (GNM_SO_IMAGE_TYPE
, NULL
);
1166 sheet_object_image_set_image (soi
, "", data
, len
);
1167 wbcg_insert_object (wbcg
, GNM_SO (soi
));
1168 g_object_unref (input
);
1170 go_cmd_context_error (GO_CMD_CONTEXT (wbcg
), err
);
1176 static GNM_ACTION_DEF (cb_insert_hyperlink
) { dialog_hyperlink (wbcg
, GNM_SC (wbcg_cur_scg (wbcg
))); }
1177 static GNM_ACTION_DEF (cb_formula_guru
) { dialog_formula_guru (wbcg
, NULL
); }
1178 static GNM_ACTION_DEF (cb_insert_sort_ascending
) { workbook_cmd_wrap_sort (GNM_WBC (wbcg
), 1);}
1179 static GNM_ACTION_DEF (cb_insert_sort_descending
){ workbook_cmd_wrap_sort (GNM_WBC (wbcg
), 0);}
1182 sort_by_rows (WBCGtk
*wbcg
, gboolean descending
)
1186 GnmRange tmp_ns
={{0,0},{0,0}}, tmp_s
={{0,0},{0,0}};
1188 GnmSortClause
*clause
;
1191 int cnt_singletons
= 0, cnt_non_singletons
= 0;
1192 gboolean top_to_bottom
= TRUE
;
1193 gboolean not_acceptable
= FALSE
;
1195 g_return_if_fail (GNM_IS_WBC_GTK (wbcg
));
1197 sv
= wb_control_cur_sheet_view (GNM_WBC (wbcg
));
1198 for (l
= sv
->selections
; l
!= NULL
; l
= l
->next
) {
1199 GnmRange
const *r
= l
->data
;
1200 if (range_is_singleton (r
)) {
1204 cnt_non_singletons
++;
1209 not_acceptable
= (cnt_non_singletons
> 1 ||
1210 (cnt_non_singletons
== 0 && cnt_singletons
> 1));
1212 if (!not_acceptable
&& cnt_singletons
> 0 && cnt_non_singletons
== 1) {
1213 gboolean first
= TRUE
;
1214 for (l
= sv
->selections
; l
!= NULL
; l
= l
->next
) {
1215 GnmRange
const *r
= l
->data
;
1216 gboolean t_b
= FALSE
, l_r
= FALSE
;
1218 if (!range_is_singleton (r
))
1220 t_b
= r
->start
.col
>= tmp_ns
.start
.col
&&
1221 r
->end
.col
<= tmp_ns
.end
.col
;
1222 l_r
= r
->start
.row
>= tmp_ns
.start
.row
&&
1223 r
->end
.row
<= tmp_ns
.end
.row
;
1225 not_acceptable
= TRUE
;
1231 top_to_bottom
= t_b
;
1233 if ((top_to_bottom
&& !t_b
) ||
1234 (!top_to_bottom
&& !l_r
)) {
1235 not_acceptable
= TRUE
;
1243 if (not_acceptable
) {
1244 GError
*msg
= g_error_new (go_error_invalid(), 0,
1245 _("%s does not support multiple ranges"),
1247 go_cmd_context_error (GO_CMD_CONTEXT (wbcg
), msg
);
1252 if (cnt_singletons
== 1 && cnt_non_singletons
== 0) {
1253 Sheet
*sheet
= sv_sheet (sv
);
1255 sel
= g_new0 (GnmRange
, 1);
1256 range_init_full_sheet (sel
, sheet
);
1257 sel
->start
.row
= tmp_s
.start
.row
;
1258 range_clip_to_finite (sel
, sheet
);
1260 clause
= g_new0 (GnmSortClause
, 1);
1261 clause
[0].offset
= tmp_s
.start
.col
- sel
->start
.col
;
1262 clause
[0].asc
= descending
;
1263 clause
[0].cs
= gnm_conf_get_core_sort_default_by_case ();
1264 clause
[0].val
= TRUE
;
1265 } else if (cnt_singletons
== 0) {
1266 sel
= gnm_range_dup (&tmp_ns
);
1267 range_clip_to_finite (sel
, sv_sheet (sv
));
1269 numclause
= range_width (sel
);
1270 clause
= g_new0 (GnmSortClause
, numclause
);
1271 for (i
= 0; i
< numclause
; i
++) {
1272 clause
[i
].offset
= i
;
1273 clause
[i
].asc
= descending
;
1274 clause
[i
].cs
= gnm_conf_get_core_sort_default_by_case ();
1275 clause
[i
].val
= TRUE
;
1277 } else /* cnt_singletons > 0 && cnt_non_singletons == 1*/ {
1278 sel
= gnm_range_dup (&tmp_ns
);
1279 range_clip_to_finite (sel
, sv_sheet (sv
));
1280 numclause
= cnt_singletons
;
1281 clause
= g_new0 (GnmSortClause
, numclause
);
1283 for (l
= sv
->selections
; l
!= NULL
; l
= l
->next
) {
1284 GnmRange
const *r
= l
->data
;
1285 if (!range_is_singleton (r
))
1288 clause
[i
].offset
= (top_to_bottom
) ?
1289 r
->start
.col
- sel
->start
.col
1290 : r
->start
.row
- sel
->start
.row
;
1291 clause
[i
].asc
= descending
;
1292 clause
[i
].cs
= gnm_conf_get_core_sort_default_by_case ();
1293 clause
[i
].val
= TRUE
;
1299 data
= g_new (GnmSortData
, 1);
1300 data
->sheet
= sv_sheet (sv
);
1302 data
->num_clause
= numclause
;
1303 data
->clauses
= clause
;
1304 data
->locale
= NULL
;
1306 data
->retain_formats
= gnm_conf_get_core_sort_default_retain_formats ();
1308 /* Hard code sorting by row. I would prefer not to, but user testing
1310 * - that the button should always does the same things
1311 * - that the icon matches the behavior
1315 /* Note that if the user specified rows by singleton selection we switch */
1316 /* to column sorting */
1317 data
->top
= top_to_bottom
;
1319 if (sheet_range_has_heading (data
->sheet
, data
->range
, data
->top
, FALSE
))
1320 data
->range
->start
.row
+= 1;
1322 cmd_sort (GNM_WBC (wbcg
), data
);
1324 static GNM_ACTION_DEF (cb_sort_ascending
) { sort_by_rows (wbcg
, FALSE
); }
1325 static GNM_ACTION_DEF (cb_sort_descending
) { sort_by_rows (wbcg
, TRUE
); }
1328 cb_add_graph (GogGraph
*graph
, gpointer wbcg
)
1330 GnmGraphDataClosure
*data
= (GnmGraphDataClosure
*) g_object_get_data (G_OBJECT (graph
), "data-closure");
1332 if (data
->new_sheet
) {
1333 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1334 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
1335 WorkbookSheetState
*old_state
= workbook_sheet_state_new (wb_control_get_workbook (wbc
));
1336 Sheet
*new_sheet
= workbook_sheet_add_with_type (
1337 wb_control_get_workbook (wbc
),
1338 GNM_SHEET_OBJECT
, -1,
1339 gnm_sheet_get_max_cols (sheet
),
1340 gnm_sheet_get_max_rows (sheet
));
1341 SheetObject
*sog
= sheet_object_graph_new (graph
);
1342 print_info_set_paper_orientation (new_sheet
->print_info
, GTK_PAGE_ORIENTATION_LANDSCAPE
);
1343 sheet_object_set_sheet (sog
, new_sheet
);
1344 wb_view_sheet_focus (wb_control_view (wbc
), new_sheet
);
1345 cmd_reorganize_sheets (wbc
, old_state
, sheet
);
1346 g_object_unref (sog
);
1350 wbcg_insert_object (WBC_GTK (wbcg
), sheet_object_graph_new (graph
));
1353 static GNM_ACTION_DEF (cb_launch_chart_guru
)
1355 GClosure
*closure
= g_cclosure_new (G_CALLBACK (cb_add_graph
),
1357 sheet_object_graph_guru (wbcg
, NULL
, closure
);
1358 g_closure_sink (closure
);
1362 cb_add_component_new (GOComponent
*component
, gpointer wbcg
)
1364 wbcg_insert_object (WBC_GTK (wbcg
), sheet_object_component_new (component
));
1368 component_changed_cb (GOComponent
*component
, gpointer data
)
1370 cb_add_component_new (component
, data
);
1373 static GNM_ACTION_DEF (cb_launch_go_component_new
)
1375 gchar
const *mime_type
;
1377 GtkWidget
*dialog
= go_component_mime_dialog_new ();
1378 result
= gtk_dialog_run (GTK_DIALOG (dialog
));
1379 if (result
== GTK_RESPONSE_OK
) {
1380 mime_type
= go_component_mime_dialog_get_mime_type ((GOComponentMimeDialog
*) dialog
);
1383 GOComponent
*component
= go_component_new_by_mime_type (mime_type
);
1385 g_signal_connect (G_OBJECT (component
), "changed", G_CALLBACK (component_changed_cb
), wbcg
);
1386 win
= go_component_edit (component
);
1387 gtk_window_set_transient_for (win
, GTK_WINDOW (wbcg_toplevel (wbcg
)));
1388 g_object_set_data_full (G_OBJECT (win
), "component", component
, g_object_unref
);
1392 gtk_widget_destroy (dialog
);
1395 static GNM_ACTION_DEF (cb_launch_go_component_from_file
)
1397 GtkWidget
*dlg
= gtk_file_chooser_dialog_new (_("Choose object file"),
1398 GTK_WINDOW (wbcg_toplevel (wbcg
)),
1399 GTK_FILE_CHOOSER_ACTION_OPEN
,
1400 GNM_STOCK_OPEN
, GTK_RESPONSE_ACCEPT
,
1401 GNM_STOCK_CANCEL
, GTK_RESPONSE_CANCEL
,
1403 go_components_add_filter (GTK_FILE_CHOOSER (dlg
));
1404 if (gtk_dialog_run (GTK_DIALOG (dlg
)) == GTK_RESPONSE_ACCEPT
) {
1405 char *uri
= gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dlg
));
1406 GOComponent
*component
;
1407 component
= go_component_new_from_uri (uri
);
1410 wbcg_insert_object (WBC_GTK (wbcg
), sheet_object_component_new (component
));
1411 g_object_unref (component
);
1414 gtk_widget_destroy (dlg
);
1418 create_object (WBCGtk
*wbcg
, GType t
,
1419 char const *first_property_name
,
1423 va_start (args
, first_property_name
);
1424 wbcg_insert_object (wbcg
, (SheetObject
*)
1425 g_object_new_valist (t
, first_property_name
, args
));
1429 static GNM_ACTION_DEF (cmd_create_frame
)
1430 { create_object (wbcg
, sheet_widget_frame_get_type(), NULL
); }
1431 static GNM_ACTION_DEF (cmd_create_button
)
1432 { create_object (wbcg
, sheet_widget_button_get_type(), NULL
); }
1433 static GNM_ACTION_DEF (cmd_create_radiobutton
)
1434 { create_object (wbcg
, sheet_widget_radio_button_get_type(), NULL
); }
1435 static GNM_ACTION_DEF (cmd_create_scrollbar
)
1436 { create_object (wbcg
, sheet_widget_scrollbar_get_type(), NULL
); }
1437 static GNM_ACTION_DEF (cmd_create_slider
)
1438 { create_object (wbcg
, sheet_widget_slider_get_type(), NULL
); }
1439 static GNM_ACTION_DEF (cmd_create_spinbutton
)
1440 { create_object (wbcg
, sheet_widget_spinbutton_get_type(), NULL
); }
1441 static GNM_ACTION_DEF (cmd_create_checkbox
)
1442 { create_object (wbcg
, sheet_widget_checkbox_get_type(), NULL
); }
1443 static GNM_ACTION_DEF (cmd_create_list
)
1444 { create_object (wbcg
, sheet_widget_list_get_type(), NULL
); }
1445 static GNM_ACTION_DEF (cmd_create_combo
)
1446 { create_object (wbcg
, sheet_widget_combo_get_type(), NULL
); }
1447 static GNM_ACTION_DEF (cmd_create_line
)
1448 { create_object (wbcg
, GNM_SO_LINE_TYPE
, NULL
); }
1449 static GNM_ACTION_DEF (cmd_create_arrow
) {
1451 go_arrow_init_kite (&arrow
, 8., 10., 3.);
1452 create_object (wbcg
, GNM_SO_LINE_TYPE
, "end-arrow", &arrow
, NULL
);
1454 static GNM_ACTION_DEF (cmd_create_rectangle
)
1455 { create_object (wbcg
, GNM_SO_FILLED_TYPE
, NULL
); }
1456 static GNM_ACTION_DEF (cmd_create_ellipse
)
1457 { create_object (wbcg
, GNM_SO_FILLED_TYPE
, "is-oval", TRUE
, NULL
); }
1459 /*****************************************************************************/
1461 wbcg_set_selection_halign (WBCGtk
*wbcg
, GnmHAlign halign
)
1463 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1464 WorkbookView
*wb_view
;
1467 if (wbcg
->updating_ui
)
1470 /* This is a toggle button. If we are already enabled
1471 * then revert to general */
1472 wb_view
= wb_control_view (wbc
);
1473 if (gnm_style_get_align_h (wb_view
->current_style
) == halign
)
1474 halign
= GNM_HALIGN_GENERAL
;
1476 style
= gnm_style_new ();
1477 gnm_style_set_align_h (style
, halign
);
1478 cmd_selection_format (wbc
, style
, NULL
, _("Set Horizontal Alignment"));
1480 static GNM_ACTION_DEF (cb_align_left
)
1481 { wbcg_set_selection_halign (wbcg
, GNM_HALIGN_LEFT
); }
1482 static GNM_ACTION_DEF (cb_align_right
)
1483 { wbcg_set_selection_halign (wbcg
, GNM_HALIGN_RIGHT
); }
1484 static GNM_ACTION_DEF (cb_align_center
)
1485 { wbcg_set_selection_halign (wbcg
, GNM_HALIGN_CENTER
); }
1486 static GNM_ACTION_DEF (cb_center_across_selection
)
1487 { wbcg_set_selection_halign (wbcg
, GNM_HALIGN_CENTER_ACROSS_SELECTION
); }
1489 /*****************************************************************************/
1492 wbcg_set_selection_valign (WBCGtk
*wbcg
, GnmVAlign valign
)
1494 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1495 WorkbookView
*wb_view
;
1498 if (wbcg
->updating_ui
)
1501 /* This is a toggle button. If we are already enabled
1502 * then revert to general */
1503 wb_view
= wb_control_view (wbc
);
1504 if (gnm_style_get_align_v (wb_view
->current_style
) == valign
) {
1505 if (valign
== GNM_VALIGN_BOTTOM
)
1507 valign
= GNM_VALIGN_BOTTOM
;
1510 style
= gnm_style_new ();
1511 gnm_style_set_align_v (style
, valign
);
1512 cmd_selection_format (wbc
, style
, NULL
, _("Set Vertical Alignment"));
1514 static GNM_ACTION_DEF (cb_align_top
)
1515 { wbcg_set_selection_valign (wbcg
, GNM_VALIGN_TOP
); }
1516 static GNM_ACTION_DEF (cb_align_vcenter
)
1517 { wbcg_set_selection_valign (wbcg
, GNM_VALIGN_CENTER
); }
1518 static GNM_ACTION_DEF (cb_align_bottom
)
1519 { wbcg_set_selection_valign (wbcg
, GNM_VALIGN_BOTTOM
); }
1521 /*****************************************************************************/
1523 static GNM_ACTION_DEF (cb_merge_and_center
)
1525 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1526 GSList
*range_list
= selection_get_ranges (
1527 wb_control_cur_sheet_view (wbc
), FALSE
);
1528 cmd_merge_cells (wbc
, wb_control_cur_sheet (wbc
), range_list
, TRUE
);
1529 range_fragment_free (range_list
);
1532 static GNM_ACTION_DEF (cb_merge_cells
)
1534 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1535 GSList
*range_list
= selection_get_ranges (
1536 wb_control_cur_sheet_view (wbc
), FALSE
);
1537 cmd_merge_cells (wbc
, wb_control_cur_sheet (wbc
), range_list
, FALSE
);
1538 range_fragment_free (range_list
);
1541 static GNM_ACTION_DEF (cb_unmerge_cells
)
1543 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1544 GSList
*range_list
= selection_get_ranges (
1545 wb_control_cur_sheet_view (wbc
), FALSE
);
1546 cmd_unmerge_cells (wbc
, wb_control_cur_sheet (wbc
), range_list
);
1547 range_fragment_free (range_list
);
1550 static GNM_ACTION_DEF (cb_view_statusbar
)
1552 wbcg_toggle_visibility (wbcg
, GTK_TOGGLE_ACTION (a
));
1555 /*****************************************************************************/
1558 toggle_font_attr (WBCGtk
*wbcg
, GtkToggleAction
*act
,
1559 GnmStyleElement t
, unsigned true_val
, unsigned false_val
)
1561 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1562 GnmStyle
*new_style
;
1565 /* If the user did not initiate this action ignore it.
1566 * This happens whenever the ui updates and the current cell makes a
1567 * change to the toolbar indicators.
1569 if (wbcg
->updating_ui
)
1572 val
= gtk_toggle_action_get_active (act
) ? true_val
: false_val
;
1573 if (wbcg_is_editing (wbcg
)) {
1574 PangoAttribute
*attr
= NULL
;
1577 case MSTYLE_FONT_BOLD
:
1578 attr
= pango_attr_weight_new (val
? PANGO_WEIGHT_BOLD
: PANGO_WEIGHT_NORMAL
);
1580 case MSTYLE_FONT_ITALIC
:
1581 attr
= pango_attr_style_new (val
? PANGO_STYLE_ITALIC
: PANGO_STYLE_NORMAL
);
1583 case MSTYLE_FONT_UNDERLINE
:
1584 attr
= pango_attr_underline_new
1585 (gnm_translate_underline_to_pango (val
));
1587 case MSTYLE_FONT_STRIKETHROUGH
:
1588 attr
= pango_attr_strikethrough_new (val
);
1590 case MSTYLE_FONT_SCRIPT
:
1593 case GO_FONT_SCRIPT_STANDARD
:
1594 wbcg_edit_add_markup
1595 (wbcg
, go_pango_attr_superscript_new (FALSE
));
1596 attr
= go_pango_attr_subscript_new (FALSE
);
1598 case GO_FONT_SCRIPT_SUPER
:
1599 attr
= go_pango_attr_superscript_new (TRUE
);
1601 case GO_FONT_SCRIPT_SUB
:
1602 attr
= go_pango_attr_subscript_new (TRUE
);
1607 wbcg_edit_add_markup (wbcg
, attr
);
1611 new_style
= gnm_style_new ();
1614 case MSTYLE_FONT_BOLD
: gnm_style_set_font_bold (new_style
, val
); break;
1615 case MSTYLE_FONT_ITALIC
: gnm_style_set_font_italic (new_style
, val
); break;
1616 case MSTYLE_FONT_UNDERLINE
: gnm_style_set_font_uline (new_style
, val
); break;
1617 case MSTYLE_FONT_STRIKETHROUGH
: gnm_style_set_font_strike (new_style
, val
); break;
1618 case MSTYLE_FONT_SCRIPT
: gnm_style_set_font_script (new_style
, val
); break;
1621 cmd_selection_format_toggle_font_style (wbc
, new_style
, t
);
1624 static void cb_font_bold (GtkToggleAction
*act
, WBCGtk
*wbcg
)
1625 { toggle_font_attr (wbcg
, act
, MSTYLE_FONT_BOLD
, TRUE
, FALSE
); }
1626 static void cb_font_italic (GtkToggleAction
*act
, WBCGtk
*wbcg
)
1627 { toggle_font_attr (wbcg
, act
, MSTYLE_FONT_ITALIC
, TRUE
, FALSE
); }
1628 static void cb_font_underline (GtkToggleAction
*act
, WBCGtk
*wbcg
)
1629 { toggle_font_attr (wbcg
, act
, MSTYLE_FONT_UNDERLINE
, UNDERLINE_SINGLE
, UNDERLINE_NONE
); }
1630 static void cb_font_double_underline (GtkToggleAction
*act
, WBCGtk
*wbcg
)
1631 { toggle_font_attr (wbcg
, act
, MSTYLE_FONT_UNDERLINE
, UNDERLINE_DOUBLE
, UNDERLINE_NONE
); }
1632 static void cb_font_underline_low (GtkToggleAction
*act
, WBCGtk
*wbcg
)
1633 { toggle_font_attr (wbcg
, act
, MSTYLE_FONT_UNDERLINE
, UNDERLINE_SINGLE_LOW
, UNDERLINE_NONE
); }
1634 static void cb_font_double_underline_low (GtkToggleAction
*act
, WBCGtk
*wbcg
)
1635 { toggle_font_attr (wbcg
, act
, MSTYLE_FONT_UNDERLINE
, UNDERLINE_DOUBLE_LOW
, UNDERLINE_NONE
); }
1636 static void cb_font_strikethrough (GtkToggleAction
*act
, WBCGtk
*wbcg
)
1637 { toggle_font_attr (wbcg
, act
, MSTYLE_FONT_STRIKETHROUGH
, TRUE
, FALSE
); }
1638 static void cb_font_subscript (GtkToggleAction
*act
, WBCGtk
*wbcg
)
1639 { toggle_font_attr (wbcg
, act
, MSTYLE_FONT_SCRIPT
, GO_FONT_SCRIPT_SUB
, GO_FONT_SCRIPT_STANDARD
); }
1640 static void cb_font_superscript (GtkToggleAction
*act
, WBCGtk
*wbcg
)
1641 { toggle_font_attr (wbcg
, act
, MSTYLE_FONT_SCRIPT
, GO_FONT_SCRIPT_SUPER
, GO_FONT_SCRIPT_STANDARD
); }
1644 apply_number_format (WBCGtk
*wbcg
,
1646 char const *descriptor
)
1648 GnmStyle
*mstyle
= gnm_style_new ();
1649 gnm_style_set_format (mstyle
, format
);
1650 cmd_selection_format (GNM_WBC (wbcg
), mstyle
, NULL
, descriptor
);
1653 static GNM_ACTION_DEF (cb_format_as_general
)
1655 apply_number_format (wbcg
,
1656 go_format_general (),
1657 _("Format as General"));
1660 static GNM_ACTION_DEF (cb_format_as_number
)
1662 GOFormat
*fmt
= go_format_new_from_XL ("0");
1663 apply_number_format (wbcg
, fmt
, _("Format as Number"));
1664 go_format_unref (fmt
);
1667 static GNM_ACTION_DEF (cb_format_as_currency
)
1669 GOFormatDetails
*details
= go_format_details_new (GO_FORMAT_CURRENCY
);
1670 GString
*str
= g_string_new (NULL
);
1673 details
->currency
= go_format_locale_currency ();
1674 details
->num_decimals
= 2;
1675 go_format_generate_str (str
, details
);
1676 go_format_details_free (details
);
1678 fmt
= go_format_new_from_XL (str
->str
);
1679 g_string_free (str
, TRUE
);
1680 apply_number_format (wbcg
, fmt
, _("Format as Currency"));
1681 go_format_unref (fmt
);
1684 static GNM_ACTION_DEF (cb_format_as_accounting
)
1686 apply_number_format (wbcg
,
1687 go_format_default_accounting (),
1688 _("Format as Accounting"));
1691 static GNM_ACTION_DEF (cb_format_as_percentage
)
1693 GOFormat
*fmt
= go_format_new_from_XL ("0%");
1694 apply_number_format (wbcg
, fmt
, _("Format as Percentage"));
1695 go_format_unref (fmt
);
1698 static GNM_ACTION_DEF (cb_format_as_scientific
)
1700 GOFormat
*fmt
= go_format_new_from_XL ("0.00E+00");
1701 apply_number_format (wbcg
, fmt
, _("Format as Percentage"));
1702 go_format_unref (fmt
);
1705 static GNM_ACTION_DEF (cb_format_as_time
)
1707 apply_number_format (wbcg
,
1708 go_format_default_time (),
1709 _("Format as Time"));
1712 static GNM_ACTION_DEF (cb_format_as_date
)
1714 apply_number_format (wbcg
,
1715 go_format_default_date (),
1716 _("Format as Date"));
1719 /* Adds borders to all the selected regions on the sheet.
1720 * FIXME: This is a little more simplistic then it should be, it always
1721 * removes and/or overwrites any borders. What we should do is
1722 * 1) When adding -> don't add a border if the border is thicker than 'THIN'
1723 * 2) When removing -> don't remove unless the border is 'THIN'
1726 mutate_borders (WBCGtk
*wbcg
, gboolean add
)
1728 GnmBorder
*borders
[GNM_STYLE_BORDER_EDGE_MAX
];
1731 for (i
= GNM_STYLE_BORDER_TOP
; i
< GNM_STYLE_BORDER_EDGE_MAX
; ++i
)
1732 if (i
<= GNM_STYLE_BORDER_RIGHT
)
1733 borders
[i
] = gnm_style_border_fetch (
1734 add
? GNM_STYLE_BORDER_THIN
: GNM_STYLE_BORDER_NONE
,
1735 style_color_black (), gnm_style_border_get_orientation (i
));
1739 cmd_selection_format (GNM_WBC (wbcg
), NULL
, borders
,
1740 add
? _("Add Borders") : _("Remove borders"));
1743 static GNM_ACTION_DEF (cb_format_add_borders
) { mutate_borders (wbcg
, TRUE
); }
1744 static GNM_ACTION_DEF (cb_format_clear_borders
) { mutate_borders (wbcg
, FALSE
); }
1747 modify_format (WBCGtk
*wbcg
,
1748 GOFormat
*(*format_modify_fn
) (GOFormat
const *format
),
1749 char const *descriptor
)
1751 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1752 WorkbookView
const *wbv
;
1755 wbv
= wb_control_view (wbc
);
1756 g_return_if_fail (wbv
!= NULL
);
1757 g_return_if_fail (wbv
->current_style
!= NULL
);
1759 new_fmt
= (*format_modify_fn
) (gnm_style_get_format (wbv
->current_style
));
1760 if (new_fmt
!= NULL
) {
1761 GnmStyle
*style
= gnm_style_new ();
1762 gnm_style_set_format (style
, new_fmt
);
1763 cmd_selection_format (wbc
, style
, NULL
, descriptor
);
1764 go_format_unref (new_fmt
);
1769 cb_calc_decs (GnmCellIter
const *iter
, gpointer user
)
1773 GnmCell
*cell
= iter
->cell
;
1776 GString
const *dec
= go_locale_get_decimal ();
1778 if (!cell
|| !cell
->value
|| !VALUE_IS_NUMBER (cell
->value
))
1782 * If we are displaying an equation, we don't want to look into
1783 * the rendered text.
1785 if (gnm_cell_has_expr (cell
) && cell
->base
.sheet
->display_formulas
)
1788 text
= gnm_cell_get_rendered_text (cell
);
1789 p
= strstr (text
, dec
->str
);
1793 while (g_ascii_isdigit (*p
))
1797 *pdecs
= MAX (*pdecs
, decs
);
1805 inc_dec (WBCGtk
*wbcg
,
1807 GOFormat
*(*format_modify_fn
) (GOFormat
const *format
),
1808 char const *descriptor
)
1810 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1811 WorkbookView
*wbv
= wb_control_view (wbc
);
1812 GOFormat
const *fmt
= gnm_style_get_format (wbv
->current_style
);
1818 GString
*new_fmt_str
;
1820 if (!go_format_is_general (fmt
)) {
1821 modify_format (wbcg
, format_modify_fn
, descriptor
);
1825 sv
= wb_view_cur_sheet_view (wbv
);
1829 for (l
= sv
->selections
; l
; l
= l
->next
) {
1830 GnmRange
const *r
= l
->data
;
1831 sheet_foreach_cell_in_range (sv_sheet (sv
),
1832 CELL_ITER_IGNORE_BLANK
|
1833 CELL_ITER_IGNORE_HIDDEN
,
1834 r
->start
.col
, r
->start
.row
,
1835 r
->end
.col
, r
->end
.row
,
1840 new_fmt_str
= g_string_new ("0");
1841 if (decs
+ dir
> 0) {
1842 g_string_append_c (new_fmt_str
, '.');
1843 go_string_append_c_n (new_fmt_str
, '0', decs
+ dir
);
1845 new_fmt
= go_format_new_from_XL (new_fmt_str
->str
);
1846 g_string_free (new_fmt_str
, TRUE
);
1848 style
= gnm_style_new ();
1849 gnm_style_set_format (style
, new_fmt
);
1850 cmd_selection_format (wbc
, style
, NULL
, descriptor
);
1851 go_format_unref (new_fmt
);
1854 static GNM_ACTION_DEF (cb_format_inc_precision
)
1856 &go_format_inc_precision
, _("Increase precision")); }
1857 static GNM_ACTION_DEF (cb_format_dec_precision
)
1858 { inc_dec (wbcg
, -1,
1859 &go_format_dec_precision
, _("Decrease precision")); }
1860 static GNM_ACTION_DEF (cb_format_with_thousands
)
1861 { modify_format (wbcg
, &go_format_toggle_1000sep
, _("Toggle thousands separator")); }
1863 static GNM_ACTION_DEF (cb_format_dec_indent
) { workbook_cmd_dec_indent (GNM_WBC (wbcg
)); }
1864 static GNM_ACTION_DEF (cb_format_inc_indent
) { workbook_cmd_inc_indent (GNM_WBC (wbcg
)); }
1866 static GNM_ACTION_DEF (cb_copydown
)
1868 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1869 cmd_copyrel (wbc
, 0, -1, _("Copy down"));
1872 static GNM_ACTION_DEF (cb_copyright
)
1874 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1875 /* xgettext: copy from the cell to the left into current cell --
1876 this has nothing whatsoever to do with copyright. */
1877 cmd_copyrel (wbc
, -1, 0, _("Copy right"));
1880 static GNM_ACTION_DEF (cb_format_cells_auto_fit_height
)
1882 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1883 workbook_cmd_autofit_selection
1884 (wbc
, wb_control_cur_sheet (wbc
), FALSE
);
1887 static GNM_ACTION_DEF (cb_format_cells_auto_fit_width
)
1889 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1890 workbook_cmd_autofit_selection
1891 (wbc
, wb_control_cur_sheet (wbc
), TRUE
);
1894 static GNM_ACTION_DEF (cb_format_column_auto_fit
)
1896 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1897 workbook_cmd_resize_selected_colrow (wbc
,
1898 wb_control_cur_sheet (wbc
), TRUE
, -1);
1900 static GNM_ACTION_DEF (cb_set_column_width
)
1902 dialog_col_width (wbcg
, FALSE
);
1904 static GNM_ACTION_DEF (cb_format_column_std_width
)
1906 dialog_col_width (wbcg
, TRUE
);
1908 static GNM_ACTION_DEF (cb_format_column_hide
)
1910 cmd_selection_colrow_hide (GNM_WBC (wbcg
), TRUE
, FALSE
);
1912 static GNM_ACTION_DEF (cb_format_column_unhide
)
1914 cmd_selection_colrow_hide (GNM_WBC (wbcg
), TRUE
, TRUE
);
1917 static GNM_ACTION_DEF (cb_format_row_auto_fit
)
1919 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1920 workbook_cmd_resize_selected_colrow (wbc
,
1921 wb_control_cur_sheet (wbc
), FALSE
, -1);
1923 static GNM_ACTION_DEF (cb_set_row_height
)
1925 dialog_row_height (wbcg
, FALSE
);
1927 static GNM_ACTION_DEF (cb_format_row_std_height
)
1929 dialog_row_height (wbcg
, TRUE
);
1931 static GNM_ACTION_DEF (cb_format_row_hide
)
1933 cmd_selection_colrow_hide (GNM_WBC (wbcg
), FALSE
, FALSE
);
1935 static GNM_ACTION_DEF (cb_format_row_unhide
)
1937 cmd_selection_colrow_hide (GNM_WBC (wbcg
), FALSE
, TRUE
);
1940 static GNM_ACTION_DEF (cb_file_menu
)
1942 wbc_gtk_load_templates (wbcg
);
1945 static GNM_ACTION_DEF (cb_insert_menu
)
1947 GtkAction
*action
= wbcg_find_action (wbcg
, "MenuInsertObject");
1948 SheetControlGUI
*scg
= wbcg_cur_scg (wbcg
);
1949 gtk_action_set_sensitive (action
, go_components_get_mime_types () != NULL
&& scg
&& scg_sheet (scg
)->sheet_type
== GNM_SHEET_DATA
);
1952 #define TOGGLE_HANDLER(flag,property) \
1953 static GNM_ACTION_DEF (cb_sheet_pref_ ## flag ) \
1955 g_return_if_fail (GNM_IS_WBC_GTK (wbcg)); \
1957 if (!wbcg->updating_ui) { \
1958 Sheet *sheet = wbcg_cur_sheet (wbcg); \
1959 go_object_toggle (sheet, property); \
1960 sheet_update (sheet); \
1964 TOGGLE_HANDLER (display_formulas
, "display-formulas")
1965 TOGGLE_HANDLER (hide_zero
, "display-zeros")
1966 TOGGLE_HANDLER (hide_grid
, "display-grid")
1967 TOGGLE_HANDLER (hide_col_header
, "display-column-header")
1968 TOGGLE_HANDLER (hide_row_header
, "display-row-header")
1969 TOGGLE_HANDLER (display_outlines
, "display-outlines")
1970 TOGGLE_HANDLER (outline_symbols_below
, "display-outlines-below")
1971 TOGGLE_HANDLER (outline_symbols_right
, "display-outlines-right")
1972 TOGGLE_HANDLER (use_r1c1
, "use-r1c1")
1974 /* Actions that are always sensitive */
1975 static GnmActionEntry
const permanent_actions
[] = {
1976 { .name
= "MenuFile",
1977 .label
= N_("_File"),
1978 .callback
= G_CALLBACK (cb_file_menu
)
1980 { .name
= "MenuFileNewFromTemplate",
1981 .icon
= "document-new",
1982 .label
= N_("New From Template")
1984 { .name
= "FileNew",
1985 .icon
= "document-new",
1986 .label
= N_("_New"),
1987 .accelerator
= "<control>n",
1988 .tooltip
= N_("Create a new workbook"),
1989 .callback
= G_CALLBACK (cb_file_new
)
1991 { .name
= "FileOpen",
1992 .icon
= "document-open",
1993 .label
= GNM_N_STOCK_OPEN
,
1994 .label_context
= GNM_STOCK_LABEL_CONTEXT
,
1995 .accelerator
= "<control>o",
1996 .tooltip
= N_("Open a file"),
1997 .callback
= G_CALLBACK (cb_file_open
)
1999 { .name
= "FileSave",
2000 .icon
= "document-save",
2001 .label
= GNM_N_STOCK_SAVE
,
2002 .label_context
= GNM_STOCK_LABEL_CONTEXT
,
2003 .accelerator
= "<control>s",
2004 .tooltip
= N_("Save the current workbook"),
2005 .callback
= G_CALLBACK (cb_file_save
)
2007 { .name
= "FileSaveAs",
2008 .icon
= "document-save-as",
2009 .label
= GNM_N_STOCK_SAVE_AS
,
2010 .label_context
= GNM_STOCK_LABEL_CONTEXT
,
2011 .accelerator
= "<control><shift>s",
2012 .tooltip
= N_("Save the current workbook with a different name"),
2013 .callback
= G_CALLBACK (cb_file_save_as
)
2015 { .name
= "FileSend",
2016 .icon
= "gnumeric-link-email",
2017 .label
= N_("Sen_d To..."),
2018 .tooltip
= N_("Send the current file via email"),
2019 .callback
= G_CALLBACK (cb_file_sendto
)
2021 { .name
= "FilePageSetup",
2022 .icon
= "document-page-setup",
2023 .label
= N_("Page Set_up..."),
2024 .tooltip
= N_("Setup the page settings for your current printer"),
2025 .callback
= G_CALLBACK (cb_file_page_setup
)
2027 { .name
= "FilePrintPreview",
2028 .icon
= "document-print-preview",
2029 .label
= N_("Print Pre_view"),
2030 .tooltip
= N_("Print preview"),
2031 .callback
= G_CALLBACK (cb_file_print_preview
)
2033 { .name
= "FilePrint",
2034 .icon
= "document-print",
2035 .label
= N_("Print"),
2036 .accelerator
= "<control>p",
2037 .tooltip
= N_("Print the current file"),
2038 .callback
= G_CALLBACK (cb_file_print
)
2040 { .name
= "FilePrintArea",
2041 .label
= N_("Print Area & Breaks")
2043 { .name
= "FileHistoryFull",
2044 .label
= N_("Full _History..."),
2045 .tooltip
= N_("Access previously used file"),
2046 .callback
= G_CALLBACK (cb_file_history_full
)
2048 { .name
= "FileClose",
2049 .icon
= "window-close",
2050 .label
= N_("_Close"),
2051 .accelerator
= "<control>w",
2052 .tooltip
= N_("Close the current file"),
2053 .callback
= G_CALLBACK (cb_file_close
)
2055 { .name
= "FileQuit",
2056 .icon
= "application-exit",
2057 .label
= N_("_Quit"),
2058 .accelerator
= "<control>q",
2059 .tooltip
= N_("Quit the application"),
2060 .callback
= G_CALLBACK (cb_file_quit
)
2062 /* ---------------------------------------- */
2063 { .name
= "MenuEdit",
2064 .label
= N_("_Edit")
2066 { .name
= "MenuEditClear",
2067 .icon
= "edit-clear",
2068 .label
= N_("C_lear")
2070 { .name
= "MenuEditDelete",
2071 .icon
= "edit-delete",
2072 .label
= N_("_Delete")
2074 { .name
= "MenuEditItems",
2075 .label
= N_("_Modify")
2077 { .name
= "MenuEditSheet",
2078 .label
= N_("S_heet")
2080 { .name
= "MenuEditSelect",
2081 .label
= N_("_Select")
2084 { .name
= "EditCopy",
2085 .icon
= "edit-copy",
2086 .label
= N_("_Copy"),
2087 .accelerator
= "<control>c",
2088 .tooltip
= N_("Copy the selection"),
2089 .callback
= G_CALLBACK (cb_edit_copy
)
2092 /* ---------------------------------------- */
2093 { .name
= "MenuView",
2094 .label
= N_("_View")
2096 { .name
= "MenuViewWindows",
2097 .label
= N_("_Windows")
2099 { .name
= "MenuViewToolbars",
2100 .label
= N_("_Toolbars")
2102 /* ---------------------------------------- */
2103 { .name
= "MenuInsert",
2104 .label
= N_("_Insert"),
2105 .callback
= G_CALLBACK (cb_insert_menu
)
2107 { .name
= "MenuInsertObject",
2108 .label
= N_("_Object")
2110 { .name
= "MenuInsertSpecial",
2111 .label
= N_("S_pecial")
2113 { .name
= "MenuInsertFormulaWrap",
2114 .icon
= "gnumeric-formulaguru",
2115 .label
= N_("Func_tion Wrapper")
2117 { .name
= "InsertNames",
2118 .label
= N_("_Name..."),
2119 .accelerator
= "F3",
2120 .tooltip
= N_("Insert a defined name"),
2121 .callback
= G_CALLBACK (cb_paste_names
)
2123 /* ---------------------------------------- */
2124 { .name
= "MenuFormat",
2125 .label
= N_("F_ormat")
2127 { .name
= "MenuFormatCells",
2128 .label
= N_("_Cells")
2130 { .name
= "MenuFormatText",
2131 .label
= N_("_Text")
2133 { .name
= "MenuFormatTextUnderline",
2134 .label
= N_("_Underline")
2136 { .name
= "MenuFormatColumn",
2137 .label
= N_("C_olumn")
2139 { .name
= "MenuFormatRow",
2142 { .name
= "MenuFormatSheet",
2143 .label
= N_("_Sheet")
2145 /* ---------------------------------------- */
2146 { .name
= "MenuTools",
2147 .label
= N_("_Tools")
2149 { .name
= "MenuToolsScenarios",
2150 .label
= N_("Sce_narios")
2152 /* ---------------------------------------- */
2153 { .name
= "MenuStatistics",
2154 .label
= N_("_Statistics")
2156 { .name
= "MenuStatisticsDescriptive",
2157 .label
= N_("_Descriptive Statistics")
2159 { .name
= "MenuToolFrequencies",
2160 .label
= N_("Fre_quency Tables")
2162 { .name
= "MenuStatisticsTimeSeries",
2163 .label
= N_("De_pendent Observations")
2165 { .name
= "MenuToolForecast",
2166 .label
= N_("F_orecast")
2168 { .name
= "MenuStatisticsOneSample",
2169 .label
= N_("_One Sample Tests")
2171 { .name
= "MenuToolOneMedian",
2172 .label
= N_("Claims About a Me_dian")
2174 { .name
= "MenuStatisticsTwoSamples",
2175 .label
= N_("_Two Sample Tests")
2177 { .name
= "MenuToolTwoMedians",
2178 .label
= N_("Claims About Two Me_dians")
2180 { .name
= "MenuToolTTest",
2181 .label
= N_("Claims About Two _Means")
2183 { .name
= "MenuStatisticsMultipleSamples",
2184 .label
= N_("_Multiple Sample Tests")
2186 { .name
= "MenuANOVA",
2187 .label
= N_("_ANOVA")
2189 { .name
= "MenuContingencyTests",
2190 .label
= N_("Contin_gency Table")
2192 /* ---------------------------------------- */
2193 { .name
= "MenuData",
2194 .label
= N_("_Data")
2196 { .name
= "MenuFilter",
2197 .label
= N_("_Filter")
2199 { .name
= "MenuEditFill",
2200 .label
= N_("F_ill")
2202 { .name
= "MenuRandomGenerator",
2203 .label
= N_("_Random Generators")
2205 { .name
= "MenuOutline",
2206 .label
= N_("_Group and Outline")
2208 { .name
= "MenuExternalData",
2209 .label
= N_("Import _Data")
2211 { .name
= "MenuExportData",
2212 .label
= N_("E_xport Data")
2214 { .name
= "MenuSlicer",
2215 .label
= N_("Data S_licer")
2217 /* ---------------------------------------- */
2218 { .name
= "MenuHelp",
2219 .label
= N_("_Help")
2222 { .name
= "HelpDocs",
2223 .icon
= "help-browser",
2224 .label
= N_("_Contents"),
2225 .accelerator
= "F1",
2226 .tooltip
= N_("Open a viewer for Gnumeric's documentation"),
2227 .callback
= G_CALLBACK (cb_help_docs
)
2229 { .name
= "HelpFunctions",
2230 .icon
= "gnumeric-formulaguru",
2231 .label
= N_("_Functions"),
2232 .tooltip
= N_("Functions help"),
2233 .callback
= G_CALLBACK (cb_help_function
)
2235 { .name
= "HelpWeb",
2236 .label
= N_("Gnumeric on the _Web"),
2237 .tooltip
= N_("Browse to Gnumeric's website"),
2238 .callback
= G_CALLBACK (cb_help_web
)
2240 { .name
= "HelpIRC",
2241 .label
= N_("_Live Assistance"),
2242 .tooltip
= N_("See if anyone is available to answer questions"),
2243 .callback
= G_CALLBACK (cb_help_irc
)
2245 { .name
= "HelpBug",
2246 .label
= N_("Report a _Problem"),
2247 .tooltip
= N_("Report problem"),
2248 .callback
= G_CALLBACK (cb_help_bug
)
2250 { .name
= "HelpAbout",
2251 .icon
= "help-about",
2252 .label
= N_("_About"),
2253 .tooltip
= N_("About this application"),
2254 .callback
= G_CALLBACK (cb_help_about
)
2258 /* actions that are sensitive only in data sheets */
2259 static GnmActionEntry
const data_only_actions
[] = {
2260 { .name
= "EditCut",
2262 .label
= N_("Cu_t"),
2263 .accelerator
= "<control>x",
2264 .tooltip
= N_("Cut the selection"),
2265 .callback
= G_CALLBACK (cb_edit_cut
)
2267 { .name
= "EditPaste",
2268 .icon
= "edit-paste",
2269 .label
= N_("_Paste"),
2270 .accelerator
= "<control>v",
2271 .tooltip
= N_("Paste the clipboard"),
2272 .callback
= G_CALLBACK (cb_edit_paste
)
2276 #define FULLSCREEN_ACCEL "F11"
2278 static GnmActionEntry
const semi_permanent_actions
[] = {
2280 { .name
= "SheetReorder",
2281 .label
= N_("_Manage Sheets..."),
2282 .tooltip
= N_("Manage the sheets in this workbook"),
2283 .callback
= G_CALLBACK (cb_sheet_order
)
2285 { .name
= "InsertSheet",
2286 .label
= N_("_Insert"),
2287 .tooltip
= N_("Insert a new sheet"),
2288 .callback
= G_CALLBACK (wbcg_insert_sheet
)
2290 /* ICK A DUPLICATE : we have no way to override a label on one proxy */
2291 { .name
= "SheetInsert",
2292 .label
= N_("_Sheet"),
2293 .tooltip
= N_("Insert a new sheet"),
2294 .callback
= G_CALLBACK (wbcg_insert_sheet
)
2296 { .name
= "InsertSheetAtEnd",
2297 .label
= N_("_Append"),
2298 .tooltip
= N_("Append a new sheet"),
2299 .callback
= G_CALLBACK (wbcg_append_sheet
)
2301 { .name
= "EditDuplicateSheet",
2302 .label
= N_("_Duplicate"),
2303 .tooltip
= N_("Make a copy of the current sheet"),
2304 .callback
= G_CALLBACK (wbcg_clone_sheet
)
2306 { .name
= "SheetRemove",
2307 .label
= N_("_Remove"),
2308 .tooltip
= N_("Irrevocably remove an entire sheet"),
2309 .callback
= G_CALLBACK (cb_sheet_remove
)
2311 { .name
= "SheetChangeName",
2312 .label
= N_("Re_name..."),
2313 .tooltip
= N_("Rename the current sheet"),
2314 .callback
= G_CALLBACK (cb_sheet_name
)
2316 { .name
= "SheetResize",
2317 .label
= N_("Resize..."),
2318 .tooltip
= N_("Change the size of the current sheet"),
2319 .callback
= G_CALLBACK (cb_sheet_resize
)
2323 { .name
= "ViewNew",
2324 .icon
= "document-new",
2325 .label
= N_("_New View..."),
2326 .tooltip
= N_("Create a new view of the workbook"),
2327 .callback
= G_CALLBACK (cb_view_new
)
2331 { .name
= "FormatWorkbook",
2332 .icon
= "document-properties",
2333 .label
= N_("View _Properties..."),
2334 .tooltip
= N_("Modify the view properties"),
2335 .callback
= G_CALLBACK (cb_workbook_attr
)
2338 { .name
= "ViewStatusbar",
2340 .label
= N_("View _Statusbar"),
2341 .tooltip
= N_("Toggle visibility of statusbar"),
2342 .callback
= G_CALLBACK (cb_view_statusbar
),
2346 { .name
= "ViewFullScreen",
2348 .icon
= "view-fullscreen",
2349 .label
= N_("F_ull Screen"),
2350 .accelerator
= FULLSCREEN_ACCEL
,
2351 .tooltip
= N_("Switch to or from full screen mode"),
2352 .callback
= G_CALLBACK (cb_view_fullscreen
)
2356 #define ZOOM_IN_ACCEL NULL
2357 #define ZOOM_OUT_ACCEL NULL
2359 static GnmActionEntry
const actions
[] = {
2361 { .name
= "FileMetaData",
2362 .icon
= "document-properties",
2363 .label
= N_("Document Proper_ties..."),
2364 .tooltip
= N_("Edit document properties"),
2365 .callback
= G_CALLBACK (cb_doc_meta_data
)
2368 /* File->PrintArea */
2369 { .name
= "FilePrintAreaSet",
2370 .label
= N_("Set Print Area"),
2371 .tooltip
= N_("Use the current selection as print area"),
2372 .callback
= G_CALLBACK (cb_file_print_area_set
)
2374 { .name
= "FilePrintAreaClear",
2375 .label
= N_("Clear Print Area"),
2376 .tooltip
= N_("Undefine the print area"),
2377 .callback
= G_CALLBACK (cb_file_print_area_clear
)
2379 { .name
= "FilePrintAreaShow",
2380 .label
= N_("Show Print Area"),
2381 .tooltip
= N_("Select the print area"),
2382 .callback
= G_CALLBACK (cb_file_print_area_show
)
2384 { .name
= "FilePrintAreaToggleColPageBreak",
2385 .label
= N_("Set Column Page Break"),
2386 .tooltip
= N_("Split the page to the left of this column"),
2387 .callback
= G_CALLBACK (cb_file_print_area_toggle_col
)
2389 { .name
= "FilePrintAreaToggleRowPageBreak",
2390 .label
= N_("Set Row Page Break"),
2391 .tooltip
= N_("Split the page above this row"),
2392 .callback
= G_CALLBACK (cb_file_print_area_toggle_row
)
2394 { .name
= "FilePrintAreaClearAllPageBreak",
2395 .label
= N_("Clear All Page Breaks"),
2396 .tooltip
= N_("Remove all manual pagebreaks from this sheet"),
2397 .callback
= G_CALLBACK (cb_file_print_area_clear_pagebreaks
)
2401 { .name
= "EditClearAll",
2402 .icon
= "edit-clear",
2403 .label
= N_("_All"),
2404 .tooltip
= N_("Clear the selected cells' formats, comments, and contents"),
2405 .callback
= G_CALLBACK (cb_edit_clear_all
)
2407 { .name
= "EditClearFormats",
2408 .label
= N_("_Formats & Hyperlinks"),
2409 .tooltip
= N_("Clear the selected cells' formats and hyperlinks"),
2410 .callback
= G_CALLBACK (cb_edit_clear_formats
)
2412 { .name
= "EditClearComments",
2413 .icon
= "gnumeric-comment-delete",
2414 .label
= N_("Co_mments"),
2415 .tooltip
= N_("Delete the selected cells' comments"),
2416 .callback
= G_CALLBACK (cb_edit_clear_comments
)
2418 { .name
= "EditClearContent",
2419 .icon
= "edit-clear",
2420 .label
= N_("_Contents"),
2421 .tooltip
= N_("Clear the selected cells' contents"),
2422 .callback
= G_CALLBACK (cb_edit_clear_content
)
2424 { .name
= "EditClearAllFiltered",
2425 .icon
= "edit-clear",
2426 .label
= N_("A_ll Filtered Rows"),
2427 .tooltip
= N_("Clear the selected cells' formats, comments, and contents in the filtered rows"),
2428 .callback
= G_CALLBACK (cb_edit_clear_all_filtered
)
2430 { .name
= "EditClearFormatsFiltered",
2431 .label
= N_("F_ormats & Hyperlinks in Filtered Rows"),
2432 .tooltip
= N_("Clear the selected cells' formats and hyperlinks in the filtered rows"),
2433 .callback
= G_CALLBACK (cb_edit_clear_formats_filtered
)
2435 { .name
= "EditClearCommentsFiltered",
2436 .icon
= "gnumeric-comment-delete",
2437 .label
= N_("Comme_nts in Filtered Rows"),
2438 .tooltip
= N_("Delete the selected cells' comments in the filtered rows"),
2439 .callback
= G_CALLBACK (cb_edit_clear_comments_filtered
)
2441 { .name
= "EditClearContentFiltered",
2442 .icon
= "edit-clear",
2443 .label
= N_("Content_s of Filtered Rows"),
2444 .tooltip
= N_("Clear the selected cells' contents in the filtered rows"),
2445 .callback
= G_CALLBACK (cb_edit_clear_content_filtered
)
2448 /* Edit -> Delete */
2449 /*Translators: Delete "Rows"*/
2450 { .name
= "EditDeleteRows",
2451 .icon
= "gnumeric-row-delete",
2452 .label
= N_("_Rows"),
2453 .tooltip
= N_("Delete the row(s) containing the selected cells"),
2454 .callback
= G_CALLBACK (cb_edit_delete_rows
)
2456 /*Translators: Delete "Columns"*/
2457 { .name
= "EditDeleteColumns",
2458 .icon
= "gnumeric-column-delete",
2459 .label
= N_("_Columns"),
2460 .tooltip
= N_("Delete the column(s) containing the selected cells"),
2461 .callback
= G_CALLBACK (cb_edit_delete_columns
)
2463 { .name
= "EditDeleteCells",
2464 .label
= N_("C_ells..."),
2465 .accelerator
= "<control>minus",
2466 .tooltip
= N_("Delete the selected cells, shifting others into their place"),
2467 .callback
= G_CALLBACK (cb_edit_delete_cells
)
2469 { .name
= "EditClearHyperlinks",
2470 .icon
= "gnumeric-link-delete",
2471 .label
= N_("_Hyperlinks"),
2472 .tooltip
= N_("Delete the selected cells' hyperlinks"),
2473 .callback
= G_CALLBACK (cb_edit_delete_links
)
2475 /* A duplicate that should not go into the menus, used only for the accelerator */
2476 { .name
= "EditDeleteCellsXL",
2477 .label
= N_("C_ells..."),
2478 .accelerator
= "<control>KP_Subtract",
2479 .tooltip
= N_("Delete the selected cells, shifting others into their place"),
2480 .callback
= G_CALLBACK (cb_edit_delete_cells
)
2483 /* Edit -> Select */
2485 /* Note : The accelerators involving space are just for display
2486 * purposes. We actually handle this in
2487 * gnm-pane.c:gnm_pane_key_mode_sheet
2488 * with the rest of the key movement and rangeselection.
2489 * Otherwise input methods would steal them */
2490 { .name
= "EditSelectAll",
2491 .label
= N_("_All"),
2492 .accelerator
= "<control><shift>space",
2493 .tooltip
= N_("Select all cells in the spreadsheet"),
2494 .callback
= G_CALLBACK (cb_edit_select_all
)
2496 { .name
= "EditSelectColumn",
2497 .label
= N_("_Column"),
2498 .accelerator
= "<control>space",
2499 .tooltip
= N_("Select an entire column"),
2500 .callback
= G_CALLBACK (cb_edit_select_col
)
2502 { .name
= "EditSelectRow",
2503 .label
= N_("_Row"),
2504 .accelerator
= "<shift>space",
2505 .tooltip
= N_("Select an entire row"),
2506 .callback
= G_CALLBACK (cb_edit_select_row
)
2509 { .name
= "EditSelectArray",
2510 .label
= N_("Arra_y"),
2511 .accelerator
= "<control>slash",
2512 .tooltip
= N_("Select an array of cells"),
2513 .callback
= G_CALLBACK (cb_edit_select_array
)
2515 { .name
= "EditSelectDepends",
2516 .label
= N_("_Depends"),
2517 .accelerator
= "<control>bracketright",
2518 .tooltip
= N_("Select all the cells that depend on the current edit cell"),
2519 .callback
= G_CALLBACK (cb_edit_select_depends
)
2521 { .name
= "EditSelectInputs",
2522 .label
= N_("_Inputs"),
2523 .accelerator
= "<control>bracketleft",
2524 .tooltip
= N_("Select all the cells are used by the current edit cell"),
2525 .callback
= G_CALLBACK (cb_edit_select_inputs
)
2528 { .name
= "EditSelectObject",
2529 .label
= N_("Next _Object"),
2530 .accelerator
= "<control>Tab",
2531 .tooltip
= N_("Select the next sheet object"),
2532 .callback
= G_CALLBACK (cb_edit_select_object
)
2535 { .name
= "EditGotoTop",
2537 .label
= N_("Go to Top"),
2538 .tooltip
= N_("Go to the top of the data"),
2539 .callback
= G_CALLBACK (cb_edit_goto_top
)
2541 { .name
= "EditGotoBottom",
2542 .icon
= "go-bottom",
2543 .label
= N_("Go to Bottom"),
2544 .tooltip
= N_("Go to the bottom of the data"),
2545 .callback
= G_CALLBACK (cb_edit_goto_bottom
)
2547 { .name
= "EditGotoFirst",
2549 .label
= N_("Go to First"),
2550 .tooltip
= N_("Go to the first data cell"),
2551 .callback
= G_CALLBACK (cb_edit_goto_first
)
2553 { .name
= "EditGotoLast",
2555 .label
= N_("Go to Last"),
2556 .tooltip
= N_("Go to the last data cell"),
2557 .callback
= G_CALLBACK (cb_edit_goto_last
)
2559 { .name
= "EditGoto",
2561 .label
= N_("_Go to Cell..."),
2562 .accelerator
= "<control>g",
2563 .tooltip
= N_("Jump to a specified cell"),
2564 .callback
= G_CALLBACK (cb_edit_goto
)
2566 /* This is a navigational aid that is not supposed to appear */
2568 { .name
= "EditGotoCellIndicator",
2569 .label
= N_("Go to Current Cell Indicator"),
2570 .accelerator
= "<shift><control>g",
2571 .tooltip
= N_("Go to Current Cell Indicator"),
2572 .callback
= G_CALLBACK (cb_edit_goto_cell_indicator
)
2577 .label
= N_("Repeat"),
2578 .accelerator
= "F4",
2579 .tooltip
= N_("Repeat the previous action"),
2580 .callback
= G_CALLBACK (cb_repeat
)
2582 { .name
= "EditPasteSpecial",
2583 .icon
= "edit-paste",
2584 .label
= N_("P_aste Special..."),
2585 .accelerator
= "<shift><control>v",
2586 .tooltip
= N_("Paste with optional filters and transformations"),
2587 .callback
= G_CALLBACK (cb_edit_paste_special
)
2590 { .name
= "EditComment",
2591 .icon
= "gnumeric-comment-edit",
2592 .label
= N_("Co_mment..."),
2593 .tooltip
= N_("Edit the selected cell's comment"),
2594 .callback
= G_CALLBACK (cb_insert_comment
)
2596 { .name
= "EditHyperlink",
2597 .icon
= "gnumeric-link-edit",
2598 .label
= N_("Hyper_link..."),
2599 .accelerator
= "<control>K",
2600 .tooltip
= N_("Edit the selected cell's hyperlink"),
2601 .callback
= G_CALLBACK (cb_insert_hyperlink
)
2604 { .name
= "EditGenerateName",
2605 .label
= N_("_Auto generate names..."),
2606 .tooltip
= N_("Use the current selection to create names"),
2607 .callback
= G_CALLBACK (cb_auto_generate__named_expr
)
2611 { .name
= "EditFind",
2612 .icon
= "edit-find",
2613 .label
= N_("S_earch..."),
2614 .accelerator
= "<control>f",
2615 .tooltip
= N_("Search for something"),
2616 .callback
= G_CALLBACK (cb_edit_search
)
2618 { .name
= "EditReplace",
2619 .icon
= "edit-find-replace",
2620 .label
= N_("Search _& Replace..."),
2621 .accelerator
= "<control>h",
2622 .tooltip
= N_("Search for something and replace it with something else"),
2623 .callback
= G_CALLBACK (cb_edit_search_replace
)
2626 { .name
= "EditRecalc",
2627 .label
= N_("Recalculate"),
2628 .accelerator
= "F9",
2629 .tooltip
= N_("Recalculate the spreadsheet"),
2630 .callback
= G_CALLBACK (cb_edit_recalc
)
2633 { .name
= "EditPreferences",
2634 .icon
= "preferences-system",
2635 .label
= N_("Preferences..."),
2636 .tooltip
= N_("Change Gnumeric Preferences"),
2637 .callback
= G_CALLBACK (cb_file_preferences
)
2641 { .name
= "ViewFreezeThawPanes",
2642 .label
= N_("_Freeze Panes"),
2643 .tooltip
= N_("Freeze the top left of the sheet"),
2644 .callback
= G_CALLBACK (cb_view_freeze_panes
)
2646 { .name
= "ViewZoom",
2647 .icon
= "zoom-fit-best", /* dubious */
2648 .label
= N_("_Zoom..."),
2649 .tooltip
= N_("Zoom the spreadsheet in or out"),
2650 .callback
= G_CALLBACK (cb_view_zoom
)
2652 { .name
= "ViewZoomIn",
2654 .label
= N_("Zoom _In"),
2655 .accelerator
= ZOOM_IN_ACCEL
,
2656 .tooltip
= N_("Increase the zoom to make things larger"),
2657 .callback
= G_CALLBACK (cb_view_zoom_in
)
2659 { .name
= "ViewZoomOut",
2661 .label
= N_("Zoom _Out"),
2662 .accelerator
= ZOOM_OUT_ACCEL
,
2663 .tooltip
= N_("Decrease the zoom to make things smaller"),
2664 .callback
= G_CALLBACK (cb_view_zoom_out
)
2668 { .name
= "InsertCells",
2669 .label
= N_("C_ells..."),
2670 .accelerator
= "<control>plus",
2671 .tooltip
= N_("Insert new cells"),
2672 .callback
= G_CALLBACK (cb_insert_cells
)
2674 /* A duplicate that should not go into the menus, used only for the accelerator */
2675 { .name
= "InsertCellsXL",
2676 .label
= N_("C_ells..."),
2677 .accelerator
= "<control>KP_Add",
2678 .tooltip
= N_("Insert new cells"),
2679 .callback
= G_CALLBACK (cb_insert_cells
)
2681 /*Translators: Insert "Columns"*/
2682 { .name
= "InsertColumns",
2683 .icon
= "gnumeric-column-add",
2684 .label
= N_("_Columns"),
2685 .tooltip
= N_("Insert new columns"),
2686 .callback
= G_CALLBACK (cb_insert_cols
)
2688 /*Translators: Insert "Rows"*/
2689 { .name
= "InsertRows",
2690 .icon
= "gnumeric-row-add",
2691 .label
= N_("_Rows"),
2692 .tooltip
= N_("Insert new rows"),
2693 .callback
= G_CALLBACK (cb_insert_rows
)
2696 { .name
= "ChartGuru",
2697 .icon
= "gnumeric-graphguru",
2698 .label
= N_("C_hart..."),
2699 .tooltip
= N_("Insert a Chart"),
2700 .callback
= G_CALLBACK (cb_launch_chart_guru
)
2702 { .name
= "NewGOComponent",
2703 .icon
= "New Goffice_Component",
2704 .label
= N_("_New..."),
2705 .tooltip
= N_("Insert a new Goffice component object"),
2706 .callback
= G_CALLBACK (cb_launch_go_component_new
)
2708 { .name
= "GOComponentFromFile",
2709 .icon
= "New Goffice_Component from a file",
2710 .label
= N_("_From File..."),
2711 .tooltip
= N_("Insert a new Goffice component object from a file"),
2712 .callback
= G_CALLBACK (cb_launch_go_component_from_file
)
2714 { .name
= "InsertImage",
2715 .icon
= "insert-image",
2716 .label
= N_("_Image..."),
2717 .tooltip
= N_("Insert an image"),
2718 .callback
= G_CALLBACK (cb_insert_image
)
2721 { .name
= "InsertComment",
2722 .icon
= "gnumeric-comment-add",
2723 .label
= N_("Co_mment..."),
2724 .tooltip
= N_("Insert a comment"),
2725 .callback
= G_CALLBACK (cb_insert_comment
)
2727 { .name
= "InsertHyperlink",
2728 .icon
= "gnumeric-link-add",
2729 .label
= N_("Hyper_link..."),
2730 .accelerator
= "<control>K",
2731 .tooltip
= N_("Insert a Hyperlink"),
2732 .callback
= G_CALLBACK (cb_insert_hyperlink
)
2734 { .name
= "InsertSortDecreasing",
2735 .icon
= "view-sort-descending",
2736 .label
= N_("Sort (_Descending)"),
2737 .tooltip
= N_("Wrap with SORT (descending)"),
2738 .callback
= G_CALLBACK (cb_insert_sort_descending
)
2740 { .name
= "InsertSortIncreasing",
2741 .icon
= "view-sort-ascending",
2742 .label
= N_("Sort (_Ascending)"),
2743 .tooltip
= N_("Wrap with SORT (ascending)"),
2744 .callback
= G_CALLBACK (cb_insert_sort_ascending
)
2747 /* Insert -> Special */
2748 { .name
= "InsertCurrentDate",
2749 .label
= N_("Current _Date"),
2750 .accelerator
= "<control>semicolon",
2751 .tooltip
= N_("Insert the current date into the selected cell(s)"),
2752 .callback
= G_CALLBACK (cb_insert_current_date
)
2755 { .name
= "InsertCurrentTime",
2756 .label
= N_("Current _Time"),
2757 .accelerator
= "<control>colon",
2758 .tooltip
= N_("Insert the current time into the selected cell(s)"),
2759 .callback
= G_CALLBACK (cb_insert_current_time
)
2762 { .name
= "InsertCurrentDateTime",
2763 .label
= N_("Current D_ate and Time"),
2764 .accelerator
= "<control>period",
2765 .tooltip
= N_("Insert the current date and time into the selected cell(s)"),
2766 .callback
= G_CALLBACK (cb_insert_current_date_time
)
2769 /* Insert -> Name */
2770 { .name
= "EditNames",
2771 .label
= N_("_Names..."),
2772 .accelerator
= "<control>F3",
2773 .tooltip
= N_("Edit defined names for expressions"),
2774 .callback
= G_CALLBACK (cb_define_name
)
2778 { .name
= "FormatAuto",
2779 .label
= N_("_Autoformat..."),
2780 .tooltip
= N_("Format a region of cells according to a pre-defined template"),
2781 .callback
= G_CALLBACK (cb_autoformat
)
2783 { .name
= "SheetDirection",
2784 .icon
= "format-text-direction-ltr",
2785 .label
= N_("Direction"),
2786 .tooltip
= N_("Toggle sheet direction, left-to-right vs right-to-left"),
2787 .callback
= G_CALLBACK (cb_direction
)
2790 /* Format -> Cells */
2791 { .name
= "FormatCells",
2792 .label
= N_("_Format..."),
2793 .accelerator
= "<control>1",
2794 .tooltip
= N_("Modify the formatting of the selected cells"),
2795 .callback
= G_CALLBACK (cb_format_cells
)
2797 { .name
= "FormatCellsCond",
2798 .label
= N_("_Conditional Formatting..."),
2799 .tooltip
= N_("Modify the conditional formatting of the selected cells"),
2800 .callback
= G_CALLBACK (cb_format_cells_cond
)
2802 { .name
= "FormatCellsFitHeight",
2803 .icon
= "gnumeric-row-size",
2804 .label
= N_("Auto Fit _Height"),
2805 .tooltip
= N_("Ensure rows are just tall enough to display content of selection"),
2806 .callback
= G_CALLBACK (cb_format_cells_auto_fit_height
)
2808 { .name
= "FormatCellsFitWidth",
2809 .icon
= "gnumeric-column-size",
2810 .label
= N_("Auto Fit _Width"),
2811 .tooltip
= N_("Ensure columns are just wide enough to display content of selection"),
2812 .callback
= G_CALLBACK (cb_format_cells_auto_fit_width
)
2817 { .name
= "ColumnSize",
2818 .icon
= "gnumeric-column-size",
2819 .label
= N_("_Width..."),
2820 .tooltip
= N_("Change width of the selected columns"),
2821 .callback
= G_CALLBACK (cb_set_column_width
)
2823 { .name
= "ColumnAutoSize",
2824 .icon
= "gnumeric-column-size",
2825 .label
= N_("_Auto Fit Width"),
2826 .tooltip
= N_("Ensure columns are just wide enough to display their content"),
2827 .callback
= G_CALLBACK (cb_format_column_auto_fit
)
2829 { .name
= "ColumnHide",
2830 .icon
= "gnumeric-column-hide",
2831 .label
= N_("_Hide"),
2832 .accelerator
= "<control>0",
2833 .tooltip
= N_("Hide the selected columns"),
2834 .callback
= G_CALLBACK (cb_format_column_hide
)
2836 { .name
= "ColumnUnhide",
2837 .icon
= "gnumeric-column-unhide",
2838 .label
= N_("_Unhide"),
2839 .accelerator
= "<control>parenright",
2840 .tooltip
= N_("Make any hidden columns in the selection visible"),
2841 .callback
= G_CALLBACK (cb_format_column_unhide
)
2843 { .name
= "ColumnDefaultSize",
2844 .icon
= "gnumeric-column-size",
2845 .label
= N_("_Standard Width"),
2846 .tooltip
= N_("Change the default column width"),
2847 .callback
= G_CALLBACK (cb_format_column_std_width
)
2851 { .name
= "RowSize",
2852 .icon
= "gnumeric-row-size",
2853 .label
= N_("H_eight..."),
2854 .tooltip
= N_("Change height of the selected rows"),
2855 .callback
= G_CALLBACK (cb_set_row_height
)
2857 { .name
= "RowAutoSize",
2858 .icon
= "gnumeric-row-size",
2859 .label
= N_("_Auto Fit Height"),
2860 .tooltip
= N_("Ensure rows are just tall enough to display their content"),
2861 .callback
= G_CALLBACK (cb_format_row_auto_fit
)
2863 { .name
= "RowHide",
2864 .icon
= "gnumeric-row-hide",
2865 .label
= N_("_Hide"),
2866 .accelerator
= "<control>9",
2867 .tooltip
= N_("Hide the selected rows"),
2868 .callback
= G_CALLBACK (cb_format_row_hide
)
2870 { .name
= "RowUnhide",
2871 .icon
= "gnumeric-row-unhide",
2872 .label
= N_("_Unhide"),
2873 .accelerator
= "<control>parenleft",
2874 .tooltip
= N_("Make any hidden rows in the selection visible"),
2875 .callback
= G_CALLBACK (cb_format_row_unhide
)
2877 { .name
= "RowDefaultSize",
2878 .icon
= "gnumeric-row-size",
2879 .label
= N_("_Standard Height"),
2880 .tooltip
= N_("Change the default row height"),
2881 .callback
= G_CALLBACK (cb_format_row_std_height
)
2885 { .name
= "ToolsPlugins",
2886 .label
= N_("_Plug-ins..."),
2887 .tooltip
= N_("Manage available plugin modules"),
2888 .callback
= G_CALLBACK (cb_tools_plugins
)
2890 { .name
= "ToolsAutoCorrect",
2891 .label
= N_("Auto _Correct..."),
2892 .tooltip
= N_("Automatically perform simple spell checking"),
2893 .callback
= G_CALLBACK (cb_tools_autocorrect
)
2895 { .name
= "ToolsAutoSave",
2896 .label
= N_("_Auto Save..."),
2897 .tooltip
= N_("Automatically save the current document at regular intervals"),
2898 .callback
= G_CALLBACK (cb_tools_auto_save
)
2900 { .name
= "ToolsGoalSeek",
2901 .label
= N_("_Goal Seek..."),
2902 .tooltip
= N_("Iteratively recalculate to find a target value"),
2903 .callback
= G_CALLBACK (cb_tools_goal_seek
)
2905 { .name
= "ToolsSolver",
2906 .label
= N_("_Solver..."),
2907 .tooltip
= N_("Iteratively recalculate with constraints to approach a target value"),
2908 .callback
= G_CALLBACK (cb_tools_solver
)
2910 { .name
= "ToolsSimulation",
2911 .label
= N_("Si_mulation..."),
2912 .tooltip
= N_("Test decision alternatives by using Monte Carlo "
2913 "simulation to find out probable outputs and risks related to them"),
2914 .callback
= G_CALLBACK (cb_tools_simulation
)
2916 { .name
= "ToolsCompare",
2917 .label
= N_("Compare Sheets..."),
2918 .tooltip
= N_("Find differences between two sheets"),
2919 .callback
= G_CALLBACK (cb_tools_compare
)
2922 /* Tools -> Scenarios */
2923 { .name
= "ToolsScenarios",
2924 .label
= N_("_View..."),
2925 .tooltip
= N_("View, delete and report different scenarios"),
2926 .callback
= G_CALLBACK (cb_tools_scenarios
)
2928 { .name
= "ToolsScenarioAdd",
2929 .label
= N_("_Add..."),
2930 .tooltip
= N_("Add a new scenario"),
2931 .callback
= G_CALLBACK (cb_tools_scenario_add
)
2936 { .name
= "ToolsSampling",
2937 .label
= N_("_Sampling..."),
2938 .tooltip
= N_("Periodic and random samples"),
2939 .callback
= G_CALLBACK (cb_tools_sampling
)
2942 /* Statistics -> Descriptive*/
2944 { .name
= "ToolsCorrelation",
2945 .label
= N_("_Correlation..."),
2946 .tooltip
= N_("Pearson Correlation"),
2947 .callback
= G_CALLBACK (cb_tools_correlation
)
2949 { .name
= "ToolsCovariance",
2950 .label
= N_("Co_variance..."),
2951 .tooltip
= N_("Covariance"),
2952 .callback
= G_CALLBACK (cb_tools_covariance
)
2954 { .name
= "ToolsDescStatistics",
2955 .label
= N_("_Descriptive Statistics..."),
2956 .tooltip
= N_("Various summary statistics"),
2957 .callback
= G_CALLBACK (cb_tools_desc_statistics
)
2960 /* Statistics -> Descriptive -> Frequencies */
2962 { .name
= "ToolsFrequency",
2963 .label
= N_("Fre_quency Tables..."),
2964 .tooltip
= N_("Frequency tables for non-numeric data"),
2965 .callback
= G_CALLBACK (cb_tools_frequency
)
2967 { .name
= "ToolsHistogram",
2968 .label
= N_("_Histogram..."),
2969 .tooltip
= N_("Various frequency tables for numeric data"),
2970 .callback
= G_CALLBACK (cb_tools_histogram
)
2972 { .name
= "ToolsRanking",
2973 .label
= N_("Ranks And _Percentiles..."),
2974 .tooltip
= N_("Ranks, placements and percentiles"),
2975 .callback
= G_CALLBACK (cb_tools_ranking
)
2978 /* Statistics -> DependentObservations */
2980 { .name
= "ToolsFourier",
2981 .label
= N_("_Fourier Analysis..."),
2982 .tooltip
= N_("Fourier Analysis"),
2983 .callback
= G_CALLBACK (cb_tools_fourier
)
2985 { .name
= "ToolsPrincipalComponents",
2987 N_("Principal Components Analysis..."),
2988 .tooltip
= N_("Principal Components Analysis"),
2989 .callback
= G_CALLBACK (cb_tools_principal_components
)
2991 /* Statistics -> DependentObservations -> Forecast*/
2993 { .name
= "ToolsExpSmoothing",
2994 .label
= N_("_Exponential Smoothing..."),
2995 .tooltip
= N_("Exponential smoothing..."),
2996 .callback
= G_CALLBACK (cb_tools_exp_smoothing
)
2998 { .name
= "ToolsAverage",
2999 .label
= N_("_Moving Average..."),
3000 .tooltip
= N_("Moving average..."),
3001 .callback
= G_CALLBACK (cb_tools_average
)
3003 { .name
= "ToolsRegression",
3004 .label
= N_("_Regression..."),
3005 .tooltip
= N_("Regression Analysis"),
3006 .callback
= G_CALLBACK (cb_tools_regression
)
3008 { .name
= "ToolsKaplanMeier",
3009 .label
= N_("_Kaplan-Meier Estimates..."),
3010 .tooltip
= N_("Creation of Kaplan-Meier Survival Curves"),
3011 .callback
= G_CALLBACK (cb_tools_kaplan_meier
)
3014 /* Statistics -> OneSample */
3016 { .name
= "ToolsNormalityTests",
3017 .label
= N_("_Normality Tests..."),
3018 .tooltip
= N_("Testing a sample for normality"),
3019 .callback
= G_CALLBACK (cb_tools_normality_tests
)
3021 { .name
= "ToolsOneMeanTest",
3022 .label
= N_("Claims About a _Mean..."),
3023 .tooltip
= N_("Testing the value of a mean"),
3024 .callback
= G_CALLBACK (cb_tools_one_mean_test
)
3027 /* Statistics -> OneSample -> OneMedian*/
3029 { .name
= "ToolsOneMedianSignTest",
3030 .label
= N_("_Sign Test..."),
3031 .tooltip
= N_("Testing the value of a median"),
3032 .callback
= G_CALLBACK (cb_tools_sign_test_one_median
)
3034 { .name
= "ToolsOneMedianWilcoxonSignedRank",
3035 .label
= N_("_Wilcoxon Signed Rank Test..."),
3036 .tooltip
= N_("Testing the value of a median"),
3037 .callback
= G_CALLBACK (cb_tools_wilcoxon_signed_rank_one_median
)
3040 /* Statistics -> TwoSamples */
3042 { .name
= "ToolsFTest",
3043 .label
= N_("Claims About Two _Variances"),
3044 .tooltip
= N_("Comparing two population variances"),
3045 .callback
= G_CALLBACK (cb_tools_ftest
)
3048 /* Statistics -> TwoSamples -> Two Means*/
3050 { .name
= "ToolTTestPaired",
3051 .label
= N_("_Paired Samples..."),
3052 .tooltip
= N_("Comparing two population means for two paired samples"),
3053 .callback
= G_CALLBACK (cb_tools_ttest_paired
)
3056 { .name
= "ToolTTestEqualVar",
3057 .label
= N_("Unpaired Samples, _Equal Variances..."),
3058 .tooltip
= N_("Comparing two population means for two unpaired samples from populations with equal variances"),
3059 .callback
= G_CALLBACK (cb_tools_ttest_equal_var
)
3062 { .name
= "ToolTTestUnequalVar",
3063 .label
= N_("Unpaired Samples, _Unequal Variances..."),
3064 .tooltip
= N_("Comparing two population means for two unpaired samples from populations with unequal variances"),
3065 .callback
= G_CALLBACK (cb_tools_ttest_unequal_var
)
3068 { .name
= "ToolZTest",
3069 .label
= N_("Unpaired Samples, _Known Variances..."),
3070 .tooltip
= N_("Comparing two population means from populations with known variances"),
3071 .callback
= G_CALLBACK (cb_tools_ztest
)
3074 /* Statistics -> TwoSamples -> Two Medians*/
3076 { .name
= "ToolsTwoMedianSignTest",
3077 .label
= N_("_Sign Test..."),
3078 .tooltip
= N_("Comparing the values of two medians of paired observations"),
3079 .callback
= G_CALLBACK (cb_tools_sign_test_two_medians
)
3081 { .name
= "ToolsTwoMedianWilcoxonSignedRank",
3082 .label
= N_("_Wilcoxon Signed Rank Test..."),
3083 .tooltip
= N_("Comparing the values of two medians of paired observations"),
3084 .callback
= G_CALLBACK (cb_tools_wilcoxon_signed_rank_two_medians
)
3086 { .name
= "ToolsTwoMedianWilcoxonMannWhitney",
3087 .label
= N_("Wilcoxon-_Mann-Whitney Test..."),
3088 .tooltip
= N_("Comparing the values of two medians of unpaired observations"),
3089 .callback
= G_CALLBACK (cb_tools_wilcoxon_mann_whitney
)
3092 /* Statistics -> MultipleSamples */
3094 /* Statistics -> MultipleSamples -> ANOVA*/
3096 { .name
= "ToolsANOVAoneFactor",
3097 .label
= N_("_One Factor..."),
3098 .tooltip
= N_("One Factor Analysis of Variance..."),
3099 .callback
= G_CALLBACK (cb_tools_anova_one_factor
)
3101 { .name
= "ToolsANOVAtwoFactor",
3102 .label
= N_("_Two Factor..."),
3103 .tooltip
= N_("Two Factor Analysis of Variance..."),
3104 .callback
= G_CALLBACK (cb_tools_anova_two_factor
)
3107 /* Statistics -> MultipleSamples -> ContingencyTable*/
3109 { .name
= "ToolsHomogeneity",
3110 .label
= N_("Test of _Homogeneity..."),
3111 .tooltip
= N_("Chi Squared Test of Homogeneity..."),
3112 .callback
= G_CALLBACK (cb_tools_chi_square_homogeneity
)
3114 { .name
= "ToolsIndependence",
3115 .label
= N_("Test of _Independence..."),
3116 .tooltip
= N_("Chi Squared Test of Independence..."),
3117 .callback
= G_CALLBACK (cb_tools_chi_square_independence
)
3121 { .name
= "DataSort",
3122 .icon
= "view-sort-ascending",
3123 .label
= N_("_Sort..."),
3124 .tooltip
= N_("Sort the selected region"),
3125 .callback
= G_CALLBACK (cb_data_sort
)
3127 { .name
= "DataShuffle",
3128 .label
= N_("Sh_uffle..."),
3129 .tooltip
= N_("Shuffle cells, rows or columns"),
3130 .callback
= G_CALLBACK (cb_data_shuffle
)
3132 { .name
= "DataValidate",
3133 .label
= N_("_Validate..."),
3134 .tooltip
= N_("Validate input with preset criteria"),
3135 .callback
= G_CALLBACK (cb_data_validate
)
3137 { .name
= "DataTextToColumns",
3138 .label
= N_("T_ext to Columns..."),
3139 .tooltip
= N_("Parse the text in the selection into data"),
3140 .callback
= G_CALLBACK (cb_data_text_to_columns
)
3142 { .name
= "DataConsolidate",
3143 .label
= N_("_Consolidate..."),
3144 .tooltip
= N_("Consolidate regions using a function"),
3145 .callback
= G_CALLBACK (cb_data_consolidate
)
3147 { .name
= "DataTable",
3148 .label
= N_("_Table..."),
3149 .tooltip
= N_("Create a Data Table to evaluate a function with multiple inputs"),
3150 .callback
= G_CALLBACK (cb_data_table
)
3152 { .name
= "DataExport",
3153 .label
= N_("E_xport into Other Format..."),
3154 .tooltip
= N_("Export the current workbook or sheet"),
3155 .callback
= G_CALLBACK (cb_data_export
)
3157 { .name
= "DataExportText",
3158 .label
= N_("Export as _Text File..."),
3159 .tooltip
= N_("Export the current sheet as a text file"),
3160 .callback
= G_CALLBACK (cb_data_export_text
)
3162 { .name
= "DataExportCSV",
3163 .label
= N_("Export as _CSV File..."),
3164 .tooltip
= N_("Export the current sheet as a csv file"),
3165 .callback
= G_CALLBACK (cb_data_export_csv
)
3167 { .name
= "DataExportRepeat",
3168 .label
= N_("Repeat Export"),
3169 .accelerator
= "<control>E",
3170 .tooltip
= N_("Repeat the last data export"),
3171 .callback
= G_CALLBACK (cb_data_export_repeat
)
3175 { .name
= "EditFillAutofill",
3176 .label
= N_("Auto_fill"),
3177 .tooltip
= N_("Automatically fill the current selection"),
3178 .callback
= G_CALLBACK (cb_edit_fill_autofill
)
3180 { .name
= "ToolsMerge",
3181 .label
= N_("_Merge..."),
3182 .tooltip
= N_("Merges columnar data into a sheet creating duplicate sheets for each row"),
3183 .callback
= G_CALLBACK (cb_tools_merge
)
3185 { .name
= "ToolsTabulate",
3186 .label
= N_("_Tabulate Dependency..."),
3187 .tooltip
= N_("Make a table of a cell's value as a function of other cells"),
3188 .callback
= G_CALLBACK (cb_tools_tabulate
)
3190 { .name
= "EditFillSeries",
3191 .label
= N_("_Series..."),
3192 .tooltip
= N_("Fill according to a linear or exponential series"),
3193 .callback
= G_CALLBACK (cb_edit_fill_series
)
3195 { .name
= "RandomGeneratorUncorrelated",
3196 .label
= N_("_Uncorrelated..."),
3197 .tooltip
= N_("Generate random numbers of a selection of distributions"),
3198 .callback
= G_CALLBACK (cb_tools_random_generator_uncorrelated
)
3200 { .name
= "RandomGeneratorCorrelated",
3201 .label
= N_("_Correlated..."),
3202 .tooltip
= N_("Generate variates for correlated normal distributed random variables"),
3203 .callback
= G_CALLBACK (cb_tools_random_generator_correlated
)
3205 { .name
= "CopyDown",
3206 .label
= N_("Fill Downwards"),
3207 .accelerator
= "<control>D",
3208 .tooltip
= N_("Copy the content from the top row to the cells below"),
3209 .callback
= G_CALLBACK (cb_copydown
)
3211 { .name
= "CopyRight",
3212 .label
= N_("Fill to Right"),
3213 .accelerator
= "<control>R",
3214 .tooltip
= N_("Copy the content from the left column to the cells on the right"),
3215 .callback
= G_CALLBACK (cb_copyright
)
3219 /* Data -> Outline */
3220 { .name
= "DataOutlineHideDetail",
3221 .icon
= "gnumeric-detail-hide",
3222 .label
= N_("_Hide Detail"),
3223 .tooltip
= N_("Collapse an outline group"),
3224 .callback
= G_CALLBACK (cb_data_hide_detail
)
3226 { .name
= "DataOutlineShowDetail",
3227 .icon
= "gnumeric-detail-show",
3228 .label
= N_("_Show Detail"),
3229 .tooltip
= N_("Uncollapse an outline group"),
3230 .callback
= G_CALLBACK (cb_data_show_detail
)
3232 { .name
= "DataOutlineGroup",
3233 .icon
= "gnumeric-group",
3234 .label
= N_("_Group..."),
3235 .accelerator
= "<shift><alt>Right",
3236 .tooltip
= N_("Add an outline group"),
3237 .callback
= G_CALLBACK (cb_data_group
)
3239 { .name
= "DataOutlineUngroup",
3240 .icon
= "gnumeric-ungroup",
3241 .label
= N_("_Ungroup..."),
3242 .accelerator
= "<shift><alt>Left",
3243 .tooltip
= N_("Remove an outline group"),
3244 .callback
= G_CALLBACK (cb_data_ungroup
)
3247 /* Data -> Filter */
3248 { .name
= "DataAutoFilter",
3249 .icon
= "gnumeric-autofilter",
3250 .label
= N_("Add _Auto Filter"),
3251 .tooltip
= N_("Add or remove a filter"),
3252 .callback
= G_CALLBACK (cb_auto_filter
)
3254 { .name
= "DataFilterShowAll",
3255 .label
= N_("_Clear Advanced Filter"),
3256 .tooltip
= N_("Show all rows hidden by an advanced filter"),
3257 .callback
= G_CALLBACK (cb_show_all
)
3259 { .name
= "DataFilterAdvancedfilter",
3260 .label
= N_("Advanced _Filter..."),
3261 .tooltip
= N_("Filter data with given criteria"),
3262 .callback
= G_CALLBACK (cb_data_filter
)
3264 /* Data -> External */
3265 { .name
= "DataImportText",
3266 .label
= N_("Import _Text File..."),
3267 .tooltip
= N_("Import data from a text file"),
3268 .callback
= G_CALLBACK (cb_data_import_text
)
3270 { .name
= "DataImportOther",
3271 .label
= N_("Import _Other File..."),
3272 .tooltip
= N_("Import data from a file"),
3273 .callback
= G_CALLBACK (cb_data_import_other
)
3276 /* Data -> Data Slicer */
3277 /* label and tip are context dependent, see wbcg_menu_state_update */
3278 { .name
= "DataSlicer",
3279 .label
= N_("Add _Data Slicer"),
3280 .tooltip
= N_("Create a data slicer"),
3281 .callback
= G_CALLBACK (cb_data_slicer_create
)
3283 { .name
= "DataSlicerRefresh",
3284 .label
= N_("_Refresh"),
3285 .tooltip
= N_("Regenerate a data slicer from the source data"),
3286 .callback
= G_CALLBACK (cb_data_slicer_refresh
)
3288 { .name
= "DataSlicerEdit",
3289 .label
= N_("_Edit Data Slicer..."),
3290 .tooltip
= N_("Adjust a data slicer"),
3291 .callback
= G_CALLBACK (cb_data_slicer_edit
)
3294 /* Standard Toolbar */
3295 { .name
= "AutoSum",
3296 .icon
= "gnumeric-autosum",
3298 .accelerator
= "<alt>equal",
3299 .tooltip
= N_("Sum into the current cell"),
3300 .callback
= G_CALLBACK (cb_autosum
)
3302 { .name
= "InsertFormula",
3303 .icon
= "gnumeric-formulaguru",
3304 .label
= N_("_Function..."),
3305 .tooltip
= N_("Edit a function in the current cell"),
3306 .callback
= G_CALLBACK (cb_formula_guru
)
3309 { .name
= "SortAscending",
3310 .icon
= "view-sort-ascending",
3311 .label
= N_("Sort Ascending"),
3312 .tooltip
= N_("Sort the selected region in ascending order based on the first column selected"),
3313 .callback
= G_CALLBACK (cb_sort_ascending
)
3315 { .name
= "SortDescending",
3316 .icon
= "view-sort-descending",
3317 .label
= N_("Sort Descending"),
3318 .tooltip
= N_("Sort the selected region in descending order based on the first column selected"),
3319 .callback
= G_CALLBACK (cb_sort_descending
)
3322 /* Object Toolbar */
3323 { .name
= "CreateFrame",
3324 .icon
= "gnumeric-object-frame",
3325 .label
= N_("Frame"),
3326 .tooltip
= N_("Create a frame"),
3327 .callback
= G_CALLBACK (cmd_create_frame
)
3329 { .name
= "CreateCheckbox",
3330 .icon
= "gnumeric-object-checkbox",
3331 .label
= N_("Checkbox"),
3332 .tooltip
= N_("Create a checkbox"),
3333 .callback
= G_CALLBACK (cmd_create_checkbox
)
3335 { .name
= "CreateScrollbar",
3336 .icon
= "gnumeric-object-scrollbar",
3337 .label
= N_("Scrollbar"),
3338 .tooltip
= N_("Create a scrollbar"),
3339 .callback
= G_CALLBACK (cmd_create_scrollbar
)
3341 { .name
= "CreateSlider",
3342 .icon
= "gnumeric-object-slider",
3343 .label
= N_("Slider"),
3344 .tooltip
= N_("Create a slider"),
3345 .callback
= G_CALLBACK (cmd_create_slider
)
3347 { .name
= "CreateSpinButton",
3348 .icon
= "gnumeric-object-spinbutton",
3349 .label
= N_("SpinButton"),
3350 .tooltip
= N_("Create a spin button"),
3351 .callback
= G_CALLBACK (cmd_create_spinbutton
)
3353 { .name
= "CreateList",
3354 .icon
= "gnumeric-object-list",
3355 .label
= N_("List"),
3356 .tooltip
= N_("Create a list"),
3357 .callback
= G_CALLBACK (cmd_create_list
)
3359 { .name
= "CreateCombo",
3360 .icon
= "gnumeric-object-combo",
3361 .label
= N_("Combo Box"),
3362 .tooltip
= N_("Create a combo box"),
3363 .callback
= G_CALLBACK (cmd_create_combo
)
3365 { .name
= "CreateLine",
3366 .icon
= "gnumeric-object-line",
3367 .label
= N_("Line"),
3368 .tooltip
= N_("Create a line object"),
3369 .callback
= G_CALLBACK (cmd_create_line
)
3371 { .name
= "CreateArrow",
3372 .icon
= "gnumeric-object-arrow",
3373 .label
= N_("Arrow"),
3374 .tooltip
= N_("Create an arrow object"),
3375 .callback
= G_CALLBACK (cmd_create_arrow
)
3377 { .name
= "CreateRectangle",
3378 .icon
= "gnumeric-object-rectangle",
3379 .label
= N_("Rectangle"),
3380 .tooltip
= N_("Create a rectangle object"),
3381 .callback
= G_CALLBACK (cmd_create_rectangle
)
3383 { .name
= "CreateEllipse",
3384 .icon
= "gnumeric-object-ellipse",
3385 .label
= N_("Ellipse"),
3386 .tooltip
= N_("Create an ellipse object"),
3387 .callback
= G_CALLBACK (cmd_create_ellipse
)
3389 { .name
= "CreateButton",
3390 .icon
= "gnumeric-object-button",
3391 .label
= N_("Button"),
3392 .tooltip
= N_("Create a button"),
3393 .callback
= G_CALLBACK (cmd_create_button
)
3395 { .name
= "CreateRadioButton",
3396 .icon
= "gnumeric-object-radiobutton",
3397 .label
= N_("RadioButton"),
3398 .tooltip
= N_("Create a radio button"),
3399 .callback
= G_CALLBACK (cmd_create_radiobutton
)
3402 /* Format toolbar */
3403 { .name
= "FormatMergeCells",
3404 .icon
= "gnumeric-cells-merge",
3405 .label
= N_("Merge"),
3406 .tooltip
= N_("Merge a range of cells"),
3407 .callback
= G_CALLBACK (cb_merge_cells
)
3409 { .name
= "FormatUnmergeCells",
3410 .icon
= "gnumeric-cells-split",
3411 .label
= N_("Unmerge"),
3412 .tooltip
= N_("Split merged ranges of cells"),
3413 .callback
= G_CALLBACK (cb_unmerge_cells
)
3416 { .name
= "FormatAsGeneral",
3417 .label
= N_("General"),
3418 .accelerator
= "<control>asciitilde",
3419 .tooltip
= N_("Format the selection as General"),
3420 .callback
= G_CALLBACK (cb_format_as_general
)
3422 { .name
= "FormatAsNumber",
3423 .label
= N_("Number"),
3424 .accelerator
= "<control>exclam",
3425 .tooltip
= N_("Format the selection as numbers"),
3426 .callback
= G_CALLBACK (cb_format_as_number
)
3428 { .name
= "FormatAsCurrency",
3429 .label
= N_("Currency"),
3430 .accelerator
= "<control>dollar",
3431 .tooltip
= N_("Format the selection as currency"),
3432 .callback
= G_CALLBACK (cb_format_as_currency
)
3434 { .name
= "FormatAsAccounting",
3435 .icon
= "gnumeric-format-accounting",
3436 .label
= N_("Accounting"),
3437 .tooltip
= N_("Format the selection as accounting"),
3438 .callback
= G_CALLBACK (cb_format_as_accounting
)
3440 { .name
= "FormatAsPercentage",
3441 .icon
= "gnumeric-format-percentage",
3442 .label
= N_("Percentage"),
3443 .accelerator
= "<control>percent",
3444 .tooltip
= N_("Format the selection as percentage"),
3445 .callback
= G_CALLBACK (cb_format_as_percentage
)
3447 { .name
= "FormatAsScientific",
3448 .label
= N_("Scientific"),
3449 .accelerator
= "<control>asciicircum",
3450 .tooltip
= N_("Format the selection as scientific"),
3451 .callback
= G_CALLBACK (cb_format_as_scientific
)
3453 { .name
= "FormatAsDate",
3454 .label
= N_("Date"),
3455 .accelerator
= "<control>numbersign",
3456 .tooltip
= N_("Format the selection as date"),
3457 .callback
= G_CALLBACK (cb_format_as_date
)
3459 { .name
= "FormatAsTime",
3460 .label
= N_("Time"),
3461 .accelerator
= "<control>at",
3462 .tooltip
= N_("Format the selection as time"),
3463 .callback
= G_CALLBACK (cb_format_as_time
)
3465 { .name
= "FormatAddBorders",
3466 .label
= N_("AddBorders"),
3467 .accelerator
= "<control>ampersand",
3468 .tooltip
= N_("Add a border around the selection"),
3469 .callback
= G_CALLBACK (cb_format_add_borders
)
3471 { .name
= "FormatClearBorders",
3472 .label
= N_("ClearBorders"),
3473 .accelerator
= "<control>underscore",
3474 .tooltip
= N_("Clear the border around the selection"),
3475 .callback
= G_CALLBACK (cb_format_clear_borders
)
3478 { .name
= "FormatWithThousands",
3479 .icon
= "gnumeric-format-thousand-separator",
3480 .label
= N_("Thousands Separator"),
3481 .tooltip
= N_("Set the format of the selected cells to include a thousands separator"),
3482 .callback
= G_CALLBACK (cb_format_with_thousands
)
3484 { .name
= "FormatIncreasePrecision",
3485 .icon
= "gnumeric-format-precision-increase",
3486 .label
= N_("Increase Precision"),
3487 .tooltip
= N_("Increase the number of decimals displayed"),
3488 .callback
= G_CALLBACK (cb_format_inc_precision
)
3490 { .name
= "FormatDecreasePrecision",
3491 .icon
= "gnumeric-format-precision-decrease",
3492 .label
= N_("Decrease Precision"),
3493 .tooltip
= N_("Decrease the number of decimals displayed"),
3494 .callback
= G_CALLBACK (cb_format_dec_precision
)
3497 /* Gtk marks these accelerators as invalid because they use Tab
3498 * enable them manually in gnm-pane.c */
3499 { .name
= "FormatDecreaseIndent",
3500 .icon
= "format-indent-less",
3501 .accelerator
= "<control><alt><shift>Tab",
3502 .tooltip
= N_("Decrease the indent, and align the contents to the left"),
3503 .callback
= G_CALLBACK (cb_format_dec_indent
)
3505 { .name
= "FormatIncreaseIndent",
3506 .icon
= "format-indent-more",
3507 .accelerator
= "<control><alt>Tab",
3508 .tooltip
= N_("Increase the indent, and align the contents to the left"),
3509 .callback
= G_CALLBACK (cb_format_inc_indent
)
3512 /* ---------------------------------------- */
3514 { .name
= "SheetDisplayOutlines",
3516 .label
= N_("Display _Outlines"),
3517 .accelerator
= "<control>8",
3518 .tooltip
= N_("Toggle whether or not to display outline groups"),
3519 .callback
= G_CALLBACK (cb_sheet_pref_display_outlines
)
3521 { .name
= "SheetOutlineBelow",
3523 .label
= N_("Outlines _Below"),
3524 .tooltip
= N_("Toggle whether to display row outlines on top or bottom"),
3525 .callback
= G_CALLBACK (cb_sheet_pref_outline_symbols_below
)
3527 { .name
= "SheetOutlineRight",
3529 .label
= N_("Outlines _Right"),
3530 .tooltip
= N_("Toggle whether to display column outlines on the left or right"),
3531 .callback
= G_CALLBACK (cb_sheet_pref_outline_symbols_right
)
3533 { .name
= "SheetDisplayFormulas",
3535 .icon
= "gnumeric-formulaguru",
3536 .label
= N_("Display _Formul\303\246"),
3537 .accelerator
= "<control>quoteleft",
3538 .tooltip
= N_("Display the value of a formula or the formula itself"),
3539 .callback
= G_CALLBACK (cb_sheet_pref_display_formulas
)
3541 { .name
= "SheetHideZeros",
3543 .label
= N_("_Hide Zeros"),
3544 .tooltip
= N_("Toggle whether or not to display zeros as blanks"),
3545 .callback
= G_CALLBACK (cb_sheet_pref_hide_zero
)
3547 { .name
= "SheetHideGridlines",
3549 .label
= N_("Hide _Gridlines"),
3550 .tooltip
= N_("Toggle whether or not to display gridlines"),
3551 .callback
= G_CALLBACK (cb_sheet_pref_hide_grid
)
3553 { .name
= "SheetHideColHeader",
3555 .label
= N_("Hide _Column Headers"),
3556 .tooltip
= N_("Toggle whether or not to display column headers"),
3557 .callback
= G_CALLBACK (cb_sheet_pref_hide_col_header
)
3559 { .name
= "SheetHideRowHeader",
3561 .label
= N_("Hide _Row Headers"),
3562 .tooltip
= N_("Toggle whether or not to display row headers"),
3563 .callback
= G_CALLBACK (cb_sheet_pref_hide_row_header
)
3566 /* TODO : Make this a sub menu when we have more convention types */
3567 { .name
= "SheetUseR1C1",
3569 .label
= N_("Use R1C1 N_otation "),
3570 .tooltip
= N_("Display addresses as R1C1 or A1"),
3571 .callback
= G_CALLBACK (cb_sheet_pref_use_r1c1
)
3574 { .name
= "AlignLeft",
3576 .icon
= "format-justify-left",
3577 .label
= N_("_Left Align"),
3578 .tooltip
= N_("Align left"),
3579 .callback
= G_CALLBACK (cb_align_left
)
3581 { .name
= "AlignCenter",
3583 .icon
= "format-justify-center",
3584 .label
= N_("_Center"),
3585 .tooltip
= N_("Center horizontally"),
3586 .callback
= G_CALLBACK (cb_align_center
)
3588 { .name
= "AlignRight",
3590 .icon
= "format-justify-right",
3591 .label
= N_("_Right Align"),
3592 .tooltip
= N_("Align right"),
3593 .callback
= G_CALLBACK (cb_align_right
)
3595 { .name
= "CenterAcrossSelection",
3597 .icon
= "gnumeric-center-across-selection",
3598 .label
= N_("_Center Across Selection"),
3599 .tooltip
= N_("Center horizontally across the selection"),
3600 .callback
= G_CALLBACK (cb_center_across_selection
)
3602 { .name
= "MergeAndCenter",
3604 .label
= N_("_Merge and Center"),
3605 .tooltip
= N_("Merge the selection into 1 cell, and center horizontally."),
3606 .callback
= G_CALLBACK (cb_merge_and_center
)
3608 #warning "Add justify"
3609 #warning "h/v distributed?"
3611 #warning "Get vertical alignment icons"
3612 { .name
= "AlignTop",
3614 .label
= N_("Align _Top"),
3615 .tooltip
= N_("Align Top"),
3616 .callback
= G_CALLBACK (cb_align_top
)
3618 { .name
= "AlignVCenter",
3620 .label
= N_("_Vertically Center"),
3621 .tooltip
= N_("Vertically Center"),
3622 .callback
= G_CALLBACK (cb_align_vcenter
)
3624 { .name
= "AlignBottom",
3626 .label
= N_("Align _Bottom"),
3627 .tooltip
= N_("Align Bottom"),
3628 .callback
= G_CALLBACK (cb_align_bottom
)
3632 static GnmActionEntry
const font_actions
[] = {
3633 { .name
= "FontBold",
3635 .icon
= "format-text-bold",
3636 .label
= N_("_Bold"),
3637 .accelerator
= "<control>b", /* ALSO "<control>2" */
3638 .tooltip
= N_("Bold"),
3639 .callback
= G_CALLBACK (cb_font_bold
),
3640 .is_active
= FALSE
},
3641 { .name
= "FontItalic",
3643 .icon
= "format-text-italic",
3644 .label
= N_("_Italic"),
3645 .accelerator
= "<control>i", /* ALSO "<control>3" */
3646 .tooltip
= N_("Italic"),
3647 .callback
= G_CALLBACK (cb_font_italic
),
3648 .is_active
= FALSE
},
3649 { .name
= "FontUnderline",
3651 .icon
= "format-text-underline",
3652 .label
= N_("_Underline"),
3653 .accelerator
= "<control>u", /* ALSO "<control>4" */
3654 .tooltip
= N_("Underline"),
3655 .callback
= G_CALLBACK (cb_font_underline
),
3656 .is_active
= FALSE
},
3657 { .name
= "FontDoubleUnderline",
3659 .icon
= "stock_text_underlined-double", /* from icon theme */
3660 .label
= N_("_Double Underline"),
3661 .accelerator
= "<control><shift>d",
3662 .tooltip
= N_("Double Underline"),
3663 .callback
= G_CALLBACK (cb_font_double_underline
),
3664 .is_active
= FALSE
},
3665 { .name
= "FontSingleLowUnderline",
3667 .label
= N_("_Single Low Underline"),
3668 .accelerator
= "<control><shift>l",
3669 .tooltip
= N_("Single Low Underline"),
3670 .callback
= G_CALLBACK (cb_font_underline_low
),
3671 .is_active
= FALSE
},
3672 { .name
= "FontDoubleLowUnderline",
3674 .label
= N_("Double _Low Underline"),
3675 .tooltip
= N_("Double Low Underline"),
3676 .callback
= G_CALLBACK (cb_font_double_underline_low
),
3677 .is_active
= FALSE
},
3678 { .name
= "FontStrikeThrough",
3680 .icon
= "format-text-strikethrough",
3681 .label
= N_("_Strikethrough"),
3682 .accelerator
= "<control>5",
3683 .tooltip
= N_("Strikethrough"),
3684 .callback
= G_CALLBACK (cb_font_strikethrough
),
3685 .is_active
= FALSE
},
3686 { .name
= "FontSuperscript",
3688 .icon
= "gnumeric-superscript",
3689 .label
= N_("Su_perscript"),
3690 .accelerator
= "<control>asciicircum",
3691 .tooltip
= N_("Superscript"),
3692 .callback
= G_CALLBACK (cb_font_superscript
),
3693 .is_active
= FALSE
},
3694 { .name
= "FontSubscript",
3696 .icon
= "gnumeric-subscript",
3697 .label
= N_("Subscrip_t"),
3698 .accelerator
= "<control>underscore",
3699 .tooltip
= N_("Subscript"),
3700 .callback
= G_CALLBACK (cb_font_subscript
), .is_active
= FALSE
}
3703 /****************************************************************************/
3705 static GOActionComboPixmapsElement
const halignment_combo_info
[] = {
3706 { N_("Align left"), "format-justify-left", GNM_HALIGN_LEFT
},
3707 { N_("Center horizontally"), "format-justify-center", GNM_HALIGN_CENTER
},
3708 { N_("Align right"), "format-justify-right", GNM_HALIGN_RIGHT
},
3709 { N_("Fill horizontally"), "gnumeric-format-halign-fill", GNM_HALIGN_FILL
},
3710 { N_("Justify horizontally"), "format-justify-fill", GNM_HALIGN_JUSTIFY
},
3711 { N_("Distributed"), "gnumeric-format-halign-distributed", GNM_HALIGN_DISTRIBUTED
},
3712 { N_("Center horizontally across the selection"),
3713 "gnumeric-center-across-selection", GNM_HALIGN_CENTER_ACROSS_SELECTION
},
3714 { N_("Align numbers right, and text left"),
3715 "gnumeric-format-halign-general", GNM_HALIGN_GENERAL
},
3718 static GOActionComboPixmapsElement
const valignment_combo_info
[] = {
3719 { N_("Align top"), "gnumeric-format-valign-top", GNM_VALIGN_TOP
},
3720 { N_("Center vertically"), "gnumeric-format-valign-center", GNM_VALIGN_CENTER
},
3721 { N_("Align bottom"), "gnumeric-format-valign-bottom", GNM_VALIGN_BOTTOM
},
3722 { N_("Justify"), "gnumeric-format-valign-justify", GNM_VALIGN_JUSTIFY
},
3723 { N_("Align distributed"), "gnumeric-format-valign-distributed", GNM_VALIGN_DISTRIBUTED
},
3728 cb_halignment_activated (GOActionComboPixmaps
*a
, WBCGtk
*wbcg
)
3730 wbcg_set_selection_halign (wbcg
,
3731 go_action_combo_pixmaps_get_selected (a
, NULL
));
3734 cb_valignment_activated (GOActionComboPixmaps
*a
, WBCGtk
*wbcg
)
3736 wbcg_set_selection_valign (wbcg
,
3737 go_action_combo_pixmaps_get_selected (a
, NULL
));
3741 wbc_gtk_init_alignments (WBCGtk
*wbcg
)
3743 wbcg
->halignment
= go_action_combo_pixmaps_new ("HAlignmentSelector",
3744 halignment_combo_info
, 3, 1);
3745 g_object_set (G_OBJECT (wbcg
->halignment
),
3746 "label", _("Horizontal Alignment"),
3747 "tooltip", _("Horizontal Alignment"),
3749 g_signal_connect (G_OBJECT (wbcg
->halignment
),
3751 G_CALLBACK (cb_halignment_activated
), wbcg
);
3752 gnm_action_group_add_action (wbcg
->actions
, GTK_ACTION (wbcg
->halignment
));
3754 wbcg
->valignment
= go_action_combo_pixmaps_new ("VAlignmentSelector",
3755 valignment_combo_info
, 1, 3);
3756 g_object_set (G_OBJECT (wbcg
->valignment
),
3757 "label", _("Vertical Alignment"),
3758 "tooltip", _("Vertical Alignment"),
3760 g_signal_connect (G_OBJECT (wbcg
->valignment
),
3762 G_CALLBACK (cb_valignment_activated
), wbcg
);
3763 gnm_action_group_add_action (wbcg
->actions
, GTK_ACTION (wbcg
->valignment
));
3766 /****************************************************************************/
3769 cb_custom_color_created (GOActionComboColor
*caction
, GtkWidget
*dialog
, WBCGtk
*wbcg
)
3771 wbc_gtk_attach_guru (wbcg
, dialog
);
3772 wbcg_set_transient (wbcg
, GTK_WINDOW (dialog
));
3776 cb_fore_color_changed (GOActionComboColor
*a
, WBCGtk
*wbcg
)
3778 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
3781 gboolean is_default
;
3783 if (wbcg
->updating_ui
)
3785 c
= go_action_combo_color_get_color (a
, &is_default
);
3787 if (wbcg_is_editing (wbcg
)) {
3788 wbcg_edit_add_markup (wbcg
, go_color_to_pango (c
, TRUE
));
3792 mstyle
= gnm_style_new ();
3793 gnm_style_set_font_color (mstyle
, is_default
3794 ? style_color_auto_font ()
3795 : gnm_color_new_go (c
));
3796 cmd_selection_format (wbc
, mstyle
, NULL
, _("Set Foreground Color"));
3800 wbc_gtk_init_color_fore (WBCGtk
*gtk
)
3802 GnmColor
*sc_auto_font
= style_color_auto_font ();
3803 GOColor default_color
= sc_auto_font
->go_color
;
3804 style_color_unref (sc_auto_font
);
3806 gtk
->fore_color
= go_action_combo_color_new ("ColorFore", "gnumeric-font",
3807 _("Automatic"), default_color
, NULL
); /* set group to view */
3808 go_action_combo_color_set_allow_alpha (gtk
->fore_color
, TRUE
);
3809 g_object_set (G_OBJECT (gtk
->fore_color
),
3810 "label", _("Foreground"),
3811 "tooltip", _("Foreground"),
3813 g_signal_connect (G_OBJECT (gtk
->fore_color
),
3815 G_CALLBACK (cb_fore_color_changed
), gtk
);
3816 g_signal_connect (G_OBJECT (gtk
->fore_color
),
3817 "display-custom-dialog",
3818 G_CALLBACK (cb_custom_color_created
), gtk
);
3819 gnm_action_group_add_action (gtk
->font_actions
,
3820 GTK_ACTION (gtk
->fore_color
));
3824 cb_back_color_changed (GOActionComboColor
*a
, WBCGtk
*wbcg
)
3826 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
3829 gboolean is_default
;
3831 if (wbcg
->updating_ui
)
3834 c
= go_action_combo_color_get_color (a
, &is_default
);
3836 mstyle
= gnm_style_new ();
3838 /* We need to have a pattern of at least solid to draw a background colour */
3839 if (!gnm_style_is_element_set (mstyle
, MSTYLE_PATTERN
) ||
3840 gnm_style_get_pattern (mstyle
) < 1)
3841 gnm_style_set_pattern (mstyle
, 1);
3843 gnm_style_set_back_color (mstyle
, gnm_color_new_go (c
));
3845 gnm_style_set_pattern (mstyle
, 0); /* Set background to NONE */
3846 cmd_selection_format (wbc
, mstyle
, NULL
, _("Set Background Color"));
3850 wbc_gtk_init_color_back (WBCGtk
*gtk
)
3852 gtk
->back_color
= go_action_combo_color_new ("ColorBack", "gnumeric-bucket",
3853 _("Clear Background"), 0, NULL
);
3854 g_object_set (G_OBJECT (gtk
->back_color
),
3855 "label", _("Background"),
3856 "tooltip", _("Background"),
3858 g_object_connect (G_OBJECT (gtk
->back_color
),
3859 "signal::combo-activate", G_CALLBACK (cb_back_color_changed
), gtk
,
3860 "signal::display-custom-dialog", G_CALLBACK (cb_custom_color_created
), gtk
,
3862 gnm_action_group_add_action (gtk
->actions
, GTK_ACTION (gtk
->back_color
));
3865 /****************************************************************************/
3867 static GOActionComboPixmapsElement
const border_combo_info
[] = {
3868 { N_("Left"), "gnumeric-format-border-left", 11 },
3869 { N_("Clear Borders"), "gnumeric-format-border-none", 12 },
3870 { N_("Right"), "gnumeric-format-border-right", 13 },
3872 { N_("All Borders"), "gnumeric-format-border-all", 21 },
3873 { N_("Outside Borders"), "gnumeric-format-border-outside", 22 },
3874 { N_("Thick Outside Borders"), "gnumeric-format-border-thick-outside", 23 },
3876 { N_("Bottom"), "gnumeric-format-border-bottom", 31 },
3877 { N_("Double Bottom"), "gnumeric-format-border-double-bottom", 32 },
3878 { N_("Thick Bottom"), "gnumeric-format-border-thick-bottom", 33 },
3880 { N_("Top and Bottom"), "gnumeric-format-border-top-n-bottom", 41 },
3881 { N_("Top and Double Bottom"), "gnumeric-format-border-top-n-double-bottom", 42 },
3882 { N_("Top and Thick Bottom"), "gnumeric-format-border-top-n-thick-bottom", 43 },
3888 cb_border_activated (GOActionComboPixmaps
*a
, WorkbookControl
*wbc
)
3890 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
3891 GnmBorder
*borders
[GNM_STYLE_BORDER_EDGE_MAX
];
3893 int index
= go_action_combo_pixmaps_get_selected (a
, NULL
);
3896 for (i
= GNM_STYLE_BORDER_TOP
; i
< GNM_STYLE_BORDER_EDGE_MAX
; i
++)
3900 case 11 : /* left */
3901 borders
[GNM_STYLE_BORDER_LEFT
] = gnm_style_border_fetch (GNM_STYLE_BORDER_THIN
,
3902 sheet_style_get_auto_pattern_color (sheet
),
3903 gnm_style_border_get_orientation (GNM_STYLE_BORDER_LEFT
));
3906 case 12 : /* none */
3907 for (i
= GNM_STYLE_BORDER_TOP
; i
< GNM_STYLE_BORDER_EDGE_MAX
; i
++)
3908 borders
[i
] = gnm_style_border_ref (gnm_style_border_none ());
3911 case 13 : /* right */
3912 borders
[GNM_STYLE_BORDER_RIGHT
] = gnm_style_border_fetch (GNM_STYLE_BORDER_THIN
,
3913 sheet_style_get_auto_pattern_color (sheet
),
3914 gnm_style_border_get_orientation (GNM_STYLE_BORDER_RIGHT
));
3918 for (i
= GNM_STYLE_BORDER_HORIZ
; i
<= GNM_STYLE_BORDER_VERT
; ++i
)
3919 borders
[i
] = gnm_style_border_fetch (GNM_STYLE_BORDER_THIN
,
3920 sheet_style_get_auto_pattern_color (sheet
),
3921 gnm_style_border_get_orientation (i
));
3924 case 22 : /* outside */
3925 for (i
= GNM_STYLE_BORDER_TOP
; i
<= GNM_STYLE_BORDER_RIGHT
; ++i
)
3926 borders
[i
] = gnm_style_border_fetch (GNM_STYLE_BORDER_THIN
,
3927 sheet_style_get_auto_pattern_color (sheet
),
3928 gnm_style_border_get_orientation (i
));
3931 case 23 : /* thick_outside */
3932 for (i
= GNM_STYLE_BORDER_TOP
; i
<= GNM_STYLE_BORDER_RIGHT
; ++i
)
3933 borders
[i
] = gnm_style_border_fetch (GNM_STYLE_BORDER_THICK
,
3934 sheet_style_get_auto_pattern_color (sheet
),
3935 gnm_style_border_get_orientation (i
));
3938 case 41 : /* top_n_bottom */
3939 case 42 : /* top_n_double_bottom */
3940 case 43 : /* top_n_thick_bottom */
3941 borders
[GNM_STYLE_BORDER_TOP
] = gnm_style_border_fetch (GNM_STYLE_BORDER_THIN
,
3942 sheet_style_get_auto_pattern_color (sheet
),
3943 gnm_style_border_get_orientation (GNM_STYLE_BORDER_TOP
));
3946 case 31 : /* bottom */
3947 case 32 : /* double_bottom */
3948 case 33 : /* thick_bottom */
3950 int const tmp
= index
% 10;
3951 GnmStyleBorderType
const t
=
3952 (tmp
== 1) ? GNM_STYLE_BORDER_THIN
:
3953 (tmp
== 2) ? GNM_STYLE_BORDER_DOUBLE
3954 : GNM_STYLE_BORDER_THICK
;
3956 borders
[GNM_STYLE_BORDER_BOTTOM
] = gnm_style_border_fetch (t
,
3957 sheet_style_get_auto_pattern_color (sheet
),
3958 gnm_style_border_get_orientation (GNM_STYLE_BORDER_BOTTOM
));
3963 g_warning ("Unknown border preset selected (%d)", index
);
3967 cmd_selection_format (wbc
, NULL
, borders
, _("Set Borders"));
3971 wbc_gtk_init_borders (WBCGtk
*wbcg
)
3973 wbcg
->borders
= go_action_combo_pixmaps_new ("BorderSelector", border_combo_info
, 3, 4);
3974 g_object_set (G_OBJECT (wbcg
->borders
),
3975 "label", _("Borders"),
3976 "tooltip", _("Borders"),
3979 go_combo_pixmaps_select (wbcg
->borders
, 1); /* default to none */
3981 g_signal_connect (G_OBJECT (wbcg
->borders
),
3983 G_CALLBACK (cb_border_activated
), wbcg
);
3984 gnm_action_group_add_action (wbcg
->actions
, GTK_ACTION (wbcg
->borders
));
3987 /****************************************************************************/
3990 cb_chain_sensitivity (GtkAction
*src
, G_GNUC_UNUSED GParamSpec
*pspec
,
3993 gboolean old_val
= gtk_action_get_sensitive (action
);
3994 gboolean new_val
= gtk_action_get_sensitive (src
);
3995 if ((new_val
!= 0) == (old_val
!= 0))
3998 gtk_action_connect_accelerator (action
);
4000 gtk_action_disconnect_accelerator (action
);
4001 g_object_set (action
, "sensitive", new_val
, NULL
);
4006 create_undo_redo (GOActionComboStack
**haction
, char const *hname
,
4008 GtkAction
**vaction
, char const *vname
,
4011 char const *tooltip
,
4012 char const *icon_name
,
4013 char const *accel
, const char *alt_accel
)
4015 *haction
= g_object_new
4016 (go_action_combo_stack_get_type (),
4019 "icon-name", icon_name
,
4021 "visible-vertical", FALSE
,
4023 gtk_action_group_add_action_with_accel
4024 (gtk
->semi_permanent_actions
,
4025 GTK_ACTION (*haction
),
4027 g_signal_connect (G_OBJECT (*haction
), "activate", hcb
, gtk
);
4029 *vaction
= g_object_new
4033 "icon-name", icon_name
,
4035 "visible-horizontal", FALSE
,
4037 gtk_action_group_add_action_with_accel
4038 (gtk
->semi_permanent_actions
,
4039 GTK_ACTION (*vaction
),
4041 g_signal_connect_swapped (G_OBJECT (*vaction
), "activate", vcb
, gtk
);
4043 g_signal_connect (G_OBJECT (*haction
), "notify::sensitive",
4044 G_CALLBACK (cb_chain_sensitivity
), *vaction
);
4049 cb_undo_activated (GOActionComboStack
*a
, WorkbookControl
*wbc
)
4051 unsigned n
= workbook_find_command (wb_control_get_workbook (wbc
), TRUE
,
4052 go_action_combo_stack_selection (a
));
4058 cb_redo_activated (GOActionComboStack
*a
, WorkbookControl
*wbc
)
4060 unsigned n
= workbook_find_command (wb_control_get_workbook (wbc
), FALSE
,
4061 go_action_combo_stack_selection (a
));
4067 wbc_gtk_init_undo_redo (WBCGtk
*gtk
)
4070 >k
->redo_haction
, "Redo", G_CALLBACK (cb_redo_activated
),
4071 >k
->redo_vaction
, "VRedo", G_CALLBACK (command_redo
),
4072 gtk
, _("Redo the undone action"),
4073 "edit-redo", "<control>y", "<control><shift>z");
4075 >k
->undo_haction
, "Undo", G_CALLBACK (cb_undo_activated
),
4076 >k
->undo_vaction
, "VUndo", G_CALLBACK (command_undo
),
4077 gtk
, _("Undo the last action"),
4078 "edit-undo", "<control>z", NULL
);
4081 /****************************************************************************/
4083 static GNM_ACTION_DEF (cb_zoom_activated
)
4085 WorkbookControl
*wbc
= (WorkbookControl
*)wbcg
;
4086 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
4087 char const *new_zoom
;
4091 if (sheet
== NULL
|| wbcg
->updating_ui
|| wbcg
->snotebook
== NULL
)
4094 new_zoom
= go_action_combo_text_get_entry (wbcg
->zoom_haction
);
4096 errno
= 0; /* strtol sets errno, but does not clear it. */
4097 factor
= strtol (new_zoom
, &end
, 10);
4098 if (new_zoom
!= end
&& errno
!= ERANGE
&& factor
== (gnm_float
)factor
)
4099 /* The GSList of sheet passed to cmd_zoom will be freed by cmd_zoom,
4100 * and the sheet will force an update of the zoom combo to keep the
4101 * display consistent
4103 cmd_zoom (wbc
, g_slist_append (NULL
, sheet
), factor
/ 100.);
4106 static GNM_ACTION_DEF (cb_vzoom_activated
)
4108 dialog_zoom (wbcg
, wbcg_cur_sheet (wbcg
));
4112 wbc_gtk_init_zoom (WBCGtk
*wbcg
)
4114 #warning TODO : Add zoom to selection
4115 static char const * const preset_zoom
[] = {
4126 /* ----- horizontal ----- */
4128 wbcg
->zoom_haction
=
4129 g_object_new (go_action_combo_text_get_type (),
4131 "label", _("_Zoom"),
4132 "visible-vertical", FALSE
,
4133 "tooltip", _("Zoom"),
4134 "stock-id", "zoom-in",
4136 go_action_combo_text_set_width (wbcg
->zoom_haction
, "10000%");
4137 for (i
= 0; preset_zoom
[i
] != NULL
; ++i
)
4138 go_action_combo_text_add_item (wbcg
->zoom_haction
,
4141 g_signal_connect (G_OBJECT (wbcg
->zoom_haction
),
4143 G_CALLBACK (cb_zoom_activated
), wbcg
);
4144 gnm_action_group_add_action (wbcg
->actions
,
4145 GTK_ACTION (wbcg
->zoom_haction
));
4147 /* ----- vertical ----- */
4149 wbcg
->zoom_vaction
=
4150 g_object_new (GTK_TYPE_ACTION
,
4152 "tooltip", _("Zoom"),
4153 "icon-name", "zoom-in",
4154 "visible-horizontal", FALSE
,
4156 g_signal_connect (G_OBJECT (wbcg
->zoom_vaction
),
4158 G_CALLBACK (cb_vzoom_activated
), wbcg
);
4159 gnm_action_group_add_action (wbcg
->actions
,
4160 GTK_ACTION (wbcg
->zoom_vaction
));
4162 /* ----- chain ----- */
4164 g_signal_connect (G_OBJECT (wbcg
->zoom_haction
), "notify::sensitive",
4165 G_CALLBACK (cb_chain_sensitivity
), wbcg
->zoom_vaction
);
4168 /****************************************************************************/
4170 typedef struct { GtkAction base
; } GnmFontAction
;
4171 typedef struct { GtkActionClass base
; } GnmFontActionClass
;
4173 static PangoFontDescription
*
4174 gnm_font_action_get_font_desc (GtkAction
*act
)
4176 PangoFontDescription
*desc
=
4177 g_object_get_data (G_OBJECT (act
), "font-data");
4182 wbcg_font_action_set_font_desc (GtkAction
*act
, PangoFontDescription
*desc
)
4184 PangoFontDescription
*old_desc
;
4187 old_desc
= g_object_get_data (G_OBJECT (act
), "font-data");
4189 old_desc
= pango_font_description_new ();
4190 g_object_set_data_full (G_OBJECT (act
),
4191 "font-data", old_desc
,
4192 (GDestroyNotify
)pango_font_description_free
);
4194 pango_font_description_merge (old_desc
, desc
, TRUE
);
4196 for (p
= gtk_action_get_proxies (act
); p
; p
= p
->next
) {
4197 GtkWidget
*w
= p
->data
;
4199 GtkFontChooser
*chooser
;
4201 if (!GTK_IS_BIN (w
))
4204 child
= gtk_bin_get_child (GTK_BIN (w
));
4205 if (!GTK_IS_FONT_CHOOSER (child
))
4208 chooser
= GTK_FONT_CHOOSER (child
);
4209 gtk_font_chooser_set_font_desc (chooser
, old_desc
);
4214 cb_font_set (GtkFontChooser
*chooser
, GtkAction
*act
)
4216 PangoFontDescription
*desc
= gtk_font_chooser_get_font_desc (chooser
);
4217 wbcg_font_action_set_font_desc (act
, desc
);
4218 pango_font_description_free (desc
);
4219 gtk_action_activate (act
);
4223 cb_font_button_screen_changed (GtkWidget
*widget
)
4225 /* Doesn't look right */
4227 GdkScreen
*screen
= gtk_widget_get_screen (widget
);
4230 int w
= gnm_widget_measure_string (widget
,
4231 "XXMonospace | 99XX");
4232 gtk_widget_set_size_request (widget
, w
, -1);
4237 /* Filter to ignore non-scalable fonts. */
4239 cb_font_filter (G_GNUC_UNUSED
const PangoFontFamily
*family
,
4240 const PangoFontFace
*face_
,
4243 PangoFontFace
*face
= (PangoFontFace
*)face_
;
4246 static int debug
= -1;
4248 pango_font_face_list_sizes (face
, &sizes
, &n_sizes
);
4252 debug
= gnm_debug_flag ("fonts");
4254 if (n_sizes
> 0 && debug
) {
4255 PangoFontDescription
*desc
= pango_font_face_describe (face
);
4256 char *s
= pango_font_description_to_string (desc
);
4257 g_printerr ("Ignoring bitmap face %s\n", s
);
4259 pango_font_description_free (desc
);
4262 return n_sizes
== 0;
4266 gnm_font_action_create_tool_item (GtkAction
*action
)
4268 GtkWidget
*item
= g_object_new
4269 (GTK_TYPE_TOOL_ITEM
,
4271 GtkWidget
*but
= g_object_new
4272 (gnm_font_button_get_type(),
4273 "dialog-type", GO_TYPE_FONT_SEL_DIALOG
,
4274 "show-preview-entry", TRUE
,
4275 "show-style", FALSE
,
4276 "relief", gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (item
)),
4277 "focus-on-click", FALSE
,
4279 if (0) gtk_font_chooser_set_filter_func (GTK_FONT_CHOOSER (but
),
4283 gtk_widget_show_all (but
);
4284 gtk_container_add (GTK_CONTAINER (item
), but
);
4285 g_signal_connect (but
,
4286 "font-set", G_CALLBACK (cb_font_set
),
4288 g_signal_connect (but
,
4290 G_CALLBACK (cb_font_button_screen_changed
),
4296 gnm_font_action_class_init (GObjectClass
*gobject_class
)
4298 GtkActionClass
*act
= GTK_ACTION_CLASS (gobject_class
);
4300 act
->toolbar_item_type
= GTK_TYPE_MENU_TOOL_BUTTON
;
4301 act
->create_tool_item
= gnm_font_action_create_tool_item
;
4305 GSF_CLASS (GnmFontAction
, gnm_font_action
,
4306 gnm_font_action_class_init
, NULL
, GTK_TYPE_ACTION
)
4310 #define GNM_FONT_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), gnm_font_action_get_type(), GnmFontAction))
4313 cb_font_changed (GtkAction
*act
, WBCGtk
*gtk
)
4315 PangoFontDescription
*desc
= gnm_font_action_get_font_desc (act
);
4316 const char *family
= pango_font_description_get_family (desc
);
4317 int size
= pango_font_description_get_size (desc
);
4320 * Ignore events during destruction. This is an attempt at avoiding
4321 * https://bugzilla.redhat.com/show_bug.cgi?id=803904 for which we
4324 if (gtk
->snotebook
== NULL
)
4327 if (wbcg_is_editing (WBC_GTK (gtk
))) {
4328 wbcg_edit_add_markup (WBC_GTK (gtk
),
4329 pango_attr_family_new (family
));
4330 wbcg_edit_add_markup (WBC_GTK (gtk
),
4331 pango_attr_size_new (size
));
4333 GnmStyle
*style
= gnm_style_new ();
4334 char *font_name
= pango_font_description_to_string (desc
);
4335 char *title
= g_strdup_printf (_("Setting Font %s"), font_name
);
4338 gnm_style_set_font_name (style
, family
);
4339 gnm_style_set_font_size (style
, size
/ (double)PANGO_SCALE
);
4341 cmd_selection_format (GNM_WBC (gtk
), style
, NULL
, title
);
4347 cb_font_name_vaction_response (GtkDialog
*dialog
,
4351 WBCGtk
*wbcg
= g_object_get_data (G_OBJECT (act
), "wbcg");
4353 if (response_id
== GTK_RESPONSE_OK
) {
4354 PangoFontDescription
*desc
= gtk_font_chooser_get_font_desc
4355 (GTK_FONT_CHOOSER (dialog
));
4356 wbcg_font_action_set_font_desc (act
, desc
);
4357 pango_font_description_free (desc
);
4358 cb_font_changed (act
, wbcg
);
4361 gtk_widget_destroy (GTK_WIDGET (dialog
));
4366 cb_font_name_vaction_clicked (GtkAction
*act
, WBCGtk
*wbcg
)
4368 GtkFontChooser
*font_dialog
;
4369 const char *key
= "font-name-dialog";
4371 if (gnm_dialog_raise_if_exists (wbcg
, key
))
4374 font_dialog
= g_object_new (GO_TYPE_FONT_SEL_DIALOG
, NULL
);
4375 gtk_font_chooser_set_font_desc (font_dialog
,
4376 gnm_font_action_get_font_desc (act
));
4377 g_signal_connect (font_dialog
, "response",
4378 G_CALLBACK (cb_font_name_vaction_response
),
4381 gtk_window_present (GTK_WINDOW (font_dialog
));
4383 gnm_keyed_dialog (wbcg
, GTK_WINDOW (font_dialog
), key
);
4387 wbc_gtk_init_font_name (WBCGtk
*gtk
, gboolean horiz
)
4389 GtkAction
*act
= g_object_new
4390 (horiz
? gnm_font_action_get_type () : GTK_TYPE_ACTION
,
4391 "visible-vertical", !horiz
,
4392 "visible-horizontal", horiz
,
4393 "name", (horiz
? "FontName" : "VFontName"),
4394 "tooltip", _("Change font"),
4395 "icon-name", "gnumeric-font",
4398 g_object_set_data (G_OBJECT (act
), "wbcg", gtk
);
4400 g_signal_connect (G_OBJECT (act
),
4403 ? G_CALLBACK (cb_font_changed
)
4404 : G_CALLBACK (cb_font_name_vaction_clicked
)),
4407 gnm_action_group_add_action (gtk
->font_actions
, act
);
4412 /****************************************************************************/
4415 list_actions (GtkActionGroup
*group
)
4422 actions
= gtk_action_group_list_actions (group
);
4423 for (l
= actions
; l
; l
= l
->next
) {
4424 GtkAction
*act
= l
->data
;
4425 const char *name
= gtk_action_get_name (act
);
4426 g_printerr ("Action %s\n", name
);
4429 g_list_free (actions
);
4433 wbc_gtk_init_actions (WBCGtk
*wbcg
)
4439 } const toggles
[] = {
4440 { "FontBold", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.bold
) },
4441 { "FontItalic", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.italic
) },
4442 { "FontUnderline", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.underline
) },
4443 { "FontDoubleUnderline", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.d_underline
) },
4444 { "FontSingleLowUnderline",TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.sl_underline
) },
4445 { "FontDoubleLowUnderline",TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.dl_underline
) },
4446 { "FontSuperscript", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.superscript
) },
4447 { "FontSubscript", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.subscript
) },
4448 { "FontStrikeThrough", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.strikethrough
) },
4450 { "AlignLeft", FALSE
, G_STRUCT_OFFSET (WBCGtk
, h_align
.left
) },
4451 { "AlignCenter", FALSE
, G_STRUCT_OFFSET (WBCGtk
, h_align
.center
) },
4452 { "AlignRight", FALSE
, G_STRUCT_OFFSET (WBCGtk
, h_align
.right
) },
4453 { "CenterAcrossSelection", FALSE
, G_STRUCT_OFFSET (WBCGtk
, h_align
.center_across_selection
) },
4454 { "AlignTop", FALSE
, G_STRUCT_OFFSET (WBCGtk
, v_align
.top
) },
4455 { "AlignVCenter", FALSE
, G_STRUCT_OFFSET (WBCGtk
, v_align
.center
) },
4456 { "AlignBottom", FALSE
, G_STRUCT_OFFSET (WBCGtk
, v_align
.bottom
) }
4460 wbcg
->permanent_actions
= gtk_action_group_new ("PermanentActions");
4461 wbcg
->actions
= gtk_action_group_new ("Actions");
4462 wbcg
->font_actions
= gtk_action_group_new ("FontActions");
4463 wbcg
->data_only_actions
= gtk_action_group_new ("DataOnlyActions");
4464 wbcg
->semi_permanent_actions
= gtk_action_group_new ("SemiPermanentActions");
4466 gnm_action_group_add_actions (wbcg
->permanent_actions
,
4467 permanent_actions
, G_N_ELEMENTS (permanent_actions
), wbcg
);
4468 gnm_action_group_add_actions (wbcg
->actions
,
4469 actions
, G_N_ELEMENTS (actions
), wbcg
);
4470 gnm_action_group_add_actions (wbcg
->font_actions
,
4471 font_actions
, G_N_ELEMENTS (font_actions
), wbcg
);
4472 gnm_action_group_add_actions (wbcg
->data_only_actions
,
4473 data_only_actions
, G_N_ELEMENTS (data_only_actions
), wbcg
);
4474 gnm_action_group_add_actions (wbcg
->semi_permanent_actions
,
4475 semi_permanent_actions
, G_N_ELEMENTS (semi_permanent_actions
), wbcg
);
4477 wbc_gtk_init_alignments (wbcg
);
4478 wbc_gtk_init_color_fore (wbcg
);
4479 wbc_gtk_init_color_back (wbcg
);
4480 wbc_gtk_init_borders (wbcg
);
4481 wbc_gtk_init_undo_redo (wbcg
);
4482 wbc_gtk_init_zoom (wbcg
);
4483 wbcg
->font_name_haction
= wbc_gtk_init_font_name (wbcg
, TRUE
);
4484 wbcg
->font_name_vaction
= wbc_gtk_init_font_name (wbcg
, FALSE
);
4486 for (i
= G_N_ELEMENTS (toggles
); i
-- > 0 ; ) {
4487 GtkAction
*act
= wbcg_find_action (wbcg
, toggles
[i
].name
);
4488 G_STRUCT_MEMBER (GtkToggleAction
*, wbcg
, toggles
[i
].offset
) =
4489 (GtkToggleAction
*) (act
);
4492 if (gnm_debug_flag ("actions")) {
4493 list_actions (wbcg
->permanent_actions
);
4494 list_actions (wbcg
->actions
);
4495 list_actions (wbcg
->font_actions
);
4496 list_actions (wbcg
->data_only_actions
);
4497 list_actions (wbcg
->semi_permanent_actions
);
4498 list_actions (wbcg
->file_history
.actions
);
4499 list_actions (wbcg
->toolbar
.actions
);
4500 list_actions (wbcg
->windows
.actions
);
4501 list_actions (wbcg
->templates
.actions
);