/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/window.py

  • Committer: Jelmer Vernooij
  • Date: 2010-03-03 14:10:25 UTC
  • mto: This revision was merged to the branch mainline in revision 686.
  • Revision ID: jelmer@samba.org-20100303141025-rz53ongyh8miv3q5
Don't crash when there is already a lan-notify instance running.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
 
2
# Some parts of the code are:
 
3
# Copyright (C) 2005, 2006 by Canonical Ltd
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 2 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 
 
19
import os
 
20
import sys
 
21
import gtk
 
22
import gobject
 
23
 
 
24
from bzrlib.plugins.gtk import _i18n, icon_path
 
25
 
 
26
 
 
27
class OliveGui(gtk.Window):
 
28
    """ Olive main window """
 
29
    
 
30
    def __init__(self, calling_app):
 
31
        # Pointer to calling instance for signal connection
 
32
        self.signal = calling_app
 
33
        
 
34
        # Initialise window
 
35
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
 
36
        self.set_title(_i18n("Olive - Bazaar GUI"))
 
37
        self.set_icon_list(gtk.gdk.pixbuf_new_from_file(icon_path("oliveicon2.png")),
 
38
                           gtk.gdk.pixbuf_new_from_file(icon_path("olive-gtk.png")),
 
39
                           # Who has the svg version of the icon? Would be nice to include
 
40
                           #gtk.gdk.pixbuf_new_from_file(icon_path("olive.svg"))
 
41
                           )
 
42
        self.set_property("width-request", 700)
 
43
        self.set_property("height-request", 400)
 
44
        
 
45
        self.connect("destroy", self.destroy)
 
46
        self.connect("delete_event", self.signal.on_window_main_delete_event)
 
47
        
 
48
        # Accelerator group to Quit program
 
49
        accelgroup = gtk.AccelGroup()
 
50
        self.add_accel_group(accelgroup)
 
51
        self.quit_action = gtk.Action(_i18n("Quit"), None, None, gtk.STOCK_QUIT)
 
52
        self.quit_action.connect('activate', self.signal.on_window_main_delete_event)
 
53
        actiongroup = gtk.ActionGroup('QuitAction')
 
54
        actiongroup.add_action_with_accel(self.quit_action, None)
 
55
        self.quit_action.set_accel_group(accelgroup)
 
56
        self.quit_action.connect_accelerator()
 
57
        
 
58
        # High level build up of window
 
59
        self.vbox = gtk.VBox(False, 0)
 
60
        self.add(self.vbox)
 
61
        
 
62
        # Menu bar
 
63
        self._create_menubar()
 
64
        self.vbox.pack_start(self.mb, False, False, 0)
 
65
        
 
66
        # Toolbar
 
67
        self._create_toolbar()
 
68
        self.vbox.pack_start(self.tb, False, False, 0)
 
69
        
 
70
        # Locationbar
 
71
        self._create_locationbar()
 
72
        self.vbox.pack_start(self.locationbar, False, False, 0)
 
73
        
 
74
        # Main area
 
75
        self.hpaned_main = gtk.HPaned()
 
76
        self._create_bookmarklist()
 
77
        self.hpaned_main.add(self.scrolledwindow_left)
 
78
        self._create_filelist()
 
79
        self.hpaned_main.add(self.scrolledwindow_right)
 
80
        self.vbox.pack_start(self.hpaned_main, True, True, 0)
 
81
        
 
82
        # Statusbar
 
83
        self.statusbar = gtk.Statusbar()
 
84
        self.vbox.pack_end(self.statusbar, False, False, 0)
 
85
    
 
86
    def show(self):
 
87
        self.show_all()        
 
88
    
 
89
    def destroy(self, widget=None, data=None):
 
90
        """ Ends the program """
 
91
        gtk.main_quit()
 
92
 
 
93
    def _create_menubar(self):
 
94
        self.mb = gtk.MenuBar()
 
95
        
 
96
        # File menu
 
97
        self.mb_file = gtk.MenuItem(_i18n("_File"))
 
98
        self.mb_file_menu = gtk.Menu()
 
99
        
 
100
        self.mb_file_add = gtk.ImageMenuItem(gtk.STOCK_ADD, _i18n("_Add file(s)"))
 
