[gnumeric] Add hyperlink and comment removal menu items.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Add hyperlink and comment removal menu items.
- Date: Thu, 8 Jul 2010 03:58:44 +0000 (UTC)
commit ceb83b066d167957dcaf839c4371003291996577
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Wed Jul 7 21:59:29 2010 -0600
Add hyperlink and comment removal menu items.
2010-07-07 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/GNOME_Gnumeric-gtk.xml.in: add and move hyperlink and
comment items
* src/HILDON_Gnumeric-gtk.xml.in: ditto
* component/Gnumeric-embed.xml.in: ditto
* src/sheet-view.c (sv_update): also check the comment and hyperlink
items
* src/wbc-gtk-actions.c (cb_edit_delete_links): new
(permanent_actions): new Modify submenu of the Edit menu
(actions): add and move hyperlink and comment actions
* src/wbc-gtk.c (wbcg_menu_state_update): handle hyperlink and comment
items
* src/workbook-control.h: new MS_* flags
ChangeLog | 15 +++++++++
NEWS | 1 +
component/Gnumeric-embed.xml.in | 13 +++++---
src/GNOME_Gnumeric-gtk.xml.in | 13 +++++---
src/HILDON_Gnumeric-gtk.xml.in | 13 +++++---
src/sheet-view.c | 9 ++++-
src/wbc-gtk-actions.c | 66 +++++++++++++++++++++++++++++---------
src/wbc-gtk.c | 44 +++++++++++++++++++++++++-
src/workbook-control.h | 4 ++-
9 files changed, 143 insertions(+), 35 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 348c73f..267589d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2010-07-07 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * src/GNOME_Gnumeric-gtk.xml.in: add and move hyperlink and
+ comment items
+ * src/HILDON_Gnumeric-gtk.xml.in: ditto
+ * component/Gnumeric-embed.xml.in: ditto
+ * src/sheet-view.c (sv_update): also check the comment and hyperlink
+ items
+ * src/wbc-gtk-actions.c (cb_edit_delete_links): new
+ (permanent_actions): new Modify submenu of the Edit menu
+ (actions): add and move hyperlink and comment actions
+ * src/wbc-gtk.c (wbcg_menu_state_update): handle hyperlink and comment
+ items
+ * src/workbook-control.h: new MS_* flags
+
+2010-07-07 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* src/func.c (copy_hash_table_to_ptr_array): also exclude py_* functions
2010-07-07 Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/NEWS b/NEWS
index 9b3e45b..a60281e 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ Andreas:
documentation. [#623455]
* Fix HDATE and friends. [#623764]
* New functions DATE2HDATE, DATE2HDATE_HEB and DATE2JULIAN.
+ * Add hyperlink and comment removal menu items.
Jean:
* Fix strong/weak cursor display. [#623241]
diff --git a/component/Gnumeric-embed.xml.in b/component/Gnumeric-embed.xml.in
index 6d3ded7..6468fbe 100644
--- a/component/Gnumeric-embed.xml.in
+++ b/component/Gnumeric-embed.xml.in
@@ -40,14 +40,20 @@
<menu name="Clear" action="MenuEditClear">
<menuitem action="EditClearAll"/>
<menuitem action="EditClearFormats"/>
- <menuitem action="EditClearComments"/>
<menuitem action="EditClearContent"/>
</menu>
<menu name="Delete" action="MenuEditDelete">
<menuitem action="EditDeleteColumns"/>
<menuitem action="EditDeleteRows"/>
<menuitem action="EditDeleteCells"/>
+ <menuitem action="EditClearComments"/>
+ <menuitem action="EditClearHyperlinks"/>
</menu>
+ <menu name="EditItems" action="MenuEditItems">
+ <menuitem action="EditComment"/>
+ <menuitem action="EditHyperlink"/>
+ <menuitem action="EditNames"/>
+ </menu>
<separator name="edit-sep3"/>
<menuitem action="EditFind"/>
<menuitem action="EditReplace"/>
@@ -111,10 +117,7 @@
-->
<menuitem action="InsertImage"/>
<menuitem action="InsertFormula"/>
- <menu name="Names" action="MenuInsertNames">
- <menuitem action="EditNames"/>
- <menuitem action="PasteNames"/>
- </menu>
+ <menuitem action="InsertNames"/>
<menuitem action="InsertComment"/>
<menuitem action="InsertHyperlink"/>
<menu name="Special" action="MenuInsertSpecial">
diff --git a/src/GNOME_Gnumeric-gtk.xml.in b/src/GNOME_Gnumeric-gtk.xml.in
index 0bf43cf..dbd6fd0 100644
--- a/src/GNOME_Gnumeric-gtk.xml.in
+++ b/src/GNOME_Gnumeric-gtk.xml.in
@@ -41,14 +41,20 @@
<menu name="Clear" action="MenuEditClear">
<menuitem action="EditClearAll"/>
<menuitem action="EditClearFormats"/>
- <menuitem action="EditClearComments"/>
<menuitem action="EditClearContent"/>
</menu>
<menu name="Delete" action="MenuEditDelete">
<menuitem action="EditDeleteColumns"/>
<menuitem action="EditDeleteRows"/>
<menuitem action="EditDeleteCells"/>
+ <menuitem action="EditClearComments"/>
+ <menuitem action="EditClearHyperlinks"/>
</menu>
+ <menu name="EditItems" action="MenuEditItems">
+ <menuitem action="EditComment"/>
+ <menuitem action="EditHyperlink"/>
+ <menuitem action="EditNames"/>
+ </menu>
<separator name="edit-sep3"/>
<menuitem action="EditFind"/>
<menuitem action="EditReplace"/>
@@ -112,10 +118,7 @@
-->
<menuitem action="InsertImage"/>
<menuitem action="InsertFormula"/>
- <menu name="Names" action="MenuInsertNames">
- <menuitem action="EditNames"/>
- <menuitem action="PasteNames"/>
- </menu>
+ <menuitem action="InsertNames"/>
<menuitem action="InsertComment"/>
<menuitem action="InsertHyperlink"/>
<menu name="Special" action="MenuInsertSpecial">
diff --git a/src/HILDON_Gnumeric-gtk.xml.in b/src/HILDON_Gnumeric-gtk.xml.in
index c984dde..2e8eb92 100644
--- a/src/HILDON_Gnumeric-gtk.xml.in
+++ b/src/HILDON_Gnumeric-gtk.xml.in
@@ -52,14 +52,20 @@
<menu name="Clear" action="MenuEditClear">
<menuitem action="EditClearAll"/>
<menuitem action="EditClearFormats"/>
- <menuitem action="EditClearComments"/>
<menuitem action="EditClearContent"/>
</menu>
<menu name="Delete" action="MenuEditDelete">
<menuitem action="EditDeleteColumns"/>
<menuitem action="EditDeleteRows"/>
<menuitem action="EditDeleteCells"/>
+ <menuitem action="EditClearComments"/>
+ <menuitem action="EditClearHyperLinks"/>
</menu>
+ <menu name="EditItems" action="MenuEditItems">
+ <menuitem action="EditComment"/>
+ <menuitem action="EditHyperlink"/>
+ <menuitem action="EditNames"/>
+ </menu>
<separator name="edit-sep3"/>
<menuitem action="EditFind"/>
<menuitem action="EditReplace"/>
@@ -121,10 +127,7 @@
-->
<menuitem action="InsertImage"/>
<menuitem action="InsertFormula"/>
- <menu name="Names" action="MenuInsertNames">
- <menuitem action="EditNames"/>
- <menuitem action="PasteNames"/>
- </menu>
+ <menuitem action="InsertNames"/>
<menuitem action="InsertComment"/>
<menuitem action="InsertHyperlink"/>
<menu name="Special" action="MenuInsertSpecial">
diff --git a/src/sheet-view.c b/src/sheet-view.c
index 901d1a9..f790142 100644
--- a/src/sheet-view.c
+++ b/src/sheet-view.c
@@ -639,8 +639,12 @@ sv_update (SheetView *sv)
if (sv->edit_pos_changed.location) {
sv->edit_pos_changed.location = FALSE;
- if (wb_view_cur_sheet_view (sv->sv_wbv) == sv)
+ if (wb_view_cur_sheet_view (sv->sv_wbv) == sv) {
wb_view_selection_desc (sv->sv_wbv, TRUE, NULL);
+ SHEET_VIEW_FOREACH_CONTROL
+ (sv, sc, wb_control_menu_state_update
+ (sc_wbc (sc), MS_COMMENT_LINKS););
+ }
}
if (sv->selection_content_changed) {
@@ -652,7 +656,8 @@ sv_update (SheetView *sv)
cb_update_auto_expr, (gpointer) sv, NULL);
}
SHEET_VIEW_FOREACH_CONTROL (sv, sc,
- wb_control_menu_state_update (sc_wbc (sc), MS_ADD_VS_REMOVE_FILTER););
+ wb_control_menu_state_update (sc_wbc (sc), MS_ADD_VS_REMOVE_FILTER |
+ MS_COMMENT_LINKS_RANGE););
}
SHEET_VIEW_FOREACH_CONTROL (sv, sc,
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index 76f898a..11197e0 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -355,6 +355,31 @@ static GNM_ACTION_DEF (cb_edit_delete_cells)
{
dialog_delete_cells (wbcg);
}
+static GNM_ACTION_DEF (cb_edit_delete_links)
+ {
+ SheetControlGUI *scg = wbcg_cur_scg (wbcg);
+ GnmStyle *style = gnm_style_new ();
+ GSList *l;
+ int n_links = 0;
+ gchar const *format;
+ gchar *name;
+ WorkbookControl *wbc = WORKBOOK_CONTROL (wbcg);
+ Sheet *sheet = wb_control_cur_sheet (wbc);;
+
+ for (l = scg_view (scg)->selections; l != NULL; l = l->next) {
+ GnmRange const *r = l->data;
+ GnmStyleList *styles;
+
+ styles = sheet_style_collect_hlinks (sheet, r);
+ n_links += g_slist_length (styles);
+ style_list_free (styles);
+ }
+ format = ngettext ("Remove %d Link", "Remove %d Links", n_links);
+ name = g_strdup_printf (format, n_links);
+ gnm_style_set_hlink (style, NULL);
+ cmd_selection_format (wbc, style, NULL, name);
+ g_free (name);
+ }
static GNM_ACTION_DEF (cb_edit_select_all)
{
@@ -1741,13 +1766,13 @@ static GtkActionEntry const permanent_actions[] = {
{ "MenuEdit", NULL, N_("_Edit") },
{ "MenuEditClear", GTK_STOCK_CLEAR, N_("C_lear") },
{ "MenuEditDelete", GTK_STOCK_DELETE, N_("_Delete") },
+ { "MenuEditItems", NULL, N_("_Modify") },
{ "MenuEditSheet", NULL, N_("S_heet") },
{ "MenuEditSelect", NULL, N_("_Select") },
{ "MenuView", NULL, N_("_View") },
{ "MenuViewWindows", NULL, N_("_Windows") },
{ "MenuViewToolbars", NULL, N_("_Toolbars") },
{ "MenuInsert", NULL, N_("_Insert") },
- { "MenuInsertNames", NULL, N_("_Names") },
{ "MenuInsertSpecial", NULL, N_("S_pecial") },
{ "MenuFormat", NULL, N_("F_ormat") },
{ "MenuFormatColumn", NULL, N_("C_olumn") },
@@ -1835,8 +1860,8 @@ static GtkActionEntry const permanent_actions[] = {
NULL, N_("Redo the undone action"),
G_CALLBACK (cb_edit_redo_last) },
- { "PasteNames", GTK_STOCK_PASTE, N_("_Paste..."),
- "F3", N_("Paste the definition of a name or names"),
+ { "InsertNames", GTK_STOCK_PASTE, N_("_Name..."),
+ "F3", N_("Insert a defined name"),
G_CALLBACK (cb_paste_names) },
{ "HelpDocs", GTK_STOCK_HELP, N_("_Contents"),
@@ -1887,16 +1912,13 @@ static GtkActionEntry const actions[] = {
G_CALLBACK (cb_file_print_area_show)},
/* Edit -> Clear */
- { "EditClearAll", NULL, N_("_All"),
+ { "EditClearAll", GTK_STOCK_CLEAR, N_("_All"),
NULL, N_("Clear the selected cells' formats, comments, and contents"),
G_CALLBACK (cb_edit_clear_all) },
{ "EditClearFormats", NULL, N_("_Formats"),
NULL, N_("Clear the selected cells' formats"),
G_CALLBACK (cb_edit_clear_formats) },
- { "EditClearComments", NULL, N_("Co_mments"),
- NULL, N_("Clear the selected cells' comments"),
- G_CALLBACK (cb_edit_clear_comments) },
- { "EditClearContent", NULL, N_("_Contents"),
+ { "EditClearContent", GTK_STOCK_CLEAR, N_("_Contents"),
NULL, N_("Clear the selected cells' contents"),
G_CALLBACK (cb_edit_clear_content) },
@@ -1910,6 +1932,12 @@ static GtkActionEntry const actions[] = {
{ "EditDeleteCells", NULL, N_("C_ells..."),
"<control>minus", N_("Delete the selected cells, shifting others into their place"),
G_CALLBACK (cb_edit_delete_cells) },
+ { "EditClearComments", "Gnumeric_CommentDelete", N_("Co_mments"),
+ NULL, N_("Delete the selected cells' comments"),
+ G_CALLBACK (cb_edit_clear_comments) },
+ { "EditClearHyperlinks", "Gnumeric_Link_Delete", N_("_Hyperlinks"),
+ NULL, N_("Delete the selected cells' hyperlinks"),
+ G_CALLBACK (cb_edit_delete_links) },
/* A duplicate that should not go into the menus, used only for the accelerator */
{ "EditDeleteCellsXL", NULL, N_("C_ells..."),
"<control>KP_Subtract", N_("Delete the selected cells, shifting others into their place"),
@@ -2001,9 +2029,17 @@ static GtkActionEntry const actions[] = {
"<shift><control>V", N_("Paste with optional filters and transformations"),
G_CALLBACK (cb_edit_paste_special) },
- { "InsertComment", "Gnumeric_CommentEdit", N_("Co_mment..."),
+ { "EditComment", "Gnumeric_CommentEdit", N_("Co_mment..."),
NULL, N_("Edit the selected cell's comment"),
G_CALLBACK (cb_insert_comment) },
+ { "EditHyperlink", "Gnumeric_Link_Edit", N_("Hyper_link..."),
+ "<control>K", N_("Edit the selected cell's hyperlink"),
+ G_CALLBACK (cb_insert_hyperlink) },
+#if 0
+ { "EditGenerateName", NULL, N_("_Auto generate names..."),
+ NULL, N_("Use the current selection to create names"),
+ G_CALLBACK (cb_auto_generate__named_expr) },
+#endif
{ "EditFind", GTK_STOCK_FIND, N_("S_earch..."),
"<control>F", N_("Search for something"),
@@ -2059,6 +2095,9 @@ static GtkActionEntry const actions[] = {
NULL, N_("Insert an image"),
G_CALLBACK (cb_insert_image) },
+ { "InsertComment", "Gnumeric_CommentAdd", N_("Co_mment..."),
+ NULL, N_("Insert a comment"),
+ G_CALLBACK (cb_insert_comment) },
{ "InsertHyperlink", "Gnumeric_Link_Add", N_("Hyper_link..."),
"<control>K", N_("Insert a Hyperlink"),
G_CALLBACK (cb_insert_hyperlink) },
@@ -2076,14 +2115,9 @@ static GtkActionEntry const actions[] = {
G_CALLBACK (cb_insert_current_date_time) },
/* Insert -> Name */
- { "EditNames", NULL, N_("_Define..."),
- "<control>F3", N_("Edit sheet and workbook names"),
+ { "EditNames", NULL, N_("_Names..."),
+ "<control>F3", N_("Edit defined names for expressions"),
G_CALLBACK (cb_define_name) },
-#if 0
- { "EditGenerateName", NULL, N_("_Auto generate names..."),
- NULL, N_("Use the current selection to create names"),
- G_CALLBACK (cb_auto_generate__named_expr) },
-#endif
/* Format */
{ "FormatCells", NULL, N_("_Cells..."),
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index a9cd45c..a973f7d 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -59,6 +59,7 @@
#include "ranges.h"
#include "dead-kittens.h"
#include "tools/analysis-auto-expression.h"
+#include "sheet-object-cell-comment.h"
#include <goffice/goffice.h>
#include <gsf/gsf-impl-utils.h>
@@ -1541,7 +1542,7 @@ wbcg_menu_state_update (WorkbookControl *wbc, int flags)
wbc_gtk_set_action_sensitivity (wbcg, "EditReplace", !has_guru);
if (MS_DEFINE_NAME & flags) {
wbc_gtk_set_action_sensitivity (wbcg, "EditNames", !has_guru);
- wbc_gtk_set_action_sensitivity (wbcg, "PasteNames", !has_guru);
+ wbc_gtk_set_action_sensitivity (wbcg, "InsertNames", !has_guru);
}
if (MS_CONSOLIDATE & flags)
wbc_gtk_set_action_sensitivity (wbcg, "DataConsolidate", !has_guru);
@@ -1615,7 +1616,48 @@ wbcg_menu_state_update (WorkbookControl *wbc, int flags)
wbc_gtk_set_action_sensitivity (wbcg, "DataAutoFilter", active);
}
+ if (MS_COMMENT_LINKS & flags) {
+ gboolean has_comment
+ = (sheet_get_comment (sheet, &sv->edit_pos) != NULL);
+ gboolean has_link;
+ GnmRange rge;
+ range_init_cellpos (&rge, &sv->edit_pos);
+ has_link = (NULL !=
+ sheet_style_region_contains_link (sheet, &rge));
+ wbc_gtk_set_action_sensitivity
+ (wbcg, "EditComment", has_comment);
+ wbc_gtk_set_action_sensitivity
+ (wbcg, "EditHyperlink", has_link);
+ }
+ if (MS_COMMENT_LINKS_RANGE & flags) {
+ GSList *l;
+ gboolean has_links = FALSE, has_comments = FALSE;
+ for (l = scg_view (scg)->selections;
+ l != NULL; l = l->next) {
+ GnmRange const *r = l->data;
+ GSList *objs;
+ GnmStyleList *styles;
+ if (!has_links) {
+ styles = sheet_style_collect_hlinks
+ (sheet, r);
+ has_links = (styles != NULL);
+ style_list_free (styles);
+ }
+ if (!has_comments) {
+ objs = sheet_objects_get
+ (sheet, r, CELL_COMMENT_TYPE);
+ has_comments = (objs != NULL);
+ g_slist_free (objs);
+ }
+ if(has_comments && has_links)
+ break;
+ }
+ wbc_gtk_set_action_sensitivity
+ (wbcg, "EditClearHyperlinks", has_links);
+ wbc_gtk_set_action_sensitivity
+ (wbcg, "EditClearComments", has_comments);
+ }
{
gboolean const has_slicer = (NULL != sv_editpos_in_slicer (sv));
char const* label = has_slicer
diff --git a/src/workbook-control.h b/src/workbook-control.h
index 5bef8a2..f41328a 100644
--- a/src/workbook-control.h
+++ b/src/workbook-control.h
@@ -56,7 +56,9 @@ enum {
MS_ADD_VS_REMOVE_FILTER = 1 << 10,
MS_SHOW_PRINTAREA = 1 << 11,
MS_SELECT_OBJECT = 1 << 12,
- MS_FILTER_STATE_CHANGED = 1 << 13
+ MS_FILTER_STATE_CHANGED = 1 << 13,
+ MS_COMMENT_LINKS_RANGE = 1 << 14,
+ MS_COMMENT_LINKS = 1 << 15
};
#define MS_ALL \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]