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 |
try: |
|
18 |
import pygtk |
|
19 |
pygtk.require("2.0") |
|
20 |
except: |
|
21 |
pass
|
|
0.13.10
by Jelmer Vernooij
Don't pass around gladefile all the time. |
22 |
|
23 |
import gtk |
|
0.8.93
by Szilveszter Farkas (Phanatic)
Some further cleanups. More to come. |
24 |
|
142
by Jelmer Vernooij
Move some files to the top-level directory, add first test. |
25 |
from olive import Preferences |
475.1.2
by Vincent Ladeuil
Fix bug #187283 fix replacing _() by _i18n(). |
26 |
from bzrlib.plugins.gtk import _i18n |
151
by Jelmer Vernooij
Move dialog to top-level directory. |
27 |
from bzrlib.plugins.gtk.dialog import error_dialog |
126.1.21
by Szilveszter Farkas (Phanatic)
Remove trash from olive.glade. Some cleanups. |
28 |
|
29 |
||
30 |
class BookmarkDialog(gtk.Dialog): |
|
121
by Szilveszter Farkas (Phanatic)
Use OliveBookmarkDialog instead of OliveBookmark. |
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 |
||
142
by Jelmer Vernooij
Move some files to the top-level directory, add first test. |
40 |
self.pref = Preferences() |
121
by Szilveszter Farkas (Phanatic)
Use OliveBookmarkDialog instead of OliveBookmark. |
41 |
|
42 |
# Get arguments
|
|
43 |
self.selected = selected |
|
44 |
||
45 |
# Create widgets
|
|
475.1.2
by Vincent Ladeuil
Fix bug #187283 fix replacing _() by _i18n(). |
46 |
self._label_location = gtk.Label(_i18n("Location:")) |
47 |
self._label_title = gtk.Label(_i18n("Title:")) |
|
121
by Szilveszter Farkas (Phanatic)
Use OliveBookmarkDialog instead of OliveBookmark. |
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() == '': |
|
475.1.2
by Vincent Ladeuil
Fix bug #187283 fix replacing _() by _i18n(). |
82 |
error_dialog(_i18n('No title given'), |
83 |
_i18n('Please specify a title to continue.')) |
|
121
by Szilveszter Farkas (Phanatic)
Use OliveBookmarkDialog instead of OliveBookmark. |
84 |
return
|
85 |
||
86 |
self.pref.set_bookmark_title(self._entry_location.get_text(), |
|
87 |
self._entry_title.get_text()) |
|
88 |
self.pref.write() |
|
89 |
||
90 |
self.response(gtk.RESPONSE_OK) |