101
        self.mb_file_add.connect('activate', self.signal.on_menuitem_add_files_activate)
 
102
        self.mb_file_menu.append(self.mb_file_add)
 
103
        
 
104
        self.mb_file_remove = gtk.ImageMenuItem(gtk.STOCK_REMOVE, _i18n("_Remove file(s)"))
 
105
        self.mb_file_remove.connect('activate', self.signal.on_menuitem_remove_file_activate)
 
106
        self.mb_file_menu.append(self.mb_file_remove)
 
107
        
 
108
        self.mb_file_menu.append(gtk.SeparatorMenuItem())
 
109
        
 
110
        self.mb_file_bookmark = gtk.MenuItem(_i18n("_Bookmark current directory"))
 
111
        self.mb_file_bookmark.connect('activate', self.signal.on_menuitem_file_bookmark_activate)
 
112
        self.mb_file_menu.append(self.mb_file_bookmark)
 
113
        
 
114
        self.mb_file_mkdir = gtk.MenuItem(_i18n("_Make directory"))
 
115
        self.mb_file_mkdir.connect('activate', self.signal.on_menuitem_file_make_directory_activate)
 
116
        self.mb_file_menu.append(self.mb_file_mkdir)
 
117
        
 
118
        self.mb_file_menu.append(gtk.SeparatorMenuItem())
 
119
        
 
120
        self.mb_file_rename = gtk.MenuItem(_i18n("_Rename"))
 
121
        self.mb_file_rename.connect('activate', self.signal.on_menuitem_file_rename_activate)
 
122
        self.mb_file_menu.append(self.mb_file_rename)
 
123
        
 
124
        self.mb_file_move = gtk.MenuItem(_i18n("_Move"))
 
125
        self.mb_file_move.connect('activate', self.signal.on_menuitem_file_move_activate)
 
126
        self.mb_file_menu.append(self.mb_file_move)
 
127
        
 
128
        self.mb_file_annotate = gtk.MenuItem(_i18n("_Annotate"))
 
129
        self.mb_file_annotate.connect('activate', self.signal.on_menuitem_file_annotate_activate)
 
130
        self.mb_file_menu.append(self.mb_file_annotate)
 
131
        
 
132
        self.mb_file_menu.append(gtk.SeparatorMenuItem())
 
133
        
 
134
        self.mb_file_quit = self.quit_action.create_menu_item()
 
135
        self.mb_file_menu.append(self.mb_file_quit)
 
136
        
 
137
        self.mb_file.set_submenu(self.mb_file_menu)
 
138
        self.mb.append(self.mb_file)
 
139
        
 
140
        # View menu
 
141
        self.mb_view = gtk.MenuItem(_i18n("_View"))
 
142
        self.mb_view_menu = gtk.Menu()
 
143
        
 
144
        self.mb_view_showhidden = gtk.CheckMenuItem(_i18n("Show _hidden files"))
 
145
        self.mb_view_showhidden.connect('activate', self.signal.on_menuitem_view_show_hidden_files_activate)
 
146
        self.mb_view_menu.append(self.mb_view_showhidden)
 
147
        
 
148
        self.mb_view_showignored = gtk.CheckMenuItem(_i18n("Show _ignored files"))
 
149
        self.mb_view_showignored.connect('activate', self.signal.on_menuitem_view_show_ignored_files_activate)
 
150
        self.mb_view_menu.append(self.mb_view_showignored)
 
151
        
 
152
        self.mb_view_menu.append(gtk.SeparatorMenuItem())
 
153
        
 
154
        self.mb_view_refresh = gtk.ImageMenuItem(gtk.STOCK_REFRESH, _i18n("_Refresh"))
 
155
        self.mb_view_refresh.connect('activate', self.signal.on_menuitem_view_refresh_activate)
 
156
        self.mb_view_menu.append(self.mb_view_refresh)
 
157
        
 
158
        self.mb_view.set_submenu(self.mb_view_menu)
 
159
        self.mb.append(self.mb_view)
 
160
        
 
161
        # Branch menu
 
162
        self.mb_branch = gtk.MenuItem(_i18n("_Branch"))
 
163
        self.mb_branch_menu = gtk.Menu()
 
