[Pkg-bazaar-commits] ./bzr-gtk/unstable r539: Merge removal of glade from olive mkdir dialog.

Jelmer Vernooij jelmer at samba.org
Fri Apr 10 07:50:40 UTC 2009


------------------------------------------------------------
revno: 539
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-07-18 12:33:31 +0200
message:
  Merge removal of glade from olive mkdir dialog.
modified:
  NEWS
  olive/__init__.py
  olive/mkdir.py
    ------------------------------------------------------------
    revno: 533.7.1
    committer: Jasper Groenewegen <colbrac at xs4all.nl>
    branch nick: mkdirdialog
    timestamp: Thu 2008-07-17 23:10:05 +0200
    message:
      Replace glade OliveMkdir dialog with MkdirDialog
    modified:
      olive/__init__.py
      olive/mkdir.py
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2008-07-18 10:33:10 +0000
+++ b/NEWS	2008-07-18 10:33:31 +0000
@@ -53,7 +53,7 @@
 
   * Remove glade from merge dialog. (Jasper Groenewegen)
 
-  * Remove glade from olive about, rename, remove, move dialogs. (Jasper Groenewegen)
+  * Remove glade from olive about, rename, remove, move, mkdir dialogs. (Jasper Groenewegen)
 
 0.94.0    2008-05-04
 

=== modified file 'olive/__init__.py'
--- a/olive/__init__.py	2008-07-18 10:33:10 +0000
+++ b/olive/__init__.py	2008-07-18 10:33:31 +0000
@@ -724,9 +724,12 @@
     
     def on_menuitem_file_make_directory_activate(self, widget):
         """ File/Make directory... menu handler. """
-        from mkdir import OliveMkdir
-        mkdir = OliveMkdir(self.wt, self.wtpath)
-        mkdir.display()
+        from bzrlib.plugins.gtk.olive.mkdir import MkdirDialog
+        mkdir = MkdirDialog(self.wt, self.wtpath, self.window)
+        response = mkdir.run()
+        mkdir.destroy()
+        if response == gtk.RESPONSE_OK:
+            self.refresh_right()
     
     def on_menuitem_file_move_activate(self, widget):
         """ File/Move... menu handler. """

=== modified file 'olive/mkdir.py'
--- a/olive/mkdir.py	2008-05-05 18:16:46 +0000
+++ b/olive/mkdir.py	2008-07-17 21:10:05 +0000
@@ -23,75 +23,70 @@
     pass
 
 import gtk
-import gtk.glade
 
 import bzrlib.errors as errors
 
 from bzrlib.plugins.gtk import _i18n
 from bzrlib.plugins.gtk.dialog import error_dialog, warning_dialog
-from guifiles import GLADEFILENAME
-
 from bzrlib.plugins.gtk.errors import show_bzr_error
 
 
-class OliveMkdir:
+class MkdirDialog(gtk.Dialog):
     """ Display the Make directory dialog and perform the needed actions. """
-    def __init__(self, wt, wtpath):
+    
+    def __init__(self, wt, wtpath, parent=None):
         """ Initialize the Make directory dialog. """
-        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_mkdir', 'olive-gtk')
-        
-        self.window = self.glade.get_widget('window_mkdir')
-        
-        # Dictionary for signal_autoconnect
-        dic = { "on_button_mkdir_mkdir_clicked": self.mkdir,
-                "on_button_mkdir_cancel_clicked": self.close }
-        
-        # Connect the signals to the handlers
-        self.glade.signal_autoconnect(dic)
-        
+        gtk.Dialog.__init__(self, title="Olive - Make directory",
+                                  parent=parent,
+                                  flags=0,
+                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+        
+        # Get arguments
         self.wt = wt
         self.wtpath = wtpath
-
-    def display(self):
-        """ Display the Make directory dialog. """
-        self.window.show_all()
+        
+        # Create widgets
+        self._hbox = gtk.HBox()
+        self._label_directory_name = gtk.Label(_i18n("Directory name"))
+        self._entry = gtk.Entry()
+        self._versioned = gtk.CheckButton(_i18n("_Versioned directory"), use_underline=True)
+        self._button_mkdir = gtk.Button(_i18n("_Make directory"), use_underline=True)
+        self._button_mkdir_icon = gtk.Image()
+        self._button_mkdir_icon.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)
+        self._button_mkdir.set_image(self._button_mkdir_icon)
+        
+        self._entry.connect('activate', self._on_mkdir_clicked)
+        self._button_mkdir.connect('clicked', self._on_mkdir_clicked)
+        
+        # Add widgets to dialog
+        self.vbox.add(self._hbox)
+        self._hbox.add(self._label_directory_name)
+        self._hbox.add(self._entry)
+        self._hbox.set_spacing(5)
+        self.vbox.add(self._versioned)
+        self.action_area.pack_end(self._button_mkdir)
+        
+        self.vbox.show_all()
 
     @show_bzr_error
-    def mkdir(self, widget):
-        # Get the widgets
-        entry = self.glade.get_widget('entry_mkdir')
-        checkbox = self.glade.get_widget('checkbutton_mkdir_versioned')
-        
-        dirname = entry.get_text()
+    def _on_mkdir_clicked(self, widget):
+        dirname = self._entry.get_text()
         
         if dirname == "":
             error_dialog(_i18n('No directory name given'),
                          _i18n('Please specify a desired name for the new directory.'))
             return
         
-        if checkbox.get_active():
-            # Want to create a versioned directory
-            try:
-                os.mkdir(os.path.join(self.wt.basedir, self.wtpath, dirname))
-
+        try:
+            os.mkdir(os.path.join(self.wt.basedir, self.wtpath, dirname))
+            
+            if self._versioned.get_active():
                 self.wt.add([os.path.join(self.wtpath, dirname)])
-            except OSError, e:
-                if e.errno == 17:
-                    error_dialog(_i18n('Directory already exists'),
-                                 _i18n('Please specify another name to continue.'))
-                else:
-                    raise
-        else:
-            # Just a simple directory
-            try:
-                os.mkdir(os.path.join(self.wt.basedir, self.wtpath, dirname))
-            except OSError, e:
-                if e.errno == 17:
-                    error_dialog(_i18n('Directory already exists'),
-                                 _i18n('Please specify another name to continue.'))
-                    return
-
-        self.close()
-    
-    def close(self, widget=None):
-        self.window.destroy()
+        except OSError, e:
+            if e.errno == 17:
+                error_dialog(_i18n('Directory already exists'),
+                             _i18n('Please specify another name to continue.'))
+            else:
+                raise
+        
+        self.response(gtk.RESPONSE_OK)



More information about the Pkg-bazaar-commits mailing list