[gedit/wip/gtkapp: 4/15] Remove the now unused SAVING_SESSION window state



commit 2ffff8111c5fb012a539d4412fd5a6feea87bee0
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Dec 22 23:59:28 2012 +0100

    Remove the now unused SAVING_SESSION window state

 gedit/gedit-app.c           |    4 +-
 gedit/gedit-commands-file.c |   15 ++----
 gedit/gedit-window.c        |  121 ++++++------------------------------------
 gedit/gedit-window.h        |    6 +--
 4 files changed, 25 insertions(+), 121 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index 8ff1bf9..f1dfbcf 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -455,9 +455,7 @@ window_delete_event (GeditWindow *window,
 	ws = gedit_window_get_state (window);
 
 	if (ws & 
-	    (GEDIT_WINDOW_STATE_SAVING |
-	     GEDIT_WINDOW_STATE_PRINTING |
-	     GEDIT_WINDOW_STATE_SAVING_SESSION))
+	    (GEDIT_WINDOW_STATE_SAVING | GEDIT_WINDOW_STATE_PRINTING))
 	{
 		return TRUE;
 	}
diff --git a/gedit/gedit-commands-file.c b/gedit/gedit-commands-file.c
index a47667c..c19416d 100644
--- a/gedit/gedit-commands-file.c
+++ b/gedit/gedit-commands-file.c
@@ -1017,8 +1017,7 @@ _gedit_cmd_file_save_documents_list (GeditWindow *window,
 	gedit_debug (DEBUG_COMMANDS);
 
 	g_return_if_fail (!(gedit_window_get_state (window) & 
-			    (GEDIT_WINDOW_STATE_PRINTING |
-			     GEDIT_WINDOW_STATE_SAVING_SESSION)));
+			    GEDIT_WINDOW_STATE_PRINTING));
 
 	l = docs;
 	while (l != NULL)
@@ -1853,8 +1852,7 @@ file_close_all (GeditWindow *window,
 
 	g_return_if_fail (!(gedit_window_get_state (window) &
 	                    (GEDIT_WINDOW_STATE_SAVING |
-	                     GEDIT_WINDOW_STATE_PRINTING |
-	                     GEDIT_WINDOW_STATE_SAVING_SESSION)));
+	                     GEDIT_WINDOW_STATE_PRINTING)));
 
 	g_object_set_data (G_OBJECT (window),
 			   GEDIT_IS_CLOSING_ALL,
@@ -1920,8 +1918,7 @@ _gedit_cmd_file_close_all (GtkAction   *action,
 
 	g_return_if_fail (!(gedit_window_get_state (window) &
 	                    (GEDIT_WINDOW_STATE_SAVING |
-	                    GEDIT_WINDOW_STATE_PRINTING |
-	                    GEDIT_WINDOW_STATE_SAVING_SESSION)));
+	                    GEDIT_WINDOW_STATE_PRINTING)));
 
 	file_close_all (window, FALSE);
 }
@@ -1948,8 +1945,7 @@ quit_all ()
 
 		if (!(gedit_window_get_state (window) &
 		                    (GEDIT_WINDOW_STATE_SAVING |
-		                     GEDIT_WINDOW_STATE_PRINTING |
-		                     GEDIT_WINDOW_STATE_SAVING_SESSION)))
+		                     GEDIT_WINDOW_STATE_PRINTING)))
 		{
 			file_close_all (window, TRUE);
 		}
@@ -1975,8 +1971,7 @@ _gedit_cmd_file_quit (GtkAction   *action,
 
 	g_return_if_fail (!(gedit_window_get_state (window) &
 	                    (GEDIT_WINDOW_STATE_SAVING |
-	                     GEDIT_WINDOW_STATE_PRINTING |
-	                     GEDIT_WINDOW_STATE_SAVING_SESSION)));
+	                     GEDIT_WINDOW_STATE_PRINTING)));
 
 	file_close_all (window, TRUE);
 }
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index a710cf2..b106dd8 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -2639,8 +2639,7 @@ set_sensitivity_according_to_window_state (GeditWindow *window)
 {
 	GtkAction *action;
 	GeditLockdownMask lockdown;
-	GeditNotebook *notebook;
-	gint i;
+	gint num_tabs;
 
 	lockdown = gedit_app_get_lockdown (gedit_app_get_default ());
 
@@ -2664,82 +2663,31 @@ set_sensitivity_according_to_window_state (GeditWindow *window)
 	gtk_action_set_sensitive (action, 
 				  !(window->priv->state & GEDIT_WINDOW_STATE_PRINTING) &&
 				  !(lockdown & GEDIT_LOCKDOWN_SAVE_TO_DISK));
-			
-	action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
-					      "FileNew");
-	gtk_action_set_sensitive (action, 
-				  !(window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION));
-				  
-	action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
-					      "FileOpen");
-	gtk_action_set_sensitive (action, 
-				  !(window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION));
 
