[gtranslator] Implemented close_all action.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtranslator] Implemented close_all action.
- Date: Tue, 18 Aug 2009 20:14:23 +0000 (UTC)
commit c9afca43ae89b2e04f292c9d8694c5d55b5b4ce6
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Tue Aug 18 13:36:10 2009 +0200
Implemented close_all action.
src/actions-file.c | 108 ++++++++++++++++++++++++++++++++++------------------
src/actions.h | 3 +
src/window.c | 2 +-
3 files changed, 75 insertions(+), 38 deletions(-)
---
diff --git a/src/actions-file.c b/src/actions-file.c
index 28815c9..61a1b0e 100644
--- a/src/actions-file.c
+++ b/src/actions-file.c
@@ -693,6 +693,68 @@ gtranslator_file_close (GtkAction * widget,
gtranslator_close_tab (tab, window);
}
+static GList *
+get_modified_documents (GtranslatorWindow *window)
+{
+ GtranslatorNotebook *nb;
+ GtranslatorTab *tab;
+ GtranslatorPo *po;
+ gint pages;
+ GList *list = NULL;
+
+ nb = gtranslator_window_get_notebook (window);
+ pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
+
+ while (pages > 0)
+ {
+ tab = GTR_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (nb),
+ pages - 1));
+
+ po = gtranslator_tab_get_po (tab);
+ if (gtranslator_po_get_state (po) == GTR_PO_STATE_MODIFIED)
+ list = g_list_prepend (list, po);
+
+ pages--;
+ }
+
+ return list;
+}
+
+static void
+close_all_documents (GtranslatorWindow *window,
+ gboolean logout_mode)
+{
+ GList *list;
+
+ list = get_modified_documents (window);
+
+ if (list != NULL)
+ {
+ GtkWidget *dlg;
+
+ dlg = gtranslator_close_confirmation_dialog_new (GTK_WINDOW (window),
+ list, logout_mode);
+
+ g_signal_connect (dlg,
+ "response",
+ G_CALLBACK (close_confirmation_dialog_response_handler),
+ window);
+
+ g_list_free (list);
+
+ gtk_widget_show (dlg);
+ }
+ else
+ {
+ close_all_tabs (window);
+
+ if (logout_mode)
+ {
+ gtk_widget_destroy (GTK_WIDGET (window));
+ }
+ }
+}
+
void
gtranslator_file_quit (GtkAction *action,
GtranslatorWindow *window)
@@ -744,52 +806,24 @@ gtranslator_file_quit (GtkAction *action,
}
else
{
- g_warning (N_("Failed to write profile data into profiles file '%s'"), filename);
- }
+ g_warning (_("Failed to write profile data into profiles file '%s'"), filename);
+ }
}
g_free (config_folder);
g_object_unref (file_temp);
g_object_unref (file);
- nb = gtranslator_window_get_notebook (window);
- pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK(nb));
-
- while (pages > 0)
- {
- tab = GTR_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (nb),
- pages - 1));
-
- po = gtranslator_tab_get_po (tab);
- if (gtranslator_po_get_state (po) == GTR_PO_STATE_MODIFIED)
- list = g_list_prepend (list, po);
-
- pages--;
- }
-
g_object_set_data (G_OBJECT (window),
GTR_IS_CLOSING_ALL,
GINT_TO_POINTER (1));
- if (list != NULL)
- {
- GtkWidget *dlg;
-
- dlg = gtranslator_close_confirmation_dialog_new (GTK_WINDOW (window),
- list, TRUE);
-
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (close_confirmation_dialog_response_handler),
- window);
-
- g_list_free (list);
+ close_all_documents (window, TRUE);
+}
- gtk_widget_show (dlg);
- }
- else {
- close_all_tabs (window);
-
- gtk_widget_destroy (GTK_WIDGET (window));
- }
+void
+_gtranslator_file_close_all (GtkAction *action,
+ GtranslatorWindow *window)
+{
+ close_all_documents (window, FALSE);
}
diff --git a/src/actions.h b/src/actions.h
index 75e47ad..41e38d2 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -51,6 +51,9 @@ void gtranslator_file_quit (GtkAction *action,
void gtranslator_actions_load_locations (GtranslatorWindow *window,
const GSList *locations);
+void _gtranslator_file_close_all (GtkAction *action,
+ GtranslatorWindow *window);
+
/*Edit*/
void gtranslator_actions_edit_undo (GtkAction *action,
GtranslatorWindow *window);
diff --git a/src/window.c b/src/window.c
index f9a000f..3759c9d 100644
--- a/src/window.c
+++ b/src/window.c
@@ -280,7 +280,7 @@ static const GtkActionEntry entries[] = {
{ "FileSaveAll", GTK_STOCK_SAVE, N_("_Save All"), "<shift><control>L",
N_("Save all open files"), NULL }, //G_CALLBACK (_gedit_cmd_file_save_all) },
{ "FileCloseAll", GTK_STOCK_CLOSE, N_("_Close All"), "<shift><control>W",
- N_("Close all open files"), NULL }, //G_CALLBACK (_gedit_cmd_file_close_all) },
+ N_("Close all open files"), G_CALLBACK (_gtranslator_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]