bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
1 |
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
|
|
0.8.29
by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups. |
2 |
#
|
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
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.
|
|
|
0.8.29
by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups. |
7 |
#
|
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
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.
|
|
|
0.8.29
by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups. |
12 |
#
|
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
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 |
||
|
0.8.33
by Szilveszter Farkas (Phanatic)
Implemented bookmarking. |
17 |
import ConfigParser |
|
0.8.15
by Szilveszter Farkas (Phanatic)
2006-07-18 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
18 |
import os |
19 |
import os.path |
|
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
20 |
import sys |
21 |
||
22 |
try: |
|
|
0.8.14
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
23 |
import pygtk |
24 |
pygtk.require("2.0") |
|
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
25 |
except: |
|
0.8.14
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
26 |
pass
|
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
27 |
try: |
|
0.8.14
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
28 |
import gtk |
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
29 |
import gtk.gdk |
|
0.8.14
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
30 |
import gtk.glade |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
31 |
except: |
|
0.8.14
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
32 |
sys.exit(1) |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
33 |
|
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
34 |
from handler import OliveHandler |
|
0.8.53
by Szilveszter Farkas (Phanatic)
Set sensitivity of menus and toolbuttons. |
35 |
from olive.backend.info import is_branch |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
36 |
|
37 |
# Olive GTK UI version
|
|
38 |
__version__ = '0.1' |
|
39 |
||
40 |
class OliveGtk: |
|
41 |
""" The main Olive GTK frontend class. This is called when launching the |
|
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
42 |
program. """
|
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
43 |
|
44 |
def __init__(self): |
|
45 |
# Load the glade file
|
|
|
0.8.51
by Szilveszter Farkas (Phanatic)
Some fixes for the Win32 platform; typo fixed. |
46 |
if sys.platform == 'win32': |
47 |
self.gladefile = os.path.dirname(sys.executable) + "/share/olive/olive.glade" |
|
48 |
else: |
|
49 |
self.gladefile = "/usr/share/olive/olive.glade" |
|
50 |
||
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
51 |
if not os.path.exists(self.gladefile): |
52 |
# Load from current directory if not installed
|
|
53 |
self.gladefile = "olive.glade" |
|
|
0.8.51
by Szilveszter Farkas (Phanatic)
Some fixes for the Win32 platform; typo fixed. |
54 |
# Check again
|
55 |
if not os.path.exists(self.gladefile): |
|
56 |
# Fail
|
|
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
57 |
print _('Glade file cannot be found.') |
|
0.8.51
by Szilveszter Farkas (Phanatic)
Some fixes for the Win32 platform; typo fixed. |
58 |
sys.exit(1) |
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
59 |
|
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
60 |
self.toplevel = gtk.glade.XML(self.gladefile, 'window_main', 'olive-gtk') |
|
0.8.14
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
61 |
|
62 |
self.window = self.toplevel.get_widget('window_main') |
|
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
63 |
|
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
64 |
self.pref = OlivePreferences() |
65 |
self.comm = OliveCommunicator(self.toplevel, self.pref) |
|
|
0.8.15
by Szilveszter Farkas (Phanatic)
2006-07-18 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
66 |
handler = OliveHandler(self.gladefile, self.comm) |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
67 |
|
68 |
# Dictionary for signal_autoconnect
|
|
69 |
dic = { "on_window_main_destroy": gtk.main_quit, |
|
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
70 |
"on_window_main_delete_event": handler.on_window_main_delete_event, |
71 |
"on_quit_activate": handler.on_window_main_delete_event, |
|
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
72 |
"on_about_activate": handler.on_about_activate, |
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
73 |
"on_menuitem_add_files_activate": handler.on_menuitem_add_files_activate, |
74 |
"on_menuitem_remove_file_activate": handler.on_menuitem_remove_file_activate, |
|
|
0.8.37
by Szilveszter Farkas (Phanatic)
Implemented Make directory functionality; some cleanups. |
75 |
"on_menuitem_file_make_directory_activate": handler.on_menuitem_file_make_directory_activate, |
|
0.8.38
by Szilveszter Farkas (Phanatic)
Implemented Move functionality; move() backend code refined. |
76 |
"on_menuitem_file_move_activate": handler.on_menuitem_file_move_activate, |
|
0.8.40
by Szilveszter Farkas (Phanatic)
Implemented Rename functionality. |
77 |
"on_menuitem_file_rename_activate": handler.on_menuitem_file_rename_activate, |
|
0.8.49
by Szilveszter Farkas (Phanatic)
Added View menu; implemented Refresh; some TODO changes. |
78 |
"on_menuitem_view_show_hidden_files_activate": handler.on_menuitem_view_show_hidden_files_activate, |
79 |
"on_menuitem_view_refresh_activate": handler.on_menuitem_view_refresh_activate, |
|
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
80 |
"on_menuitem_branch_initialize_activate": handler.on_menuitem_branch_initialize_activate, |
|
0.8.22
by Szilveszter Farkas (Phanatic)
2006-07-31 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
81 |
"on_menuitem_branch_get_activate": handler.on_menuitem_branch_get_activate, |
82 |
"on_menuitem_branch_checkout_activate": handler.on_menuitem_branch_checkout_activate, |
|
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
83 |
"on_menuitem_branch_commit_activate": handler.on_menuitem_branch_commit_activate, |
84 |
"on_menuitem_branch_push_activate": handler.on_menuitem_branch_push_activate, |
|
|
0.8.36
by Szilveszter Farkas (Phanatic)
Implemented pull functionality. |
85 |
"on_menuitem_branch_pull_activate": handler.on_menuitem_branch_pull_activate, |
|
0.8.29
by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups. |
86 |
"on_menuitem_branch_status_activate": handler.on_menuitem_branch_status_activate, |
|
0.8.28
by Szilveszter Farkas (Phanatic)
Statistics menu added |
87 |
"on_menuitem_stats_diff_activate": handler.on_menuitem_stats_diff_activate, |
|
0.8.43
by Szilveszter Farkas (Phanatic)
Implemented Log functionality (via bzrk). |
88 |
"on_menuitem_stats_log_activate": handler.on_menuitem_stats_log_activate, |
|
0.8.42
by Szilveszter Farkas (Phanatic)
Implemented Informations functionality; some bzrlib API changes handled. |
89 |
"on_menuitem_stats_infos_activate": handler.on_menuitem_stats_infos_activate, |
|
0.8.49
by Szilveszter Farkas (Phanatic)
Added View menu; implemented Refresh; some TODO changes. |
90 |
"on_toolbutton_refresh_clicked": handler.on_menuitem_view_refresh_activate, |
|
0.8.52
by Szilveszter Farkas (Phanatic)
GUI (toolbar + menu) cleanup. |
91 |
"on_toolbutton_log_clicked": handler.on_menuitem_stats_log_activate, |
92 |
"on_menutoolbutton_diff_clicked": handler.on_menuitem_stats_diff_activate, |
|
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
93 |
"on_toolbutton_commit_clicked": handler.on_menuitem_branch_commit_activate, |
|
0.8.36
by Szilveszter Farkas (Phanatic)
Implemented pull functionality. |
94 |
"on_toolbutton_pull_clicked": handler.on_menuitem_branch_pull_activate, |
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
95 |
"on_toolbutton_push_clicked": handler.on_menuitem_branch_push_activate, |
|
0.8.24
by Szilveszter Farkas (Phanatic)
Implemented context menu for the file list. |
96 |
"on_treeview_right_button_press_event": handler.on_treeview_right_button_press_event, |
|
0.8.33
by Szilveszter Farkas (Phanatic)
Implemented bookmarking. |
97 |
"on_treeview_right_row_activated": handler.on_treeview_right_row_activated, |
98 |
"on_treeview_left_button_press_event": handler.on_treeview_left_button_press_event, |
|
99 |
"on_treeview_left_row_activated": handler.on_treeview_left_row_activated } |
|
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
100 |
|
101 |
# Connect the signals to the handlers
|
|
102 |
self.toplevel.signal_autoconnect(dic) |
|
103 |
||
|
0.8.41
by Szilveszter Farkas (Phanatic)
Main window preferences (size, position) are stored. |
104 |
# Apply window size and position
|
105 |
width = self.pref.get_preference('window_width', 'int') |
|
106 |
height = self.pref.get_preference('window_height', 'int') |
|
107 |
self.window.resize(width, height) |
|
108 |
x = self.pref.get_preference('window_x', 'int') |
|
109 |
y = self.pref.get_preference('window_y', 'int') |
|
110 |
self.window.move(x, y) |
|
111 |
# Apply paned position
|
|
112 |
pos = self.pref.get_preference('paned_position', 'int') |
|
113 |
self.comm.hpaned_main.set_position(pos) |
|
114 |
||
|
0.8.52
by Szilveszter Farkas (Phanatic)
GUI (toolbar + menu) cleanup. |
115 |
# Apply menu to the toolbutton
|
116 |
menubutton = self.toplevel.get_widget('menutoolbutton_diff') |
|
117 |
menubutton.set_menu(handler.menu.toolbar_diff) |
|
118 |
||
|
0.8.49
by Szilveszter Farkas (Phanatic)
Added View menu; implemented Refresh; some TODO changes. |
119 |
# Now we can show the window
|
120 |
self.window.show_all() |
|
121 |
||
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
122 |
# Load default data into the panels
|
123 |
self.treeview_left = self.toplevel.get_widget('treeview_left') |
|
124 |
self.treeview_right = self.toplevel.get_widget('treeview_right') |
|
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
125 |
self._load_left() |
126 |
self._load_right() |
|
|
0.8.49
by Szilveszter Farkas (Phanatic)
Added View menu; implemented Refresh; some TODO changes. |
127 |
|
128 |
# Apply menu state
|
|
129 |
self.comm.menuitem_view_show_hidden_files.set_active(self.pref.get_preference('dotted_files', 'bool')) |
|
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
130 |
|
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
131 |
def _load_left(self): |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
132 |
""" Load data into the left panel. (Bookmarks) """ |
|
0.8.33
by Szilveszter Farkas (Phanatic)
Implemented bookmarking. |
133 |
# set cursor to busy
|
134 |
self.comm.set_busy(self.treeview_left) |
|
135 |
||
136 |
# Create TreeStore
|
|
137 |
treestore = gtk.TreeStore(str) |
|
138 |
||
139 |
# Get bookmarks
|
|
140 |
bookmarks = self.comm.pref.get_bookmarks() |
|
141 |
||
142 |
# Add them to the TreeStore
|
|
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
143 |
titer = treestore.append(None, [_('Bookmarks')]) |
|
0.8.33
by Szilveszter Farkas (Phanatic)
Implemented bookmarking. |
144 |
for item in bookmarks: |
145 |
treestore.append(titer, [item]) |
|
146 |
||
147 |
# Create the column and add it to the TreeView
|
|
148 |
self.treeview_left.set_model(treestore) |
|
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
149 |
tvcolumn_bookmark = gtk.TreeViewColumn(_('Bookmark')) |
|
0.8.33
by Szilveszter Farkas (Phanatic)
Implemented bookmarking. |
150 |
self.treeview_left.append_column(tvcolumn_bookmark) |
151 |
||
152 |
# Set up the cells
|
|
153 |
cell = gtk.CellRendererText() |
|
154 |
tvcolumn_bookmark.pack_start(cell, True) |
|
155 |
tvcolumn_bookmark.add_attribute(cell, 'text', 0) |
|
156 |
||
157 |
# Expand the tree
|
|
158 |
self.treeview_left.expand_all() |
|
159 |
||
160 |
self.comm.set_busy(self.treeview_left, False) |
|
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
161 |
|
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
162 |
def _load_right(self): |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
163 |
""" Load data into the right panel. (Filelist) """ |
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
164 |
import olive.backend.fileops as fileops |
165 |
||
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
166 |
# set cursor to busy
|
167 |
self.comm.set_busy(self.treeview_right) |
|
168 |
||
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
169 |
# Create ListStore
|
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
170 |
liststore = gtk.ListStore(str, str, str) |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
171 |
|
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
172 |
dirs = ['..'] |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
173 |
files = [] |
174 |
||
175 |
# Fill the appropriate lists
|
|
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
176 |
path = self.comm.get_path() |
|
0.8.49
by Szilveszter Farkas (Phanatic)
Added View menu; implemented Refresh; some TODO changes. |
177 |
dotted_files = self.pref.get_preference('dotted_files', 'bool') |
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
178 |
for item in os.listdir(path): |
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
179 |
if not dotted_files and item[0] == '.': |
180 |
continue
|
|
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
181 |
if os.path.isdir(path + '/' + item): |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
182 |
dirs.append(item) |
183 |
else: |
|
184 |
files.append(item) |
|
185 |
||
186 |
# Sort'em
|
|
187 |
dirs.sort() |
|
188 |
files.sort() |
|
189 |
||
190 |
# Add'em to the ListStore
|
|
191 |
for item in dirs: |
|
|
0.8.17
by Szilveszter Farkas (Phanatic)
2006-07-19 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
192 |
liststore.append([gtk.STOCK_DIRECTORY, item, '']) |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
193 |
for item in files: |
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
194 |
status = fileops.status(path + '/' + item) |
195 |
if status == 'renamed': |
|
196 |
st = _('renamed') |
|
197 |
elif status == 'removed': |
|
198 |
st = _('removed') |
|
199 |
elif status == 'added': |
|
200 |
st = _('added') |
|
201 |
elif status == 'modified': |
|
202 |
st = _('modified') |
|
203 |
elif status == 'unchanged': |
|
204 |
st = _('unchanged') |
|
205 |
else: |
|
206 |
st = _('unknown') |
|
207 |
liststore.append([gtk.STOCK_FILE, item, st]) |
|
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
208 |
|
209 |
# Create the columns and add them to the TreeView
|
|
210 |
self.treeview_right.set_model(liststore) |
|
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
211 |
tvcolumn_filename = gtk.TreeViewColumn(_('Filename')) |
212 |
tvcolumn_status = gtk.TreeViewColumn(_('Status')) |
|
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
213 |
self.treeview_right.append_column(tvcolumn_filename) |
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
214 |
self.treeview_right.append_column(tvcolumn_status) |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
215 |
|
216 |
# Set up the cells
|
|
|
0.8.17
by Szilveszter Farkas (Phanatic)
2006-07-19 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
217 |
cellpb = gtk.CellRendererPixbuf() |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
218 |
cell = gtk.CellRendererText() |
|
0.8.17
by Szilveszter Farkas (Phanatic)
2006-07-19 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
219 |
tvcolumn_filename.pack_start(cellpb, False) |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
220 |
tvcolumn_filename.pack_start(cell, True) |
|
0.8.17
by Szilveszter Farkas (Phanatic)
2006-07-19 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
221 |
tvcolumn_filename.set_attributes(cellpb, stock_id=0) |
|
0.8.12
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
222 |
tvcolumn_filename.add_attribute(cell, 'text', 1) |
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
223 |
tvcolumn_status.pack_start(cell, True) |
224 |
tvcolumn_status.add_attribute(cell, 'text', 2) |
|
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
225 |
|
|
0.8.53
by Szilveszter Farkas (Phanatic)
Set sensitivity of menus and toolbuttons. |
226 |
# Check if current directory is a branch
|
227 |
if is_branch(self.comm.get_path()): |
|
228 |
self.comm.menuitem_branch.set_sensitive(True) |
|
229 |
self.comm.menuitem_stats.set_sensitive(True) |
|
230 |
self.comm.menuitem_add_files.set_sensitive(True) |
|
231 |
self.comm.menuitem_remove_files.set_sensitive(True) |
|
232 |
self.comm.menuitem_file_make_directory.set_sensitive(True) |
|
233 |
self.comm.menuitem_file_rename.set_sensitive(True) |
|
234 |
self.comm.menuitem_file_move.set_sensitive(True) |
|
235 |
self.comm.menutoolbutton_diff.set_sensitive(True) |
|
236 |
self.comm.toolbutton_log.set_sensitive(True) |
|
237 |
self.comm.toolbutton_commit.set_sensitive(True) |
|
238 |
self.comm.toolbutton_pull.set_sensitive(True) |
|
239 |
self.comm.toolbutton_push.set_sensitive(True) |
|
240 |
else: |
|
241 |
self.comm.menuitem_branch.set_sensitive(False) |
|
242 |
self.comm.menuitem_stats.set_sensitive(False) |
|
243 |
self.comm.menuitem_add_files.set_sensitive(False) |
|
244 |
self.comm.menuitem_remove_files.set_sensitive(False) |
|
245 |
self.comm.menuitem_file_make_directory.set_sensitive(False) |
|
246 |
self.comm.menuitem_file_rename.set_sensitive(False) |
|
247 |
self.comm.menuitem_file_move.set_sensitive(False) |
|
248 |
self.comm.menutoolbutton_diff.set_sensitive(False) |
|
249 |
self.comm.toolbutton_log.set_sensitive(False) |
|
250 |
self.comm.toolbutton_commit.set_sensitive(False) |
|
251 |
self.comm.toolbutton_pull.set_sensitive(False) |
|
252 |
self.comm.toolbutton_push.set_sensitive(False) |
|
253 |
||
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
254 |
# set cursor to default
|
255 |
self.comm.set_busy(self.treeview_right, False) |
|
|
0.8.15
by Szilveszter Farkas (Phanatic)
2006-07-18 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
256 |
|
257 |
class OliveCommunicator: |
|
258 |
""" This class is responsible for the communication between the different |
|
259 |
modules. """
|
|
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
260 |
def __init__(self, toplevel, pref): |
|
0.8.15
by Szilveszter Farkas (Phanatic)
2006-07-18 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
261 |
# Get glade main component
|
262 |
self.toplevel = toplevel |
|
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
263 |
# Preferences object
|
264 |
self.pref = pref |
|
|
0.8.15
by Szilveszter Farkas (Phanatic)
2006-07-18 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
265 |
# Default path
|
266 |
self._path = os.getcwd() |
|
267 |
||
268 |
# Initialize the statusbar
|
|
269 |
self.statusbar = self.toplevel.get_widget('statusbar') |
|
270 |
self.context_id = self.statusbar.get_context_id('olive') |
|
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
271 |
|
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
272 |
# Get the main window
|
273 |
self.window_main = self.toplevel.get_widget('window_main') |
|
|
0.8.41
by Szilveszter Farkas (Phanatic)
Main window preferences (size, position) are stored. |
274 |
# Get the HPaned
|
275 |
self.hpaned_main = self.toplevel.get_widget('hpaned_main') |
|
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
276 |
# Get the TreeViews
|
277 |
self.treeview_left = self.toplevel.get_widget('treeview_left') |
|
278 |
self.treeview_right = self.toplevel.get_widget('treeview_right') |
|
|
0.8.49
by Szilveszter Farkas (Phanatic)
Added View menu; implemented Refresh; some TODO changes. |
279 |
# Get some important menu items
|
|
0.8.53
by Szilveszter Farkas (Phanatic)
Set sensitivity of menus and toolbuttons. |
280 |
self.menuitem_add_files = self.toplevel.get_widget('menuitem_add_files') |
281 |
self.menuitem_remove_files = self.toplevel.get_widget('menuitem_remove_file') |
|
282 |
self.menuitem_file_make_directory = self.toplevel.get_widget('menuitem_file_make_directory') |
|
283 |
self.menuitem_file_rename = self.toplevel.get_widget('menuitem_file_rename') |
|
284 |
self.menuitem_file_move = self.toplevel.get_widget('menuitem_file_move') |
|
|
0.8.49
by Szilveszter Farkas (Phanatic)
Added View menu; implemented Refresh; some TODO changes. |
285 |
self.menuitem_view_show_hidden_files = self.toplevel.get_widget('menuitem_view_show_hidden_files') |
|
0.8.53
by Szilveszter Farkas (Phanatic)
Set sensitivity of menus and toolbuttons. |
286 |
self.menuitem_branch = self.toplevel.get_widget('menuitem_branch') |
|
0.8.50
by Szilveszter Farkas (Phanatic)
Major updates in the OliveMenu class. |
287 |
self.menuitem_branch_commit = self.toplevel.get_widget('menuitem_branch_commit') |
|
0.8.53
by Szilveszter Farkas (Phanatic)
Set sensitivity of menus and toolbuttons. |
288 |
self.menuitem_stats = self.toplevel.get_widget('menuitem_stats') |
|
0.8.50
by Szilveszter Farkas (Phanatic)
Major updates in the OliveMenu class. |
289 |
self.menuitem_stats_diff = self.toplevel.get_widget('menuitem_stats_diff') |
290 |
self.menuitem_stats_log = self.toplevel.get_widget('menuitem_stats_log') |
|
|
0.8.53
by Szilveszter Farkas (Phanatic)
Set sensitivity of menus and toolbuttons. |
291 |
# Get some toolbuttons
|
292 |
self.menutoolbutton_diff = self.toplevel.get_widget('menutoolbutton_diff') |
|
293 |
self.toolbutton_log = self.toplevel.get_widget('toolbutton_log') |
|
294 |
self.toolbutton_commit = self.toplevel.get_widget('toolbutton_commit') |
|
295 |
self.toolbutton_pull = self.toplevel.get_widget('toolbutton_pull') |
|
296 |
self.toolbutton_push = self.toplevel.get_widget('toolbutton_push') |
|
|
0.8.15
by Szilveszter Farkas (Phanatic)
2006-07-18 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
297 |
|
298 |
def set_path(self, path): |
|
299 |
""" Set the current path while browsing the directories. """ |
|
300 |
self._path = path |
|
301 |
||
302 |
def get_path(self): |
|
303 |
""" Get the current path. """ |
|
304 |
return self._path |
|
|
0.8.19
by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
305 |
|
306 |
def get_selected_right(self): |
|
307 |
""" Get the selected filename. """ |
|
308 |
treeselection = self.treeview_right.get_selection() |
|
309 |
(model, iter) = treeselection.get_selected() |
|
310 |
||
311 |
if iter is None: |
|
312 |
return None |
|
313 |
else: |
|
314 |
return model.get_value(iter, 1) |
|
|
0.8.33
by Szilveszter Farkas (Phanatic)
Implemented bookmarking. |
315 |
|
316 |
def get_selected_left(self): |
|
317 |
""" Get the selected bookmark. """ |
|
318 |
treeselection = self.treeview_left.get_selection() |
|
319 |
(model, iter) = treeselection.get_selected() |
|
320 |
||
321 |
if iter is None: |
|
322 |
return None |
|
323 |
else: |
|
324 |
return model.get_value(iter, 0) |
|
|
0.8.15
by Szilveszter Farkas (Phanatic)
2006-07-18 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
325 |
|
326 |
def set_statusbar(self, message): |
|
327 |
""" Set the statusbar message. """ |
|
328 |
self.statusbar.push(self.context_id, message) |
|
329 |
||
330 |
def clear_statusbar(self): |
|
331 |
""" Clean the last message from the statusbar. """ |
|
332 |
self.statusbar.pop(self.context_id) |
|
333 |
||
|
0.8.33
by Szilveszter Farkas (Phanatic)
Implemented bookmarking. |
334 |
def refresh_left(self): |
335 |
""" Refresh the bookmark list. """ |
|
336 |
# set cursor to busy
|
|
337 |
self.set_busy(self.treeview_left) |
|
338 |
||
339 |
# Get TreeStore and clear it
|
|
340 |
treestore = self.treeview_left.get_model() |
|
341 |
treestore.clear() |
|
342 |
||
343 |
# Get bookmarks
|
|
344 |
bookmarks = self.pref.get_bookmarks() |
|
345 |
||
346 |
# Add them to the TreeStore
|
|
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
347 |
titer = treestore.append(None, [_('Bookmarks')]) |
|
0.8.33
by Szilveszter Farkas (Phanatic)
Implemented bookmarking. |
348 |
for item in bookmarks: |
349 |
treestore.append(titer, [item]) |
|
350 |
||
351 |
# Add the TreeStore to the TreeView
|
|
352 |
self.treeview_left.set_model(treestore) |
|
353 |
||
354 |
# Expand the tree
|
|
355 |
self.treeview_left.expand_all() |
|
356 |
||
357 |
self.set_busy(self.treeview_left, False) |
|
358 |
||
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
359 |
def refresh_right(self, path=None): |
|
0.8.15
by Szilveszter Farkas (Phanatic)
2006-07-18 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
360 |
""" Refresh the file list. """ |
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
361 |
import olive.backend.fileops as fileops |
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
362 |
|
363 |
self.set_busy(self.treeview_right) |
|
364 |
||
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
365 |
if path is None: |
366 |
path = self.get_path() |
|
|
0.8.39
by Szilveszter Farkas (Phanatic)
Fixed the double-click Bookmarks bug. |
367 |
|
368 |
# A workaround for double-clicking Bookmarks
|
|
369 |
if not os.path.exists(path): |
|
370 |
self.set_busy(self.treeview_right, False) |
|
371 |
return
|
|
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
372 |
|
373 |
# Get ListStore and clear it
|
|
374 |
liststore = self.treeview_right.get_model() |
|
375 |
liststore.clear() |
|
376 |
||
377 |
dirs = ['..'] |
|
378 |
files = [] |
|
379 |
||
380 |
# Fill the appropriate lists
|
|
|
0.8.49
by Szilveszter Farkas (Phanatic)
Added View menu; implemented Refresh; some TODO changes. |
381 |
dotted_files = self.pref.get_preference('dotted_files', 'bool') |
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
382 |
for item in os.listdir(path): |
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
383 |
if not dotted_files and item[0] == '.': |
384 |
continue
|
|
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
385 |
if os.path.isdir(path + '/' + item): |
386 |
dirs.append(item) |
|
387 |
else: |
|
388 |
files.append(item) |
|
389 |
||
390 |
# Sort'em
|
|
391 |
dirs.sort() |
|
392 |
files.sort() |
|
393 |
||
394 |
# Add'em to the ListStore
|
|
395 |
for item in dirs: |
|
396 |
liststore.append([gtk.STOCK_DIRECTORY, item, '']) |
|
397 |
for item in files: |
|
|
0.8.55
by Szilveszter Farkas (Phanatic)
Gettext support added. |
398 |
status = fileops.status(path + '/' + item) |
399 |
if status == 'renamed': |
|
400 |
st = _('renamed') |
|
401 |
elif status == 'removed': |
|
402 |
st = _('removed') |
|
403 |
elif status == 'added': |
|
404 |
st = _('added') |
|
405 |
elif status == 'modified': |
|
406 |
st = _('modified') |
|
407 |
elif status == 'unchanged': |
|
408 |
st = _('unchanged') |
|
409 |
else: |
|
410 |
st = _('unknown') |
|
411 |
liststore.append([gtk.STOCK_FILE, item, st]) |
|
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
412 |
|
413 |
# Add the ListStore to the TreeView
|
|
414 |
self.treeview_right.set_model(liststore) |
|
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
415 |
|
|
0.8.53
by Szilveszter Farkas (Phanatic)
Set sensitivity of menus and toolbuttons. |
416 |
# Check if current directory is a branch
|
417 |
if is_branch(self.get_path()): |
|
418 |
# Activate some items
|
|
419 |
self.menuitem_branch.set_sensitive(True) |
|
420 |
self.menuitem_stats.set_sensitive(True) |
|
421 |
self.menuitem_add_files.set_sensitive(True) |
|
422 |
self.menuitem_remove_files.set_sensitive(True) |
|
423 |
self.menuitem_file_make_directory.set_sensitive(True) |
|
424 |
self.menuitem_file_rename.set_sensitive(True) |
|
425 |
self.menuitem_file_move.set_sensitive(True) |
|
426 |
self.menutoolbutton_diff.set_sensitive(True) |
|
427 |
self.toolbutton_log.set_sensitive(True) |
|
428 |
self.toolbutton_commit.set_sensitive(True) |
|
429 |
self.toolbutton_pull.set_sensitive(True) |
|
430 |
self.toolbutton_push.set_sensitive(True) |
|
431 |
else: |
|
432 |
# Deactivate some items
|
|
433 |
self.menuitem_branch.set_sensitive(False) |
|
434 |
self.menuitem_stats.set_sensitive(False) |
|
435 |
self.menuitem_add_files.set_sensitive(False) |
|
436 |
self.menuitem_remove_files.set_sensitive(False) |
|
437 |
self.menuitem_file_make_directory.set_sensitive(False) |
|
438 |
self.menuitem_file_rename.set_sensitive(False) |
|
439 |
self.menuitem_file_move.set_sensitive(False) |
|
440 |
self.menutoolbutton_diff.set_sensitive(False) |
|
441 |
self.toolbutton_log.set_sensitive(False) |
|
442 |
self.toolbutton_commit.set_sensitive(False) |
|
443 |
self.toolbutton_pull.set_sensitive(False) |
|
444 |
self.toolbutton_push.set_sensitive(False) |
|
445 |
||
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
446 |
self.set_busy(self.treeview_right, False) |
447 |
||
448 |
def set_busy(self, widget, busy=True): |
|
449 |
if busy: |
|
450 |
widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) |
|
451 |
else: |
|
452 |
widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR)) |
|
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
453 |
|
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
454 |
gtk.main_iteration(0) |
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
455 |
|
456 |
class OlivePreferences: |
|
457 |
""" A class which handles Olive's preferences. """ |
|
458 |
def __init__(self): |
|
459 |
""" Initialize the Preferences class. """ |
|
460 |
# Some default options
|
|
|
0.8.41
by Szilveszter Farkas (Phanatic)
Main window preferences (size, position) are stored. |
461 |
self.defaults = { 'strict_commit' : False, |
462 |
'dotted_files' : False, |
|
463 |
'window_width' : 700, |
|
464 |
'window_height' : 400, |
|
465 |
'window_x' : 40, |
|
466 |
'window_y' : 40, |
|
467 |
'paned_position': 200 } |
|
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
468 |
|
469 |
# Create a config parser object
|
|
470 |
self.config = ConfigParser.RawConfigParser() |
|
471 |
||
472 |
# Load the configuration
|
|
473 |
if sys.platform == 'win32': |
|
474 |
# Windows - no dotted files
|
|
475 |
self.config.read([os.path.expanduser('~/olive.conf')]) |
|
476 |
else: |
|
477 |
self.config.read([os.path.expanduser('~/.olive.conf')]) |
|
478 |
||
479 |
def _get_default(self, option): |
|
480 |
""" Get the default option for a preference. """ |
|
481 |
try: |
|
482 |
ret = self.defaults[option] |
|
483 |
except KeyError: |
|
484 |
return None |
|
485 |
else: |
|
486 |
return ret |
|
487 |
||
488 |
def refresh(self): |
|
489 |
""" Refresh the configuration. """ |
|
490 |
# First write out the changes
|
|
491 |
self.write() |
|
492 |
# Then load the configuration again
|
|
493 |
if sys.platform == 'win32': |
|
494 |
# Windows - no dotted files
|
|
495 |
self.config.read([os.path.expanduser('~/olive.conf')]) |
|
496 |
else: |
|
497 |
self.config.read([os.path.expanduser('~/.olive.conf')]) |
|
498 |
||
499 |
def write(self): |
|
500 |
""" Write the configuration to the appropriate files. """ |
|
501 |
if sys.platform == 'win32': |
|
502 |
# Windows - no dotted files
|
|
503 |
fp = open(os.path.expanduser('~/olive.conf'), 'w') |
|
504 |
self.config.write(fp) |
|
505 |
fp.close() |
|
506 |
else: |
|
507 |
fp = open(os.path.expanduser('~/.olive.conf'), 'w') |
|
508 |
self.config.write(fp) |
|
509 |
fp.close() |
|
510 |
||
|
0.8.41
by Szilveszter Farkas (Phanatic)
Main window preferences (size, position) are stored. |
511 |
def get_preference(self, option, kind='str'): |
512 |
""" Get the value of the given option. |
|
513 |
|
|
514 |
:param kind: str/bool/int/float. default: str
|
|
515 |
"""
|
|
516 |
if self.config.has_option('preferences', option): |
|
517 |
if kind == 'bool': |
|
518 |
return self.config.getboolean('preferences', option) |
|
519 |
elif kind == 'int': |
|
520 |
return self.config.getint('preferences', option) |
|
521 |
elif kind == 'float': |
|
522 |
return self.config.getfloat('preferences', option) |
|
523 |
else: |
|
524 |
return self.config.get('preferences', option) |
|
525 |
else: |
|
526 |
try: |
|
527 |
return self._get_default(option) |
|
528 |
except KeyError: |
|
529 |
return None |
|
530 |
||
531 |
def set_preference(self, option, value): |
|
532 |
""" Set the value of the given option. """ |
|
533 |
if self.config.has_section('preferences'): |
|
534 |
self.config.set('preferences', option, value) |
|
535 |
else: |
|
536 |
self.config.add_section('preferences') |
|
537 |
self.config.set('preferences', option, value) |
|
538 |
||
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
539 |
def get_bookmarks(self): |
540 |
""" Return the list of bookmarks. """ |
|
541 |
bookmarks = self.config.sections() |
|
542 |
if self.config.has_section('preferences'): |
|
543 |
bookmarks.remove('preferences') |
|
544 |
return bookmarks |
|
545 |
||
546 |
def add_bookmark(self, path): |
|
547 |
""" Add bookmark. """ |
|
548 |
try: |
|
549 |
self.config.add_section(path) |
|
|
0.8.33
by Szilveszter Farkas (Phanatic)
Implemented bookmarking. |
550 |
except ConfigParser.DuplicateSectionError: |
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
551 |
return False |
552 |
else: |
|
553 |
return True |
|
554 |
||
|
0.8.33
by Szilveszter Farkas (Phanatic)
Implemented bookmarking. |
555 |
def remove_bookmark(self, path): |
|
0.8.32
by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes. |
556 |
""" Remove bookmark. """ |
557 |
return self.config.remove_section(path) |