/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: Szilveszter Farkas (Phanatic)
  • Date: 2006-12-17 23:22:10 UTC
  • Revision ID: szilveszter.farkas@gmail.com-20061217232210-nxws311ray6wlpw3
Use OliveBookmarkDialog instead of OliveBookmark.

Fixed: #67922 (bookmarks in olive)

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
        
37
37
        self.window = self.glade.get_widget('window_bookmark')
38
38
        
39
 
        self.pref = self.pref = OlivePreferences()
 
39
        self.pref = OlivePreferences()
40
40
        
41
41
        # Dictionary for signal_autoconnect
42
42
        dic = { "on_button_bookmark_save_clicked": self.bookmark,
72
72
    
73
73
    def close(self, widget=None):
74
74
        self.window.destroy()
 
75
 
 
76
class OliveBookmarkDialog(gtk.Dialog):
 
77
    """ This class wraps the old Bookmark window into a gtk.Dialog. """
 
78
    
 
79
    def __init__(self, selected, parent=None):
 
80
        """ Initialize the Bookmark dialog. """
 
81
        gtk.Dialog.__init__(self, title="Bookmarks - Olive",
 
82
                                  parent=parent,
 
83
                                  flags=0,
 
84
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
 
85
        
 
86
        self.pref = OlivePreferences()
 
87
        
 
88
        # Get arguments
 
89
        self.selected = selected
 
90
        
 
91
        # Create widgets
 
92
        self._label_location = gtk.Label(_("Location:"))
 
93
        self._label_title = gtk.Label(_("Title:"))
 
94
        self._entry_location = gtk.Entry()
 
95
        self._entry_title = gtk.Entry()
 
96
        self._button_save = gtk.Button(stock=gtk.STOCK_SAVE)
 
97
        
 
98
        self._button_save.connect('clicked', self._on_save_clicked)
 
99
        
 
100
        # Set default values
 
101
        self._entry_location.set_text(self.selected)
 
102
        self._entry_location.set_sensitive(False)
 
103
        self._entry_title.set_text(self.pref.get_bookmark_title(self.selected))
 
104
        self._entry_title.set_flags(gtk.CAN_FOCUS | gtk.HAS_FOCUS)
 
105
        
 
106
        # Create a table and put widgets into it
 
107
        self._table = gtk.Table(rows=2, columns=2)
 
108
        self._table.attach(self._label_location, 0, 1, 0, 1)
 
109
        self._table.attach(self._label_title, 0, 1, 1, 2)
 
110
        self._table.attach(self._entry_location, 1, 2, 0, 1)
 
111
        self._table.attach(self._entry_title, 1, 2, 1, 2)
 
112
        
 
113
        self._label_location.set_alignment(0, 0.5)
 
114
        self._label_title.set_alignment(0, 0.5)
 
115
        self._table.set_row_spacings(3)
 
116
        self._table.set_col_spacings(3)
 
117
        self.vbox.set_spacing(3)
 
118
        
 
119
        self.vbox.add(self._table)
 
120
        
 
121
        self.action_area.pack_end(self._button_save)
 
122
        
 
123
        self.vbox.show_all()
 
124
        
 
125
    def _on_save_clicked(self, button):
 
126
        """ Save button clicked handler. """
 
127
        if self._entry_title.get_text() == '':
 
128
            error_dialog(_('No title given'),
 
129
                         _('Please specify a title to continue.'))
 
130
            return
 
131
        
 
132
        self.pref.set_bookmark_title(self._entry_location.get_text(),
 
133
                                     self._entry_title.get_text())
 
134
        self.pref.write()
 
135
        
 
136
        self.response(gtk.RESPONSE_OK)