Updating branch refs/heads/master
         to 1d7bef769029aae39ddcecb6c529177393363dcf (commit)
       from f67680befa81f562943b591a7143e25baea1fb17 (commit)

commit 1d7bef769029aae39ddcecb6c529177393363dcf
Author: Nick Schermer <n...@xfce.org>
Date:   Sat Dec 8 10:46:08 2007 +0000

        * mousepad/mousepad-{dialog,window}.c: Show save as button in
          question dialog for readonly documents. Also add the modified
          readonly documents to the save-as queue when running save all.
    
    (Old svn revision: 26451)

 ChangeLog                   |    7 +++++++
 mousepad/mousepad-dialogs.c |   39 ++++++++++++++++++++++-----------------
 mousepad/mousepad-dialogs.h |    3 ++-
 mousepad/mousepad-window.c  |   13 +++++++++++--
 4 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 724b54b..2c1a270 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2007-12-08     Nick Schermer <n...@xfce.org>
 
+       * mousepad/mousepad-{dialog,window}.c: Show save as button in
+         question dialog for readonly documents. Also add the modified
+         readonly documents to the save-as queue when running save all.
+
+
+2007-12-08     Nick Schermer <n...@xfce.org>
+
        * mousepad/mousepad-{search-bar,window}.c: Remove highlight when
          hiding the search bar. Search ahead when opening the search bar.
 
diff --git a/mousepad/mousepad-dialogs.c b/mousepad/mousepad-dialogs.c
index adaffc3..3ec9dad 100644
--- a/mousepad/mousepad-dialogs.c
+++ b/mousepad/mousepad-dialogs.c
@@ -350,36 +350,41 @@ mousepad_dialogs_clear_recent (GtkWindow *parent)
 
 
 gint
-mousepad_dialogs_save_changes (GtkWindow *parent)
+mousepad_dialogs_save_changes (GtkWindow *parent,
+                               gboolean   readonly)
 {
   GtkWidget *dialog;
   GtkWidget *image;
   gint       response;
 
-  /* the dialog icon */
-  image = gtk_image_new_from_stock (GTK_STOCK_SAVE, GTK_ICON_SIZE_DIALOG);
-  gtk_widget_show (image);
-
   /* create the question dialog */
   dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL | 
GTK_DIALOG_DESTROY_WITH_PARENT,
                                    GTK_MESSAGE_OTHER, GTK_BUTTONS_NONE,
                                    _("Do you want to save the changes before 
closing?"));
+  gtk_window_set_title (GTK_WINDOW (dialog), _("Save Changes"));
+  gtk_dialog_add_action_widget (GTK_DIALOG (dialog), 
mousepad_util_image_button (GTK_STOCK_DELETE, _("_Don't Save")), 
MOUSEPAD_RESPONSE_DONT_SAVE);
+  gtk_dialog_add_buttons (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, 
MOUSEPAD_RESPONSE_CANCEL, NULL);
 
-  gtk_dialog_add_action_widget (GTK_DIALOG (dialog),
-                                mousepad_util_image_button (GTK_STOCK_DELETE, 
_("_Don't Save")),
-                                MOUSEPAD_RESPONSE_DONT_SAVE);
-
-  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
-                          GTK_STOCK_CANCEL, MOUSEPAD_RESPONSE_CANCEL,
-                          GTK_STOCK_SAVE, MOUSEPAD_RESPONSE_SAVE,
-                          NULL);
+  /* we show the save as button instead of save for readonly document */
+  if (G_UNLIKELY (readonly))
+    {
+      image = gtk_image_new_from_stock (GTK_STOCK_SAVE_AS, 
GTK_ICON_SIZE_DIALOG);
+      gtk_dialog_add_buttons (GTK_DIALOG (dialog), GTK_STOCK_SAVE_AS, 
MOUSEPAD_RESPONSE_SAVE_AS, NULL);
+      gtk_dialog_set_default_response (GTK_DIALOG (dialog), 
MOUSEPAD_RESPONSE_SAVE_AS);
+    }
+  else
+    {
+      image = gtk_image_new_from_stock (GTK_STOCK_SAVE, GTK_ICON_SIZE_DIALOG);
+      gtk_dialog_add_buttons (GTK_DIALOG (dialog), GTK_STOCK_SAVE, 
MOUSEPAD_RESPONSE_SAVE, NULL);
+      gtk_dialog_set_default_response (GTK_DIALOG (dialog), 
MOUSEPAD_RESPONSE_SAVE);
+    }
 
-  gtk_window_set_title (GTK_WINDOW (dialog), _("Save Changes"));
+  /* the dialog icon */
   gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image);
