bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
190.1.1
by Szilveszter Farkas (Phanatic)
Added 'gtags' command and basic Tags window (just a skeleton). |
1 |
# Copyright (C) 2007 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
|
|
22 |
||
23 |
import gtk |
|
24 |
||
25 |
from bzrlib.plugins.gtk.logview import LogView |
|
26 |
||
27 |
class TagsWindow(gtk.Window): |
|
28 |
""" Tags window. Allows the user to view/add/remove tags. """ |
|
29 |
def __init__(self, branch, parent=None): |
|
30 |
""" Initialize the Tags window. """ |
|
31 |
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) |
|
32 |
||
33 |
# Get arguments
|
|
34 |
self.branch = branch |
|
35 |
self._parent = parent |
|
36 |
||
37 |
# Create the widgets
|
|
38 |
self._button_add = gtk.Button(stock=gtk.STOCK_ADD) |
|
39 |
self._button_remove = gtk.Button(stock=gtk.STOCK_REMOVE) |
|
40 |
self._button_close = gtk.Button(stock=gtk.STOCK_CLOSE) |
|
41 |
self._model = gtk.ListStore(str, str) |
|
42 |
self._treeview_tags = gtk.TreeView(self._model) |
|
43 |
self._scrolledwindow_tags = gtk.ScrolledWindow() |
|
44 |
self._logview = LogView() |
|
45 |
self._hbox = gtk.HBox() |
|
46 |
self._vbox_buttons = gtk.VBox() |
|
47 |
self._vpaned = gtk.VPaned() |
|
48 |
||
49 |
# Set callbacks
|
|
50 |
self._button_close.connect('clicked', self._on_close_clicked) |
|
51 |
||
52 |
# Set properties
|
|
53 |
self.set_title(_("Tags - Olive")) |
|
54 |
||
55 |
self._scrolledwindow_tags.set_policy(gtk.POLICY_AUTOMATIC, |
|
56 |
gtk.POLICY_AUTOMATIC) |
|
57 |
||
58 |
# Construct the dialog
|
|
59 |
self._scrolledwindow_tags.add(self._treeview_tags) |
|
60 |
||
61 |
self._vbox_buttons.pack_start(self._button_add) |
|
62 |
self._vbox_buttons.pack_start(self._button_remove) |
|
63 |
self._vbox_buttons.pack_start(self._button_close) |
|
64 |
||
65 |
self._vpaned.add1(self._scrolledwindow_tags) |
|
66 |
self._vpaned.add2(self._logview) |
|
67 |
||
68 |
self._hbox.pack_start(self._vpaned) |
|
69 |
self._hbox.pack_start(self._vbox_buttons) |
|
70 |
||
71 |
self.add(self._hbox) |
|
72 |
||
73 |
# Display everything
|
|
74 |
self._hbox.show_all() |
|
75 |
||
76 |
def _on_close_clicked(self, widget): |
|
77 |
""" Close button event handler. """ |
|
78 |
self.destroy() |
|
79 |
if self._parent is None: |
|
80 |
gtk.main_quit() |