/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/bookmark.py

  • Committer: Javier Derderian
  • Date: 2008-04-11 20:34:06 UTC
  • mto: (465.1.1 gtk.patch)
  • mto: This revision was merged to the branch mainline in revision 466.
  • Revision ID: javierder@gmail.com-20080411203406-ftlwyodw9vr87olv
Updated "Compare with..." (#78765) to use revbrowser.RevisionBrowser.
Also needed to fix #215872 to make it work.

Show diffs side-by-side

added added

removed removed

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