Rev 540: Merge removal of glade from olive add dialog. in file:///data/jelmer/bzr-gtk/trunk/
Jelmer Vernooij
jelmer at samba.org
Fri Jul 18 11:33:51 BST 2008
At file:///data/jelmer/bzr-gtk/trunk/
------------------------------------------------------------
revno: 540
revision-id: jelmer at samba.org-20080718103349-9o8lrztocd3zhfp1
parent: jelmer at samba.org-20080718103331-1yc1ii3vpb8qws6p
parent: colbrac at xs4all.nl-20080717204124-v781x33qxslpiw99
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-07-18 12:33:49 +0200
message:
Merge removal of glade from olive add dialog.
modified:
NEWS news-20070325173539-3va57o99cz3o57xe-1
olive/__init__.py __init__.py-20060925014013-13wdvwl8vi8gfqi1-2
olive/add.py add.py-20060721181724-0mfkrqwpsa09q1t3-1
------------------------------------------------------------
revno: 533.8.1
revision-id: colbrac at xs4all.nl-20080717204124-v781x33qxslpiw99
parent: jelmer at samba.org-20080717115103-djh5sb0pvpse2zkb
committer: Jasper Groenewegen <colbrac at xs4all.nl>
branch nick: adddialog
timestamp: Thu 2008-07-17 22:41:24 +0200
message:
Replace OliveAdd glade add dialog with AddDialog
modified:
olive/__init__.py __init__.py-20060925014013-13wdvwl8vi8gfqi1-2
olive/add.py add.py-20060721181724-0mfkrqwpsa09q1t3-1
=== modified file 'NEWS'
--- a/NEWS 2008-07-18 10:33:31 +0000
+++ b/NEWS 2008-07-18 10:33:49 +0000
@@ -53,7 +53,7 @@
* Remove glade from merge dialog. (Jasper Groenewegen)
- * Remove glade from olive about, rename, remove, move, mkdir dialogs. (Jasper Groenewegen)
+ * Remove glade from olive about, rename, remove, move, mkdir, add dialogs. (Jasper Groenewegen)
0.94.0 2008-05-04
=== modified file 'olive/__init__.py'
--- a/olive/__init__.py 2008-07-18 10:33:31 +0000
+++ b/olive/__init__.py 2008-07-18 10:33:49 +0000
@@ -473,10 +473,13 @@
def on_menuitem_add_files_activate(self, widget):
""" Add file(s)... menu handler. """
- from add import OliveAdd
- add = OliveAdd(self.wt, self.wtpath, self.get_selected_right())
- add.display()
-
+ from bzrlib.plugins.gtk.olive.add import AddDialog
+ add = AddDialog(self.wt, self.wtpath, self.get_selected_right(), self.window)
+ response = add.run()
+ add.destroy()
+ if response == gtk.RESPONSE_OK:
+ self.refresh_right()
+
def on_menuitem_branch_get_activate(self, widget):
""" Branch/Get... menu handler. """
from bzrlib.plugins.gtk.branch import BranchDialog
=== modified file 'olive/add.py'
--- a/olive/add.py 2008-06-29 18:32:05 +0000
+++ b/olive/add.py 2008-07-17 20:41:24 +0000
@@ -23,44 +23,52 @@
pass
import gtk
-import gtk.glade
import bzrlib.add
import bzrlib.errors as errors
from bzrlib.plugins.gtk import _i18n
from bzrlib.plugins.gtk.dialog import error_dialog
-from guifiles import GLADEFILENAME
-
-
-class OliveAdd:
- """ Display the Add file(s) dialog and perform the needed actions. """
- def __init__(self, wt, wtpath, selected=[]):
- """ Initialize the Add file(s) dialog. """
- self.glade = gtk.glade.XML(GLADEFILENAME, 'window_add', 'olive-gtk')
-
- self.window = self.glade.get_widget('window_add')
-
- # Dictionary for signal_autoconnect
- dic = { "on_button_add_add_clicked": self.add,
- "on_button_add_cancel_clicked": self.close }
-
- # Connect the signals to the handlers
- self.glade.signal_autoconnect(dic)
-
+from bzrlib.plugins.gtk.errors import show_bzr_error
+
+
+class AddDialog(gtk.Dialog):
+ """ Dialog for adding selected file or recursively all unknown files/folders in branch """
+
+ def __init__(self, wt, wtpath, selected, parent=None):
+ """ Initialize the Add dialog. """
+ gtk.Dialog.__init__(self, title="Olive - Add file(s)",
+ parent=parent,
+ flags=0,
+ buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+
+ # Get arguments
self.wt = wt
self.wtpath = wtpath
self.selected = selected
-
- def display(self):
- """ Display the Add file(s) dialog. """
- self.window.show_all()
-
- def add(self, widget):
- radio_selected = self.glade.get_widget('radiobutton_add_selected')
- radio_unknown = self.glade.get_widget('radiobutton_add_unknown')
-
- if radio_selected.get_active():
+
+ # Create widgets
+ self._label_add_question = gtk.Label(_i18n("Which file(s) do you want to add?"))
+ self._radiobutton_add_selected = gtk.RadioButton(None,_i18n("Selected: %s"%self.selected))
+ self._radiobutton_add_unknown = gtk.RadioButton(self._radiobutton_add_selected,
+ _i18n("All unknowns recursively"))
+ self._button_add = gtk.Button(stock=gtk.STOCK_ADD)
+
+ self._button_add.connect('clicked', self._on_add_clicked)
+
+ # Add widgets to dialog window and decorate
+ self.vbox.add(self._label_add_question)
+ self.vbox.add(self._radiobutton_add_selected)
+ self.vbox.add(self._radiobutton_add_unknown)
+ self.vbox.set_spacing(3)
+ self.action_area.pack_end(self._button_add)
+
+ self.vbox.show_all()
+
+ @show_bzr_error
+ def _on_add_clicked(self, button):
+ """ """
+ if self._radiobutton_add_selected.get_active():
# Add only the selected file
filename = self.selected
@@ -75,7 +83,7 @@
error_dialog(_i18n('Directory is not a branch'),
_i18n('You can perform this action only in a branch.'))
return
- elif radio_unknown.get_active():
+ elif self._radiobutton_add_unknown.get_active():
# Add unknown files recursively
try:
self.wt.add(self.wt.unknowns())
@@ -84,7 +92,4 @@
_i18n('You can perform this action only in a branch.'))
return
- self.close()
-
- def close(self, widget=None):
- self.window.destroy()
+ self.response(gtk.RESPONSE_OK)
More information about the bazaar-commits
mailing list