164
        
 
165
        self.mb_branch_initialize = gtk.MenuItem(_i18n("_Initialize"))
 
166
        self.mb_branch_initialize.connect('activate', self.signal.on_menuitem_branch_initialize_activate)
 
167
        self.mb_branch_menu.append(self.mb_branch_initialize)
 
168
        
 
169
        self.mb_branch_get = gtk.MenuItem(_i18n("_Get"))
 
170
        self.mb_branch_get.connect('activate', self.signal.on_menuitem_branch_get_activate)
 
171
        self.mb_branch_menu.append(self.mb_branch_get)
 
172
        
 
173
        self.mb_branch_checkout = gtk.MenuItem(_i18n("C_heckout"))
 
174
        self.mb_branch_checkout.connect('activate', self.signal.on_menuitem_branch_checkout_activate)
 
175
        self.mb_branch_menu.append(self.mb_branch_checkout)
 
176
        
 
177
        self.mb_branch_menu.append(gtk.SeparatorMenuItem())
 
178
        
 
179
        self.mb_branch_pull = gtk.ImageMenuItem(_i18n("Pu_ll"))
 
180
        pullimage = gtk.Image()
 
181
        pullimage.set_from_file(icon_path("pull16.png"))
 
182
        self.mb_branch_pull.set_image(pullimage)
 
183
        self.mb_branch_pull.connect('activate', self.signal.on_menuitem_branch_pull_activate)
 
184
        self.mb_branch_menu.append(self.mb_branch_pull)
 
185
        
 
186
        self.mb_branch_push = gtk.ImageMenuItem(_i18n("Pu_sh"))
 
187
        pushimage = gtk.Image()
 
188
        pushimage.set_from_file(icon_path("push16.png"))
 
189
        self.mb_branch_push.set_image(pushimage)
 
190
        self.mb_branch_push.connect('activate', self.signal.on_menuitem_branch_push_activate)
 
191
        self.mb_branch_menu.append(self.mb_branch_push)
 
192
        
 
193
        self.mb_branch_update = gtk.MenuItem(_i18n("_Update"))
 
194
        self.mb_branch_update.connect('activate', self.signal.on_menuitem_branch_update_activate)
 
195
        self.mb_branch_menu.append(self.mb_branch_update)
 
196
        
 
197
        self.mb_branch_menu.append(gtk.SeparatorMenuItem())
 
198
        
 
199
        self.mb_branch_revert = gtk.ImageMenuItem(_i18n("_Revert all changes"))
 
200
        revertimage = gtk.Image()
 
201
        revertimage.set_from_stock(gtk.STOCK_REVERT_TO_SAVED, gtk.ICON_SIZE_MENU)
 
202
        self.mb_branch_revert.set_image(revertimage)
 
203
        self.mb_branch_revert.connect('activate', self.signal.on_menuitem_branch_revert_activate)
 
204
        self.mb_branch_menu.append(self.mb_branch_revert)
 
205
        
 
206
        self.mb_branch_merge = gtk.MenuItem(_i18n("_Merge"))
 
207
        self.mb_branch_merge.connect('activate', self.signal.on_menuitem_branch_merge_activate)
 
208
        self.mb_branch_menu.append(self.mb_branch_merge)
 
209
        
 
210
        self.mb_branch_commit = gtk.ImageMenuItem(_i18n("_Commit"))
 
211
        commitimage = gtk.Image()
 
212
        commitimage.set_from_file(icon_path("commit16.png"))
 
213
        self.mb_branch_commit.set_image(commitimage)
 
214
        self.mb_branch_commit.connect('activate', self.signal.on_menuitem_branch_commit_activate)
 
215
        self.mb_branch_menu.append(self.mb_branch_commit)
 
216
        
 
217
        self.mb_branch_menu.append(gtk.SeparatorMenuItem())
 
218
        
 
219
        self.mb_branch_tags = gtk.ImageMenuItem(_i18n("Ta_gs"))
 
220
        tagsimage = gtk.Image()
 
221
        tagsimage.set_from_file(icon_path("tag-16.png"))
 
222
        self.mb_branch_tags.set_image(tagsimage)
 
