[pitivi: 8/65] encodingdialog: Show a warning icon and tooltip when the output file already exists



commit c7d458eaf872a1b7a39e423da727da053e5ee0e7
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Sun Jun 19 21:51:23 2011 -0400

    encodingdialog: Show a warning icon and tooltip when the output file already exists
    
    Fixes bug #594485

 data/ui/encodingdialog.ui   |    2 ++
 pitivi/ui/encodingdialog.py |   22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/encodingdialog.ui b/data/ui/encodingdialog.ui
index f985e90..2aaef21 100644
--- a/data/ui/encodingdialog.ui
+++ b/data/ui/encodingdialog.ui
@@ -152,6 +152,7 @@
                             <property name="AtkObject::accessible-name" translatable="yes">Folder</property>
                           </object>
                         </child>
+                        <signal name="current-folder-changed" handler="_checkForExistingFile" swapped="no"/>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -235,6 +236,7 @@
                             <property name="AtkObject::accessible-name" translatable="yes">File name</property>
                           </object>
                         </child>
+                        <signal name="changed" handler="_checkForExistingFile" swapped="no"/>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
diff --git a/pitivi/ui/encodingdialog.py b/pitivi/ui/encodingdialog.py
index ff30909..e3212f0 100644
--- a/pitivi/ui/encodingdialog.py
+++ b/pitivi/ui/encodingdialog.py
@@ -27,6 +27,7 @@ import os
 import gtk
 import gst
 import pango
+from gettext import gettext as _
 
 from pitivi import configure
 from pitivi.settings import ExportSettings
@@ -214,6 +215,27 @@ class EncodingDialog(Renderer, Loggable):
         self.filebutton.set_current_folder(self.app.settings.lastExportFolder)
         self.updateFilename(self.project.name)
 
+    def _checkForExistingFile(self, *args):
+        """
+        Display a warning icon and tooltip if the file path already exists.
+        """
+        path = self.filebutton.get_current_folder()
+        if not path:
+            # This happens when the window is initialized.
+            return
+        warning_icon = gtk.STOCK_DIALOG_WARNING
+        filename = self.fileentry.get_text()
+        if not filename:
+            tooltip_text = _("A file name is required.")
+        elif filename and os.path.exists(os.path.join(path, filename)):
+            tooltip_text = _("This file already exists.\n"
+                             "If you don't want to overwrite it, choose a "
+                             "different file name or folder.")
+        else:
+            warning_icon = None
+            tooltip_text = None
+        self.fileentry.set_icon_from_stock(1, warning_icon)
+        self.fileentry.set_icon_tooltip_text(1, tooltip_text)
 
     def updateFilename(self, basename):
         """Updates the filename UI element to show the specified file name."""



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