/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
0.8.57 by Szilveszter Farkas (Phanatic)
Bookmarks have titles; you can also edit them.
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
import sys
18
19
try:
20
    import pygtk
21
    pygtk.require("2.0")
22
except:
23
    pass
24
try:
25
    import gtk
26
    import gtk.glade
27
except:
28
    sys.exit(1)
29
30
class OliveBookmark:
31
    """ Display the Edit bookmark dialog and perform the needed actions. """
0.13.6 by Jelmer Vernooij
Don't pass along dialog context everywhere.
32
    def __init__(self, gladefile, comm):
0.8.57 by Szilveszter Farkas (Phanatic)
Bookmarks have titles; you can also edit them.
33
        """ Initialize the Edit bookmark dialog. """
34
        self.gladefile = gladefile
35
        self.glade = gtk.glade.XML(self.gladefile, 'window_bookmark', 'olive-gtk')
36
        
37
        # Communication object
38
        self.comm = comm
39
        
40
        self.window = self.glade.get_widget('window_bookmark')
41
        
42
        # Dictionary for signal_autoconnect
43
        dic = { "on_button_bookmark_save_clicked": self.bookmark,
44
                "on_button_bookmark_cancel_clicked": self.close }
45
        
46
        # Connect the signals to the handlers
47
        self.glade.signal_autoconnect(dic)
48
        
49
        # Get some important widgets
50
        self.entry_location = self.glade.get_widget('entry_bookmark_location')
51
        self.entry_title = self.glade.get_widget('entry_bookmark_title')
52
53
    def display(self):
54
        """ Display the Edit bookmark dialog. """
55
        path = self.comm.get_selected_left()
56
        self.entry_location.set_text(path)
57
        self.entry_title.set_text(self.comm.pref.get_bookmark_title(path))
58
        self.window.show_all()
59
        
60
    def bookmark(self, widget):
61
        if self.entry_title.get_text() == '':
0.13.6 by Jelmer Vernooij
Don't pass along dialog context everywhere.
62
            error_dialog(_('No title given'),
0.8.57 by Szilveszter Farkas (Phanatic)
Bookmarks have titles; you can also edit them.
63
                                     _('Please specify a title to continue.'))
64
            return
65
        
66
        self.comm.pref.set_bookmark_title(self.entry_location.get_text(),
67
                                          self.entry_title.get_text())
68
        
69
        self.close()
70
        self.comm.refresh_left()
71
    
72
    def close(self, widget=None):
73
        self.window.destroy()