/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: Vincent Ladeuil
  • Date: 2008-05-05 18:16:46 UTC
  • mto: (487.1.1 gtk)
  • mto: This revision was merged to the branch mainline in revision 490.
  • Revision ID: v.ladeuil+lp@free.fr-20080505181646-n95l8ltw2u6jtr26
Fix bug #187283 fix replacing _() by _i18n().

* genpot.sh 
Remove duplication. Add the ability to specify the genrated pot
file on command-line for debugging purposes.

* po/olive-gtk.pot:
Regenerated.

* __init__.py, branch.py, branchview/treeview.py, checkout.py,
commit.py, conflicts.py, diff.py, errors.py, initialize.py,
merge.py, nautilus-bzr.py, olive/__init__.py, olive/add.py,
olive/bookmark.py, olive/guifiles.py, olive/info.py,
olive/menu.py, olive/mkdir.py, olive/move.py, olive/remove.py,
olive/rename.py, push.py, revbrowser.py, status.py, tags.py:
Replace all calls to _() by calls to _i18n(), the latter being
defined in __init__.py and imported in the other modules from
there. This fix the problem encountered countless times when
running bzr selftest and getting silly error messages about
boolean not being callables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
import sys
18
 
 
19
17
try:
20
18
    import pygtk
21
19
    pygtk.require("2.0")
22
20
except:
23
21
    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. """
32
 
    def __init__(self, gladefile, comm, dialog):
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
 
        # Dialog object
40
 
        self.dialog = dialog
41
 
        
42
 
        self.window = self.glade.get_widget('window_bookmark')
43
 
        
44
 
        # Dictionary for signal_autoconnect
45
 
        dic = { "on_button_bookmark_save_clicked": self.bookmark,
46
 
                "on_button_bookmark_cancel_clicked": self.close }
47
 
        
48
 
        # Connect the signals to the handlers
49
 
        self.glade.signal_autoconnect(dic)
50
 
        
51
 
        # Get some important widgets
52
 
        self.entry_location = self.glade.get_widget('entry_bookmark_location')
53
 
        self.entry_title = self.glade.get_widget('entry_bookmark_title')
54
 
 
55
 
    def display(self):
56
 
        """ Display the Edit bookmark dialog. """
57
 
        path = self.comm.get_selected_left()
58
 
        self.entry_location.set_text(path)
59
 
        self.entry_title.set_text(self.comm.pref.get_bookmark_title(path))
60
 
        self.window.show_all()
61
 
        
62
 
    def bookmark(self, widget):
63
 
        if self.entry_title.get_text() == '':
64
 
            self.dialog.error_dialog(_('No title given'),
65
 
                                     _('Please specify a title to continue.'))
 
22
 
 
23
import gtk
 
24
 
 
25
from olive import Preferences
 
26
from bzrlib.plugins.gtk import _i18n
 
27
from bzrlib.plugins.gtk.dialog import error_dialog
 
28
 
 
29
 
 
30
class BookmarkDialog(gtk.Dialog):
 
31
    """ This class wraps the old Bookmark window into a gtk.Dialog. """
 
32
    
 
33
    def __init__(self, selected, parent=None):
 
34
        """ Initialize the Bookmark dialog. """
 
35
        gtk.Dialog.__init__(self, title="Bookmarks - Olive",
 
36
                                  parent=parent,
 
37
                                  flags=0,
 
38
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
 
39
        
 
40
        self.pref = Preferences()
 
41
        
 
42
        # Get arguments
 
43
        self.selected = selected
 
44
        
 
45
        # Create widgets
 
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)
 
51
        
 
52
        self._button_save.connect('clicked', self._on_save_clicked)
 
53
        
 
54
        # Set default values
 
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)
 
59
        
 
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)
 
66
        
 
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)
 
72
        
 
73
        self.vbox.add(self._table)
 
74
        
 
75
        self.action_area.pack_end(self._button_save)
 
76
        
 
77
        self.vbox.show_all()
 
78
        
 
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.'))
66
84
            return
67
85
        
68
 
        self.comm.pref.set_bookmark_title(self.entry_location.get_text(),
69
 
                                          self.entry_title.get_text())
 
86
        self.pref.set_bookmark_title(self._entry_location.get_text(),
 
87
                                     self._entry_title.get_text())
 
88
        self.pref.write()
70
89
        
71
 
        self.close()
72
 
        self.comm.refresh_left()
73
 
    
74
 
    def close(self, widget=None):
75
 
        self.window.destroy()
 
90
        self.response(gtk.RESPONSE_OK)