/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: Vincent Ladeuil
  • Date: 2008-06-10 15:25:47 UTC
  • mto: This revision was merged to the branch mainline in revision 504.
  • Revision ID: v.ladeuil+lp@free.fr-20080610152547-dwmil1p8pd0mfpnl
Fix third failing test (thanks to jam).

* tests/test_commit.py:
(TestPendingRevisions.test_pending_revisions_multi_merge): Fix
provided by jam: bzr we now filter the pending merges so that only
the 'heads()' are included. We just ensure that the pending merges
contain the unique tips for the ancestries.

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_refresh.set_tooltip_text(_i18n("Refresh the file list"))
285
 
        self.tb_refresh.set_is_important(True)
286
 
        self.tb.add(self.tb_refresh)
287
 
        
288
 
        self.tb_diff_icon = gtk.Image()
289
 
        self.tb_diff_icon.set_from_file(icon_path("diff.png"))
290
 
        self.tb_diff = gtk.ToolButton(self.tb_diff_icon, _i18n("Diff"))
291
 
        self.tb_diff.connect('clicked', self.signal.on_menuitem_stats_diff_activate)
292
 
        self.tb_diff.set_tooltip_text(_i18n("View changes since last commit"))
293
 
        self.tb.add(self.tb_diff)
294
 
        
295
 
        self.tb_log_icon = gtk.Image()
296
 
        self.tb_log_icon.set_from_file(icon_path("log.png"))
297
 
        self.tb_log = gtk.ToolButton(self.tb_log_icon, _i18n("Log"))
298
 
        self.tb_log.connect('clicked', self.signal.on_menuitem_stats_log_activate)
299
 
        self.tb_log.set_tooltip_text(_i18n("View the revision history"))
300
 
        self.tb.add(self.tb_log)
301
 
        
302
 
        self.tb.add(gtk.SeparatorToolItem())
303
 
        
304
 
        self.tb_commit_icon = gtk.Image()
305
 
        self.tb_commit_icon.set_from_file(icon_path("commit.png"))
306
 
        self.tb_commit = gtk.ToolButton(self.tb_commit_icon, _i18n("Commit"))
307
 
        self.tb_commit.connect('clicked', self.signal.on_menuitem_branch_commit_activate)
308
 
        self.tb_commit.set_tooltip_text(_i18n("Commit changes to the current branch"))
309
 
        self.tb_commit.set_is_important(True)
310
 
        self.tb.add(self.tb_commit)
311
 
        
312
 
        self.tb.add(gtk.SeparatorToolItem())
313
 
        
314
 
        self.tb_pull_icon = gtk.Image()
315
 
        self.tb_pull_icon.set_from_file(icon_path("pull.png"))
316
 
        self.tb_pull = gtk.ToolButton(self.tb_pull_icon, _i18n("Pull"))
317
 
        self.tb_pull.connect('clicked', self.signal.on_menuitem_branch_pull_activate)
318
 
        self.tb_pull.set_tooltip_text(_i18n("Pull changes from the parent branch"))
319
 
        self.tb.add(self.tb_pull)
320
 
        
321
 
        self.tb_push_icon = gtk.Image()
322
 
        self.tb_push_icon.set_from_file(icon_path("push.png"))
323
 
        self.tb_push = gtk.ToolButton(self.tb_push_icon, _i18n("Push"))
324
 
        self.tb_push.connect('clicked', self.signal.on_menuitem_branch_push_activate)
325
 
        self.tb_push.set_tooltip_text(_i18n("Push the branch to a remote location"))
326
 
        self.tb.add(self.tb_push)
327
 
        
328
 
        self.tb_update_icon = gtk.Image()
329
 
        self.tb_update_icon.set_from_file(icon_path("pull.png"))
330
 
        self.tb_update = gtk.ToolButton(self.tb_update_icon, _i18n("Update"))
331
 
        self.tb_update.connect('clicked', self.signal.on_menuitem_branch_update_activate)
332
 
        self.tb_update.set_tooltip_text(_i18n("Update the working tree"))
333
 
        self.tb.add(self.tb_update)
334
 
    
335
 
    def _create_locationbar(self):
336
 
        """ Creates the location bar, including the history widgets """
337
 
        self.locationbar = gtk.HBox()
338
 
        
339
 
        self.button_location_up = gtk.Button()
340
 
        self.button_location_up.set_relief(gtk.RELIEF_NONE)
341
 
        image_location_up = gtk.Image()
342
 
        image_location_up.set_from_stock(gtk.STOCK_GO_UP, gtk.ICON_SIZE_BUTTON)
