Rev 538: Merge removal of glade from olive move dialog. in file:///data/jelmer/bzr-gtk/trunk/
Jelmer Vernooij
jelmer at samba.org
Fri Jul 18 11:33:13 BST 2008
At file:///data/jelmer/bzr-gtk/trunk/
------------------------------------------------------------
revno: 538
revision-id: jelmer at samba.org-20080718103310-tvkaozsyvdul0dm5
parent: jelmer at samba.org-20080718103237-md6rusj25xq1j900
parent: colbrac at xs4all.nl-20080717211627-2yoa94j55a8o8evp
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-07-18 12:33:10 +0200
message:
Merge removal of glade from olive move dialog.
modified:
NEWS news-20070325173539-3va57o99cz3o57xe-1
olive/__init__.py __init__.py-20060925014013-13wdvwl8vi8gfqi1-2
olive/move.py move.py-20060809140408-txw8f17jvqykh0iv-1
------------------------------------------------------------
revno: 533.6.1
revision-id: colbrac at xs4all.nl-20080717211627-2yoa94j55a8o8evp
parent: jelmer at samba.org-20080717115103-djh5sb0pvpse2zkb
committer: Jasper Groenewegen <colbrac at xs4all.nl>
branch nick: movedialog
timestamp: Thu 2008-07-17 23:16:27 +0200
message:
Replace glade OliveMove with MoveDialog
modified:
olive/__init__.py __init__.py-20060925014013-13wdvwl8vi8gfqi1-2
olive/move.py move.py-20060809140408-txw8f17jvqykh0iv-1
=== modified file 'NEWS'
--- a/NEWS 2008-07-18 10:32:37 +0000
+++ b/NEWS 2008-07-18 10:33:10 +0000
@@ -53,7 +53,7 @@
* Remove glade from merge dialog. (Jasper Groenewegen)
- * Remove glade from olive about, rename, remove dialogs. (Jasper Groenewegen)
+ * Remove glade from olive about, rename, remove, move dialogs. (Jasper Groenewegen)
0.94.0 2008-05-04
=== modified file 'olive/__init__.py'
--- a/olive/__init__.py 2008-07-18 10:32:37 +0000
+++ b/olive/__init__.py 2008-07-18 10:33:10 +0000
@@ -730,9 +730,12 @@
def on_menuitem_file_move_activate(self, widget):
""" File/Move... menu handler. """
- from move import OliveMove
- move = OliveMove(self.wt, self.wtpath, self.get_selected_right())
- move.display()
+ from bzrlib.plugins.gtk.olive.move import MoveDialog
+ move = MoveDialog(self.wt, self.wtpath, self.get_selected_right(), self.window)
+ response = move.run()
+ move.destroy()
+ if response == gtk.RESPONSE_OK:
+ self.refresh_right()
def on_menuitem_file_rename_activate(self, widget):
""" File/Rename... menu handler. """
=== modified file 'olive/move.py'
--- a/olive/move.py 2008-06-28 16:59:50 +0000
+++ b/olive/move.py 2008-07-17 21:16:27 +0000
@@ -15,7 +15,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-from os.path import dirname
try:
import pygtk
@@ -24,7 +23,6 @@
pass
import gtk
-import gtk.glade
import bzrlib.errors as errors
from bzrlib.workingtree import WorkingTree
@@ -32,24 +30,19 @@
from bzrlib.plugins.gtk import _i18n
from bzrlib.plugins.gtk.dialog import error_dialog
from bzrlib.plugins.gtk.errors import show_bzr_error
-from guifiles import GLADEFILENAME
-
-
-class OliveMove:
+
+
+class MoveDialog(gtk.Dialog):
""" Display the Move dialog and perform the needed actions. """
- def __init__(self, wt, wtpath, selected=[]):
+
+ def __init__(self, wt, wtpath, selected, parent=None):
""" Initialize the Move dialog. """
- self.glade = gtk.glade.XML(GLADEFILENAME, 'window_move', 'olive-gtk')
-
- self.window = self.glade.get_widget('window_move')
-
- # Dictionary for signal_autoconnect
- dic = { "on_button_move_move_clicked": self.move,
- "on_button_move_cancel_clicked": self.close }
-
- # Connect the signals to the handlers
- self.glade.signal_autoconnect(dic)
-
+ gtk.Dialog.__init__(self, title="Olive - Move",
+ parent=parent,
+ flags=0,
+ buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+
+ # Get arguments
self.wt = wt
self.wtpath = wtpath
self.selected = selected
@@ -58,22 +51,48 @@
self.selected = ""
if self.wtpath == "":
- directory = dirname(self.wt.abspath(self.selected))
+ directory = os.path.dirname(self.wt.abspath(self.selected))
else:
- directory = dirname(self.wt.abspath(self.wtpath + os.sep + self.selected))
-
- # Set FileChooser directory
- self.filechooser = self.glade.get_widget('filechooserbutton_move')
- self.filechooser.set_filename(directory)
-
- def display(self):
- """ Display the Move dialog. """
- self.window.show_all()
+ directory = os.path.dirname(self.wt.abspath(self.wtpath + os.sep + self.selected))
+
+ # Create widgets
+ self._hbox = gtk.HBox()
+ self._label_move_to = gtk.Label(_i18n("Move to"))
+ self._filechooser_dialog = gtk.FileChooserDialog(title="Please select a folder",
+ parent=self.window,
+ action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+ self._filechooser_dialog.set_default_response(gtk.RESPONSE_OK)
+ self.filechooser = gtk.FileChooserButton(self._filechooser_dialog)
+ self._button_move = gtk.Button(_i18n("_Move"))
+ self._button_move_icon = gtk.Image()
+ self._button_move_icon.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
+ self._button_move.set_image(self._button_move_icon)
+
+ self._button_move.connect('clicked', self._on_move_clicked)
+
+ # Set location
+ self._filechooser_dialog.set_current_folder(directory)
+
+ # Add widgets to dialog
+ self.vbox.add(self._hbox)
+ self._hbox.add(self._label_move_to)
+ self._hbox.add(self.filechooser)
+ self._hbox.set_spacing(5)
+ self.action_area.pack_end(self._button_move)
+
+ self.vbox.show_all()
@show_bzr_error
- def move(self, widget):
+ def _on_move_clicked(self, widget):
destination = self.filechooser.get_filename()
-
+
+ if destination == None:
+ error_dialog(_i18n('No folder was selected'),
+ _i18n('Please select a folder to move the selected file to'))
+ return
+
filename = self.selected
if filename is None:
@@ -92,7 +111,5 @@
return
wt1.move([source], wt1.relpath(destination))
- self.close()
-
- def close(self, widget=None):
- self.window.destroy()
+
+ self.response(gtk.RESPONSE_OK)
More information about the bazaar-commits
mailing list