25
from olive import Preferences
26
from bzrlib.plugins.gtk import _i18n
27
from bzrlib.plugins.gtk.dialog import error_dialog
30
class BookmarkDialog(gtk.Dialog):
31
""" This class wraps the old Bookmark window into a gtk.Dialog. """
27
from olive import gladefile
30
""" Display the Edit bookmark dialog and perform the needed actions. """
31
def __init__(self, comm):
32
""" Initialize the Edit bookmark dialog. """
33
self.glade = gtk.glade.XML(gladefile, 'window_bookmark', 'olive-gtk')
35
self.window = self.glade.get_widget('window_bookmark')
37
# Dictionary for signal_autoconnect
38
dic = { "on_button_bookmark_save_clicked": self.bookmark,
39
"on_button_bookmark_cancel_clicked": self.close }
41
# Connect the signals to the handlers
42
self.glade.signal_autoconnect(dic)
44
# Get some important widgets
45
self.entry_location = self.glade.get_widget('entry_bookmark_location')
46
self.entry_title = self.glade.get_widget('entry_bookmark_title')
49
""" Display the Edit bookmark dialog. """
50
path = self.comm.get_selected_left()
51
self.entry_location.set_text(path)
52
self.entry_title.set_text(self.comm.pref.get_bookmark_title(path))
53
self.window.show_all()
55
def bookmark(self, widget):
56
if self.entry_title.get_text() == '':
57
error_dialog(_('No title given'),
58
_('Please specify a title to continue.'))
61
self.comm.pref.set_bookmark_title(self.entry_location.get_text(),
62
self.entry_title.get_text())
33
def __init__(self, selected, parent=None):
34
""" Initialize the Bookmark dialog. """
35
gtk.Dialog.__init__(self, title="Bookmarks - Olive",
38
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
40
self.pref = Preferences()
43
self.selected = selected
46
self._label_location = gtk.Label(_i18n("Location:"))
47
self._label_title = gtk.Label(_i18n("Title:"))
48
self._entry_location = gtk.Entry()
49
self._entry_title = gtk.Entry()
50
self._button_save = gtk.Button(stock=gtk.STOCK_SAVE)
52
self._button_save.connect('clicked', self._on_save_clicked)
55
self._entry_location.set_text(self.selected)
56
self._entry_location.set_sensitive(False)
57
self._entry_title.set_text(self.pref.get_bookmark_title(self.selected))
58
self._entry_title.set_flags(gtk.CAN_FOCUS | gtk.HAS_FOCUS)
60
# Create a table and put widgets into it
61
self._table = gtk.Table(rows=2, columns=2)
62
self._table.attach(self._label_location, 0, 1, 0, 1)
63
self._table.attach(self._label_title, 0, 1, 1, 2)
64
self._table.attach(self._entry_location, 1, 2, 0, 1)
65
self._table.attach(self._entry_title, 1, 2, 1, 2)
67
self._label_location.set_alignment(0, 0.5)
68
self._label_title.set_alignment(0, 0.5)
69
self._table.set_row_spacings(3)
70
self._table.set_col_spacings(3)
71
self.vbox.set_spacing(3)
73
self.vbox.add(self._table)
75
self.action_area.pack_end(self._button_save)
79
def _on_save_clicked(self, button):
80
""" Save button clicked handler. """
81
if self._entry_title.get_text() == '':
82
error_dialog(_i18n('No title given'),
83
_i18n('Please specify a title to continue.'))
86
self.pref.set_bookmark_title(self._entry_location.get_text(),
87
self._entry_title.get_text())
90
self.response(gtk.RESPONSE_OK)
66
def close(self, widget=None):