343
 
        self.button_location_up.add(image_location_up)
344
 
        self.button_location_up.connect("clicked", self.signal.on_button_location_up_clicked)
345
 
        self.locationbar.pack_start(self.button_location_up, False, False, 0)
346
 
        
347
 
        self.entry_location = gtk.Entry()
348
 
        self.entry_location.connect("activate", self.signal.on_button_location_jump_clicked)
349
 
        self.locationbar.pack_start(self.entry_location, True, True, 0)
350
 
        
351
 
        self.location_status = gtk.Image()
352
 
        self.location_status.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_BUTTON)
353
 
        self.locationbar.pack_start(self.location_status, False, False, 0)
354
 
        
355
 
        self.button_location_jump = gtk.Button(stock=gtk.STOCK_JUMP_TO)
356
 
        self.button_location_jump.set_relief(gtk.RELIEF_NONE)
357
 
        self.button_location_jump.connect("clicked", self.signal.on_button_location_jump_clicked)
358
 
        self.locationbar.pack_start(self.button_location_jump, False, False, 0)
359
 
        
360
 
        self.locationbar.pack_start(gtk.VSeparator(), False, False, 0)
361
 
        
362
 
        self.checkbutton_history = gtk.CheckButton(_i18n("H_istory Mode"))
363
 
        self.checkbutton_history.connect("toggled", self.signal.on_checkbutton_history_toggled)
364
 
        self.locationbar.pack_start(self.checkbutton_history, False, False, 0)
365
 
        
366
 
        self.entry_history_revno = gtk.Entry()
367
 
        self.entry_history_revno.set_property("width-request", 75)
368
 
        self.entry_history_revno.set_sensitive(False)
369
 
        self.entry_history_revno.connect("activate", self.signal.on_entry_history_revno_activate)
370
 
        self.locationbar.pack_start(self.entry_history_revno, False, False, 0)
371
 
        
372
 
        self.button_history_browse = gtk.Button()
373
 
        self.button_history_browse.set_sensitive(False)
374
 
        self.image_history_browse = gtk.Image()
375
 
        self.image_history_browse.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)
376
 
        self.button_history_browse.add(self.image_history_browse)
377
 
        self.button_history_browse.connect("clicked", self.signal.on_button_history_browse_clicked)
378
 
        self.locationbar.pack_start(self.button_history_browse, False, False, 0)
379
 
    
380
 
    def _create_bookmarklist(self):
381
 
        """ Creates the bookmark list (a ListStore in a TreeView in a ScrolledWindow)"""
382
 
        self.scrolledwindow_left = gtk.ScrolledWindow()
383
 
        self.scrolledwindow_left.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
384
 
        
385
 
        self.treeview_left = gtk.TreeView()
386
 
        self.treeview_left.connect("button-press-event", self.signal.on_treeview_left_button_press_event)
387
 
        self.treeview_left.connect("row-activated", self.signal.on_treeview_left_row_activated)
388
 
        self.scrolledwindow_left.add(self.treeview_left)
389
 
 
390
 
        self.bookmarklist = gtk.ListStore(gobject.TYPE_STRING, 
391
 
                                          gobject.TYPE_STRING, 
392
 
                                          gobject.TYPE_STRING)
393
 
        self.treeview_left.set_model(self.bookmarklist)
394
 
        
395
 
        icon = gtk.CellRendererPixbuf()
396
 
        cell = gtk.CellRendererText()
397
 
        
398
 
        col_bookmark = gtk.TreeViewColumn(_i18n('Bookmarks'))
399
 
        col_bookmark.pack_start(icon, False)
400
 
        col_bookmark.pack_start(cell, False)
401
 
        col_bookmark.set_attributes(icon, stock_id=2)
402
 
        col_bookmark.add_attribute(cell, 'text', 0)
403
 
        self.treeview_left.append_column(col_bookmark)
404
 
    
405
 
    def _create_filelist(self):
406
 
        """ Creates the file list (a ListStore in a TreeView in a ScrolledWindow)"""
407
 
        self.scrolledwindow_right = gtk.ScrolledWindow()
408
 
        self.scrolledwindow_right.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
409
 
        
410
 
        self.treeview_right = gtk.TreeView()
411
 
        self.treeview_right.connect("button-press-event", self.signal.on_treeview_right_button_press_event)
412
 
        self.treeview_right.connect("row-activated", self.signal.on_treeview_right_row_activated)
413
 
        self.scrolledwindow_right.add(self.treeview_right)
414
 
        
415
 
        # Model: [ icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local), fileid ]