223
        self.mb_branch_tags.connect('activate', self.signal.on_menuitem_branch_tags_activate)
 
224
        self.mb_branch_menu.append(self.mb_branch_tags)
 
225
        
 
226
        self.mb_branch_status = gtk.MenuItem(_i18n("S_tatus"))
 
227
        self.mb_branch_status.connect('activate', self.signal.on_menuitem_branch_status_activate)
 
228
        self.mb_branch_menu.append(self.mb_branch_status)
 
229
        
 
230
        self.mb_branch_missingrevisions = gtk.MenuItem(_i18n("Missing _revisions"))
 
231
        self.mb_branch_missingrevisions.connect('activate', self.signal.on_menuitem_branch_missing_revisions_activate)
 
232
        self.mb_branch_menu.append(self.mb_branch_missingrevisions)
 
233
        
 
234
        self.mb_branch_conflicts = gtk.MenuItem(_i18n("Con_flicts"))
 
235
        self.mb_branch_conflicts.connect('activate', self.signal.on_menuitem_branch_conflicts_activate)
 
236
        self.mb_branch_menu.append(self.mb_branch_conflicts)
 
237
        
 
238
        self.mb_branch.set_submenu(self.mb_branch_menu)
 
239
        self.mb.append(self.mb_branch)
 
240
        
 
241
        # Statistics menu
 
242
        self.mb_statistics = gtk.MenuItem(_i18n("_Statistics"))
 
243
        self.mb_statistics_menu = gtk.Menu()
 
244
        
 
245
        self.mb_statistics_differences = gtk.ImageMenuItem(_i18n("_Differences"))
 
246
        diffimage = gtk.Image()
 
247
        diffimage.set_from_file(icon_path("diff16.png"))
 
248
        self.mb_statistics_differences.set_image(diffimage)
 
249
        self.mb_statistics_differences.connect('activate', self.signal.on_menuitem_stats_diff_activate)
 
250
        self.mb_statistics_menu.append(self.mb_statistics_differences)
 
251
        
 
252
        self.mb_statistics_log = gtk.ImageMenuItem(_i18n("_Log"))
 
253
        logimage = gtk.Image()
 
254
        logimage.set_from_file(icon_path("log16.png"))
 
255
        self.mb_statistics_log.set_image(logimage)
 
256
        self.mb_statistics_log.connect('activate', self.signal.on_menuitem_stats_log_activate)
 
257
        self.mb_statistics_menu.append(self.mb_statistics_log)
 
258
        
 
259
        self.mb_statistics_information = gtk.MenuItem(_i18n("_Information"))
 
260
        self.mb_statistics_information.connect('activate', self.signal.on_menuitem_stats_infos_activate)
 
261
        self.mb_statistics_menu.append(self.mb_statistics_information)
 
262
        
 
263
        self.mb_statistics.set_submenu(self.mb_statistics_menu)
 
264
        self.mb.append(self.mb_statistics)
 
265
        
 
266
        # Help menu
 
267
        self.mb_help = gtk.MenuItem(_i18n("Help"))
 
268
        self.mb_help_menu = gtk.Menu()
 
269
        
 
270
        self.mb_help_about = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
 
271
        self.mb_help_about.connect('activate', self.signal.on_about_activate)
 
272
        self.mb_help_menu.append(self.mb_help_about)
 
273
        
 
274
        self.mb_help.set_submenu(self.mb_help_menu)
 
275
        self.mb.append(self.mb_help)
 
276
    
 
277
    def _create_toolbar(self):
 
278
        self.tb = gtk.Toolbar()
 
279
        
 
280
        self.tb_refresh_icon = gtk.Image()
 
281
        self.tb_refresh_icon.set_from_file(icon_path("refresh.png"))
 
282
        self.tb_refresh = gtk.ToolButton(self.tb_refresh_icon, _i18n("Refresh"))
 
283
        self.tb_refresh.connect('clicked', self.signal.on_menuitem_view_refresh_activate)
 
284
        self.tb.add(self.tb_refresh)
 
285
        
 
286
        self.tb_diff_icon = gtk.Image()
 
287
        self.tb_diff_icon.set_from_file(icon_path("diff.png"))
 
288
        self.tb_diff = gtk.ToolButton(self.tb_diff_icon, _i18n("Diff"))
 
