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 gnm_sheet_view_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 gnm_sheet_view_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 gnm_sheet_view_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 gnm_sheet_view_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 gnm_sheet_view_freeze_panes (sv
, &frozen_tl
, &unfrozen_tl
);
772 gnm_sheet_view_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
, cb_calc_decs
, &decs
);
1837 new_fmt_str
= g_string_new ("0");
1838 if (decs
+ dir
> 0) {
1839 g_string_append_c (new_fmt_str
, '.');
1840 go_string_append_c_n (new_fmt_str
, '0', decs
+ dir
);
1842 new_fmt
= go_format_new_from_XL (new_fmt_str
->str
);
1843 g_string_free (new_fmt_str
, TRUE
);
1845 style
= gnm_style_new ();
1846 gnm_style_set_format (style
, new_fmt
);
1847 cmd_selection_format (wbc
, style
, NULL
, descriptor
);
1848 go_format_unref (new_fmt
);
1851 static GNM_ACTION_DEF (cb_format_inc_precision
)
1853 &go_format_inc_precision
, _("Increase precision")); }
1854 static GNM_ACTION_DEF (cb_format_dec_precision
)
1855 { inc_dec (wbcg
, -1,
1856 &go_format_dec_precision
, _("Decrease precision")); }
1857 static GNM_ACTION_DEF (cb_format_with_thousands
)
1858 { modify_format (wbcg
, &go_format_toggle_1000sep
, _("Toggle thousands separator")); }
1860 static GNM_ACTION_DEF (cb_format_dec_indent
) { workbook_cmd_dec_indent (GNM_WBC (wbcg
)); }
1861 static GNM_ACTION_DEF (cb_format_inc_indent
) { workbook_cmd_inc_indent (GNM_WBC (wbcg
)); }
1863 static GNM_ACTION_DEF (cb_copydown
)
1865 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1866 cmd_copyrel (wbc
, 0, -1, _("Copy down"));
1869 static GNM_ACTION_DEF (cb_copyright
)
1871 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1872 /* xgettext: copy from the cell to the left into current cell --
1873 this has nothing whatsoever to do with copyright. */
1874 cmd_copyrel (wbc
, -1, 0, _("Copy right"));
1877 static GNM_ACTION_DEF (cb_format_cells_auto_fit_height
)
1879 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1880 workbook_cmd_autofit_selection
1881 (wbc
, wb_control_cur_sheet (wbc
), FALSE
);
1884 static GNM_ACTION_DEF (cb_format_cells_auto_fit_width
)
1886 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1887 workbook_cmd_autofit_selection
1888 (wbc
, wb_control_cur_sheet (wbc
), TRUE
);
1891 static GNM_ACTION_DEF (cb_format_column_auto_fit
)
1893 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1894 workbook_cmd_resize_selected_colrow (wbc
,
1895 wb_control_cur_sheet (wbc
), TRUE
, -1);
1897 static GNM_ACTION_DEF (cb_set_column_width
)
1899 dialog_col_width (wbcg
, FALSE
);
1901 static GNM_ACTION_DEF (cb_format_column_std_width
)
1903 dialog_col_width (wbcg
, TRUE
);
1905 static GNM_ACTION_DEF (cb_format_column_hide
)
1907 cmd_selection_colrow_hide (GNM_WBC (wbcg
), TRUE
, FALSE
);
1909 static GNM_ACTION_DEF (cb_format_column_unhide
)
1911 cmd_selection_colrow_hide (GNM_WBC (wbcg
), TRUE
, TRUE
);
1914 static GNM_ACTION_DEF (cb_format_row_auto_fit
)
1916 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
1917 workbook_cmd_resize_selected_colrow (wbc
,
1918 wb_control_cur_sheet (wbc
), FALSE
, -1);
1920 static GNM_ACTION_DEF (cb_set_row_height
)
1922 dialog_row_height (wbcg
, FALSE
);
1924 static GNM_ACTION_DEF (cb_format_row_std_height
)
1926 dialog_row_height (wbcg
, TRUE
);
1928 static GNM_ACTION_DEF (cb_format_row_hide
)
1930 cmd_selection_colrow_hide (GNM_WBC (wbcg
), FALSE
, FALSE
);
1932 static GNM_ACTION_DEF (cb_format_row_unhide
)
1934 cmd_selection_colrow_hide (GNM_WBC (wbcg
), FALSE
, TRUE
);
1937 static GNM_ACTION_DEF (cb_file_menu
)
1939 wbc_gtk_load_templates (wbcg
);
1942 static GNM_ACTION_DEF (cb_insert_menu
)
1944 GtkAction
*action
= wbcg_find_action (wbcg
, "MenuInsertObject");
1945 SheetControlGUI
*scg
= wbcg_cur_scg (wbcg
);
1946 gtk_action_set_sensitive (action
, go_components_get_mime_types () != NULL
&& scg
&& scg_sheet (scg
)->sheet_type
== GNM_SHEET_DATA
);
1949 #define TOGGLE_HANDLER(flag,property) \
1950 static GNM_ACTION_DEF (cb_sheet_pref_ ## flag ) \
1952 g_return_if_fail (GNM_IS_WBC_GTK (wbcg)); \
1954 if (!wbcg->updating_ui) { \
1955 Sheet *sheet = wbcg_cur_sheet (wbcg); \
1956 go_object_toggle (sheet, property); \
1957 sheet_update (sheet); \
1961 TOGGLE_HANDLER (display_formulas
, "display-formulas")
1962 TOGGLE_HANDLER (hide_zero
, "display-zeros")
1963 TOGGLE_HANDLER (hide_grid
, "display-grid")
1964 TOGGLE_HANDLER (hide_col_header
, "display-column-header")
1965 TOGGLE_HANDLER (hide_row_header
, "display-row-header")
1966 TOGGLE_HANDLER (display_outlines
, "display-outlines")
1967 TOGGLE_HANDLER (outline_symbols_below
, "display-outlines-below")
1968 TOGGLE_HANDLER (outline_symbols_right
, "display-outlines-right")
1969 TOGGLE_HANDLER (use_r1c1
, "use-r1c1")
1971 /* Actions that are always sensitive */
1972 static GnmActionEntry
const permanent_actions
[] = {
1973 { .name
= "MenuFile",
1974 .label
= N_("_File"),
1975 .callback
= G_CALLBACK (cb_file_menu
)
1977 { .name
= "MenuFileNewFromTemplate",
1978 .icon
= "document-new",
1979 .label
= N_("New From Template")
1981 { .name
= "FileNew",
1982 .icon
= "document-new",
1983 .label
= N_("_New"),
1984 .accelerator
= "<control>n",
1985 .tooltip
= N_("Create a new workbook"),
1986 .callback
= G_CALLBACK (cb_file_new
)
1988 { .name
= "FileOpen",
1989 .icon
= "document-open",
1990 .label
= GNM_N_STOCK_OPEN
,
1991 .label_context
= GNM_STOCK_LABEL_CONTEXT
,
1992 .accelerator
= "<control>o",
1993 .tooltip
= N_("Open a file"),
1994 .callback
= G_CALLBACK (cb_file_open
)
1996 { .name
= "FileSave",
1997 .icon
= "document-save",
1998 .label
= GNM_N_STOCK_SAVE
,
1999 .label_context
= GNM_STOCK_LABEL_CONTEXT
,
2000 .accelerator
= "<control>s",
2001 .tooltip
= N_("Save the current workbook"),
2002 .callback
= G_CALLBACK (cb_file_save
)
2004 { .name
= "FileSaveAs",
2005 .icon
= "document-save-as",
2006 .label
= GNM_N_STOCK_SAVE_AS
,
2007 .label_context
= GNM_STOCK_LABEL_CONTEXT
,
2008 .accelerator
= "<control><shift>s",
2009 .tooltip
= N_("Save the current workbook with a different name"),
2010 .callback
= G_CALLBACK (cb_file_save_as
)
2012 { .name
= "FileSend",
2013 .icon
= "gnumeric-link-email",
2014 .label
= N_("Sen_d To..."),
2015 .tooltip
= N_("Send the current file via email"),
2016 .callback
= G_CALLBACK (cb_file_sendto
)
2018 { .name
= "FilePageSetup",
2019 .icon
= "document-page-setup",
2020 .label
= N_("Page Set_up..."),
2021 .tooltip
= N_("Setup the page settings for your current printer"),
2022 .callback
= G_CALLBACK (cb_file_page_setup
)
2024 { .name
= "FilePrintPreview",
2025 .icon
= "document-print-preview",
2026 .label
= N_("Print Pre_view"),
2027 .tooltip
= N_("Print preview"),
2028 .callback
= G_CALLBACK (cb_file_print_preview
)
2030 { .name
= "FilePrint",
2031 .icon
= "document-print",
2032 .label
= N_("Print"),
2033 .accelerator
= "<control>p",
2034 .tooltip
= N_("Print the current file"),
2035 .callback
= G_CALLBACK (cb_file_print
)
2037 { .name
= "FilePrintArea",
2038 .label
= N_("Print Area & Breaks")
2040 { .name
= "FileHistoryFull",
2041 .label
= N_("Full _History..."),
2042 .tooltip
= N_("Access previously used file"),
2043 .callback
= G_CALLBACK (cb_file_history_full
)
2045 { .name
= "FileClose",
2046 .icon
= "window-close",
2047 .label
= N_("_Close"),
2048 .accelerator
= "<control>w",
2049 .tooltip
= N_("Close the current file"),
2050 .callback
= G_CALLBACK (cb_file_close
)
2052 { .name
= "FileQuit",
2053 .icon
= "application-exit",
2054 .label
= N_("_Quit"),
2055 .accelerator
= "<control>q",
2056 .tooltip
= N_("Quit the application"),
2057 .callback
= G_CALLBACK (cb_file_quit
)
2059 /* ---------------------------------------- */
2060 { .name
= "MenuEdit",
2061 .label
= N_("_Edit")
2063 { .name
= "MenuEditClear",
2064 .icon
= "edit-clear",
2065 .label
= N_("C_lear")
2067 { .name
= "MenuEditDelete",
2068 .icon
= "edit-delete",
2069 .label
= N_("_Delete")
2071 { .name
= "MenuEditItems",
2072 .label
= N_("_Modify")
2074 { .name
= "MenuEditSheet",
2075 .label
= N_("S_heet")
2077 { .name
= "MenuEditSelect",
2078 .label
= N_("_Select")
2081 { .name
= "EditCopy",
2082 .icon
= "edit-copy",
2083 .label
= N_("_Copy"),
2084 .accelerator
= "<control>c",
2085 .tooltip
= N_("Copy the selection"),
2086 .callback
= G_CALLBACK (cb_edit_copy
)
2089 /* ---------------------------------------- */
2090 { .name
= "MenuView",
2091 .label
= N_("_View")
2093 { .name
= "MenuViewWindows",
2094 .label
= N_("_Windows")
2096 { .name
= "MenuViewToolbars",
2097 .label
= N_("_Toolbars")
2099 /* ---------------------------------------- */
2100 { .name
= "MenuInsert",
2101 .label
= N_("_Insert"),
2102 .callback
= G_CALLBACK (cb_insert_menu
)
2104 { .name
= "MenuInsertObject",
2105 .label
= N_("_Object")
2107 { .name
= "MenuInsertSpecial",
2108 .label
= N_("S_pecial")
2110 { .name
= "MenuInsertFormulaWrap",
2111 .icon
= "gnumeric-formulaguru",
2112 .label
= N_("Func_tion Wrapper")
2114 { .name
= "InsertNames",
2115 .label
= N_("_Name..."),
2116 .accelerator
= "F3",
2117 .tooltip
= N_("Insert a defined name"),
2118 .callback
= G_CALLBACK (cb_paste_names
)
2120 /* ---------------------------------------- */
2121 { .name
= "MenuFormat",
2122 .label
= N_("F_ormat")
2124 { .name
= "MenuFormatCells",
2125 .label
= N_("_Cells")
2127 { .name
= "MenuFormatText",
2128 .label
= N_("_Text")
2130 { .name
= "MenuFormatTextUnderline",
2131 .label
= N_("_Underline")
2133 { .name
= "MenuFormatColumn",
2134 .label
= N_("C_olumn")
2136 { .name
= "MenuFormatRow",
2139 { .name
= "MenuFormatSheet",
2140 .label
= N_("_Sheet")
2142 /* ---------------------------------------- */
2143 { .name
= "MenuTools",
2144 .label
= N_("_Tools")
2146 { .name
= "MenuToolsScenarios",
2147 .label
= N_("Sce_narios")
2149 /* ---------------------------------------- */
2150 { .name
= "MenuStatistics",
2151 .label
= N_("_Statistics")
2153 { .name
= "MenuStatisticsDescriptive",
2154 .label
= N_("_Descriptive Statistics")
2156 { .name
= "MenuToolFrequencies",
2157 .label
= N_("Fre_quency Tables")
2159 { .name
= "MenuStatisticsTimeSeries",
2160 .label
= N_("De_pendent Observations")
2162 { .name
= "MenuToolForecast",
2163 .label
= N_("F_orecast")
2165 { .name
= "MenuStatisticsOneSample",
2166 .label
= N_("_One Sample Tests")
2168 { .name
= "MenuToolOneMedian",
2169 .label
= N_("Claims About a Me_dian")
2171 { .name
= "MenuStatisticsTwoSamples",
2172 .label
= N_("_Two Sample Tests")
2174 { .name
= "MenuToolTwoMedians",
2175 .label
= N_("Claims About Two Me_dians")
2177 { .name
= "MenuToolTTest",
2178 .label
= N_("Claims About Two _Means")
2180 { .name
= "MenuStatisticsMultipleSamples",
2181 .label
= N_("_Multiple Sample Tests")
2183 { .name
= "MenuANOVA",
2184 .label
= N_("_ANOVA")
2186 { .name
= "MenuContingencyTests",
2187 .label
= N_("Contin_gency Table")
2189 /* ---------------------------------------- */
2190 { .name
= "MenuData",
2191 .label
= N_("_Data")
2193 { .name
= "MenuFilter",
2194 .label
= N_("_Filter")
2196 { .name
= "MenuEditFill",
2197 .label
= N_("F_ill")
2199 { .name
= "MenuRandomGenerator",
2200 .label
= N_("_Random Generators")
2202 { .name
= "MenuOutline",
2203 .label
= N_("_Group and Outline")
2205 { .name
= "MenuExternalData",
2206 .label
= N_("Import _Data")
2208 { .name
= "MenuExportData",
2209 .label
= N_("E_xport Data")
2211 { .name
= "MenuSlicer",
2212 .label
= N_("Data S_licer")
2214 /* ---------------------------------------- */
2215 { .name
= "MenuHelp",
2216 .label
= N_("_Help")
2219 { .name
= "HelpDocs",
2220 .icon
= "help-browser",
2221 .label
= N_("_Contents"),
2222 .accelerator
= "F1",
2223 .tooltip
= N_("Open a viewer for Gnumeric's documentation"),
2224 .callback
= G_CALLBACK (cb_help_docs
)
2226 { .name
= "HelpFunctions",
2227 .icon
= "gnumeric-formulaguru",
2228 .label
= N_("_Functions"),
2229 .tooltip
= N_("Functions help"),
2230 .callback
= G_CALLBACK (cb_help_function
)
2232 { .name
= "HelpWeb",
2233 .label
= N_("Gnumeric on the _Web"),
2234 .tooltip
= N_("Browse to Gnumeric's website"),
2235 .callback
= G_CALLBACK (cb_help_web
)
2237 { .name
= "HelpIRC",
2238 .label
= N_("_Live Assistance"),
2239 .tooltip
= N_("See if anyone is available to answer questions"),
2240 .callback
= G_CALLBACK (cb_help_irc
)
2242 { .name
= "HelpBug",
2243 .label
= N_("Report a _Problem"),
2244 .tooltip
= N_("Report problem"),
2245 .callback
= G_CALLBACK (cb_help_bug
)
2247 { .name
= "HelpAbout",
2248 .icon
= "help-about",
2249 .label
= N_("_About"),
2250 .tooltip
= N_("About this application"),
2251 .callback
= G_CALLBACK (cb_help_about
)
2255 /* actions that are sensitive only in data sheets */
2256 static GnmActionEntry
const data_only_actions
[] = {
2257 { .name
= "EditCut",
2259 .label
= N_("Cu_t"),
2260 .accelerator
= "<control>x",
2261 .tooltip
= N_("Cut the selection"),
2262 .callback
= G_CALLBACK (cb_edit_cut
)
2264 { .name
= "EditPaste",
2265 .icon
= "edit-paste",
2266 .label
= N_("_Paste"),
2267 .accelerator
= "<control>v",
2268 .tooltip
= N_("Paste the clipboard"),
2269 .callback
= G_CALLBACK (cb_edit_paste
)
2273 #define FULLSCREEN_ACCEL "F11"
2275 static GnmActionEntry
const semi_permanent_actions
[] = {
2277 { .name
= "SheetReorder",
2278 .label
= N_("_Manage Sheets..."),
2279 .tooltip
= N_("Manage the sheets in this workbook"),
2280 .callback
= G_CALLBACK (cb_sheet_order
)
2282 { .name
= "InsertSheet",
2283 .label
= N_("_Insert"),
2284 .tooltip
= N_("Insert a new sheet"),
2285 .callback
= G_CALLBACK (wbcg_insert_sheet
)
2287 /* ICK A DUPLICATE : we have no way to override a label on one proxy */
2288 { .name
= "SheetInsert",
2289 .label
= N_("_Sheet"),
2290 .tooltip
= N_("Insert a new sheet"),
2291 .callback
= G_CALLBACK (wbcg_insert_sheet
)
2293 { .name
= "InsertSheetAtEnd",
2294 .label
= N_("_Append"),
2295 .tooltip
= N_("Append a new sheet"),
2296 .callback
= G_CALLBACK (wbcg_append_sheet
)
2298 { .name
= "EditDuplicateSheet",
2299 .label
= N_("_Duplicate"),
2300 .tooltip
= N_("Make a copy of the current sheet"),
2301 .callback
= G_CALLBACK (wbcg_clone_sheet
)
2303 { .name
= "SheetRemove",
2304 .label
= N_("_Remove"),
2305 .tooltip
= N_("Irrevocably remove an entire sheet"),
2306 .callback
= G_CALLBACK (cb_sheet_remove
)
2308 { .name
= "SheetChangeName",
2309 .label
= N_("Re_name..."),
2310 .tooltip
= N_("Rename the current sheet"),
2311 .callback
= G_CALLBACK (cb_sheet_name
)
2313 { .name
= "SheetResize",
2314 .label
= N_("Resize..."),
2315 .tooltip
= N_("Change the size of the current sheet"),
2316 .callback
= G_CALLBACK (cb_sheet_resize
)
2320 { .name
= "ViewNew",
2321 .icon
= "document-new",
2322 .label
= N_("_New View..."),
2323 .tooltip
= N_("Create a new view of the workbook"),
2324 .callback
= G_CALLBACK (cb_view_new
)
2328 { .name
= "FormatWorkbook",
2329 .icon
= "document-properties",
2330 .label
= N_("View _Properties..."),
2331 .tooltip
= N_("Modify the view properties"),
2332 .callback
= G_CALLBACK (cb_workbook_attr
)
2335 { .name
= "ViewStatusbar",
2337 .label
= N_("View _Statusbar"),
2338 .tooltip
= N_("Toggle visibility of statusbar"),
2339 .callback
= G_CALLBACK (cb_view_statusbar
),
2343 { .name
= "ViewFullScreen",
2345 .icon
= "view-fullscreen",
2346 .label
= N_("F_ull Screen"),
2347 .accelerator
= FULLSCREEN_ACCEL
,
2348 .tooltip
= N_("Switch to or from full screen mode"),
2349 .callback
= G_CALLBACK (cb_view_fullscreen
)
2353 #define ZOOM_IN_ACCEL NULL
2354 #define ZOOM_OUT_ACCEL NULL
2356 static GnmActionEntry
const actions
[] = {
2358 { .name
= "FileMetaData",
2359 .icon
= "document-properties",
2360 .label
= N_("Document Proper_ties..."),
2361 .tooltip
= N_("Edit document properties"),
2362 .callback
= G_CALLBACK (cb_doc_meta_data
)
2365 /* File->PrintArea */
2366 { .name
= "FilePrintAreaSet",
2367 .label
= N_("Set Print Area"),
2368 .tooltip
= N_("Use the current selection as print area"),
2369 .callback
= G_CALLBACK (cb_file_print_area_set
)
2371 { .name
= "FilePrintAreaClear",
2372 .label
= N_("Clear Print Area"),
2373 .tooltip
= N_("Undefine the print area"),
2374 .callback
= G_CALLBACK (cb_file_print_area_clear
)
2376 { .name
= "FilePrintAreaShow",
2377 .label
= N_("Show Print Area"),
2378 .tooltip
= N_("Select the print area"),
2379 .callback
= G_CALLBACK (cb_file_print_area_show
)
2381 { .name
= "FilePrintAreaToggleColPageBreak",
2382 .label
= N_("Set Column Page Break"),
2383 .tooltip
= N_("Split the page to the left of this column"),
2384 .callback
= G_CALLBACK (cb_file_print_area_toggle_col
)
2386 { .name
= "FilePrintAreaToggleRowPageBreak",
2387 .label
= N_("Set Row Page Break"),
2388 .tooltip
= N_("Split the page above this row"),
2389 .callback
= G_CALLBACK (cb_file_print_area_toggle_row
)
2391 { .name
= "FilePrintAreaClearAllPageBreak",
2392 .label
= N_("Clear All Page Breaks"),
2393 .tooltip
= N_("Remove all manual pagebreaks from this sheet"),
2394 .callback
= G_CALLBACK (cb_file_print_area_clear_pagebreaks
)
2398 { .name
= "EditClearAll",
2399 .icon
= "edit-clear",
2400 .label
= N_("_All"),
2401 .tooltip
= N_("Clear the selected cells' formats, comments, and contents"),
2402 .callback
= G_CALLBACK (cb_edit_clear_all
)
2404 { .name
= "EditClearFormats",
2405 .label
= N_("_Formats & Hyperlinks"),
2406 .tooltip
= N_("Clear the selected cells' formats and hyperlinks"),
2407 .callback
= G_CALLBACK (cb_edit_clear_formats
)
2409 { .name
= "EditClearComments",
2410 .icon
= "gnumeric-comment-delete",
2411 .label
= N_("Co_mments"),
2412 .tooltip
= N_("Delete the selected cells' comments"),
2413 .callback
= G_CALLBACK (cb_edit_clear_comments
)
2415 { .name
= "EditClearContent",
2416 .icon
= "edit-clear",
2417 .label
= N_("_Contents"),
2418 .tooltip
= N_("Clear the selected cells' contents"),
2419 .callback
= G_CALLBACK (cb_edit_clear_content
)
2421 { .name
= "EditClearAllFiltered",
2422 .icon
= "edit-clear",
2423 .label
= N_("A_ll Filtered Rows"),
2424 .tooltip
= N_("Clear the selected cells' formats, comments, and contents in the filtered rows"),
2425 .callback
= G_CALLBACK (cb_edit_clear_all_filtered
)
2427 { .name
= "EditClearFormatsFiltered",
2428 .label
= N_("F_ormats & Hyperlinks in Filtered Rows"),
2429 .tooltip
= N_("Clear the selected cells' formats and hyperlinks in the filtered rows"),
2430 .callback
= G_CALLBACK (cb_edit_clear_formats_filtered
)
2432 { .name
= "EditClearCommentsFiltered",
2433 .icon
= "gnumeric-comment-delete",
2434 .label
= N_("Comme_nts in Filtered Rows"),
2435 .tooltip
= N_("Delete the selected cells' comments in the filtered rows"),
2436 .callback
= G_CALLBACK (cb_edit_clear_comments_filtered
)
2438 { .name
= "EditClearContentFiltered",
2439 .icon
= "edit-clear",
2440 .label
= N_("Content_s of Filtered Rows"),
2441 .tooltip
= N_("Clear the selected cells' contents in the filtered rows"),
2442 .callback
= G_CALLBACK (cb_edit_clear_content_filtered
)
2445 /* Edit -> Delete */
2446 /*Translators: Delete "Rows"*/
2447 { .name
= "EditDeleteRows",
2448 .icon
= "gnumeric-row-delete",
2449 .label
= N_("_Rows"),
2450 .tooltip
= N_("Delete the row(s) containing the selected cells"),
2451 .callback
= G_CALLBACK (cb_edit_delete_rows
)
2453 /*Translators: Delete "Columns"*/
2454 { .name
= "EditDeleteColumns",
2455 .icon
= "gnumeric-column-delete",
2456 .label
= N_("_Columns"),
2457 .tooltip
= N_("Delete the column(s) containing the selected cells"),
2458 .callback
= G_CALLBACK (cb_edit_delete_columns
)
2460 { .name
= "EditDeleteCells",
2461 .label
= N_("C_ells..."),
2462 .accelerator
= "<control>minus",
2463 .tooltip
= N_("Delete the selected cells, shifting others into their place"),
2464 .callback
= G_CALLBACK (cb_edit_delete_cells
)
2466 { .name
= "EditClearHyperlinks",
2467 .icon
= "gnumeric-link-delete",
2468 .label
= N_("_Hyperlinks"),
2469 .tooltip
= N_("Delete the selected cells' hyperlinks"),
2470 .callback
= G_CALLBACK (cb_edit_delete_links
)
2472 /* A duplicate that should not go into the menus, used only for the accelerator */
2473 { .name
= "EditDeleteCellsXL",
2474 .label
= N_("C_ells..."),
2475 .accelerator
= "<control>KP_Subtract",
2476 .tooltip
= N_("Delete the selected cells, shifting others into their place"),
2477 .callback
= G_CALLBACK (cb_edit_delete_cells
)
2480 /* Edit -> Select */
2482 /* Note : The accelerators involving space are just for display
2483 * purposes. We actually handle this in
2484 * gnm-pane.c:gnm_pane_key_mode_sheet
2485 * with the rest of the key movement and rangeselection.
2486 * Otherwise input methods would steal them */
2487 { .name
= "EditSelectAll",
2488 .label
= N_("_All"),
2489 .accelerator
= "<control><shift>space",
2490 .tooltip
= N_("Select all cells in the spreadsheet"),
2491 .callback
= G_CALLBACK (cb_edit_select_all
)
2493 { .name
= "EditSelectColumn",
2494 .label
= N_("_Column"),
2495 .accelerator
= "<control>space",
2496 .tooltip
= N_("Select an entire column"),
2497 .callback
= G_CALLBACK (cb_edit_select_col
)
2499 { .name
= "EditSelectRow",
2500 .label
= N_("_Row"),
2501 .accelerator
= "<shift>space",
2502 .tooltip
= N_("Select an entire row"),
2503 .callback
= G_CALLBACK (cb_edit_select_row
)
2506 { .name
= "EditSelectArray",
2507 .label
= N_("Arra_y"),
2508 .accelerator
= "<control>slash",
2509 .tooltip
= N_("Select an array of cells"),
2510 .callback
= G_CALLBACK (cb_edit_select_array
)
2512 { .name
= "EditSelectDepends",
2513 .label
= N_("_Depends"),
2514 .accelerator
= "<control>bracketright",
2515 .tooltip
= N_("Select all the cells that depend on the current edit cell"),
2516 .callback
= G_CALLBACK (cb_edit_select_depends
)
2518 { .name
= "EditSelectInputs",
2519 .label
= N_("_Inputs"),
2520 .accelerator
= "<control>bracketleft",
2521 .tooltip
= N_("Select all the cells are used by the current edit cell"),
2522 .callback
= G_CALLBACK (cb_edit_select_inputs
)
2525 { .name
= "EditSelectObject",
2526 .label
= N_("Next _Object"),
2527 .accelerator
= "<control>Tab",
2528 .tooltip
= N_("Select the next sheet object"),
2529 .callback
= G_CALLBACK (cb_edit_select_object
)
2532 { .name
= "EditGotoTop",
2534 .label
= N_("Go to Top"),
2535 .tooltip
= N_("Go to the top of the data"),
2536 .callback
= G_CALLBACK (cb_edit_goto_top
)
2538 { .name
= "EditGotoBottom",
2539 .icon
= "go-bottom",
2540 .label
= N_("Go to Bottom"),
2541 .tooltip
= N_("Go to the bottom of the data"),
2542 .callback
= G_CALLBACK (cb_edit_goto_bottom
)
2544 { .name
= "EditGotoFirst",
2546 .label
= N_("Go to First"),
2547 .tooltip
= N_("Go to the first data cell"),
2548 .callback
= G_CALLBACK (cb_edit_goto_first
)
2550 { .name
= "EditGotoLast",
2552 .label
= N_("Go to Last"),
2553 .tooltip
= N_("Go to the last data cell"),
2554 .callback
= G_CALLBACK (cb_edit_goto_last
)
2556 { .name
= "EditGoto",
2558 .label
= N_("_Go to Cell..."),
2559 .accelerator
= "<control>g",
2560 .tooltip
= N_("Jump to a specified cell"),
2561 .callback
= G_CALLBACK (cb_edit_goto
)
2563 /* This is a navigational aid that is not supposed to appear */
2565 { .name
= "EditGotoCellIndicator",
2566 .label
= N_("Go to Current Cell Indicator"),
2567 .accelerator
= "<shift><control>g",
2568 .tooltip
= N_("Go to Current Cell Indicator"),
2569 .callback
= G_CALLBACK (cb_edit_goto_cell_indicator
)
2574 .label
= N_("Repeat"),
2575 .accelerator
= "F4",
2576 .tooltip
= N_("Repeat the previous action"),
2577 .callback
= G_CALLBACK (cb_repeat
)
2579 { .name
= "EditPasteSpecial",
2580 .icon
= "edit-paste",
2581 .label
= N_("P_aste Special..."),
2582 .accelerator
= "<shift><control>v",
2583 .tooltip
= N_("Paste with optional filters and transformations"),
2584 .callback
= G_CALLBACK (cb_edit_paste_special
)
2587 { .name
= "EditComment",
2588 .icon
= "gnumeric-comment-edit",
2589 .label
= N_("Co_mment..."),
2590 .tooltip
= N_("Edit the selected cell's comment"),
2591 .callback
= G_CALLBACK (cb_insert_comment
)
2593 { .name
= "EditHyperlink",
2594 .icon
= "gnumeric-link-edit",
2595 .label
= N_("Hyper_link..."),
2596 .accelerator
= "<control>K",
2597 .tooltip
= N_("Edit the selected cell's hyperlink"),
2598 .callback
= G_CALLBACK (cb_insert_hyperlink
)
2601 { .name
= "EditGenerateName",
2602 .label
= N_("_Auto generate names..."),
2603 .tooltip
= N_("Use the current selection to create names"),
2604 .callback
= G_CALLBACK (cb_auto_generate__named_expr
)
2608 { .name
= "EditFind",
2609 .icon
= "edit-find",
2610 .label
= N_("S_earch..."),
2611 .accelerator
= "<control>f",
2612 .tooltip
= N_("Search for something"),
2613 .callback
= G_CALLBACK (cb_edit_search
)
2615 { .name
= "EditReplace",
2616 .icon
= "edit-find-replace",
2617 .label
= N_("Search _& Replace..."),
2618 .accelerator
= "<control>h",
2619 .tooltip
= N_("Search for something and replace it with something else"),
2620 .callback
= G_CALLBACK (cb_edit_search_replace
)
2623 { .name
= "EditRecalc",
2624 .label
= N_("Recalculate"),
2625 .accelerator
= "F9",
2626 .tooltip
= N_("Recalculate the spreadsheet"),
2627 .callback
= G_CALLBACK (cb_edit_recalc
)
2630 { .name
= "EditPreferences",
2631 .icon
= "preferences-system",
2632 .label
= N_("Preferences..."),
2633 .tooltip
= N_("Change Gnumeric Preferences"),
2634 .callback
= G_CALLBACK (cb_file_preferences
)
2638 { .name
= "ViewFreezeThawPanes",
2639 .label
= N_("_Freeze Panes"),
2640 .tooltip
= N_("Freeze the top left of the sheet"),
2641 .callback
= G_CALLBACK (cb_view_freeze_panes
)
2643 { .name
= "ViewZoom",
2644 .icon
= "zoom-fit-best", /* dubious */
2645 .label
= N_("_Zoom..."),
2646 .tooltip
= N_("Zoom the spreadsheet in or out"),
2647 .callback
= G_CALLBACK (cb_view_zoom
)
2649 { .name
= "ViewZoomIn",
2651 .label
= N_("Zoom _In"),
2652 .accelerator
= ZOOM_IN_ACCEL
,
2653 .tooltip
= N_("Increase the zoom to make things larger"),
2654 .callback
= G_CALLBACK (cb_view_zoom_in
)
2656 { .name
= "ViewZoomOut",
2658 .label
= N_("Zoom _Out"),
2659 .accelerator
= ZOOM_OUT_ACCEL
,
2660 .tooltip
= N_("Decrease the zoom to make things smaller"),
2661 .callback
= G_CALLBACK (cb_view_zoom_out
)
2665 { .name
= "InsertCells",
2666 .label
= N_("C_ells..."),
2667 .accelerator
= "<control>plus",
2668 .tooltip
= N_("Insert new cells"),
2669 .callback
= G_CALLBACK (cb_insert_cells
)
2671 /* A duplicate that should not go into the menus, used only for the accelerator */
2672 { .name
= "InsertCellsXL",
2673 .label
= N_("C_ells..."),
2674 .accelerator
= "<control>KP_Add",
2675 .tooltip
= N_("Insert new cells"),
2676 .callback
= G_CALLBACK (cb_insert_cells
)
2678 /*Translators: Insert "Columns"*/
2679 { .name
= "InsertColumns",
2680 .icon
= "gnumeric-column-add",
2681 .label
= N_("_Columns"),
2682 .tooltip
= N_("Insert new columns"),
2683 .callback
= G_CALLBACK (cb_insert_cols
)
2685 /*Translators: Insert "Rows"*/
2686 { .name
= "InsertRows",
2687 .icon
= "gnumeric-row-add",
2688 .label
= N_("_Rows"),
2689 .tooltip
= N_("Insert new rows"),
2690 .callback
= G_CALLBACK (cb_insert_rows
)
2693 { .name
= "ChartGuru",
2694 .icon
= "gnumeric-graphguru",
2695 .label
= N_("C_hart..."),
2696 .tooltip
= N_("Insert a Chart"),
2697 .callback
= G_CALLBACK (cb_launch_chart_guru
)
2699 { .name
= "NewGOComponent",
2700 .icon
= "New Goffice_Component",
2701 .label
= N_("_New..."),
2702 .tooltip
= N_("Insert a new Goffice component object"),
2703 .callback
= G_CALLBACK (cb_launch_go_component_new
)
2705 { .name
= "GOComponentFromFile",
2706 .icon
= "New Goffice_Component from a file",
2707 .label
= N_("_From File..."),
2708 .tooltip
= N_("Insert a new Goffice component object from a file"),
2709 .callback
= G_CALLBACK (cb_launch_go_component_from_file
)
2711 { .name
= "InsertImage",
2712 .icon
= "insert-image",
2713 .label
= N_("_Image..."),
2714 .tooltip
= N_("Insert an image"),
2715 .callback
= G_CALLBACK (cb_insert_image
)
2718 { .name
= "InsertComment",
2719 .icon
= "gnumeric-comment-add",
2720 .label
= N_("Co_mment..."),
2721 .tooltip
= N_("Insert a comment"),
2722 .callback
= G_CALLBACK (cb_insert_comment
)
2724 { .name
= "InsertHyperlink",
2725 .icon
= "gnumeric-link-add",
2726 .label
= N_("Hyper_link..."),
2727 .accelerator
= "<control>K",
2728 .tooltip
= N_("Insert a Hyperlink"),
2729 .callback
= G_CALLBACK (cb_insert_hyperlink
)
2731 { .name
= "InsertSortDecreasing",
2732 .icon
= "view-sort-descending",
2733 .label
= N_("Sort (_Descending)"),
2734 .tooltip
= N_("Wrap with SORT (descending)"),
2735 .callback
= G_CALLBACK (cb_insert_sort_descending
)
2737 { .name
= "InsertSortIncreasing",
2738 .icon
= "view-sort-ascending",
2739 .label
= N_("Sort (_Ascending)"),
2740 .tooltip
= N_("Wrap with SORT (ascending)"),
2741 .callback
= G_CALLBACK (cb_insert_sort_ascending
)
2744 /* Insert -> Special */
2745 { .name
= "InsertCurrentDate",
2746 .label
= N_("Current _Date"),
2747 .accelerator
= "<control>semicolon",
2748 .tooltip
= N_("Insert the current date into the selected cell(s)"),
2749 .callback
= G_CALLBACK (cb_insert_current_date
)
2752 { .name
= "InsertCurrentTime",
2753 .label
= N_("Current _Time"),
2754 .accelerator
= "<control>colon",
2755 .tooltip
= N_("Insert the current time into the selected cell(s)"),
2756 .callback
= G_CALLBACK (cb_insert_current_time
)
2759 { .name
= "InsertCurrentDateTime",
2760 .label
= N_("Current D_ate and Time"),
2761 .accelerator
= "<control>period",
2762 .tooltip
= N_("Insert the current date and time into the selected cell(s)"),
2763 .callback
= G_CALLBACK (cb_insert_current_date_time
)
2766 /* Insert -> Name */
2767 { .name
= "EditNames",
2768 .label
= N_("_Names..."),
2769 .accelerator
= "<control>F3",
2770 .tooltip
= N_("Edit defined names for expressions"),
2771 .callback
= G_CALLBACK (cb_define_name
)
2775 { .name
= "FormatAuto",
2776 .label
= N_("_Autoformat..."),
2777 .tooltip
= N_("Format a region of cells according to a pre-defined template"),
2778 .callback
= G_CALLBACK (cb_autoformat
)
2780 { .name
= "SheetDirection",
2781 .icon
= "format-text-direction-ltr",
2782 .label
= N_("Direction"),
2783 .tooltip
= N_("Toggle sheet direction, left-to-right vs right-to-left"),
2784 .callback
= G_CALLBACK (cb_direction
)
2787 /* Format -> Cells */
2788 { .name
= "FormatCells",
2789 .label
= N_("_Format..."),
2790 .accelerator
= "<control>1",
2791 .tooltip
= N_("Modify the formatting of the selected cells"),
2792 .callback
= G_CALLBACK (cb_format_cells
)
2794 { .name
= "FormatCellsCond",
2795 .label
= N_("_Conditional Formatting..."),
2796 .tooltip
= N_("Modify the conditional formatting of the selected cells"),
2797 .callback
= G_CALLBACK (cb_format_cells_cond
)
2799 { .name
= "FormatCellsFitHeight",
2800 .icon
= "gnumeric-row-size",
2801 .label
= N_("Auto Fit _Height"),
2802 .tooltip
= N_("Ensure rows are just tall enough to display content of selection"),
2803 .callback
= G_CALLBACK (cb_format_cells_auto_fit_height
)
2805 { .name
= "FormatCellsFitWidth",
2806 .icon
= "gnumeric-column-size",
2807 .label
= N_("Auto Fit _Width"),
2808 .tooltip
= N_("Ensure columns are just wide enough to display content of selection"),
2809 .callback
= G_CALLBACK (cb_format_cells_auto_fit_width
)
2814 { .name
= "ColumnSize",
2815 .icon
= "gnumeric-column-size",
2816 .label
= N_("_Width..."),
2817 .tooltip
= N_("Change width of the selected columns"),
2818 .callback
= G_CALLBACK (cb_set_column_width
)
2820 { .name
= "ColumnAutoSize",
2821 .icon
= "gnumeric-column-size",
2822 .label
= N_("_Auto Fit Width"),
2823 .tooltip
= N_("Ensure columns are just wide enough to display their content"),
2824 .callback
= G_CALLBACK (cb_format_column_auto_fit
)
2826 { .name
= "ColumnHide",
2827 .icon
= "gnumeric-column-hide",
2828 .label
= N_("_Hide"),
2829 .accelerator
= "<control>0",
2830 .tooltip
= N_("Hide the selected columns"),
2831 .callback
= G_CALLBACK (cb_format_column_hide
)
2833 { .name
= "ColumnUnhide",
2834 .icon
= "gnumeric-column-unhide",
2835 .label
= N_("_Unhide"),
2836 .accelerator
= "<control>parenright",
2837 .tooltip
= N_("Make any hidden columns in the selection visible"),
2838 .callback
= G_CALLBACK (cb_format_column_unhide
)
2840 { .name
= "ColumnDefaultSize",
2841 .icon
= "gnumeric-column-size",
2842 .label
= N_("_Standard Width"),
2843 .tooltip
= N_("Change the default column width"),
2844 .callback
= G_CALLBACK (cb_format_column_std_width
)
2848 { .name
= "RowSize",
2849 .icon
= "gnumeric-row-size",
2850 .label
= N_("H_eight..."),
2851 .tooltip
= N_("Change height of the selected rows"),
2852 .callback
= G_CALLBACK (cb_set_row_height
)
2854 { .name
= "RowAutoSize",
2855 .icon
= "gnumeric-row-size",
2856 .label
= N_("_Auto Fit Height"),
2857 .tooltip
= N_("Ensure rows are just tall enough to display their content"),
2858 .callback
= G_CALLBACK (cb_format_row_auto_fit
)
2860 { .name
= "RowHide",
2861 .icon
= "gnumeric-row-hide",
2862 .label
= N_("_Hide"),
2863 .accelerator
= "<control>9",
2864 .tooltip
= N_("Hide the selected rows"),
2865 .callback
= G_CALLBACK (cb_format_row_hide
)
2867 { .name
= "RowUnhide",
2868 .icon
= "gnumeric-row-unhide",
2869 .label
= N_("_Unhide"),
2870 .accelerator
= "<control>parenleft",
2871 .tooltip
= N_("Make any hidden rows in the selection visible"),
2872 .callback
= G_CALLBACK (cb_format_row_unhide
)
2874 { .name
= "RowDefaultSize",
2875 .icon
= "gnumeric-row-size",
2876 .label
= N_("_Standard Height"),
2877 .tooltip
= N_("Change the default row height"),
2878 .callback
= G_CALLBACK (cb_format_row_std_height
)
2882 { .name
= "ToolsPlugins",
2883 .label
= N_("_Plug-ins..."),
2884 .tooltip
= N_("Manage available plugin modules"),
2885 .callback
= G_CALLBACK (cb_tools_plugins
)
2887 { .name
= "ToolsAutoCorrect",
2888 .label
= N_("Auto _Correct..."),
2889 .tooltip
= N_("Automatically perform simple spell checking"),
2890 .callback
= G_CALLBACK (cb_tools_autocorrect
)
2892 { .name
= "ToolsAutoSave",
2893 .label
= N_("_Auto Save..."),
2894 .tooltip
= N_("Automatically save the current document at regular intervals"),
2895 .callback
= G_CALLBACK (cb_tools_auto_save
)
2897 { .name
= "ToolsGoalSeek",
2898 .label
= N_("_Goal Seek..."),
2899 .tooltip
= N_("Iteratively recalculate to find a target value"),
2900 .callback
= G_CALLBACK (cb_tools_goal_seek
)
2902 { .name
= "ToolsSolver",
2903 .label
= N_("_Solver..."),
2904 .tooltip
= N_("Iteratively recalculate with constraints to approach a target value"),
2905 .callback
= G_CALLBACK (cb_tools_solver
)
2907 { .name
= "ToolsSimulation",
2908 .label
= N_("Si_mulation..."),
2909 .tooltip
= N_("Test decision alternatives by using Monte Carlo "
2910 "simulation to find out probable outputs and risks related to them"),
2911 .callback
= G_CALLBACK (cb_tools_simulation
)
2913 { .name
= "ToolsCompare",
2914 .label
= N_("Compare Sheets..."),
2915 .tooltip
= N_("Find differences between two sheets"),
2916 .callback
= G_CALLBACK (cb_tools_compare
)
2919 /* Tools -> Scenarios */
2920 { .name
= "ToolsScenarios",
2921 .label
= N_("_View..."),
2922 .tooltip
= N_("View, delete and report different scenarios"),
2923 .callback
= G_CALLBACK (cb_tools_scenarios
)
2925 { .name
= "ToolsScenarioAdd",
2926 .label
= N_("_Add..."),
2927 .tooltip
= N_("Add a new scenario"),
2928 .callback
= G_CALLBACK (cb_tools_scenario_add
)
2933 { .name
= "ToolsSampling",
2934 .label
= N_("_Sampling..."),
2935 .tooltip
= N_("Periodic and random samples"),
2936 .callback
= G_CALLBACK (cb_tools_sampling
)
2939 /* Statistics -> Descriptive*/
2941 { .name
= "ToolsCorrelation",
2942 .label
= N_("_Correlation..."),
2943 .tooltip
= N_("Pearson Correlation"),
2944 .callback
= G_CALLBACK (cb_tools_correlation
)
2946 { .name
= "ToolsCovariance",
2947 .label
= N_("Co_variance..."),
2948 .tooltip
= N_("Covariance"),
2949 .callback
= G_CALLBACK (cb_tools_covariance
)
2951 { .name
= "ToolsDescStatistics",
2952 .label
= N_("_Descriptive Statistics..."),
2953 .tooltip
= N_("Various summary statistics"),
2954 .callback
= G_CALLBACK (cb_tools_desc_statistics
)
2957 /* Statistics -> Descriptive -> Frequencies */
2959 { .name
= "ToolsFrequency",
2960 .label
= N_("Fre_quency Tables..."),
2961 .tooltip
= N_("Frequency tables for non-numeric data"),
2962 .callback
= G_CALLBACK (cb_tools_frequency
)
2964 { .name
= "ToolsHistogram",
2965 .label
= N_("_Histogram..."),
2966 .tooltip
= N_("Various frequency tables for numeric data"),
2967 .callback
= G_CALLBACK (cb_tools_histogram
)
2969 { .name
= "ToolsRanking",
2970 .label
= N_("Ranks And _Percentiles..."),
2971 .tooltip
= N_("Ranks, placements and percentiles"),
2972 .callback
= G_CALLBACK (cb_tools_ranking
)
2975 /* Statistics -> DependentObservations */
2977 { .name
= "ToolsFourier",
2978 .label
= N_("_Fourier Analysis..."),
2979 .tooltip
= N_("Fourier Analysis"),
2980 .callback
= G_CALLBACK (cb_tools_fourier
)
2982 { .name
= "ToolsPrincipalComponents",
2984 N_("Principal Components Analysis..."),
2985 .tooltip
= N_("Principal Components Analysis"),
2986 .callback
= G_CALLBACK (cb_tools_principal_components
)
2988 /* Statistics -> DependentObservations -> Forecast*/
2990 { .name
= "ToolsExpSmoothing",
2991 .label
= N_("_Exponential Smoothing..."),
2992 .tooltip
= N_("Exponential smoothing..."),
2993 .callback
= G_CALLBACK (cb_tools_exp_smoothing
)
2995 { .name
= "ToolsAverage",
2996 .label
= N_("_Moving Average..."),
2997 .tooltip
= N_("Moving average..."),
2998 .callback
= G_CALLBACK (cb_tools_average
)
3000 { .name
= "ToolsRegression",
3001 .label
= N_("_Regression..."),
3002 .tooltip
= N_("Regression Analysis"),
3003 .callback
= G_CALLBACK (cb_tools_regression
)
3005 { .name
= "ToolsKaplanMeier",
3006 .label
= N_("_Kaplan-Meier Estimates..."),
3007 .tooltip
= N_("Creation of Kaplan-Meier Survival Curves"),
3008 .callback
= G_CALLBACK (cb_tools_kaplan_meier
)
3011 /* Statistics -> OneSample */
3013 { .name
= "ToolsNormalityTests",
3014 .label
= N_("_Normality Tests..."),
3015 .tooltip
= N_("Testing a sample for normality"),
3016 .callback
= G_CALLBACK (cb_tools_normality_tests
)
3018 { .name
= "ToolsOneMeanTest",
3019 .label
= N_("Claims About a _Mean..."),
3020 .tooltip
= N_("Testing the value of a mean"),
3021 .callback
= G_CALLBACK (cb_tools_one_mean_test
)
3024 /* Statistics -> OneSample -> OneMedian*/
3026 { .name
= "ToolsOneMedianSignTest",
3027 .label
= N_("_Sign Test..."),
3028 .tooltip
= N_("Testing the value of a median"),
3029 .callback
= G_CALLBACK (cb_tools_sign_test_one_median
)
3031 { .name
= "ToolsOneMedianWilcoxonSignedRank",
3032 .label
= N_("_Wilcoxon Signed Rank Test..."),
3033 .tooltip
= N_("Testing the value of a median"),
3034 .callback
= G_CALLBACK (cb_tools_wilcoxon_signed_rank_one_median
)
3037 /* Statistics -> TwoSamples */
3039 { .name
= "ToolsFTest",
3040 .label
= N_("Claims About Two _Variances"),
3041 .tooltip
= N_("Comparing two population variances"),
3042 .callback
= G_CALLBACK (cb_tools_ftest
)
3045 /* Statistics -> TwoSamples -> Two Means*/
3047 { .name
= "ToolTTestPaired",
3048 .label
= N_("_Paired Samples..."),
3049 .tooltip
= N_("Comparing two population means for two paired samples"),
3050 .callback
= G_CALLBACK (cb_tools_ttest_paired
)
3053 { .name
= "ToolTTestEqualVar",
3054 .label
= N_("Unpaired Samples, _Equal Variances..."),
3055 .tooltip
= N_("Comparing two population means for two unpaired samples from populations with equal variances"),
3056 .callback
= G_CALLBACK (cb_tools_ttest_equal_var
)
3059 { .name
= "ToolTTestUnequalVar",
3060 .label
= N_("Unpaired Samples, _Unequal Variances..."),
3061 .tooltip
= N_("Comparing two population means for two unpaired samples from populations with unequal variances"),
3062 .callback
= G_CALLBACK (cb_tools_ttest_unequal_var
)
3065 { .name
= "ToolZTest",
3066 .label
= N_("Unpaired Samples, _Known Variances..."),
3067 .tooltip
= N_("Comparing two population means from populations with known variances"),
3068 .callback
= G_CALLBACK (cb_tools_ztest
)
3071 /* Statistics -> TwoSamples -> Two Medians*/
3073 { .name
= "ToolsTwoMedianSignTest",
3074 .label
= N_("_Sign Test..."),
3075 .tooltip
= N_("Comparing the values of two medians of paired observations"),
3076 .callback
= G_CALLBACK (cb_tools_sign_test_two_medians
)
3078 { .name
= "ToolsTwoMedianWilcoxonSignedRank",
3079 .label
= N_("_Wilcoxon Signed Rank Test..."),
3080 .tooltip
= N_("Comparing the values of two medians of paired observations"),
3081 .callback
= G_CALLBACK (cb_tools_wilcoxon_signed_rank_two_medians
)
3083 { .name
= "ToolsTwoMedianWilcoxonMannWhitney",
3084 .label
= N_("Wilcoxon-_Mann-Whitney Test..."),
3085 .tooltip
= N_("Comparing the values of two medians of unpaired observations"),
3086 .callback
= G_CALLBACK (cb_tools_wilcoxon_mann_whitney
)
3089 /* Statistics -> MultipleSamples */
3091 /* Statistics -> MultipleSamples -> ANOVA*/
3093 { .name
= "ToolsANOVAoneFactor",
3094 .label
= N_("_One Factor..."),
3095 .tooltip
= N_("One Factor Analysis of Variance..."),
3096 .callback
= G_CALLBACK (cb_tools_anova_one_factor
)
3098 { .name
= "ToolsANOVAtwoFactor",
3099 .label
= N_("_Two Factor..."),
3100 .tooltip
= N_("Two Factor Analysis of Variance..."),
3101 .callback
= G_CALLBACK (cb_tools_anova_two_factor
)
3104 /* Statistics -> MultipleSamples -> ContingencyTable*/
3106 { .name
= "ToolsHomogeneity",
3107 .label
= N_("Test of _Homogeneity..."),
3108 .tooltip
= N_("Chi Squared Test of Homogeneity..."),
3109 .callback
= G_CALLBACK (cb_tools_chi_square_homogeneity
)
3111 { .name
= "ToolsIndependence",
3112 .label
= N_("Test of _Independence..."),
3113 .tooltip
= N_("Chi Squared Test of Independence..."),
3114 .callback
= G_CALLBACK (cb_tools_chi_square_independence
)
3118 { .name
= "DataSort",
3119 .icon
= "view-sort-ascending",
3120 .label
= N_("_Sort..."),
3121 .tooltip
= N_("Sort the selected region"),
3122 .callback
= G_CALLBACK (cb_data_sort
)
3124 { .name
= "DataShuffle",
3125 .label
= N_("Sh_uffle..."),
3126 .tooltip
= N_("Shuffle cells, rows or columns"),
3127 .callback
= G_CALLBACK (cb_data_shuffle
)
3129 { .name
= "DataValidate",
3130 .label
= N_("_Validate..."),
3131 .tooltip
= N_("Validate input with preset criteria"),
3132 .callback
= G_CALLBACK (cb_data_validate
)
3134 { .name
= "DataTextToColumns",
3135 .label
= N_("T_ext to Columns..."),
3136 .tooltip
= N_("Parse the text in the selection into data"),
3137 .callback
= G_CALLBACK (cb_data_text_to_columns
)
3139 { .name
= "DataConsolidate",
3140 .label
= N_("_Consolidate..."),
3141 .tooltip
= N_("Consolidate regions using a function"),
3142 .callback
= G_CALLBACK (cb_data_consolidate
)
3144 { .name
= "DataTable",
3145 .label
= N_("_Table..."),
3146 .tooltip
= N_("Create a Data Table to evaluate a function with multiple inputs"),
3147 .callback
= G_CALLBACK (cb_data_table
)
3149 { .name
= "DataExport",
3150 .label
= N_("E_xport into Other Format..."),
3151 .tooltip
= N_("Export the current workbook or sheet"),
3152 .callback
= G_CALLBACK (cb_data_export
)
3154 { .name
= "DataExportText",
3155 .label
= N_("Export as _Text File..."),
3156 .tooltip
= N_("Export the current sheet as a text file"),
3157 .callback
= G_CALLBACK (cb_data_export_text
)
3159 { .name
= "DataExportCSV",
3160 .label
= N_("Export as _CSV File..."),
3161 .tooltip
= N_("Export the current sheet as a csv file"),
3162 .callback
= G_CALLBACK (cb_data_export_csv
)
3164 { .name
= "DataExportRepeat",
3165 .label
= N_("Repeat Export"),
3166 .accelerator
= "<control>E",
3167 .tooltip
= N_("Repeat the last data export"),
3168 .callback
= G_CALLBACK (cb_data_export_repeat
)
3172 { .name
= "EditFillAutofill",
3173 .label
= N_("Auto_fill"),
3174 .tooltip
= N_("Automatically fill the current selection"),
3175 .callback
= G_CALLBACK (cb_edit_fill_autofill
)
3177 { .name
= "ToolsMerge",
3178 .label
= N_("_Merge..."),
3179 .tooltip
= N_("Merges columnar data into a sheet creating duplicate sheets for each row"),
3180 .callback
= G_CALLBACK (cb_tools_merge
)
3182 { .name
= "ToolsTabulate",
3183 .label
= N_("_Tabulate Dependency..."),
3184 .tooltip
= N_("Make a table of a cell's value as a function of other cells"),
3185 .callback
= G_CALLBACK (cb_tools_tabulate
)
3187 { .name
= "EditFillSeries",
3188 .label
= N_("_Series..."),
3189 .tooltip
= N_("Fill according to a linear or exponential series"),
3190 .callback
= G_CALLBACK (cb_edit_fill_series
)
3192 { .name
= "RandomGeneratorUncorrelated",
3193 .label
= N_("_Uncorrelated..."),
3194 .tooltip
= N_("Generate random numbers of a selection of distributions"),
3195 .callback
= G_CALLBACK (cb_tools_random_generator_uncorrelated
)
3197 { .name
= "RandomGeneratorCorrelated",
3198 .label
= N_("_Correlated..."),
3199 .tooltip
= N_("Generate variates for correlated normal distributed random variables"),
3200 .callback
= G_CALLBACK (cb_tools_random_generator_correlated
)
3202 { .name
= "CopyDown",
3203 .label
= N_("Fill Downwards"),
3204 .accelerator
= "<control>D",
3205 .tooltip
= N_("Copy the content from the top row to the cells below"),
3206 .callback
= G_CALLBACK (cb_copydown
)
3208 { .name
= "CopyRight",
3209 .label
= N_("Fill to Right"),
3210 .accelerator
= "<control>R",
3211 .tooltip
= N_("Copy the content from the left column to the cells on the right"),
3212 .callback
= G_CALLBACK (cb_copyright
)
3216 /* Data -> Outline */
3217 { .name
= "DataOutlineHideDetail",
3218 .icon
= "gnumeric-detail-hide",
3219 .label
= N_("_Hide Detail"),
3220 .tooltip
= N_("Collapse an outline group"),
3221 .callback
= G_CALLBACK (cb_data_hide_detail
)
3223 { .name
= "DataOutlineShowDetail",
3224 .icon
= "gnumeric-detail-show",
3225 .label
= N_("_Show Detail"),
3226 .tooltip
= N_("Uncollapse an outline group"),
3227 .callback
= G_CALLBACK (cb_data_show_detail
)
3229 { .name
= "DataOutlineGroup",
3230 .icon
= "gnumeric-group",
3231 .label
= N_("_Group..."),
3232 .accelerator
= "<shift><alt>Right",
3233 .tooltip
= N_("Add an outline group"),
3234 .callback
= G_CALLBACK (cb_data_group
)
3236 { .name
= "DataOutlineUngroup",
3237 .icon
= "gnumeric-ungroup",
3238 .label
= N_("_Ungroup..."),
3239 .accelerator
= "<shift><alt>Left",
3240 .tooltip
= N_("Remove an outline group"),
3241 .callback
= G_CALLBACK (cb_data_ungroup
)
3244 /* Data -> Filter */
3245 { .name
= "DataAutoFilter",
3246 .icon
= "gnumeric-autofilter",
3247 .label
= N_("Add _Auto Filter"),
3248 .tooltip
= N_("Add or remove a filter"),
3249 .callback
= G_CALLBACK (cb_auto_filter
)
3251 { .name
= "DataFilterShowAll",
3252 .label
= N_("_Clear Advanced Filter"),
3253 .tooltip
= N_("Show all rows hidden by an advanced filter"),
3254 .callback
= G_CALLBACK (cb_show_all
)
3256 { .name
= "DataFilterAdvancedfilter",
3257 .label
= N_("Advanced _Filter..."),
3258 .tooltip
= N_("Filter data with given criteria"),
3259 .callback
= G_CALLBACK (cb_data_filter
)
3261 /* Data -> External */
3262 { .name
= "DataImportText",
3263 .label
= N_("Import _Text File..."),
3264 .tooltip
= N_("Import data from a text file"),
3265 .callback
= G_CALLBACK (cb_data_import_text
)
3267 { .name
= "DataImportOther",
3268 .label
= N_("Import _Other File..."),
3269 .tooltip
= N_("Import data from a file"),
3270 .callback
= G_CALLBACK (cb_data_import_other
)
3273 /* Data -> Data Slicer */
3274 /* label and tip are context dependent, see wbcg_menu_state_update */
3275 { .name
= "DataSlicer",
3276 .label
= N_("Add _Data Slicer"),
3277 .tooltip
= N_("Create a data slicer"),
3278 .callback
= G_CALLBACK (cb_data_slicer_create
)
3280 { .name
= "DataSlicerRefresh",
3281 .label
= N_("_Refresh"),
3282 .tooltip
= N_("Regenerate a data slicer from the source data"),
3283 .callback
= G_CALLBACK (cb_data_slicer_refresh
)
3285 { .name
= "DataSlicerEdit",
3286 .label
= N_("_Edit Data Slicer..."),
3287 .tooltip
= N_("Adjust a data slicer"),
3288 .callback
= G_CALLBACK (cb_data_slicer_edit
)
3291 /* Standard Toolbar */
3292 { .name
= "AutoSum",
3293 .icon
= "gnumeric-autosum",
3295 .accelerator
= "<alt>equal",
3296 .tooltip
= N_("Sum into the current cell"),
3297 .callback
= G_CALLBACK (cb_autosum
)
3299 { .name
= "InsertFormula",
3300 .icon
= "gnumeric-formulaguru",
3301 .label
= N_("_Function..."),
3302 .tooltip
= N_("Edit a function in the current cell"),
3303 .callback
= G_CALLBACK (cb_formula_guru
)
3306 { .name
= "SortAscending",
3307 .icon
= "view-sort-ascending",
3308 .label
= N_("Sort Ascending"),
3309 .tooltip
= N_("Sort the selected region in ascending order based on the first column selected"),
3310 .callback
= G_CALLBACK (cb_sort_ascending
)
3312 { .name
= "SortDescending",
3313 .icon
= "view-sort-descending",
3314 .label
= N_("Sort Descending"),
3315 .tooltip
= N_("Sort the selected region in descending order based on the first column selected"),
3316 .callback
= G_CALLBACK (cb_sort_descending
)
3319 /* Object Toolbar */
3320 { .name
= "CreateFrame",
3321 .icon
= "gnumeric-object-frame",
3322 .label
= N_("Frame"),
3323 .tooltip
= N_("Create a frame"),
3324 .callback
= G_CALLBACK (cmd_create_frame
)
3326 { .name
= "CreateCheckbox",
3327 .icon
= "gnumeric-object-checkbox",
3328 .label
= N_("Checkbox"),
3329 .tooltip
= N_("Create a checkbox"),
3330 .callback
= G_CALLBACK (cmd_create_checkbox
)
3332 { .name
= "CreateScrollbar",
3333 .icon
= "gnumeric-object-scrollbar",
3334 .label
= N_("Scrollbar"),
3335 .tooltip
= N_("Create a scrollbar"),
3336 .callback
= G_CALLBACK (cmd_create_scrollbar
)
3338 { .name
= "CreateSlider",
3339 .icon
= "gnumeric-object-slider",
3340 .label
= N_("Slider"),
3341 .tooltip
= N_("Create a slider"),
3342 .callback
= G_CALLBACK (cmd_create_slider
)
3344 { .name
= "CreateSpinButton",
3345 .icon
= "gnumeric-object-spinbutton",
3346 .label
= N_("SpinButton"),
3347 .tooltip
= N_("Create a spin button"),
3348 .callback
= G_CALLBACK (cmd_create_spinbutton
)
3350 { .name
= "CreateList",
3351 .icon
= "gnumeric-object-list",
3352 .label
= N_("List"),
3353 .tooltip
= N_("Create a list"),
3354 .callback
= G_CALLBACK (cmd_create_list
)
3356 { .name
= "CreateCombo",
3357 .icon
= "gnumeric-object-combo",
3358 .label
= N_("Combo Box"),
3359 .tooltip
= N_("Create a combo box"),
3360 .callback
= G_CALLBACK (cmd_create_combo
)
3362 { .name
= "CreateLine",
3363 .icon
= "gnumeric-object-line",
3364 .label
= N_("Line"),
3365 .tooltip
= N_("Create a line object"),
3366 .callback
= G_CALLBACK (cmd_create_line
)
3368 { .name
= "CreateArrow",
3369 .icon
= "gnumeric-object-arrow",
3370 .label
= N_("Arrow"),
3371 .tooltip
= N_("Create an arrow object"),
3372 .callback
= G_CALLBACK (cmd_create_arrow
)
3374 { .name
= "CreateRectangle",
3375 .icon
= "gnumeric-object-rectangle",
3376 .label
= N_("Rectangle"),
3377 .tooltip
= N_("Create a rectangle object"),
3378 .callback
= G_CALLBACK (cmd_create_rectangle
)
3380 { .name
= "CreateEllipse",
3381 .icon
= "gnumeric-object-ellipse",
3382 .label
= N_("Ellipse"),
3383 .tooltip
= N_("Create an ellipse object"),
3384 .callback
= G_CALLBACK (cmd_create_ellipse
)
3386 { .name
= "CreateButton",
3387 .icon
= "gnumeric-object-button",
3388 .label
= N_("Button"),
3389 .tooltip
= N_("Create a button"),
3390 .callback
= G_CALLBACK (cmd_create_button
)
3392 { .name
= "CreateRadioButton",
3393 .icon
= "gnumeric-object-radiobutton",
3394 .label
= N_("RadioButton"),
3395 .tooltip
= N_("Create a radio button"),
3396 .callback
= G_CALLBACK (cmd_create_radiobutton
)
3399 /* Format toolbar */
3400 { .name
= "FormatMergeCells",
3401 .icon
= "gnumeric-cells-merge",
3402 .label
= N_("Merge"),
3403 .tooltip
= N_("Merge a range of cells"),
3404 .callback
= G_CALLBACK (cb_merge_cells
)
3406 { .name
= "FormatUnmergeCells",
3407 .icon
= "gnumeric-cells-split",
3408 .label
= N_("Unmerge"),
3409 .tooltip
= N_("Split merged ranges of cells"),
3410 .callback
= G_CALLBACK (cb_unmerge_cells
)
3413 { .name
= "FormatAsGeneral",
3414 .label
= N_("General"),
3415 .accelerator
= "<control>asciitilde",
3416 .tooltip
= N_("Format the selection as General"),
3417 .callback
= G_CALLBACK (cb_format_as_general
)
3419 { .name
= "FormatAsNumber",
3420 .label
= N_("Number"),
3421 .accelerator
= "<control>exclam",
3422 .tooltip
= N_("Format the selection as numbers"),
3423 .callback
= G_CALLBACK (cb_format_as_number
)
3425 { .name
= "FormatAsCurrency",
3426 .label
= N_("Currency"),
3427 .accelerator
= "<control>dollar",
3428 .tooltip
= N_("Format the selection as currency"),
3429 .callback
= G_CALLBACK (cb_format_as_currency
)
3431 { .name
= "FormatAsAccounting",
3432 .icon
= "gnumeric-format-accounting",
3433 .label
= N_("Accounting"),
3434 .tooltip
= N_("Format the selection as accounting"),
3435 .callback
= G_CALLBACK (cb_format_as_accounting
)
3437 { .name
= "FormatAsPercentage",
3438 .icon
= "gnumeric-format-percentage",
3439 .label
= N_("Percentage"),
3440 .accelerator
= "<control>percent",
3441 .tooltip
= N_("Format the selection as percentage"),
3442 .callback
= G_CALLBACK (cb_format_as_percentage
)
3444 { .name
= "FormatAsScientific",
3445 .label
= N_("Scientific"),
3446 .accelerator
= "<control>asciicircum",
3447 .tooltip
= N_("Format the selection as scientific"),
3448 .callback
= G_CALLBACK (cb_format_as_scientific
)
3450 { .name
= "FormatAsDate",
3451 .label
= N_("Date"),
3452 .accelerator
= "<control>numbersign",
3453 .tooltip
= N_("Format the selection as date"),
3454 .callback
= G_CALLBACK (cb_format_as_date
)
3456 { .name
= "FormatAsTime",
3457 .label
= N_("Time"),
3458 .accelerator
= "<control>at",
3459 .tooltip
= N_("Format the selection as time"),
3460 .callback
= G_CALLBACK (cb_format_as_time
)
3462 { .name
= "FormatAddBorders",
3463 .label
= N_("AddBorders"),
3464 .accelerator
= "<control>ampersand",
3465 .tooltip
= N_("Add a border around the selection"),
3466 .callback
= G_CALLBACK (cb_format_add_borders
)
3468 { .name
= "FormatClearBorders",
3469 .label
= N_("ClearBorders"),
3470 .accelerator
= "<control>underscore",
3471 .tooltip
= N_("Clear the border around the selection"),
3472 .callback
= G_CALLBACK (cb_format_clear_borders
)
3475 { .name
= "FormatWithThousands",
3476 .icon
= "gnumeric-format-thousand-separator",
3477 .label
= N_("Thousands Separator"),
3478 .tooltip
= N_("Set the format of the selected cells to include a thousands separator"),
3479 .callback
= G_CALLBACK (cb_format_with_thousands
)
3481 { .name
= "FormatIncreasePrecision",
3482 .icon
= "gnumeric-format-precision-increase",
3483 .label
= N_("Increase Precision"),
3484 .tooltip
= N_("Increase the number of decimals displayed"),
3485 .callback
= G_CALLBACK (cb_format_inc_precision
)
3487 { .name
= "FormatDecreasePrecision",
3488 .icon
= "gnumeric-format-precision-decrease",
3489 .label
= N_("Decrease Precision"),
3490 .tooltip
= N_("Decrease the number of decimals displayed"),
3491 .callback
= G_CALLBACK (cb_format_dec_precision
)
3494 /* Gtk marks these accelerators as invalid because they use Tab
3495 * enable them manually in gnm-pane.c */
3496 { .name
= "FormatDecreaseIndent",
3497 .icon
= "format-indent-less",
3498 .accelerator
= "<control><alt><shift>Tab",
3499 .tooltip
= N_("Decrease the indent, and align the contents to the left"),
3500 .callback
= G_CALLBACK (cb_format_dec_indent
)
3502 { .name
= "FormatIncreaseIndent",
3503 .icon
= "format-indent-more",
3504 .accelerator
= "<control><alt>Tab",
3505 .tooltip
= N_("Increase the indent, and align the contents to the left"),
3506 .callback
= G_CALLBACK (cb_format_inc_indent
)
3509 /* ---------------------------------------- */
3511 { .name
= "SheetDisplayOutlines",
3513 .label
= N_("Display _Outlines"),
3514 .accelerator
= "<control>8",
3515 .tooltip
= N_("Toggle whether or not to display outline groups"),
3516 .callback
= G_CALLBACK (cb_sheet_pref_display_outlines
)
3518 { .name
= "SheetOutlineBelow",
3520 .label
= N_("Outlines _Below"),
3521 .tooltip
= N_("Toggle whether to display row outlines on top or bottom"),
3522 .callback
= G_CALLBACK (cb_sheet_pref_outline_symbols_below
)
3524 { .name
= "SheetOutlineRight",
3526 .label
= N_("Outlines _Right"),
3527 .tooltip
= N_("Toggle whether to display column outlines on the left or right"),
3528 .callback
= G_CALLBACK (cb_sheet_pref_outline_symbols_right
)
3530 { .name
= "SheetDisplayFormulas",
3532 .icon
= "gnumeric-formulaguru",
3533 .label
= N_("Display _Formul\303\246"),
3534 .accelerator
= "<control>quoteleft",
3535 .tooltip
= N_("Display the value of a formula or the formula itself"),
3536 .callback
= G_CALLBACK (cb_sheet_pref_display_formulas
)
3538 { .name
= "SheetHideZeros",
3540 .label
= N_("_Hide Zeros"),
3541 .tooltip
= N_("Toggle whether or not to display zeros as blanks"),
3542 .callback
= G_CALLBACK (cb_sheet_pref_hide_zero
)
3544 { .name
= "SheetHideGridlines",
3546 .label
= N_("Hide _Gridlines"),
3547 .tooltip
= N_("Toggle whether or not to display gridlines"),
3548 .callback
= G_CALLBACK (cb_sheet_pref_hide_grid
)
3550 { .name
= "SheetHideColHeader",
3552 .label
= N_("Hide _Column Headers"),
3553 .tooltip
= N_("Toggle whether or not to display column headers"),
3554 .callback
= G_CALLBACK (cb_sheet_pref_hide_col_header
)
3556 { .name
= "SheetHideRowHeader",
3558 .label
= N_("Hide _Row Headers"),
3559 .tooltip
= N_("Toggle whether or not to display row headers"),
3560 .callback
= G_CALLBACK (cb_sheet_pref_hide_row_header
)
3563 /* TODO : Make this a sub menu when we have more convention types */
3564 { .name
= "SheetUseR1C1",
3566 .label
= N_("Use R1C1 N_otation "),
3567 .tooltip
= N_("Display addresses as R1C1 or A1"),
3568 .callback
= G_CALLBACK (cb_sheet_pref_use_r1c1
)
3571 { .name
= "AlignLeft",
3573 .icon
= "format-justify-left",
3574 .label
= N_("_Left Align"),
3575 .tooltip
= N_("Align left"),
3576 .callback
= G_CALLBACK (cb_align_left
)
3578 { .name
= "AlignCenter",
3580 .icon
= "format-justify-center",
3581 .label
= N_("_Center"),
3582 .tooltip
= N_("Center horizontally"),
3583 .callback
= G_CALLBACK (cb_align_center
)
3585 { .name
= "AlignRight",
3587 .icon
= "format-justify-right",
3588 .label
= N_("_Right Align"),
3589 .tooltip
= N_("Align right"),
3590 .callback
= G_CALLBACK (cb_align_right
)
3592 { .name
= "CenterAcrossSelection",
3594 .icon
= "gnumeric-center-across-selection",
3595 .label
= N_("_Center Across Selection"),
3596 .tooltip
= N_("Center horizontally across the selection"),
3597 .callback
= G_CALLBACK (cb_center_across_selection
)
3599 { .name
= "MergeAndCenter",
3601 .label
= N_("_Merge and Center"),
3602 .tooltip
= N_("Merge the selection into 1 cell, and center horizontally."),
3603 .callback
= G_CALLBACK (cb_merge_and_center
)
3605 #warning "Add justify"
3606 #warning "h/v distributed?"
3608 #warning "Get vertical alignment icons"
3609 { .name
= "AlignTop",
3611 .label
= N_("Align _Top"),
3612 .tooltip
= N_("Align Top"),
3613 .callback
= G_CALLBACK (cb_align_top
)
3615 { .name
= "AlignVCenter",
3617 .label
= N_("_Vertically Center"),
3618 .tooltip
= N_("Vertically Center"),
3619 .callback
= G_CALLBACK (cb_align_vcenter
)
3621 { .name
= "AlignBottom",
3623 .label
= N_("Align _Bottom"),
3624 .tooltip
= N_("Align Bottom"),
3625 .callback
= G_CALLBACK (cb_align_bottom
)
3629 static GnmActionEntry
const font_actions
[] = {
3630 { .name
= "FontBold",
3632 .icon
= "format-text-bold",
3633 .label
= N_("_Bold"),
3634 .accelerator
= "<control>b", /* ALSO "<control>2" */
3635 .tooltip
= N_("Bold"),
3636 .callback
= G_CALLBACK (cb_font_bold
),
3637 .is_active
= FALSE
},
3638 { .name
= "FontItalic",
3640 .icon
= "format-text-italic",
3641 .label
= N_("_Italic"),
3642 .accelerator
= "<control>i", /* ALSO "<control>3" */
3643 .tooltip
= N_("Italic"),
3644 .callback
= G_CALLBACK (cb_font_italic
),
3645 .is_active
= FALSE
},
3646 { .name
= "FontUnderline",
3648 .icon
= "format-text-underline",
3649 .label
= N_("_Underline"),
3650 .accelerator
= "<control>u", /* ALSO "<control>4" */
3651 .tooltip
= N_("Underline"),
3652 .callback
= G_CALLBACK (cb_font_underline
),
3653 .is_active
= FALSE
},
3654 { .name
= "FontDoubleUnderline",
3656 .icon
= "stock_text_underlined-double", /* from icon theme */
3657 .label
= N_("_Double Underline"),
3658 .accelerator
= "<control><shift>d",
3659 .tooltip
= N_("Double Underline"),
3660 .callback
= G_CALLBACK (cb_font_double_underline
),
3661 .is_active
= FALSE
},
3662 { .name
= "FontSingleLowUnderline",
3664 .label
= N_("_Single Low Underline"),
3665 .accelerator
= "<control><shift>l",
3666 .tooltip
= N_("Single Low Underline"),
3667 .callback
= G_CALLBACK (cb_font_underline_low
),
3668 .is_active
= FALSE
},
3669 { .name
= "FontDoubleLowUnderline",
3671 .label
= N_("Double _Low Underline"),
3672 .tooltip
= N_("Double Low Underline"),
3673 .callback
= G_CALLBACK (cb_font_double_underline_low
),
3674 .is_active
= FALSE
},
3675 { .name
= "FontStrikeThrough",
3677 .icon
= "format-text-strikethrough",
3678 .label
= N_("_Strikethrough"),
3679 .accelerator
= "<control>5",
3680 .tooltip
= N_("Strikethrough"),
3681 .callback
= G_CALLBACK (cb_font_strikethrough
),
3682 .is_active
= FALSE
},
3683 { .name
= "FontSuperscript",
3685 .icon
= "gnumeric-superscript",
3686 .label
= N_("Su_perscript"),
3687 .accelerator
= "<control>asciicircum",
3688 .tooltip
= N_("Superscript"),
3689 .callback
= G_CALLBACK (cb_font_superscript
),
3690 .is_active
= FALSE
},
3691 { .name
= "FontSubscript",
3693 .icon
= "gnumeric-subscript",
3694 .label
= N_("Subscrip_t"),
3695 .accelerator
= "<control>underscore",
3696 .tooltip
= N_("Subscript"),
3697 .callback
= G_CALLBACK (cb_font_subscript
), .is_active
= FALSE
}
3700 /****************************************************************************/
3702 static GOActionComboPixmapsElement
const halignment_combo_info
[] = {
3703 { N_("Align left"), "format-justify-left", GNM_HALIGN_LEFT
},
3704 { N_("Center horizontally"), "format-justify-center", GNM_HALIGN_CENTER
},
3705 { N_("Align right"), "format-justify-right", GNM_HALIGN_RIGHT
},
3706 { N_("Fill horizontally"), "gnumeric-format-halign-fill", GNM_HALIGN_FILL
},
3707 { N_("Justify horizontally"), "format-justify-fill", GNM_HALIGN_JUSTIFY
},
3708 { N_("Distributed"), "gnumeric-format-halign-distributed", GNM_HALIGN_DISTRIBUTED
},
3709 { N_("Center horizontally across the selection"),
3710 "gnumeric-center-across-selection", GNM_HALIGN_CENTER_ACROSS_SELECTION
},
3711 { N_("Align numbers right, and text left"),
3712 "gnumeric-format-halign-general", GNM_HALIGN_GENERAL
},
3715 static GOActionComboPixmapsElement
const valignment_combo_info
[] = {
3716 { N_("Align top"), "gnumeric-format-valign-top", GNM_VALIGN_TOP
},
3717 { N_("Center vertically"), "gnumeric-format-valign-center", GNM_VALIGN_CENTER
},
3718 { N_("Align bottom"), "gnumeric-format-valign-bottom", GNM_VALIGN_BOTTOM
},
3719 { N_("Justify"), "gnumeric-format-valign-justify", GNM_VALIGN_JUSTIFY
},
3720 { N_("Align distributed"), "gnumeric-format-valign-distributed", GNM_VALIGN_DISTRIBUTED
},
3725 cb_halignment_activated (GOActionComboPixmaps
*a
, WBCGtk
*wbcg
)
3727 wbcg_set_selection_halign (wbcg
,
3728 go_action_combo_pixmaps_get_selected (a
, NULL
));
3731 cb_valignment_activated (GOActionComboPixmaps
*a
, WBCGtk
*wbcg
)
3733 wbcg_set_selection_valign (wbcg
,
3734 go_action_combo_pixmaps_get_selected (a
, NULL
));
3738 wbc_gtk_init_alignments (WBCGtk
*wbcg
)
3740 wbcg
->halignment
= go_action_combo_pixmaps_new ("HAlignmentSelector",
3741 halignment_combo_info
, 3, 1);
3742 g_object_set (G_OBJECT (wbcg
->halignment
),
3743 "label", _("Horizontal Alignment"),
3744 "tooltip", _("Horizontal Alignment"),
3746 g_signal_connect (G_OBJECT (wbcg
->halignment
),
3748 G_CALLBACK (cb_halignment_activated
), wbcg
);
3749 gnm_action_group_add_action (wbcg
->actions
, GTK_ACTION (wbcg
->halignment
));
3751 wbcg
->valignment
= go_action_combo_pixmaps_new ("VAlignmentSelector",
3752 valignment_combo_info
, 1, 3);
3753 g_object_set (G_OBJECT (wbcg
->valignment
),
3754 "label", _("Vertical Alignment"),
3755 "tooltip", _("Vertical Alignment"),
3757 g_signal_connect (G_OBJECT (wbcg
->valignment
),
3759 G_CALLBACK (cb_valignment_activated
), wbcg
);
3760 gnm_action_group_add_action (wbcg
->actions
, GTK_ACTION (wbcg
->valignment
));
3763 /****************************************************************************/
3766 cb_custom_color_created (GOActionComboColor
*caction
, GtkWidget
*dialog
, WBCGtk
*wbcg
)
3768 wbc_gtk_attach_guru (wbcg
, dialog
);
3769 wbcg_set_transient (wbcg
, GTK_WINDOW (dialog
));
3773 cb_fore_color_changed (GOActionComboColor
*a
, WBCGtk
*wbcg
)
3775 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
3778 gboolean is_default
;
3780 if (wbcg
->updating_ui
)
3782 c
= go_action_combo_color_get_color (a
, &is_default
);
3784 if (wbcg_is_editing (wbcg
)) {
3785 wbcg_edit_add_markup (wbcg
, go_color_to_pango (c
, TRUE
));
3789 mstyle
= gnm_style_new ();
3790 gnm_style_set_font_color (mstyle
, is_default
3791 ? style_color_auto_font ()
3792 : gnm_color_new_go (c
));
3793 cmd_selection_format (wbc
, mstyle
, NULL
, _("Set Foreground Color"));
3797 wbc_gtk_init_color_fore (WBCGtk
*gtk
)
3799 GnmColor
*sc_auto_font
= style_color_auto_font ();
3800 GOColor default_color
= sc_auto_font
->go_color
;
3801 style_color_unref (sc_auto_font
);
3803 gtk
->fore_color
= go_action_combo_color_new ("ColorFore", "gnumeric-font",
3804 _("Automatic"), default_color
, NULL
); /* set group to view */
3805 go_action_combo_color_set_allow_alpha (gtk
->fore_color
, TRUE
);
3806 g_object_set (G_OBJECT (gtk
->fore_color
),
3807 "label", _("Foreground"),
3808 "tooltip", _("Foreground"),
3810 g_signal_connect (G_OBJECT (gtk
->fore_color
),
3812 G_CALLBACK (cb_fore_color_changed
), gtk
);
3813 g_signal_connect (G_OBJECT (gtk
->fore_color
),
3814 "display-custom-dialog",
3815 G_CALLBACK (cb_custom_color_created
), gtk
);
3816 gnm_action_group_add_action (gtk
->font_actions
,
3817 GTK_ACTION (gtk
->fore_color
));
3821 cb_back_color_changed (GOActionComboColor
*a
, WBCGtk
*wbcg
)
3823 WorkbookControl
*wbc
= GNM_WBC (wbcg
);
3826 gboolean is_default
;
3828 if (wbcg
->updating_ui
)
3831 c
= go_action_combo_color_get_color (a
, &is_default
);
3833 mstyle
= gnm_style_new ();
3835 /* We need to have a pattern of at least solid to draw a background colour */
3836 if (!gnm_style_is_element_set (mstyle
, MSTYLE_PATTERN
) ||
3837 gnm_style_get_pattern (mstyle
) < 1)
3838 gnm_style_set_pattern (mstyle
, 1);
3840 gnm_style_set_back_color (mstyle
, gnm_color_new_go (c
));
3842 gnm_style_set_pattern (mstyle
, 0); /* Set background to NONE */
3843 cmd_selection_format (wbc
, mstyle
, NULL
, _("Set Background Color"));
3847 wbc_gtk_init_color_back (WBCGtk
*gtk
)
3849 gtk
->back_color
= go_action_combo_color_new ("ColorBack", "gnumeric-bucket",
3850 _("Clear Background"), 0, NULL
);
3851 g_object_set (G_OBJECT (gtk
->back_color
),
3852 "label", _("Background"),
3853 "tooltip", _("Background"),
3855 g_object_connect (G_OBJECT (gtk
->back_color
),
3856 "signal::combo-activate", G_CALLBACK (cb_back_color_changed
), gtk
,
3857 "signal::display-custom-dialog", G_CALLBACK (cb_custom_color_created
), gtk
,
3859 gnm_action_group_add_action (gtk
->actions
, GTK_ACTION (gtk
->back_color
));
3862 /****************************************************************************/
3864 static GOActionComboPixmapsElement
const border_combo_info
[] = {
3865 { N_("Left"), "gnumeric-format-border-left", 11 },
3866 { N_("Clear Borders"), "gnumeric-format-border-none", 12 },
3867 { N_("Right"), "gnumeric-format-border-right", 13 },
3869 { N_("All Borders"), "gnumeric-format-border-all", 21 },
3870 { N_("Outside Borders"), "gnumeric-format-border-outside", 22 },
3871 { N_("Thick Outside Borders"), "gnumeric-format-border-thick-outside", 23 },
3873 { N_("Bottom"), "gnumeric-format-border-bottom", 31 },
3874 { N_("Double Bottom"), "gnumeric-format-border-double-bottom", 32 },
3875 { N_("Thick Bottom"), "gnumeric-format-border-thick-bottom", 33 },
3877 { N_("Top and Bottom"), "gnumeric-format-border-top-n-bottom", 41 },
3878 { N_("Top and Double Bottom"), "gnumeric-format-border-top-n-double-bottom", 42 },
3879 { N_("Top and Thick Bottom"), "gnumeric-format-border-top-n-thick-bottom", 43 },
3885 cb_border_activated (GOActionComboPixmaps
*a
, WorkbookControl
*wbc
)
3887 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
3888 GnmBorder
*borders
[GNM_STYLE_BORDER_EDGE_MAX
];
3890 int index
= go_action_combo_pixmaps_get_selected (a
, NULL
);
3893 for (i
= GNM_STYLE_BORDER_TOP
; i
< GNM_STYLE_BORDER_EDGE_MAX
; i
++)
3897 case 11 : /* left */
3898 borders
[GNM_STYLE_BORDER_LEFT
] = gnm_style_border_fetch (GNM_STYLE_BORDER_THIN
,
3899 sheet_style_get_auto_pattern_color (sheet
),
3900 gnm_style_border_get_orientation (GNM_STYLE_BORDER_LEFT
));
3903 case 12 : /* none */
3904 for (i
= GNM_STYLE_BORDER_TOP
; i
< GNM_STYLE_BORDER_EDGE_MAX
; i
++)
3905 borders
[i
] = gnm_style_border_ref (gnm_style_border_none ());
3908 case 13 : /* right */
3909 borders
[GNM_STYLE_BORDER_RIGHT
] = gnm_style_border_fetch (GNM_STYLE_BORDER_THIN
,
3910 sheet_style_get_auto_pattern_color (sheet
),
3911 gnm_style_border_get_orientation (GNM_STYLE_BORDER_RIGHT
));
3915 for (i
= GNM_STYLE_BORDER_HORIZ
; i
<= GNM_STYLE_BORDER_VERT
; ++i
)
3916 borders
[i
] = gnm_style_border_fetch (GNM_STYLE_BORDER_THIN
,
3917 sheet_style_get_auto_pattern_color (sheet
),
3918 gnm_style_border_get_orientation (i
));
3921 case 22 : /* outside */
3922 for (i
= GNM_STYLE_BORDER_TOP
; i
<= GNM_STYLE_BORDER_RIGHT
; ++i
)
3923 borders
[i
] = gnm_style_border_fetch (GNM_STYLE_BORDER_THIN
,
3924 sheet_style_get_auto_pattern_color (sheet
),
3925 gnm_style_border_get_orientation (i
));
3928 case 23 : /* thick_outside */
3929 for (i
= GNM_STYLE_BORDER_TOP
; i
<= GNM_STYLE_BORDER_RIGHT
; ++i
)
3930 borders
[i
] = gnm_style_border_fetch (GNM_STYLE_BORDER_THICK
,
3931 sheet_style_get_auto_pattern_color (sheet
),
3932 gnm_style_border_get_orientation (i
));
3935 case 41 : /* top_n_bottom */
3936 case 42 : /* top_n_double_bottom */
3937 case 43 : /* top_n_thick_bottom */
3938 borders
[GNM_STYLE_BORDER_TOP
] = gnm_style_border_fetch (GNM_STYLE_BORDER_THIN
,
3939 sheet_style_get_auto_pattern_color (sheet
),
3940 gnm_style_border_get_orientation (GNM_STYLE_BORDER_TOP
));
3943 case 31 : /* bottom */
3944 case 32 : /* double_bottom */
3945 case 33 : /* thick_bottom */
3947 int const tmp
= index
% 10;
3948 GnmStyleBorderType
const t
=
3949 (tmp
== 1) ? GNM_STYLE_BORDER_THIN
:
3950 (tmp
== 2) ? GNM_STYLE_BORDER_DOUBLE
3951 : GNM_STYLE_BORDER_THICK
;
3953 borders
[GNM_STYLE_BORDER_BOTTOM
] = gnm_style_border_fetch (t
,
3954 sheet_style_get_auto_pattern_color (sheet
),
3955 gnm_style_border_get_orientation (GNM_STYLE_BORDER_BOTTOM
));
3960 g_warning ("Unknown border preset selected (%d)", index
);
3964 cmd_selection_format (wbc
, NULL
, borders
, _("Set Borders"));
3968 wbc_gtk_init_borders (WBCGtk
*wbcg
)
3970 wbcg
->borders
= go_action_combo_pixmaps_new ("BorderSelector", border_combo_info
, 3, 4);
3971 g_object_set (G_OBJECT (wbcg
->borders
),
3972 "label", _("Borders"),
3973 "tooltip", _("Borders"),
3976 go_combo_pixmaps_select (wbcg
->borders
, 1); /* default to none */
3978 g_signal_connect (G_OBJECT (wbcg
->borders
),
3980 G_CALLBACK (cb_border_activated
), wbcg
);
3981 gnm_action_group_add_action (wbcg
->actions
, GTK_ACTION (wbcg
->borders
));
3984 /****************************************************************************/
3987 cb_chain_sensitivity (GtkAction
*src
, G_GNUC_UNUSED GParamSpec
*pspec
,
3990 gboolean old_val
= gtk_action_get_sensitive (action
);
3991 gboolean new_val
= gtk_action_get_sensitive (src
);
3992 if ((new_val
!= 0) == (old_val
!= 0))
3995 gtk_action_connect_accelerator (action
);
3997 gtk_action_disconnect_accelerator (action
);
3998 g_object_set (action
, "sensitive", new_val
, NULL
);
4003 create_undo_redo (GOActionComboStack
**haction
, char const *hname
,
4005 GtkAction
**vaction
, char const *vname
,
4008 char const *tooltip
,
4009 char const *icon_name
,
4010 char const *accel
, const char *alt_accel
)
4012 *haction
= g_object_new
4013 (go_action_combo_stack_get_type (),
4016 "icon-name", icon_name
,
4018 "visible-vertical", FALSE
,
4020 gtk_action_group_add_action_with_accel
4021 (gtk
->semi_permanent_actions
,
4022 GTK_ACTION (*haction
),
4024 g_signal_connect (G_OBJECT (*haction
), "activate", hcb
, gtk
);
4026 *vaction
= g_object_new
4030 "icon-name", icon_name
,
4032 "visible-horizontal", FALSE
,
4034 gtk_action_group_add_action_with_accel
4035 (gtk
->semi_permanent_actions
,
4036 GTK_ACTION (*vaction
),
4038 g_signal_connect_swapped (G_OBJECT (*vaction
), "activate", vcb
, gtk
);
4040 g_signal_connect (G_OBJECT (*haction
), "notify::sensitive",
4041 G_CALLBACK (cb_chain_sensitivity
), *vaction
);
4046 cb_undo_activated (GOActionComboStack
*a
, WorkbookControl
*wbc
)
4048 unsigned n
= workbook_find_command (wb_control_get_workbook (wbc
), TRUE
,
4049 go_action_combo_stack_selection (a
));
4055 cb_redo_activated (GOActionComboStack
*a
, WorkbookControl
*wbc
)
4057 unsigned n
= workbook_find_command (wb_control_get_workbook (wbc
), FALSE
,
4058 go_action_combo_stack_selection (a
));
4064 wbc_gtk_init_undo_redo (WBCGtk
*gtk
)
4067 >k
->redo_haction
, "Redo", G_CALLBACK (cb_redo_activated
),
4068 >k
->redo_vaction
, "VRedo", G_CALLBACK (command_redo
),
4069 gtk
, _("Redo the undone action"),
4070 "edit-redo", "<control>y", "<control><shift>z");
4072 >k
->undo_haction
, "Undo", G_CALLBACK (cb_undo_activated
),
4073 >k
->undo_vaction
, "VUndo", G_CALLBACK (command_undo
),
4074 gtk
, _("Undo the last action"),
4075 "edit-undo", "<control>z", NULL
);
4078 /****************************************************************************/
4080 static GNM_ACTION_DEF (cb_zoom_activated
)
4082 WorkbookControl
*wbc
= (WorkbookControl
*)wbcg
;
4083 Sheet
*sheet
= wb_control_cur_sheet (wbc
);
4084 char const *new_zoom
;
4088 if (sheet
== NULL
|| wbcg
->updating_ui
|| wbcg
->snotebook
== NULL
)
4091 new_zoom
= go_action_combo_text_get_entry (wbcg
->zoom_haction
);
4093 errno
= 0; /* strtol sets errno, but does not clear it. */
4094 factor
= strtol (new_zoom
, &end
, 10);
4095 if (new_zoom
!= end
&& errno
!= ERANGE
&& factor
== (gnm_float
)factor
)
4096 /* The GSList of sheet passed to cmd_zoom will be freed by cmd_zoom,
4097 * and the sheet will force an update of the zoom combo to keep the
4098 * display consistent
4100 cmd_zoom (wbc
, g_slist_append (NULL
, sheet
), factor
/ 100.);
4103 static GNM_ACTION_DEF (cb_vzoom_activated
)
4105 dialog_zoom (wbcg
, wbcg_cur_sheet (wbcg
));
4109 wbc_gtk_init_zoom (WBCGtk
*wbcg
)
4111 #warning TODO : Add zoom to selection
4112 static char const * const preset_zoom
[] = {
4123 /* ----- horizontal ----- */
4125 wbcg
->zoom_haction
=
4126 g_object_new (go_action_combo_text_get_type (),
4128 "label", _("_Zoom"),
4129 "visible-vertical", FALSE
,
4130 "tooltip", _("Zoom"),
4131 "stock-id", "zoom-in",
4133 go_action_combo_text_set_width (wbcg
->zoom_haction
, "10000%");
4134 for (i
= 0; preset_zoom
[i
] != NULL
; ++i
)
4135 go_action_combo_text_add_item (wbcg
->zoom_haction
,
4138 g_signal_connect (G_OBJECT (wbcg
->zoom_haction
),
4140 G_CALLBACK (cb_zoom_activated
), wbcg
);
4141 gnm_action_group_add_action (wbcg
->actions
,
4142 GTK_ACTION (wbcg
->zoom_haction
));
4144 /* ----- vertical ----- */
4146 wbcg
->zoom_vaction
=
4147 g_object_new (GTK_TYPE_ACTION
,
4149 "tooltip", _("Zoom"),
4150 "icon-name", "zoom-in",
4151 "visible-horizontal", FALSE
,
4153 g_signal_connect (G_OBJECT (wbcg
->zoom_vaction
),
4155 G_CALLBACK (cb_vzoom_activated
), wbcg
);
4156 gnm_action_group_add_action (wbcg
->actions
,
4157 GTK_ACTION (wbcg
->zoom_vaction
));
4159 /* ----- chain ----- */
4161 g_signal_connect (G_OBJECT (wbcg
->zoom_haction
), "notify::sensitive",
4162 G_CALLBACK (cb_chain_sensitivity
), wbcg
->zoom_vaction
);
4165 /****************************************************************************/
4167 typedef struct { GtkAction base
; } GnmFontAction
;
4168 typedef struct { GtkActionClass base
; } GnmFontActionClass
;
4170 static PangoFontDescription
*
4171 gnm_font_action_get_font_desc (GtkAction
*act
)
4173 PangoFontDescription
*desc
=
4174 g_object_get_data (G_OBJECT (act
), "font-data");
4179 wbcg_font_action_set_font_desc (GtkAction
*act
, PangoFontDescription
*desc
)
4181 PangoFontDescription
*old_desc
;
4184 old_desc
= g_object_get_data (G_OBJECT (act
), "font-data");
4186 old_desc
= pango_font_description_new ();
4187 g_object_set_data_full (G_OBJECT (act
),
4188 "font-data", old_desc
,
4189 (GDestroyNotify
)pango_font_description_free
);
4191 pango_font_description_merge (old_desc
, desc
, TRUE
);
4193 for (p
= gtk_action_get_proxies (act
); p
; p
= p
->next
) {
4194 GtkWidget
*w
= p
->data
;
4196 GtkFontChooser
*chooser
;
4198 if (!GTK_IS_BIN (w
))
4201 child
= gtk_bin_get_child (GTK_BIN (w
));
4202 if (!GTK_IS_FONT_CHOOSER (child
))
4205 chooser
= GTK_FONT_CHOOSER (child
);
4206 gtk_font_chooser_set_font_desc (chooser
, old_desc
);
4211 cb_font_set (GtkFontChooser
*chooser
, GtkAction
*act
)
4213 PangoFontDescription
*desc
= gtk_font_chooser_get_font_desc (chooser
);
4214 wbcg_font_action_set_font_desc (act
, desc
);
4215 pango_font_description_free (desc
);
4216 gtk_action_activate (act
);
4220 cb_font_button_screen_changed (GtkWidget
*widget
)
4222 /* Doesn't look right */
4224 GdkScreen
*screen
= gtk_widget_get_screen (widget
);
4227 int w
= gnm_widget_measure_string (widget
,
4228 "XXMonospace | 99XX");
4229 gtk_widget_set_size_request (widget
, w
, -1);
4234 /* Filter to ignore non-scalable fonts. */
4236 cb_font_filter (G_GNUC_UNUSED
const PangoFontFamily
*family
,
4237 const PangoFontFace
*face_
,
4240 PangoFontFace
*face
= (PangoFontFace
*)face_
;
4243 static int debug
= -1;
4245 pango_font_face_list_sizes (face
, &sizes
, &n_sizes
);
4249 debug
= gnm_debug_flag ("fonts");
4251 if (n_sizes
> 0 && debug
) {
4252 PangoFontDescription
*desc
= pango_font_face_describe (face
);
4253 char *s
= pango_font_description_to_string (desc
);
4254 g_printerr ("Ignoring bitmap face %s\n", s
);
4256 pango_font_description_free (desc
);
4259 return n_sizes
== 0;
4263 gnm_font_action_create_tool_item (GtkAction
*action
)
4265 GtkWidget
*item
= g_object_new
4266 (GTK_TYPE_TOOL_ITEM
,
4268 GtkWidget
*but
= g_object_new
4269 (gnm_font_button_get_type(),
4270 "dialog-type", GO_TYPE_FONT_SEL_DIALOG
,
4271 "show-preview-entry", TRUE
,
4272 "show-style", FALSE
,
4273 "relief", gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (item
)),
4274 "focus-on-click", FALSE
,
4276 if (0) gtk_font_chooser_set_filter_func (GTK_FONT_CHOOSER (but
),
4280 gtk_widget_show_all (but
);
4281 gtk_container_add (GTK_CONTAINER (item
), but
);
4282 g_signal_connect (but
,
4283 "font-set", G_CALLBACK (cb_font_set
),
4285 g_signal_connect (but
,
4287 G_CALLBACK (cb_font_button_screen_changed
),
4293 gnm_font_action_class_init (GObjectClass
*gobject_class
)
4295 GtkActionClass
*act
= GTK_ACTION_CLASS (gobject_class
);
4297 act
->toolbar_item_type
= GTK_TYPE_MENU_TOOL_BUTTON
;
4298 act
->create_tool_item
= gnm_font_action_create_tool_item
;
4302 GSF_CLASS (GnmFontAction
, gnm_font_action
,
4303 gnm_font_action_class_init
, NULL
, GTK_TYPE_ACTION
)
4307 #define GNM_FONT_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), gnm_font_action_get_type(), GnmFontAction))
4310 cb_font_changed (GtkAction
*act
, WBCGtk
*gtk
)
4312 PangoFontDescription
*desc
= gnm_font_action_get_font_desc (act
);
4313 const char *family
= pango_font_description_get_family (desc
);
4314 int size
= pango_font_description_get_size (desc
);
4317 * Ignore events during destruction. This is an attempt at avoiding
4318 * https://bugzilla.redhat.com/show_bug.cgi?id=803904 for which we
4321 if (gtk
->snotebook
== NULL
)
4324 if (wbcg_is_editing (WBC_GTK (gtk
))) {
4325 wbcg_edit_add_markup (WBC_GTK (gtk
),
4326 pango_attr_family_new (family
));
4327 wbcg_edit_add_markup (WBC_GTK (gtk
),
4328 pango_attr_size_new (size
));
4330 GnmStyle
*style
= gnm_style_new ();
4331 char *font_name
= pango_font_description_to_string (desc
);
4332 char *title
= g_strdup_printf (_("Setting Font %s"), font_name
);
4335 gnm_style_set_font_name (style
, family
);
4336 gnm_style_set_font_size (style
, size
/ (double)PANGO_SCALE
);
4338 cmd_selection_format (GNM_WBC (gtk
), style
, NULL
, title
);
4344 cb_font_name_vaction_response (GtkDialog
*dialog
,
4348 WBCGtk
*wbcg
= g_object_get_data (G_OBJECT (act
), "wbcg");
4350 if (response_id
== GTK_RESPONSE_OK
) {
4351 PangoFontDescription
*desc
= gtk_font_chooser_get_font_desc
4352 (GTK_FONT_CHOOSER (dialog
));
4353 wbcg_font_action_set_font_desc (act
, desc
);
4354 pango_font_description_free (desc
);
4355 cb_font_changed (act
, wbcg
);
4358 gtk_widget_destroy (GTK_WIDGET (dialog
));
4363 cb_font_name_vaction_clicked (GtkAction
*act
, WBCGtk
*wbcg
)
4365 GtkFontChooser
*font_dialog
;
4366 const char *key
= "font-name-dialog";
4368 if (gnm_dialog_raise_if_exists (wbcg
, key
))
4371 font_dialog
= g_object_new (GO_TYPE_FONT_SEL_DIALOG
, NULL
);
4372 gtk_font_chooser_set_font_desc (font_dialog
,
4373 gnm_font_action_get_font_desc (act
));
4374 g_signal_connect (font_dialog
, "response",
4375 G_CALLBACK (cb_font_name_vaction_response
),
4378 gtk_window_present (GTK_WINDOW (font_dialog
));
4380 gnm_keyed_dialog (wbcg
, GTK_WINDOW (font_dialog
), key
);
4384 wbc_gtk_init_font_name (WBCGtk
*gtk
, gboolean horiz
)
4386 GtkAction
*act
= g_object_new
4387 (horiz
? gnm_font_action_get_type () : GTK_TYPE_ACTION
,
4388 "visible-vertical", !horiz
,
4389 "visible-horizontal", horiz
,
4390 "name", (horiz
? "FontName" : "VFontName"),
4391 "tooltip", _("Change font"),
4392 "icon-name", "gnumeric-font",
4395 g_object_set_data (G_OBJECT (act
), "wbcg", gtk
);
4397 g_signal_connect (G_OBJECT (act
),
4400 ? G_CALLBACK (cb_font_changed
)
4401 : G_CALLBACK (cb_font_name_vaction_clicked
)),
4404 gnm_action_group_add_action (gtk
->font_actions
, act
);
4409 /****************************************************************************/
4412 list_actions (GtkActionGroup
*group
)
4419 actions
= gtk_action_group_list_actions (group
);
4420 for (l
= actions
; l
; l
= l
->next
) {
4421 GtkAction
*act
= l
->data
;
4422 const char *name
= gtk_action_get_name (act
);
4423 g_printerr ("Action %s\n", name
);
4426 g_list_free (actions
);
4430 wbc_gtk_init_actions (WBCGtk
*wbcg
)
4436 } const toggles
[] = {
4437 { "FontBold", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.bold
) },
4438 { "FontItalic", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.italic
) },
4439 { "FontUnderline", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.underline
) },
4440 { "FontDoubleUnderline", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.d_underline
) },
4441 { "FontSingleLowUnderline",TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.sl_underline
) },
4442 { "FontDoubleLowUnderline",TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.dl_underline
) },
4443 { "FontSuperscript", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.superscript
) },
4444 { "FontSubscript", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.subscript
) },
4445 { "FontStrikeThrough", TRUE
, G_STRUCT_OFFSET (WBCGtk
, font
.strikethrough
) },
4447 { "AlignLeft", FALSE
, G_STRUCT_OFFSET (WBCGtk
, h_align
.left
) },
4448 { "AlignCenter", FALSE
, G_STRUCT_OFFSET (WBCGtk
, h_align
.center
) },
4449 { "AlignRight", FALSE
, G_STRUCT_OFFSET (WBCGtk
, h_align
.right
) },
4450 { "CenterAcrossSelection", FALSE
, G_STRUCT_OFFSET (WBCGtk
, h_align
.center_across_selection
) },
4451 { "AlignTop", FALSE
, G_STRUCT_OFFSET (WBCGtk
, v_align
.top
) },
4452 { "AlignVCenter", FALSE
, G_STRUCT_OFFSET (WBCGtk
, v_align
.center
) },
4453 { "AlignBottom", FALSE
, G_STRUCT_OFFSET (WBCGtk
, v_align
.bottom
) }
4457 wbcg
->permanent_actions
= gtk_action_group_new ("PermanentActions");
4458 wbcg
->actions
= gtk_action_group_new ("Actions");
4459 wbcg
->font_actions
= gtk_action_group_new ("FontActions");
4460 wbcg
->data_only_actions
= gtk_action_group_new ("DataOnlyActions");
4461 wbcg
->semi_permanent_actions
= gtk_action_group_new ("SemiPermanentActions");
4463 gnm_action_group_add_actions (wbcg
->permanent_actions
,
4464 permanent_actions
, G_N_ELEMENTS (permanent_actions
), wbcg
);
4465 gnm_action_group_add_actions (wbcg
->actions
,
4466 actions
, G_N_ELEMENTS (actions
), wbcg
);
4467 gnm_action_group_add_actions (wbcg
->font_actions
,
4468 font_actions
, G_N_ELEMENTS (font_actions
), wbcg
);
4469 gnm_action_group_add_actions (wbcg
->data_only_actions
,
4470 data_only_actions
, G_N_ELEMENTS (data_only_actions
), wbcg
);
4471 gnm_action_group_add_actions (wbcg
->semi_permanent_actions
,
4472 semi_permanent_actions
, G_N_ELEMENTS (semi_permanent_actions
), wbcg
);
4474 wbc_gtk_init_alignments (wbcg
);
4475 wbc_gtk_init_color_fore (wbcg
);
4476 wbc_gtk_init_color_back (wbcg
);
4477 wbc_gtk_init_borders (wbcg
);
4478 wbc_gtk_init_undo_redo (wbcg
);
4479 wbc_gtk_init_zoom (wbcg
);
4480 wbcg
->font_name_haction
= wbc_gtk_init_font_name (wbcg
, TRUE
);
4481 wbcg
->font_name_vaction
= wbc_gtk_init_font_name (wbcg
, FALSE
);
4483 for (i
= G_N_ELEMENTS (toggles
); i
-- > 0 ; ) {
4484 GtkAction
*act
= wbcg_find_action (wbcg
, toggles
[i
].name
);
4485 G_STRUCT_MEMBER (GtkToggleAction
*, wbcg
, toggles
[i
].offset
) =
4486 (GtkToggleAction
*) (act
);
4489 if (gnm_debug_flag ("actions")) {
4490 list_actions (wbcg
->permanent_actions
);
4491 list_actions (wbcg
->actions
);
4492 list_actions (wbcg
->font_actions
);
4493 list_actions (wbcg
->data_only_actions
);
4494 list_actions (wbcg
->semi_permanent_actions
);
4495 list_actions (wbcg
->file_history
.actions
);
4496 list_actions (wbcg
->toolbar
.actions
);
4497 list_actions (wbcg
->windows
.actions
);
4498 list_actions (wbcg
->templates
.actions
);