416
 
        self.filelist = gtk.ListStore(gobject.TYPE_STRING,
417
 
                                      gobject.TYPE_BOOLEAN,
418
 
                                      gobject.TYPE_STRING,
419
 
                                      gobject.TYPE_STRING,
420
 
                                      gobject.TYPE_STRING,
421
 
                                      gobject.TYPE_STRING,
422
 
                                      gobject.TYPE_STRING,
423
 
                                      gobject.TYPE_INT,
424
 
                                      gobject.TYPE_STRING,
425
 
                                      gobject.TYPE_STRING)
426
 
        self.treeview_right.set_model(self.filelist)
427
 
        
428
 
        # Set up the cells
429
 
        cellpb = gtk.CellRendererPixbuf()
430
 
        cell = gtk.CellRendererText()
431
 
        # For columns that get a different text color based on status (4)
432
 
        cellstatus = gtk.CellRendererText()
433
 
        
434
 
        self.col_filename = gtk.TreeViewColumn(_i18n('Filename'))
435
 
        self.col_filename.pack_start(cellpb, False)
436
 
        self.col_filename.pack_start(cell, True)
437
 
        self.col_filename.set_attributes(cellpb, stock_id=0)
438
 
        self.col_filename.add_attribute(cell, 'text', 2)
439
 
        self.col_filename.set_resizable(True)
440
 
        self.treeview_right.append_column(self.col_filename)
441
 
        
442
 
        self.col_status = gtk.TreeViewColumn(_i18n('Status'))
443
 
        self.col_status.pack_start(cellstatus, True)
444
 
        self.col_status.add_attribute(cellstatus, 'text', 3)
445
 
        self.col_status.set_cell_data_func(cellstatus, self._map_status_color)
446
 
        self.col_status.set_resizable(True)
447
 
        self.treeview_right.append_column(self.col_status)
448
 
        
449
 
        self.col_size = gtk.TreeViewColumn(_i18n('Size'))
450
 
        self.col_size.pack_start(cell, True)
451
 
        self.col_size.add_attribute(cell, 'text', 6)
452
 
        self.col_size.set_resizable(True)
453
 
        self.treeview_right.append_column(self.col_size)
454
 
        
455
 
        self.col_mtime = gtk.TreeViewColumn(_i18n('Last modified'))
456
 
        self.col_mtime.pack_start(cell, True)
457
 
        self.col_mtime.add_attribute(cell, 'text', 8)
458
 
        self.col_mtime.set_resizable(True)
459
 
        self.treeview_right.append_column(self.col_mtime)
460
 
        
461
 
        # Set up the properties of the TreeView
462
 
        self.treeview_right.set_headers_visible(True)
463
 
        self.treeview_right.set_headers_clickable(True)
464
 
        self.treeview_right.set_search_column(1)
465
 
        
466
 
        # Set up sorting
467
 
        self.filelist.set_sort_func(13, self.signal._sort_filelist_callback, None)
468
 
        self.filelist.set_sort_column_id(13, gtk.SORT_ASCENDING)
469
 
        self.col_filename.set_sort_column_id(13)
470
 
        self.col_status.set_sort_column_id(3)
471
 
        self.col_size.set_sort_column_id(5)
472
 
        self.col_mtime.set_sort_column_id(7)
473
 
    
474
 
    def _map_status_color(self, column, cell, model, iter):
475
 
        status = model.get_value(iter, 4)
476
 
        if status == 'unchanged':
477
 
            colorstatus = gtk.gdk.color_parse('black')
478
 
            weight = 400 # standard value
479
 
        elif status == 'removed':
480
 
            colorstatus = gtk.gdk.color_parse('red')
481
 
            weight = 800
482
 
        elif status == 'added':
483
 
            colorstatus = gtk.gdk.color_parse('green')
484
 
            weight = 800
485
 
        elif status == 'modified':
486
 
            colorstatus = gtk.gdk.color_parse("#FD00D3")
487
 
            weight = 800
488
 
        elif status == 'renamed':
489
 
            colorstatus = gtk.gdk.color_parse('blue')
490
 
            weight = 800
491
 
        elif status == 'ignored':
492
 
            colorstatus = gtk.gdk.color_parse('grey')
493
 
            weight = 600
494
 
        else: # status == unknown
495
 
            colorstatus = gtk.gdk.color_parse('orange')
496
 
            weight = 800
497
 
        cell.set_property('foreground-gdk', colorstatus)
498
 
        cell.set_property('weight', weight)
499
 
    
500
 
    def set_view_to_localbranch(self, notbranch=False):
501
 
        """ Change the sensitivity of gui items to reflect the fact that the path is a branch or not"""