-	gtk_action_group_set_sensitive (window->priv->recents_action_group,
-					!(window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION));
+	num_tabs = gedit_multi_notebook_get_n_tabs (window->priv->multi_notebook);
 
-	i = 0;
-	notebook = gedit_multi_notebook_get_nth_notebook (window->priv->multi_notebook, i);
-	while (notebook != NULL)
+	if (!gtk_action_group_get_sensitive (window->priv->action_group))
 	{
-		gedit_notebook_set_close_buttons_sensitive (notebook,
-							    !(window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION));
-		notebook = gedit_multi_notebook_get_nth_notebook (window->priv->multi_notebook,
-								  ++i);
+		gtk_action_group_set_sensitive (window->priv->action_group,
+						num_tabs > 0);
 	}
 
-	if ((window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION) != 0)
+	if (!gtk_action_group_get_sensitive (window->priv->quit_action_group))
 	{
-		/* TODO: If we really care, Find could be active
-		 * when in SAVING_SESSION state */
-
-		if (gtk_action_group_get_sensitive (window->priv->action_group))
-		{
-			gtk_action_group_set_sensitive (window->priv->action_group,
-							FALSE);
-		}
-		
-		if (gtk_action_group_get_sensitive (window->priv->quit_action_group))
-		{
-			gtk_action_group_set_sensitive (window->priv->quit_action_group,
-							FALSE);
-		}
-		
-		if (gtk_action_group_get_sensitive (window->priv->close_action_group))
-		{
-			gtk_action_group_set_sensitive (window->priv->close_action_group,
-							FALSE);
-		}
+		gtk_action_group_set_sensitive (window->priv->quit_action_group,
+						num_tabs > 0);
 	}
-	else
-	{
-		gint num_tabs;
-
-		num_tabs = gedit_multi_notebook_get_n_tabs (window->priv->multi_notebook);
 
-		if (!gtk_action_group_get_sensitive (window->priv->action_group))
-		{
-			gtk_action_group_set_sensitive (window->priv->action_group,
-							num_tabs > 0);
-		}
-		
-		if (!gtk_action_group_get_sensitive (window->priv->quit_action_group))
-		{
-			gtk_action_group_set_sensitive (window->priv->quit_action_group,
-							num_tabs > 0);
-		}
-		
-		if (!gtk_action_group_get_sensitive (window->priv->close_action_group))
-		{
+	if (!gtk_action_group_get_sensitive (window->priv->close_action_group))
+	{
 #ifdef OS_OSX
-			/* On OS X, File Close is always sensitive */
-			gtk_action_group_set_sensitive (window->priv->close_action_group,
-							TRUE);
+		/* On OS X, File Close is always sensitive */
+		gtk_action_group_set_sensitive (window->priv->close_action_group,
+						TRUE);
 #else
-			gtk_action_group_set_sensitive (window->priv->close_action_group,
-							num_tabs > 0);
+		gtk_action_group_set_sensitive (window->priv->close_action_group,
+						num_tabs > 0);
 #endif
-		}
 	}
 }
 
@@ -2825,8 +2773,7 @@ update_window_state (GeditWindow *window)
 	old_ws = window->priv->state;
 	old_num_of_errors = window->priv->num_tabs_with_error;
 	
-	window->priv->state = old_ws & GEDIT_WINDOW_STATE_SAVING_SESSION;
-	
+	window->priv->state = 0;
 	window->priv->num_tabs_with_error = 0;
 
 	gedit_multi_notebook_foreach_tab (window->priv->multi_notebook,
@@ -2948,9 +2895,6 @@ get_drop_window (GtkWidget *widget)
 
 	target_window = gtk_widget_get_toplevel (widget);
 	g_return_val_if_fail (GEDIT_IS_WINDOW (target_window), NULL);
-
-	if ((GEDIT_WINDOW(target_window)->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION) != 0)
-		return NULL;
 	
 	return GEDIT_WINDOW (target_window);
 }
