Patch for action sensitivities



This patch attempts to systematically set the sensitivities of all the
actions which might need it; I've ordered the logic to match the order
in which the actions occur in the initialiser array.

Fixes various things, including a crasher if you click on one of the
Zoom toolbar buttons before you've loaded a document.

OK to commit?


Dave Malcolm
cvs server: Diffing .
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evince/ChangeLog,v
retrieving revision 1.113
diff -u -r1.113 ChangeLog
--- ChangeLog	14 Jan 2005 00:10:12 -0000	1.113
+++ ChangeLog	14 Jan 2005 00:27:32 -0000
@@ -1,6 +1,13 @@
 2005-01-13  Dave Malcolm  <dmalcolm redhat com>
 
-	* shell/ev-window.c (Module): Fix sensitivity of the Find action
+	* shell/ev-window.c (update_action_sensitivity): Fix sensitivity
+	of all actions that might require it.  Fixes a crash when you
+	click on the Zoom actions in a window lacking a document.
+
+2005-01-13  Dave Malcolm  <dmalcolm redhat com>
+
+	* shell/ev-window.c (update_action_sensitivity): Fix sensitivity
+	of the Find action
 
 2005-01-13  Marco Pesenti Gritti  <marco gnome org>
 
cvs server: Diffing backend
cvs server: Diffing cut-n-paste
cvs server: Diffing cut-n-paste/recent-files
cvs server: Diffing data
cvs server: Diffing dvi
cvs server: Diffing dvi/dvilib
cvs server: Diffing pdf
cvs server: Diffing pdf/fofi
cvs server: Diffing pdf/goo
cvs server: Diffing pdf/splash
cvs server: Diffing pdf/xpdf
cvs server: Diffing pixbuf
cvs server: Diffing po
cvs server: Diffing ps
cvs server: Diffing shell
Index: shell/ev-window.c
===================================================================
RCS file: /cvs/gnome/evince/shell/ev-window.c,v
retrieving revision 1.43
diff -u -r1.43 ev-window.c
--- shell/ev-window.c	14 Jan 2005 00:10:12 -0000	1.43
+++ shell/ev-window.c	14 Jan 2005 00:27:32 -0000
@@ -178,29 +178,52 @@
 update_action_sensitivity (EvWindow *ev_window)
 {
 	EvDocument *document;
-	int n_pages;
-	int page;
 
 	document = ev_window->priv->document;
 
-	if (document)
-		n_pages = ev_document_get_n_pages (document);
-	else
-		n_pages = 1;
-
-	page = ev_view_get_page (EV_VIEW (ev_window->priv->view));
-
-	set_action_sensitive (ev_window, "GoFirstPage", page > 1);
-	set_action_sensitive (ev_window, "GoPageDown", page > 1);
-	set_action_sensitive (ev_window, "GoPageUp", page < n_pages);
-	set_action_sensitive (ev_window, "GoLastPage", page < n_pages);
+	/* File menu */
+	set_action_sensitive (ev_window, "FileSaveAs", document!=NULL);
+	set_action_sensitive (ev_window, "FilePrint", document!=NULL);
+
+        /* Edit menu */
+	set_action_sensitive (ev_window, "EditCopy", document!=NULL);
+	set_action_sensitive (ev_window, "EditSelectAll", document!=NULL);
 
 	if (document)
 		set_action_sensitive (ev_window, "EditFind", EV_IS_DOCUMENT_FIND (document));
 	else
 		set_action_sensitive (ev_window, "EditFind", FALSE);
 
-	
+        /* View menu */
+	set_action_sensitive (ev_window, "ViewZoomIn", document!=NULL);
+	set_action_sensitive (ev_window, "ViewZoomOut", document!=NULL);
+	set_action_sensitive (ev_window, "ViewNormalSize", document!=NULL);
+	set_action_sensitive (ev_window, "ViewBestFit", document!=NULL);
+	set_action_sensitive (ev_window, "ViewPageWidth", document!=NULL);
+
+        /* Go menu */
+	set_action_sensitive (ev_window, "GoBack", document!=NULL);
+	set_action_sensitive (ev_window, "GoForward", document!=NULL);
+	if (document) {
+		int n_pages;
+		int page;
+
+		page = ev_view_get_page (EV_VIEW (ev_window->priv->view));
+		n_pages = ev_document_get_n_pages (document);
+
+		set_action_sensitive (ev_window, "GoPageDown", page > 1);
+		set_action_sensitive (ev_window, "GoPageUp", page < n_pages);
+		set_action_sensitive (ev_window, "GoFirstPage", page > 1);
+		set_action_sensitive (ev_window, "GoLastPage", page < n_pages);
+	} else {
+		set_action_sensitive (ev_window, "GoFirstPage", FALSE);
+		set_action_sensitive (ev_window, "GoPageDown", FALSE);
+		set_action_sensitive (ev_window, "GoPageUp", FALSE);
+		set_action_sensitive (ev_window, "GoLastPage", FALSE);
+	}
+        
+	/* Help menu */
+	/* Nothing to do here */
 }
 
 void


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