502
 
        self.mb_branch_initialize.set_sensitive(notbranch)
503
 
        self.mb_branch_get.set_sensitive(notbranch)
504
 
        self.mb_branch_checkout.set_sensitive(notbranch)
505
 
        self.mb_branch_pull.set_sensitive(not notbranch)
506
 
        self.mb_branch_push.set_sensitive(not notbranch)
507
 
        self.mb_branch_update.set_sensitive(not notbranch)
508
 
        self.mb_branch_revert.set_sensitive(not notbranch)
509
 
        self.mb_branch_merge.set_sensitive(not notbranch)
510
 
        self.mb_branch_commit.set_sensitive(not notbranch)
511
 
        self.mb_branch_tags.set_sensitive(not notbranch)
512
 
        self.mb_branch_status.set_sensitive(not notbranch)
513
 
        self.mb_branch_missingrevisions.set_sensitive(not notbranch)
514
 
        self.mb_branch_conflicts.set_sensitive(not notbranch)
515
 
        self.mb_statistics.set_sensitive(not notbranch)
516
 
        self.mb_statistics_differences.set_sensitive(not notbranch)
517
 
        self.mb_file_add.set_sensitive(not notbranch)
518
 
        self.mb_file_remove.set_sensitive(not notbranch)
519
 
        self.mb_file_mkdir.set_sensitive(not notbranch)
520
 
        self.mb_file_rename.set_sensitive(not notbranch)
521
 
        self.mb_file_move.set_sensitive(not notbranch)
522
 
        self.mb_file_annotate.set_sensitive(not notbranch)
523
 
        self.tb_diff.set_sensitive(not notbranch)
524
 
        self.tb_log.set_sensitive(not notbranch)
525
 
        self.tb_commit.set_sensitive(not notbranch)
526
 
        self.tb_pull.set_sensitive(not notbranch)
527
 
        self.tb_push.set_sensitive(not notbranch)
528
 
        self.tb_update.set_sensitive(not notbranch)
529
 
    
530
 
    def set_view_to_remotebranch(self):
531
 
        """ Change the sensitivity of gui items to reflect the fact that the branch is remote"""
532
 
        self.mb_file_add.set_sensitive(False)
533
 
        self.mb_file_remove.set_sensitive(False)
534
 
        self.mb_file_mkdir.set_sensitive(False)
535
 
        self.mb_file_rename.set_sensitive(False)
536
 
        self.mb_file_move.set_sensitive(False)
537
 
        self.mb_file_annotate.set_sensitive(False)
538
 
        self.mb_branch_initialize.set_sensitive(False)
539
 
        self.mb_branch_get.set_sensitive(True)
540
 
        self.mb_branch_checkout.set_sensitive(True)
541
 
        self.mb_branch_pull.set_sensitive(False)
542
 
        self.mb_branch_push.set_sensitive(False)
543
 
        self.mb_branch_update.set_sensitive(False)
544
 
        self.mb_branch_revert.set_sensitive(False)
545
 
        self.mb_branch_merge.set_sensitive(False)
546
 
        self.mb_branch_commit.set_sensitive(False)
547
 
        self.mb_branch_tags.set_sensitive(True)
548
 
        self.mb_branch_status.set_sensitive(False)
549
 
        self.mb_branch_missingrevisions.set_sensitive(False)
550
 
        self.mb_branch_conflicts.set_sensitive(False)
551
 
        self.mb_statistics.set_sensitive(True)
552
 
        self.mb_statistics_differences.set_sensitive(False)
553
 
        self.tb_diff.set_sensitive(False)
554
 
        self.tb_log.set_sensitive(True)
555
 
        self.tb_commit.set_sensitive(False)
556
 
        self.tb_pull.set_sensitive(False)
557
 
        self.tb_push.set_sensitive(False)
558
 
        self.tb_update.set_sensitive(False)
559
 
    
560
 
    def set_location_status(self, stock_id, allowPopup=False):
561
 
        self.location_status.destroy()
562
 
        if allowPopup:
563
 
            self.location_status = gtk.Button()
564
 
            self.location_status.set_relief(gtk.RELIEF_NONE)
565
 
            image = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_BUTTON)
566
 
            image.show()
567
 
            self.location_status.add(image)
568
 
        else:
569
 
            self.location_status = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_BUTTON)
570
 
        self.locationbar.pack_start(self.location_status, False, False, 0)
571
 
        if sys.platform == 'win32':
572
 
            self.locationbar.reorder_child(self.location_status, 2)
573
 
        else:
574
 
            self.locationbar.reorder_child(self.location_status, 1)
575
 
        self.location_status.show()