[gnumeric] Fix actions sensitivity for chart sheets. [#645842]



commit c77a80c92ee2be3fac4a7c02864be384822ebdba
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sun Aug 21 16:16:26 2011 +0200

    Fix actions sensitivity for chart sheets. [#645842]

 ChangeLog               |   11 ++++-
 NEWS                    |    1 +
 src/sheet-control-gui.c |    4 +-
 src/wbc-gtk-actions.c   |  100 ++++++++++++++++++++++++++++------------------
 src/wbc-gtk-impl.h      |    3 +-
 src/wbc-gtk.c           |   38 +++++++++++++-----
 6 files changed, 102 insertions(+), 55 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5d35c6f..231322a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,13 @@
-2011-08-20  Jean Brefort  <jean brefort normalesup org>
+2011-08-21  Jean Brefort  <jean brefort normalesup org>
+
+	* src/sheet-control-gui.c (sheet_object_key_pressed): missing spaces.
+	* src/wbc-gtk-actions.c: fix actions sensitivity for chart sheets. [#645842]
+	* src/wbc-gtk-impl.h: ditto.
+	* src/wbc-gtk.c (wbc_gtk_set_action_sensitivity),
+	(wbc_gtk_set_action_label), (wbcg_update_action_sensitivity),
+	(create_undo_redo), (wbc_gtk_finalize), (wbc_gtk_init): ditto.
 
-	reviewed by: <delete if not using a buddy>
+2011-08-20  Jean Brefort  <jean brefort normalesup org>
 
 	* src/sheet.c (cb_max_cell_height): fix row height autofit when zoom
 	level is not 1. [#656418]
diff --git a/NEWS b/NEWS
index 9913ec2..4587e89 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ Jean:
 	* Make things build against gtk+-3.0.
 	* Make Ctrl-PgUp and Ctrl-PgDn work on chart-only sheets. [#645673]
 	* Fix row height autofit when zoom level is not 1. [#656418]
+	* Fix actions sensitivity for chart sheets. [#645842]
 
 Valek:
 	* In xls import, set LABEL encoding based on FONT charset converted to 
diff --git a/src/sheet-control-gui.c b/src/sheet-control-gui.c
index 6db34c5..d576854 100644
--- a/src/sheet-control-gui.c
+++ b/src/sheet-control-gui.c
@@ -1424,8 +1424,8 @@ static gboolean
 sheet_object_key_pressed (GtkWidget *w, GdkEventKey *event, SheetControlGUI *scg)
 {
 	Sheet *sheet = scg_sheet (scg);
-	WorkbookControl * wbc = scg_wbc(scg);
-	Workbook * wb = wb_control_get_workbook(wbc);
+	WorkbookControl * wbc = scg_wbc (scg);
+	Workbook * wb = wb_control_get_workbook (wbc);
 	switch (event->keyval) {
 	case GDK_KEY_KP_Page_Up:
 	case GDK_KEY_Page_Up:
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index 42b9864..96b1b4b 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -2070,15 +2070,9 @@ static GtkActionEntry const permanent_actions[] = {
 		NULL, N_("Quit the application"),
 		G_CALLBACK (cb_file_quit) },
 
-	{ "EditCut", GTK_STOCK_CUT, NULL,
-		NULL, N_("Cut the selection"),
-		G_CALLBACK (cb_edit_cut) },
 	{ "EditCopy", GTK_STOCK_COPY, NULL,
 		NULL, N_("Copy the selection"),
 		G_CALLBACK (cb_edit_copy) },
-	{ "EditPaste", GTK_STOCK_PASTE, NULL,
-		NULL, N_("Paste the clipboard"),
-		G_CALLBACK (cb_edit_paste) },
 	{ "UndoLast", GTK_STOCK_UNDO, N_("_Undo"),
 		NULL, N_("Undo the last action"),
 		G_CALLBACK (cb_edit_undo_last) },
@@ -2110,6 +2104,55 @@ static GtkActionEntry const permanent_actions[] = {
 		G_CALLBACK (cb_help_about) },
 };
 
+/* actions that are sensitive only in data sheets */
+static GtkActionEntry const data_only_actions[] = {
+	{ "EditCut", GTK_STOCK_CUT, NULL,
+		NULL, N_("Cut the selection"),
+		G_CALLBACK (cb_edit_cut) },
+	{ "EditPaste", GTK_STOCK_PASTE, NULL,
+		NULL, N_("Paste the clipboard"),
+		G_CALLBACK (cb_edit_paste) },
+};
+
+static GtkActionEntry const semi_permanent_actions[] = {
+/* Edit -> Sheet */
+	{ "SheetReorder", NULL, N_("_Manage Sheets..."),
+		NULL, N_("Manage the sheets in this workbook"),
+		G_CALLBACK (cb_sheet_order) },
+	{ "InsertSheet", NULL, N_("_Insert"),
+		NULL, N_("Insert a new sheet"),
+		G_CALLBACK (wbcg_insert_sheet) },
+    /* ICK A DUPLICATE : we have no way to override a label on one proxy */
+	{ "SheetInsert", NULL, N_("_Sheet"),
+		NULL, N_("Insert a new sheet"),
+		G_CALLBACK (wbcg_insert_sheet) },
+	{ "InsertSheetAtEnd", NULL, N_("_Append"),
+		NULL, N_("Append a new sheet"),
+		G_CALLBACK (wbcg_append_sheet) },
+	{ "EditDuplicateSheet", NULL, N_("_Duplicate"),
+		NULL, N_("Make a copy of the current sheet"),
+		G_CALLBACK (wbcg_clone_sheet) },
+	{ "SheetRemove", NULL, N_("_Remove"),
+		NULL, N_("Irrevocably remove an entire sheet"),
+		G_CALLBACK (cb_sheet_remove) },
+	{ "SheetChangeName", NULL, N_("Re_name"),
+		NULL, N_("Rename the current sheet"),
+		G_CALLBACK (cb_sheet_name) },
+	{ "SheetResize", NULL, N_("Resize..."),
+		NULL, N_("Change the size of the current sheet"),
+		G_CALLBACK (cb_sheet_resize) },
+
+/* View */
+	{ "ViewNew", GTK_STOCK_NEW, N_("_New View..."),
+		NULL, N_("Create a new view of the workbook"),
+		G_CALLBACK (cb_view_new) },
+
+/* Format */
+	{ "FormatWorkbook", GTK_STOCK_PROPERTIES, N_("View _Properties..."),
+		NULL, N_("Modify the view properties"),
+		G_CALLBACK (cb_workbook_attr) },
+};
+
 #ifdef GNM_USE_HILDON
 #define FULLSCREEN_ACCEL "F6"
 #define ZOOM_IN_ACCEL "F7"
@@ -2243,33 +2286,6 @@ static GtkActionEntry const actions[] = {
 		"<control>G", N_("Jump to a specified cell"),
 		G_CALLBACK (cb_edit_goto) },
 
-/* Edit -> Sheet */
-	{ "SheetReorder", NULL, N_("_Manage Sheets..."),
-		NULL, N_("Manage the sheets in this workbook"),
-		G_CALLBACK (cb_sheet_order) },
-	{ "InsertSheet", NULL, N_("_Insert"),
-		NULL, N_("Insert a new sheet"),
-		G_CALLBACK (wbcg_insert_sheet) },
-    /* ICK A DUPLICATE : we have no way to override a label on one proxy */
-	{ "SheetInsert", NULL, N_("_Sheet"),
-		NULL, N_("Insert a new sheet"),
-		G_CALLBACK (wbcg_insert_sheet) },
-	{ "InsertSheetAtEnd", NULL, N_("_Append"),
-		NULL, N_("Append a new sheet"),
-		G_CALLBACK (wbcg_append_sheet) },
-	{ "EditDuplicateSheet", NULL, N_("_Duplicate"),
-		NULL, N_("Make a copy of the current sheet"),
-		G_CALLBACK (wbcg_clone_sheet) },
-	{ "SheetRemove", NULL, N_("_Remove"),
-		NULL, N_("Irrevocably remove an entire sheet"),
-		G_CALLBACK (cb_sheet_remove) },
-	{ "SheetChangeName", NULL, N_("Re_name"),
-		NULL, N_("Rename the current sheet"),
-		G_CALLBACK (cb_sheet_name) },
-	{ "SheetResize", NULL, N_("Resize..."),
-		NULL, N_("Change the size of the current sheet"),
-		G_CALLBACK (cb_sheet_resize) },
-
 /* Edit */
 	{ "Repeat", NULL, N_("Repeat"),
 		"F4", N_("Repeat the previous action"),
@@ -2306,9 +2322,6 @@ static GtkActionEntry const actions[] = {
 		G_CALLBACK (cb_file_preferences) },
 
 /* View */
-	{ "ViewNew", GTK_STOCK_NEW, N_("_New View..."),
-		NULL, N_("Create a new view of the workbook"),
-		G_CALLBACK (cb_view_new) },
 	{ "ViewFreezeThawPanes", NULL, N_("_Freeze Panes"),
 		NULL, N_("Freeze the top left of the sheet"),
 		G_CALLBACK (cb_view_freeze_panes) },
@@ -2384,9 +2397,6 @@ static GtkActionEntry const actions[] = {
 		G_CALLBACK (cb_define_name) },
 
 /* Format */
-	{ "FormatWorkbook", GTK_STOCK_PROPERTIES, N_("View _Properties..."),
-		NULL, N_("Modify the view properties"),
-		G_CALLBACK (cb_workbook_attr) },
 	{ "FormatAuto", NULL, N_("_Autoformat..."),
 		NULL, N_("Format a region of cells according to a pre-defined template"),
 		G_CALLBACK (cb_autoformat) },
@@ -2895,7 +2905,9 @@ static GtkToggleActionEntry const toggle_actions[] = {
 	{ "AlignBottom", NULL,
 		N_("Align _Bottom"), NULL,
 		N_("Align Bottom"), G_CALLBACK (cb_align_bottom), FALSE },
+};
 
+static GtkToggleActionEntry const semi_permanent_toggle_actions[] = {
 	{ "ViewStatusbar", NULL,
 		N_("View _Statusbar"), NULL,
 		N_("Toggle visibility of statusbar"),
@@ -3016,6 +3028,10 @@ wbc_gtk_init_actions (WBCGtk *wbcg)
 	gtk_action_group_set_translation_domain (wbcg->actions, GETTEXT_PACKAGE);
 	wbcg->font_actions = gtk_action_group_new ("FontActions");
 	gtk_action_group_set_translation_domain (wbcg->font_actions, GETTEXT_PACKAGE);
+	wbcg->data_only_actions = gtk_action_group_new ("DataOnlyActions");
+	gtk_action_group_set_translation_domain (wbcg->data_only_actions, GETTEXT_PACKAGE);
+	wbcg->semi_permanent_actions = gtk_action_group_new ("SemiPermanentActions");
+	gtk_action_group_set_translation_domain (wbcg->semi_permanent_actions, GETTEXT_PACKAGE);
 
 	gtk_action_group_add_actions (wbcg->permanent_actions,
 		permanent_actions, G_N_ELEMENTS (permanent_actions), wbcg);
@@ -3025,6 +3041,12 @@ wbc_gtk_init_actions (WBCGtk *wbcg)
 		toggle_actions, G_N_ELEMENTS (toggle_actions), wbcg);
 	gtk_action_group_add_toggle_actions (wbcg->font_actions,
 		font_toggle_actions, G_N_ELEMENTS (font_toggle_actions), wbcg);
+	gtk_action_group_add_actions (wbcg->data_only_actions,
+		data_only_actions, G_N_ELEMENTS (data_only_actions), wbcg);
+	gtk_action_group_add_actions (wbcg->semi_permanent_actions,
+		semi_permanent_actions, G_N_ELEMENTS (semi_permanent_actions), wbcg);
+	gtk_action_group_add_toggle_actions (wbcg->semi_permanent_actions,
+		semi_permanent_toggle_actions, G_N_ELEMENTS (semi_permanent_toggle_actions), wbcg);
 
 	wbc_gtk_init_alignments (wbcg);
 }
diff --git a/src/wbc-gtk-impl.h b/src/wbc-gtk-impl.h
index 8a14298..96777e4 100644
--- a/src/wbc-gtk-impl.h
+++ b/src/wbc-gtk-impl.h
@@ -106,7 +106,8 @@ struct _WBCGtk {
 	GtkWidget	 *status_area;
 	int status_area_width;
 	GtkUIManager     *ui;
-	GtkActionGroup   *permanent_actions, *actions, *font_actions;
+	GtkActionGroup   *permanent_actions, *actions, *font_actions, 
+			 *data_only_actions, *semi_permanent_actions;
 	struct {
 		GtkActionGroup   *actions;
 		guint		  merge_id;
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 788320b..04e2f99 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -141,6 +141,10 @@ wbc_gtk_set_action_sensitivity (WBCGtk const *wbcg,
 	GtkAction *a = gtk_action_group_get_action (wbcg->actions, action);
 	if (a == NULL)
 		a = gtk_action_group_get_action (wbcg->permanent_actions, action);
+	if (a == NULL)
+		a = gtk_action_group_get_action (wbcg->semi_permanent_actions, action);
+	if (a == NULL)
+		a = gtk_action_group_get_action (wbcg->data_only_actions, action);
 	g_object_set (G_OBJECT (a), "sensitive", sensitive, NULL);
 }
 
@@ -156,6 +160,9 @@ wbc_gtk_set_action_label (WBCGtk const *wbcg,
 {
 	GtkAction *a = gtk_action_group_get_action (wbcg->actions, action);
 
+	if (!a)
+		a = gtk_action_group_get_action (wbcg->semi_permanent_actions, action);
+
 	if (prefix != NULL) {
 		char *text;
 		gboolean is_suffix = (suffix != NULL);
@@ -361,7 +368,8 @@ wbcg_update_action_sensitivity (WorkbookControl *wbc)
 	WBCGtk *wbcg = WBC_GTK (wbc);
 	SheetControlGUI	   *scg = wbcg_cur_scg (wbcg);
 	gboolean edit_object = scg != NULL &&
-		(scg->selected_objects != NULL || wbcg->new_object != NULL);
+		(scg->selected_objects != NULL || wbcg->new_object != NULL ||
+		 scg_sheet (scg)->sheet_type == GNM_SHEET_OBJECT);
 	gboolean enable_actions = TRUE;
 	gboolean enable_edit_ok_cancel = FALSE;
 
@@ -395,17 +403,21 @@ wbcg_update_action_sensitivity (WorkbookControl *wbc)
 		NULL);
 
 	if (scg && scg_sheet (scg)->sheet_type == GNM_SHEET_OBJECT) {
-		GtkAction *action = gtk_action_group_get_action (wbcg->permanent_actions, "EditPaste");
-		gtk_action_set_sensitive (action, FALSE);
-		action = gtk_action_group_get_action (wbcg->permanent_actions, "EditCut");
-		gtk_action_set_sensitive (action, FALSE);
+		g_object_set (G_OBJECT (wbcg->data_only_actions),
+			"sensitive", FALSE,
+			NULL);
+		g_object_set (G_OBJECT (wbcg->semi_permanent_actions),
+			"sensitive",TRUE,
+			NULL);
 		gtk_widget_set_sensitive (GTK_WIDGET (wbcg->edit_line.entry), FALSE);
 		gtk_widget_set_sensitive (GTK_WIDGET (wbcg->selection_descriptor), FALSE);
 	} else {
-		GtkAction *action = gtk_action_group_get_action (wbcg->permanent_actions, "EditPaste");
-		gtk_action_set_sensitive (action, TRUE);
-		action = gtk_action_group_get_action (wbcg->permanent_actions, "EditCut");
-		gtk_action_set_sensitive (action, TRUE);
+		g_object_set (G_OBJECT (wbcg->data_only_actions),
+			"sensitive", TRUE,
+			NULL);
+		g_object_set (G_OBJECT (wbcg->semi_permanent_actions),
+			"sensitive", enable_actions,
+			NULL);
 		gtk_widget_set_sensitive (GTK_WIDGET (wbcg->edit_line.entry), TRUE);
 		gtk_widget_set_sensitive (GTK_WIDGET (wbcg->selection_descriptor), TRUE);
 	}
@@ -3321,7 +3333,7 @@ create_undo_redo (GOActionComboStack **haction, char const *hname,
 		 "sensitive", FALSE,
 		 "visible-vertical", FALSE,
 		 NULL);
-	gtk_action_group_add_action_with_accel (gtk->actions,
+	gtk_action_group_add_action_with_accel (gtk->semi_permanent_actions,
 		GTK_ACTION (*haction), accel);
 	g_signal_connect (G_OBJECT (*haction), "activate", hcb, gtk);
 
@@ -3330,7 +3342,7 @@ create_undo_redo (GOActionComboStack **haction, char const *hname,
 		      "sensitive", FALSE,
 		      "visible-horizontal", FALSE,
 		      NULL);
-	gtk_action_group_add_action (gtk->actions, GTK_ACTION (*vaction));
+	gtk_action_group_add_action (gtk->semi_permanent_actions, GTK_ACTION (*vaction));
 	g_signal_connect_swapped (G_OBJECT (*vaction), "activate", vcb, gtk);
 
 	g_signal_connect (G_OBJECT (*haction), "notify::sensitive",
@@ -5338,6 +5350,8 @@ wbc_gtk_finalize (GObject *obj)
 	UNREF_OBJ (actions);
 	UNREF_OBJ (permanent_actions);
 	UNREF_OBJ (font_actions);
+	UNREF_OBJ (data_only_actions);
+	UNREF_OBJ (semi_permanent_actions);
 	UNREF_OBJ (ui);
 
 	/* Disconnect signals that would attempt to change things during
@@ -5897,6 +5911,8 @@ wbc_gtk_init (GObject *obj)
 	gtk_ui_manager_insert_action_group (wbcg->ui, wbcg->permanent_actions, 0);
 	gtk_ui_manager_insert_action_group (wbcg->ui, wbcg->actions, 0);
 	gtk_ui_manager_insert_action_group (wbcg->ui, wbcg->font_actions, 0);
+	gtk_ui_manager_insert_action_group (wbcg->ui, wbcg->data_only_actions, 0);
+	gtk_ui_manager_insert_action_group (wbcg->ui, wbcg->semi_permanent_actions, 0);
 	gtk_window_add_accel_group (wbcg_toplevel (wbcg),
 		gtk_ui_manager_get_accel_group (wbcg->ui));
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]