[gtranslator] Implemented save_all action.



commit 1a542897275cb056f0d53e755d3761b70947d560
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue Aug 18 22:10:46 2009 +0200

    Implemented save_all action.

 src/actions-file.c |   46 ++++++++++++++++++++++++++++++++++++++++++++--
 src/actions.h      |    5 ++++-
 src/window.c       |    4 ++--
 3 files changed, 50 insertions(+), 5 deletions(-)
---
diff --git a/src/actions-file.c b/src/actions-file.c
index 61a1b0e..ea83405 100644
--- a/src/actions-file.c
+++ b/src/actions-file.c
@@ -822,8 +822,50 @@ gtranslator_file_quit (GtkAction *action,
 }
 
 void
-_gtranslator_file_close_all (GtkAction *action,
-			     GtranslatorWindow *window)
+_gtranslator_actions_file_close_all (GtkAction *action,
+				     GtranslatorWindow *window)
 {
 	close_all_documents (window, FALSE);
 }
+
+void
+_gtranslator_actions_file_save_all (GtkAction *action,
+				    GtranslatorWindow *window)
+{
+	GList *list, *l;
+	
+	list = get_modified_documents (window);
+	
+	for (l = list; l != NULL; l = g_list_next (l))
+	{
+		GError *error = NULL;
+		GtranslatorStatusbar *status;
+	
+		gtranslator_po_save_file (GTR_PO (l->data), &error);
+		
+		if (error)
+		{
+			GtkWidget *dialog;
+			
+			dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+							 GTK_DIALOG_DESTROY_WITH_PARENT,
+							 GTK_MESSAGE_WARNING,
+							 GTK_BUTTONS_OK,
+							 "%s", error->message);
+			gtk_dialog_run (GTK_DIALOG (dialog));
+			gtk_widget_destroy (dialog);
+			g_clear_error (&error);
+			
+			return;
+		}
+	
+		/* We have to change the state of the tab */
+		gtranslator_po_set_state (GTR_PO (l->data), GTR_PO_STATE_SAVED);
+	
+		/* Flash a message */
+		status = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
+		gtranslator_statusbar_flash_message (status, 0, _("Files saved."));
+	}
+	
+	g_list_free (list);
+}
diff --git a/src/actions.h b/src/actions.h
index 41e38d2..6c47f66 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -51,7 +51,10 @@ void       gtranslator_file_quit                (GtkAction *action,
 void       gtranslator_actions_load_locations   (GtranslatorWindow *window,
 						 const GSList      *locations);
 
-void      _gtranslator_file_close_all           (GtkAction *action,
+void      _gtranslator_actions_file_close_all   (GtkAction *action,
+						 GtranslatorWindow *window);
+
+void      _gtranslator_actions_file_save_all    (GtkAction *action,
 						 GtranslatorWindow *window);
 
 /*Edit*/
diff --git a/src/window.c b/src/window.c
index 3759c9d..728ed8b 100644
--- a/src/window.c
+++ b/src/window.c
@@ -278,9 +278,9 @@ static const GtkActionEntry entries[] = {
 	
 	/* Documents menu */
 	{ "FileSaveAll", GTK_STOCK_SAVE, N_("_Save All"), "<shift><control>L",
-	  N_("Save all open files"), NULL }, //G_CALLBACK (_gedit_cmd_file_save_all) },
+	  N_("Save all open files"), G_CALLBACK (_gtranslator_actions_file_save_all) },
 	{ "FileCloseAll", GTK_STOCK_CLOSE, N_("_Close All"), "<shift><control>W",
-	  N_("Close all open files"), G_CALLBACK (_gtranslator_file_close_all) },
+	  N_("Close all open files"), G_CALLBACK (_gtranslator_actions_file_close_all) },
 	{ "DocumentsPreviousDocument", NULL, N_("_Previous Document"), "<alt><control>Page_Up",
 	  N_("Activate previous document"), G_CALLBACK (gtranslator_actions_documents_previous_document) },
 	{ "DocumentsNextDocument", NULL, N_("_Next Document"), "<alt><control>Page_Down",



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