289
        self.tb_diff.connect('clicked', self.signal.on_menuitem_stats_diff_activate)
 
290
        self.tb.add(self.tb_diff)
 
291
        
 
292
        self.tb_log_icon = gtk.Image()
 
293
        self.tb_log_icon.set_from_file(icon_path("log.png"))
 
294
        self.tb_log = gtk.ToolButton(self.tb_log_icon, _i18n("Log"))
 
295
        self.tb_log.connect('clicked', self.signal.on_menuitem_stats_log_activate)
 
296
        self.tb.add(self.tb_log)
 
297
        
 
298
        self.tb.add(gtk.SeparatorToolItem())
 
299
        
 
300
        self.tb_commit_icon = gtk.Image()
 
301
        self.tb_commit_icon.set_from_file(icon_path("commit.png"))
 
302
        self.tb_commit = gtk.ToolButton(self.tb_commit_icon, _i18n("Commit"))
 
303
        self.tb_commit.connect('clicked', self.signal.on_menuitem_branch_commit_activate)
 
304
        self.tb.add(self.tb_commit)
 
305
        
 
306
        self.tb.add(gtk.SeparatorToolItem())
 
307
        
 
308
        self.tb_pull_icon = gtk.Image()
 
309
        self.tb_pull_icon.set_from_file(icon_path("pull.png"))
 
310
        self.tb_pull = gtk.ToolButton(self.tb_pull_icon, _i18n("Pull"))
 
311
        self.tb_pull.connect('clicked', self.signal.on_menuitem_branch_pull_activate)
 
312
        self.tb.add(self.tb_pull)
 
313
        
 
314
        self.tb_push_icon = gtk.Image()
 
315
        self.tb_push_icon.set_from_file(icon_path("push.png"))
 
316
        self.tb_push = gtk.ToolButton(self.tb_push_icon, _i18n("Push"))
 
317
        self.tb_push.connect('clicked', self.signal.on_menuitem_branch_push_activate)
 
318
        self.tb.add(self.tb_push)
 
319
        
 
320
        self.tb_update_icon = gtk.Image()
 
321
        self.tb_update_icon.set_from_file(icon_path("pull.png"))
 
322
        self.tb_update = gtk.ToolButton(self.tb_update_icon, _i18n("Update"))
 
323
        self.tb_update.connect('clicked', self.signal.on_menuitem_branch_update_activate)
 
324
        self.tb.add(self.tb_update)
 
325
    
 
326
    def _create_locationbar(self):
 
327
        """ Creates the location bar, including the history widgets """
 
328
        self.locationbar = gtk.HBox()
 
329
        
 
330
        self.button_location_up = gtk.Button()
 
331
        self.button_location_up.set_relief(gtk.RELIEF_NONE)
 
332
        image_location_up = gtk.Image()
 
333
        image_location_up.set_from_stock(gtk.STOCK_GO_UP, gtk.ICON_SIZE_BUTTON)
 
334
        self.button_location_up.add(image_location_up)
 
335
        self.button_location_up.connect("clicked", self.signal.on_button_location_up_clicked)
 
336
        self.locationbar.pack_start(self.button_location_up, False, False, 0)
 
337
        
 
338
        self.entry_location = gtk.Entry()
 
339
        self.entry_location.connect("activate", self.signal.on_button_location_jump_clicked)
 
340
        self.locationbar.pack_start(self.entry_location, True, True, 0)
 
341
        
 
342
        self.location_status = gtk.Image()
 
343
        self.location_status.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_BUTTON)
 
344
        self.locationbar.pack_start(self.location_status, False, False, 0)
 
345
        
 
346
        self.button_location_jump = gtk.Button(stock=gtk.STOCK_JUMP_TO)
 
347
        self.button_location_jump.set_relief(gtk.RELIEF_NONE)
 
348
        self.button_location_jump.connect("clicked", self.signal.on_button_location_jump_clicked)
 
349
        self.locationbar.pack_start(self.button_location_jump, False, False, 0)
 
350
        
 
351
        self.locationbar.pack_start(gtk.VSeparator(), False, False, 0)
 
352
        
 
353
        self.checkbutton_history = gtk.CheckButton(_i18n("H_istory Mode"))
 
