[nautilus-actions: 23/45] Update count modified actions



commit 080e0635b2ae6d5ef8ffff4b09d14425fa2843fc
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Jul 27 05:50:52 2009 +0200

    Update count modified actions

 ChangeLog                   |    8 +++++
 src/nact/nact-main-window.c |   18 +++++++++-
 src/nact/nact-window.c      |   72 ++++--------------------------------------
 src/nact/nact-window.h      |    7 +---
 4 files changed, 32 insertions(+), 73 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 71f063e..aad09d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,9 +4,17 @@
 	* src/common/na-utils.h (na_utils_path_to_key):
 	New function moved from na-gconf.c.
 
+	* src/nact/nact-window.c:
+	* src/nact/nact-window.h
+	(nact_window_set_current_action, nact_window_warn_action_modified,
+	nact_window_warn_profile_modified): Removed functions.
+
 	* src/nact/nact-gconf-reader.c:
 	Import the two new export formats.
 
+	* src/nact/nact-main-window.c:
+	Update count_modified_actions.
+
 2009-07-26 Pierre Wieser <pwieser trychlos org>
 
 	* src/common/na-action.h:
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index c800261..32661c8 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -1072,6 +1072,14 @@ count_actions( NactWindow *window )
 	return( g_slist_length( NACT_MAIN_WINDOW( window )->private->actions ));
 }
 
+/*
+ * exact count of modified actions is subject to some approximation
+ * 1. counting the actions currently in the list is ok
+ * 2. what about deleted actions ?
+ *    we can create any new actions, deleting them, and so on
+ *    if we have eventually deleted all newly created actions, then the
+ *    final count of modified actions should be zero... don't it ?
+ */
 static gint
 count_modified_actions( NactWindow *window )
 {
@@ -1080,9 +1088,15 @@ count_modified_actions( NactWindow *window )
 			return( 0 );
 	}
 
-	gint count = g_slist_length( NACT_MAIN_WINDOW( window )->private->deleted );
-
 	GSList *ia;
+	gint count = 0;
+
+	for( ia = NACT_MAIN_WINDOW( window )->private->deleted ; ia ; ia = ia->next ){
+		if( na_object_get_origin( NA_OBJECT( ia->data )) != NULL ){
+			count += 1;
+		}
+	}
+
 	for( ia = NACT_MAIN_WINDOW( window )->private->actions ; ia ; ia = ia->next ){
 		if( is_modified_action( window, NA_ACTION( ia->data ))){
 			count += 1;
diff --git a/src/nact/nact-window.c b/src/nact/nact-window.c
index ee86e0d..08d4ffa 100644
--- a/src/nact/nact-window.c
+++ b/src/nact/nact-window.c
@@ -238,13 +238,13 @@ nact_window_get_pivot( NactWindow *window )
  * This is called by one of the editors to advertize the main window
  * that the newly selected action has changed.
  */
-void
+/*void
 nact_window_set_current_action( NactWindow *window, const NAAction *action )
 {
 	if( NACT_WINDOW_GET_CLASS( window )->set_current_action ){
 		NACT_WINDOW_GET_CLASS( window )->set_current_action( window, action );
 	}
-}
+}*/
 
 /**
  * Saves a modified action to the I/O storage subsystem.
@@ -314,6 +314,9 @@ nact_window_delete_action( NactWindow *window, NAAction *action )
  * @count
  *
  * Returns TRUE if the user confirms he wants to quit.
+ *
+ * Note: the count of modified actions is subject to some approximation.
+ * So, just say that 'actions have been modified'
  */
 gboolean
 nact_window_warn_count_modified( NactWindow *window, gint count )
@@ -324,7 +327,8 @@ nact_window_warn_count_modified( NactWindow *window, gint count )
 		first = g_strdup_printf( _( "One action has been modified." ));
 		second = g_strdup( _( "Are you sure you want to quit without saving it ?" ));
 	} else {
-		first = g_strdup_printf( _( "%d actions have been modified." ), count );
+		/*first = g_strdup_printf( _( "%d actions have been modified." ), count );*/
+		first = g_strdup_printf( _( "Actions have been modified." ));
 		second = g_strdup( _( "Are you sure you want to quit without saving them ?" ));
 	}
 
@@ -337,68 +341,6 @@ nact_window_warn_count_modified( NactWindow *window, gint count )
 }
 
 /**
- * Emits a warning if the action has been modified.
- *
- * @window: this NactWindow object.
- *
- * @action: the modified action.
- *
- * Returns TRUE if the user confirms he wants to quit.
- */
-gboolean
-nact_window_warn_action_modified( NactWindow *window, const NAAction *action )
-{
-	gchar *label = na_action_get_label( action );
-
-	gchar *first;
-	if( label && strlen( label )){
-		first = g_strdup_printf( _( "The action \"%s\" has been modified." ), label );
-	} else {
-		first = g_strdup( _( "The newly created action has been modified." ));
-	}
-	gchar *second = g_strdup( _( "Are you sure you want to quit without saving it ?" ));
-
-	gboolean ok = base_window_yesno_dlg( BASE_WINDOW( window ), GTK_MESSAGE_QUESTION, first, second );
-
-	g_free( second );
-	g_free( first );
-	g_free( label );
-
-	return( ok );
-}
-
-/**
- * Emits a warning if the profile has been modified.
- *
- * @window: this NactWindow object.
- *
- * @profile: the modified profile.
- *
- * Returns TRUE if the user confirms he wants to quit.
- */
-gboolean
-nact_window_warn_profile_modified( NactWindow *window, const NAActionProfile *profile )
-{
-	gchar *label = na_action_profile_get_label( profile );
-
-	gchar *first;
-	if( label && strlen( label )){
-		first = g_strdup_printf( _( "The profile \"%s\" has been modified." ), label );
-	} else {
-		first = g_strdup( _( "The newly created profile has been modified." ));
-	}
-	gchar *second = g_strdup( _( "Are you sure you want to quit without saving it ?" ));
-
-	gboolean ok = base_window_yesno_dlg( BASE_WINDOW( window ), GTK_MESSAGE_QUESTION, first, second );
-
-	g_free( second );
-	g_free( first );
-	g_free( label );
-
-	return( ok );
-}
-
-/**
  * Records a connected signal, to be disconnected at NactWindow dispose.
  */
 void
diff --git a/src/nact/nact-window.h b/src/nact/nact-window.h
index aadca3f..c92a1c0 100644
--- a/src/nact/nact-window.h
+++ b/src/nact/nact-window.h
@@ -77,16 +77,11 @@ GType    nact_window_get_type( void );
 
 NAPivot *nact_window_get_pivot( NactWindow *window );
 
-/* TODO: check these functions */
-void     nact_window_set_current_action( NactWindow *window, const NAAction *action );
+/*void     nact_window_set_current_action( NactWindow *window, const NAAction *action );*/
 gboolean nact_window_save_action( NactWindow *window, NAAction *action );
 gboolean nact_window_delete_action( NactWindow *window, NAAction *action );
 
-/* TODO: move the function to nact-main-window */
 gboolean nact_window_warn_count_modified( NactWindow *window, gint count );
-/* TODO: remove the function */
-gboolean nact_window_warn_action_modified( NactWindow *window, const NAAction *action );
-gboolean nact_window_warn_profile_modified( NactWindow *window, const NAActionProfile *profile );
 
 void     nact_window_signal_connect( NactWindow *window, GObject *instance, const gchar *signal, GCallback fn );
 void     nact_window_signal_connect_by_name( NactWindow *window, const gchar *name, const gchar *signal, GCallback fn );



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