Use the GtkFileChooserDialog widget (new in GTK 2.4) instead of
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 3 Feb 2005 21:54:55 +0000 (21:54 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 3 Feb 2005 21:54:55 +0000 (21:54 +0000)
GtkFileSelection.

src/gkofoto/gkofoto/generatehtmldialog.py
src/gkofoto/gkofoto/handleimagesdialog.py
src/gkofoto/gkofoto/registerimagesdialog.py

index f6022d4..6044f25 100644 (file)
@@ -34,17 +34,14 @@ class GenerateHTMLDialog:
 
     def _onBrowse(self, *unused):
         directorySelectedInDirList = False
-        dirDialog = gtk.FileSelection(title="Choose directory")
-        dirDialog.file_list.set_sensitive(False)
-        dirDialog.fileop_del_file.set_sensitive(False)
-        dirDialog.fileop_ren_file.set_sensitive(False)
+        dirDialog = gtk.FileChooserDialog(
+            title="Choose directory",
+            action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
+            buttons=(
+                gtk.STOCK_OK, gtk.RESPONSE_OK,
+                gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
         if dirDialog.run() == gtk.RESPONSE_OK:
-            model, iterator = dirDialog.dir_list.get_selection().get_selected()
-            directory = dirDialog.get_filename()
-            if iterator:
-                directory = os.path.join(
-                    directory, model.get_value(iterator, 0))
-            self.directoryTextEntry.set_text(directory)
+            self.directoryTextEntry.set_text(dirDialog.get_filename())
         dirDialog.destroy()
 
     def _onCancel(self, *unused):
index a2a29e5..ea5c6f4 100644 (file)
@@ -8,13 +8,20 @@ from kofoto.shelf import \
      makeValidTag
 from kofoto.clientutils import walk_files
 
-class HandleImagesDialog(gtk.FileSelection):
+class HandleImagesDialog(gtk.FileChooserDialog):
     def __init__(self):
-        gtk.FileSelection.__init__(self, title="Register images")
-        self.set_select_multiple(True)
-        self.ok_button.connect("clicked", self._ok)
+        gtk.FileChooserDialog.__init__(
+            self,
+            title="Handle images",
+            action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
+            buttons=(
+                gtk.STOCK_OK, gtk.RESPONSE_OK,
+                gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+        self.connect("response", self._response)
 
-    def _ok(self, widget):
+    def _response(self, widget, responseId):
+        if responseId == gtk.RESPONSE_CANCEL:
+            return
         widgets = gtk.glade.XML(env.gladeFile, "handleImagesProgressDialog")
         handleImagesProgressDialog = widgets.get_widget(
             "handleImagesProgressDialog")
@@ -40,7 +47,7 @@ class HandleImagesDialog(gtk.FileSelection):
         investigatedFiles = 0
         modifiedImages = []
         movedImages = []
-        for filepath in walk_files(self.get_selections()):
+        for filepath in walk_files([self.get_filename()]):
             try:
                 filepath = filepath.decode("utf-8")
             except UnicodeDecodeError:
index 1dd0e23..316c61f 100644 (file)
@@ -5,14 +5,21 @@ from environment import env
 from kofoto.shelf import ImageExistsError, NotAnImageError, makeValidTag
 from kofoto.clientutils import walk_files
 
-class RegisterImagesDialog(gtk.FileSelection):
+class RegisterImagesDialog(gtk.FileChooserDialog):
     def __init__(self, albumToAddTo=None):
-        gtk.FileSelection.__init__(self, title="Register images")
+        gtk.FileChooserDialog.__init__(
+            self,
+            title="Register images",
+            action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
+            buttons=(
+                gtk.STOCK_OK, gtk.RESPONSE_OK,
+                gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
         self.__albumToAddTo = albumToAddTo
-        self.set_select_multiple(True)
-        self.ok_button.connect("clicked", self._ok)
+        self.connect("response", self._response)
 
-    def _ok(self, widget):
+    def _response(self, widget, responseId):
+        if responseId == gtk.RESPONSE_CANCEL:
+            return
         widgets = gtk.glade.XML(env.gladeFile, "registrationProgressDialog")
         registrationProgressDialog = widgets.get_widget(
             "registrationProgressDialog")
@@ -35,7 +42,7 @@ class RegisterImagesDialog(gtk.FileSelection):
         filesInvestigated = 0
         images = []
         registrationTimeString = unicode(time.strftime("%Y-%m-%d %H:%M:%S"))
-        for filepath in walk_files(self.get_selections()):
+        for filepath in walk_files([self.get_filename()]):
             try:
                 try:
                     filepath = filepath.decode("utf-8")