354
        self.checkbutton_history.connect("toggled", self.signal.on_checkbutton_history_toggled)
 
355
        self.locationbar.pack_start(self.checkbutton_history, False, False, 0)
 
356
        
 
357
        self.entry_history_revno = gtk.Entry()
 
358
        self.entry_history_revno.set_property("width-request", 75)
 
359
        self.entry_history_revno.set_sensitive(False)
 
360
        self.entry_history_revno.connect("activate", self.signal.on_entry_history_revno_activate)
 
361
        self.locationbar.pack_start(self.entry_history_revno, False, False, 0)
 
362
        
 
363
        self.button_history_browse = gtk.Button()
 
364
        self.button_history_browse.set_sensitive(False)
 
365
        self.image_history_browse = gtk.Image()
 
366
        self.image_history_browse.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)
 
367
        self.button_history_browse.add(self.image_history_browse)
 
368
        self.button_history_browse.connect("clicked", self.signal.on_button_history_browse_clicked)
 
369
        self.locationbar.pack_start(self.button_history_browse, False, False, 0)
 
370
    
 
371
    def _create_bookmarklist(self):
 
372
        """ Creates the bookmark list (a ListStore in a TreeView in a ScrolledWindow)"""
 
373
        self.scrolledwindow_left = gtk.ScrolledWindow()
 
374
        self.scrolledwindow_left.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
 
375
        
 
376
        self.treeview_left = gtk.TreeView()
 
377
        self.treeview_left.connect("button-press-event", self.signal.on_treeview_left_button_press_event)
 
378
        self.treeview_left.connect("row-activated", self.signal.on_treeview_left_row_activated)
 
379
        self.scrolledwindow_left.add(self.treeview_left)
 
380
 
 
381
        self.bookmarklist = gtk.ListStore(gobject.TYPE_STRING, 
 
382
                                          gobject.TYPE_STRING, 
 
383
                                          gobject.TYPE_STRING)
 
384
        self.treeview_left.set_model(self.bookmarklist)
 
385
        
 
386
        icon = gtk.CellRendererPixbuf()
 
387
        cell = gtk.CellRendererText()
 
388
        
 
389
        col_bookmark = gtk.TreeViewColumn(_i18n('Bookmarks'))
 
390
        col_bookmark.pack_start(icon, False)
 
391
        col_bookmark.pack_start(cell, False)
 
392
        col_bookmark.set_attributes(icon, stock_id=2)
 
393
        col_bookmark.add_attribute(cell, 'text', 0)
 
394
        self.treeview_left.append_column(col_bookmark)
 
395
    
 
396
    def _create_filelist(self):
 
397
        """ Creates the file list (a ListStore in a TreeView in a ScrolledWindow)"""
 
398
        self.scrolledwindow_right = gtk.ScrolledWindow()
 
399
        self.scrolledwindow_right.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
 
400
        
 
401
        self.treeview_right = gtk.TreeView()
 
402
        self.treeview_right.connect("button-press-event", self.signal.on_treeview_right_button_press_event)
 
403
        self.treeview_right.connect("row-activated", self.signal.on_treeview_right_row_activated)
 
404
        self.scrolledwindow_right.add(self.treeview_right)
 
405
        
 
406
        # Model: [ icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local), fileid ]
 
407
        self.filelist = gtk.ListStore(gobject.TYPE_STRING,
 
408
                                      gobject.TYPE_BOOLEAN,
 
409
                                      gobject.TYPE_STRING,
 
410
                                      gobject.TYPE_STRING,
 
411
                                      gobject.TYPE_STRING,
 
412
                                      gobject.TYPE_STRING,
 
413
                                      gobject.TYPE_STRING,
 
414
                                      gobject.TYPE_INT,
 
415
                                      gobject.TYPE_STRING,
 
416
                                      gobject.TYPE_STRING)
 
417
        self.treeview_right.set_model(self.filelist)
 
418
        
 
419
        # Set up the cells
 
420
        cellpb = gtk.CellRendererPixbuf()
 
421
        cell = gtk.CellRendererText()
 
422
        # For columns that get a different text color based on status (4)
 
423
        cellstatus = gtk.CellRendererText()
 