-  gtk_dialog_set_default_response (GTK_DIALOG (dialog), 
MOUSEPAD_RESPONSE_SAVE);
+  gtk_widget_show (image);
 
-  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                            _("If you don't save the document, 
all the changes will be lost."));
+  /* secondary text */
+  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("If 
you don't save the document, all the changes will be lost."));
 
   /* run the dialog and wait for a response */
   response = gtk_dialog_run (GTK_DIALOG (dialog));
diff --git a/mousepad/mousepad-dialogs.h b/mousepad/mousepad-dialogs.h
index 5ecfc15..de24257 100644
--- a/mousepad/mousepad-dialogs.h
+++ b/mousepad/mousepad-dialogs.h
@@ -58,7 +58,8 @@ gboolean   mousepad_dialogs_go_to          (GtkWindow     
*parent,
 
 gboolean   mousepad_dialogs_clear_recent   (GtkWindow     *parent);
 
-gint       mousepad_dialogs_save_changes   (GtkWindow     *parent);
+gint       mousepad_dialogs_save_changes   (GtkWindow     *parent,
+                                            gboolean       readonly);
 
 gint       mousepad_dialogs_revert         (GtkWindow     *parent);
 
diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c
index 9defb9d..34ba8a4 100644
--- a/mousepad/mousepad-window.c
+++ b/mousepad/mousepad-window.c
@@ -1177,6 +1177,7 @@ mousepad_window_close_document (MousepadWindow   *window,
 {
   gboolean succeed = FALSE;
   gint     response;
+  gboolean readonly;
 
   _mousepad_return_val_if_fail (MOUSEPAD_IS_WINDOW (window), FALSE);
   _mousepad_return_val_if_fail (MOUSEPAD_IS_DOCUMENT (document), FALSE);
@@ -1184,8 +1185,11 @@ mousepad_window_close_document (MousepadWindow   *window,
   /* check if the document has been modified */
   if (gtk_text_buffer_get_modified (document->buffer))
     {
+      /* whether the file is readonly */
+      readonly = mousepad_file_get_read_only (document->file);
+
       /* run save changes dialog */
-      response = mousepad_dialogs_save_changes (GTK_WINDOW (window));
+      response = mousepad_dialogs_save_changes (GTK_WINDOW (window), readonly);
 
       switch (response)
         {
@@ -1201,6 +1205,10 @@ mousepad_window_close_document (MousepadWindow   *window,
           case MOUSEPAD_RESPONSE_SAVE:
             succeed = mousepad_window_action_save (NULL, window);
             break;
+
+          case MOUSEPAD_RESPONSE_SAVE_AS:
+            succeed = mousepad_window_action_save_as (NULL, window);
+            break;
         }
     }
   else
@@ -3371,7 +3379,8 @@ mousepad_window_action_save_all (GtkAction      *action,
       if (!gtk_text_buffer_get_modified (MOUSEPAD_DOCUMENT (document)->buffer))
         continue;
 
-      if (mousepad_file_get_filename (MOUSEPAD_DOCUMENT (document)->file) == 
NULL)
+      if (mousepad_file_get_filename (MOUSEPAD_DOCUMENT (document)->file) == 
NULL ||
+          mousepad_file_get_read_only ((MOUSEPAD_DOCUMENT (document)->file)))
         {
           /* add the document to a queue to bother the user later */
           unnamed = g_slist_prepend (unnamed, document);
_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to