@@ -3413,8 +3357,6 @@ on_tab_added (GeditMultiNotebook *multi,
 
 	gedit_debug (DEBUG_WINDOW);
 
-	g_return_if_fail ((window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION) == 0);
-
 	num_notebooks = gedit_multi_notebook_get_n_notebooks (multi);
 	num_tabs = gedit_multi_notebook_get_n_tabs (multi);
 
@@ -3501,8 +3443,6 @@ on_tab_removed (GeditMultiNotebook *multi,
 
 	gedit_debug (DEBUG_WINDOW);
 
-	g_return_if_fail ((window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION) == 0);
-
 	num_notebooks = gedit_multi_notebook_get_n_notebooks (multi);
 	num_tabs = gedit_multi_notebook_get_n_tabs (multi);
 
@@ -4558,8 +4498,7 @@ void
 gedit_window_close_all_tabs (GeditWindow *window)
 {
 	g_return_if_fail (GEDIT_IS_WINDOW (window));
-	g_return_if_fail (!(window->priv->state & GEDIT_WINDOW_STATE_SAVING) &&
-			  !(window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION));
+	g_return_if_fail (!(window->priv->state & GEDIT_WINDOW_STATE_SAVING));
 
 	window->priv->removing_tabs = TRUE;
 
@@ -4580,8 +4519,7 @@ gedit_window_close_tabs (GeditWindow *window,
 			 const GList *tabs)
 {
 	g_return_if_fail (GEDIT_IS_WINDOW (window));
-	g_return_if_fail (!(window->priv->state & GEDIT_WINDOW_STATE_SAVING) &&
-			  !(window->priv->state & GEDIT_WINDOW_STATE_SAVING_SESSION));
+	g_return_if_fail (!(window->priv->state & GEDIT_WINDOW_STATE_SAVING));
 
 	window->priv->removing_tabs = TRUE;
 
@@ -4813,29 +4751,6 @@ _gedit_window_get_all_tabs (GeditWindow *window)
 	return gedit_multi_notebook_get_all_tabs (window->priv->multi_notebook);
 }
 
-void 
-_gedit_window_set_saving_session_state (GeditWindow *window,
-					gboolean     saving_session)
-{
-	GeditWindowState old_state;
-
-	g_return_if_fail (GEDIT_IS_WINDOW (window));
-	
-	old_state = window->priv->state;
-
-	if (saving_session)
-		window->priv->state |= GEDIT_WINDOW_STATE_SAVING_SESSION;
-	else
-		window->priv->state &= ~GEDIT_WINDOW_STATE_SAVING_SESSION;
-
-	if (old_state != window->priv->state)
-	{
-		set_sensitivity_according_to_window_state (window);
-
-		g_object_notify (G_OBJECT (window), "state");
-	}
-}
-
 static void
 hide_notebook_tabs_on_fullscreen (GtkNotebook	*notebook, 
 				  GParamSpec	*pspec,
diff --git a/gedit/gedit-window.h b/gedit/gedit-window.h
index 16ad51f..9ae0883 100644
--- a/gedit/gedit-window.h
+++ b/gedit/gedit-window.h
@@ -46,8 +46,7 @@ typedef enum
 	GEDIT_WINDOW_STATE_SAVING		= 1 << 1,
 	GEDIT_WINDOW_STATE_PRINTING		= 1 << 2,
 	GEDIT_WINDOW_STATE_LOADING		= 1 << 3,
-	GEDIT_WINDOW_STATE_ERROR		= 1 << 4,
-	GEDIT_WINDOW_STATE_SAVING_SESSION	= 1 << 5
+	GEDIT_WINDOW_STATE_ERROR		= 1 << 4
 } GeditWindowState;
 
 #define GEDIT_TYPE_WINDOW              (gedit_window_get_type())
@@ -166,9 +165,6 @@ GFile		*_gedit_window_get_default_location 	(GeditWindow         *window);
 void		 _gedit_window_set_default_location 	(GeditWindow         *window,
 							 GFile               *location);
 
-void		 _gedit_window_set_saving_session_state	(GeditWindow         *window,
-							 gboolean             saving_session);
-
 void		 _gedit_window_fullscreen		(GeditWindow         *window);
 
 void		 _gedit_window_unfullscreen		(GeditWindow         *window);



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