424
        
 
425
        self.col_filename = gtk.TreeViewColumn(_i18n('Filename'))
 
426
        self.col_filename.pack_start(cellpb, False)
 
427
        self.col_filename.pack_start(cell, True)
 
428
        self.col_filename.set_attributes(cellpb, stock_id=0)
 
429
        self.col_filename.add_attribute(cell, 'text', 2)
 
430
        self.col_filename.set_resizable(True)
 
431
        self.treeview_right.append_column(self.col_filename)
 
432
        
 
433
        self.col_status = gtk.TreeViewColumn(_i18n('Status'))
 
434
        self.col_status.pack_start(cellstatus, True)
 
435
        self.col_status.add_attribute(cellstatus, 'text', 3)
 
436
        self.col_status.set_cell_data_func(cellstatus, self._map_status_color)
 
437
        self.col_status.set_resizable(True)
 
438
        self.treeview_right.append_column(self.col_status)
 
439
        
 
440
        self.col_size = gtk.TreeViewColumn(_i18n('Size'))
 
441
        self.col_size.pack_start(cell, True)
 
442
        self.col_size.add_attribute(cell, 'text', 6)
 
443
        self.col_size.set_resizable(True)
 
444
        self.treeview_right.append_column(self.col_size)
 
445
        
 
446
        self.col_mtime = gtk.TreeViewColumn(_i18n('Last modified'))
 
447
        self.col_mtime.pack_start(cell, True)
 
448
        self.col_mtime.add_attribute(cell, 'text', 8)
 
449
        self.col_mtime.set_resizable(True)
 
450
        self.treeview_right.append_column(self.col_mtime)
 
451
        
 
452
        # Set up the properties of the TreeView
 
453
        self.treeview_right.set_headers_visible(True)
 
454
        self.treeview_right.set_headers_clickable(True)
 
455
        self.treeview_right.set_search_column(1)
 
456
        
 
457
        # Set up sorting
 
458
        self.filelist.set_sort_func(13, self.signal._sort_filelist_callback, None)
 
459
        self.filelist.set_sort_column_id(13, gtk.SORT_ASCENDING)
 
460
        self.col_filename.set_sort_column_id(13)
 
461
        self.col_status.set_sort_column_id(3)
 
462
        self.col_size.set_sort_column_id(5)
 
463
        self.col_mtime.set_sort_column_id(7)
 
464
    
 
465
    def _map_status_color(self, column, cell, model, iter):
 
466
        status = model.get_value(iter, 4)
 
467
        if status == 'unchanged':
 
468
            colorstatus = gtk.gdk.color_parse('black')
 
469
            weight = 400 # standard value
 
470
        elif status == 'removed':
 
471
            colorstatus = gtk.gdk.color_parse('red')
 
472
            weight = 800
 
473
        elif status == 'added':
 
474
            colorstatus = gtk.gdk.color_parse('green')
 
475
            weight = 800
 
476
        elif status == 'modified':
 
477
            colorstatus = gtk.gdk.color_parse("#FD00D3")
 
478
            weight = 800
 
479
        elif status == 'renamed':
 
480
            colorstatus = gtk.gdk.color_parse('blue')
 
481
            weight = 800
 
482
        elif status == 'ignored':
 
483
            colorstatus = gtk.gdk.color_parse('grey')
 
484
            weight = 600
 
485
        else: # status == unknown
 
486
            colorstatus = gtk.gdk.color_parse('orange')
 
487
            weight = 800
 
488
        cell.set_property('foreground-gdk', colorstatus)
 
489
        cell.set_property('weight', weight)
 
490
    
 
491
    def set_view_to_localbranch(self, notbranch=False):
 
492
        """ Change the sensitivity of gui items to reflect the fact that the path is a branch or not"""
 
493
        self.mb_branch_initialize.set_sensitive(notbranch)
 
494
        self.mb_branch_get.set_sensitive(notbranch)
 
495
        self.mb_branch_checkout.set_sensitive(notbranch)
 
496
        self.mb_branch_pull.set_sensitive(not notbranch)
 
497
        self.mb_branch_push.set_sensitive(not notbranch)
 
498
        self.mb_branch_update.set_sensitive(not notbranch)
 
499
        self.mb_branch_revert.set_sensitive(not notbranch)
 
500
        self.mb_branch_merge.set_sensitive(not notbranch)
 
501
        self.mb_branch_commit.set_sensitive(not notbranch)
 
502
        self.mb_branch_tags.set_sensitive(not notbranch)
 
503
        self.mb_branch_status.set_sensitive(not notbranch)
 
504
        self.mb_branch_missingrevisions.set_sensitive(not notbranch)
 
505
        self.mb_branch_conflicts.set_sensitive(not notbranch)
 
506
        self.mb_statistics.set_sensitive(not notbranch)
 
507
        self.mb_statistics_differences.set_sensitive(not notbranch)
 
508
        self.mb_file_add.set_sensitive(not notbranch)
 
509
        self.mb_file_remove.set_sensitive(not notbranch)
 
510
        self.mb_file_mkdir.set_sensitive(not notbranch)
 
511
        self.mb_file_rename.set_sensitive(not notbranch)
 
512
        self.mb_file_move.set_sensitive(not notbranch)
 
513
        self.mb_file_annotate.set_sensitive(not notbranch)
 
514
        self.tb_diff.set_sensitive(not notbranch)
 
515
        self.tb_log.set_sensitive(not notbranch)
 
516
        self.tb_commit.set_sensitive(not notbranch)
 
517
        self.tb_pull.set_sensitive(not notbranch)
 
518
        self.tb_push.set_sensitive(not notbranch)
 
519
        self.tb_update.set_sensitive(not notbranch)
 
520
    
 
521
    def set_view_to_remotebranch(self):
 
522
        """ Change the sensitivity of gui items to reflect the fact that the branch is remote"""
 
523
        self.mb_file_add.set_sensitive(False)
 
524
        self.mb_file_remove.set_sensitive(False)
 
525
        self.mb_file_mkdir.set_sensitive(False)
 
526
        self.mb_file_rename.set_sensitive(False)
 
527
        self.mb_file_move.set_sensitive(False)
 
528
        self.mb_file_annotate.set_sensitive(False)
 
529
        self.mb_branch_initialize.set_sensitive(False)
 
530
        self.mb_branch_get.set_sensitive(True)
 
531
        self.mb_branch_checkout.set_sensitive(True)
 
532
        self.mb_branch_pull.set_sensitive(False)
 
533
        self.mb_branch_push.set_sensitive(False)
 
534
        self.mb_branch_update.set_sensitive(False)
 
535
        self.mb_branch_revert.set_sensitive(False)
 
536
        self.mb_branch_merge.set_sensitive(False)
 
537
        self.mb_branch_commit.set_sensitive(False)
 
538
        self.mb_branch_tags.set_sensitive(True)
 
539
        self.mb_branch_status.set_sensitive(False)
 
540
        self.mb_branch_missingrevisions.set_sensitive(False)
 
541
        self.mb_branch_conflicts.set_sensitive(False)
 
542
        self.mb_statistics.set_sensitive(True)
 
543
        self.mb_statistics_differences.set_sensitive(False)
 
544
        self.tb_diff.set_sensitive(False)
 
545
        self.tb_log.set_sensitive(True)
 
546
        self.tb_commit.set_sensitive(False)
 
547
        self.tb_pull.set_sensitive(False)
 
548
        self.tb_push.set_sensitive(False)
 
549
        self.tb_update.set_sensitive(False)
 
550
    
 
551
    def set_location_status(self, stock_id, allowPopup=False):
 
552
        self.location_status.destroy()
 
553
        if allowPopup:
 
554
            self.location_status = gtk.Button()
 
555
            self.location_status.set_relief(gtk.RELIEF_NONE)
 
556
            image = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_BUTTON)
 
557
            image.show()
 
558
            self.location_status.add(image)
 
559
        else:
 
560
            self.location_status = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_BUTTON)
 
561
        self.locationbar.pack_start(self.location_status, False, False, 0)
 
562
        if sys.platform == 'win32':
 
563
            self.locationbar.reorder_child(self.location_status, 2)
 
564
        else:
 
565
            self.locationbar.reorder_child(self.location_status, 1)
 
566
        self.location_status.show()