/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: Jasper Groenewegen
  • Date: 2008-07-27 11:37:31 UTC
  • mto: (577.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 579.
  • Revision ID: colbrac@xs4all.nl-20080727113731-p2krsw6o3m57ctu6
Add PointlessMerge error
Merge dialog title change
Merge dialog icon
Tweak logic

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
19
19
import os
20
 
import sys
21
20
import gtk
22
21
import gobject
23
22
 
281
280
        self.tb_refresh_icon.set_from_file(icon_path("refresh.png"))
282
281
        self.tb_refresh = gtk.ToolButton(self.tb_refresh_icon, _i18n("Refresh"))
283
282
        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
283
        self.tb.add(self.tb_refresh)
287
284
        
288
285
        self.tb_diff_icon = gtk.Image()
289
286
        self.tb_diff_icon.set_from_file(icon_path("diff.png"))
290
287
        self.tb_diff = gtk.ToolButton(self.tb_diff_icon, _i18n("Diff"))
291
288
        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
289
        self.tb.add(self.tb_diff)
294
290
        
295
291
        self.tb_log_icon = gtk.Image()
296
292
        self.tb_log_icon.set_from_file(icon_path("log.png"))
297
293
        self.tb_log = gtk.ToolButton(self.tb_log_icon, _i18n("Log"))
298
294
        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
295
        self.tb.add(self.tb_log)
301
296
        
302
297
        self.tb.add(gtk.SeparatorToolItem())
305
300
        self.tb_commit_icon.set_from_file(icon_path("commit.png"))
306
301
        self.tb_commit = gtk.ToolButton(self.tb_commit_icon, _i18n("Commit"))
307
302
        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
303
        self.tb.add(self.tb_commit)
311
304
        
312
305
        self.tb.add(gtk.SeparatorToolItem())
315
308
        self.tb_pull_icon.set_from_file(icon_path("pull.png"))
316
309
        self.tb_pull = gtk.ToolButton(self.tb_pull_icon, _i18n("Pull"))
317
310
        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
311
        self.tb.add(self.tb_pull)
320
312
        
321
313
        self.tb_push_icon = gtk.Image()
322
314
        self.tb_push_icon.set_from_file(icon_path("push.png"))
323
315
        self.tb_push = gtk.ToolButton(self.tb_push_icon, _i18n("Push"))
324
316
        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
317
        self.tb.add(self.tb_push)
327
318
        
328
319
        self.tb_update_icon = gtk.Image()
329
320
        self.tb_update_icon.set_from_file(icon_path("pull.png"))
330
321
        self.tb_update = gtk.ToolButton(self.tb_update_icon, _i18n("Update"))
331
322
        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
323
        self.tb.add(self.tb_update)
334
324
    
335
325
    def _create_locationbar(self):
348
338
        self.entry_location.connect("activate", self.signal.on_button_location_jump_clicked)
349
339
        self.locationbar.pack_start(self.entry_location, True, True, 0)
350
340
        
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)
 
341
        self.image_location_error = gtk.Image()
 
342
        self.image_location_error.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_BUTTON)
 
343
        self.locationbar.pack_start(self.image_location_error, False, False, 0)
354
344
        
355
345
        self.button_location_jump = gtk.Button(stock=gtk.STOCK_JUMP_TO)
356
346
        self.button_location_jump.set_relief(gtk.RELIEF_NONE)
383
373
        self.scrolledwindow_left.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
384
374
        
385
375
        self.treeview_left = gtk.TreeView()
 
376
        self.treeview_left.set_headers_visible(False)
386
377
        self.treeview_left.connect("button-press-event", self.signal.on_treeview_left_button_press_event)
387
378
        self.treeview_left.connect("row-activated", self.signal.on_treeview_left_row_activated)
388
379
        self.scrolledwindow_left.add(self.treeview_left)
389
380
 
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
 
    
 
381
        # Move olive/__init__.py _load_left List creation here
 
382
            
405
383
    def _create_filelist(self):
406
384
        """ Creates the file list (a ListStore in a TreeView in a ScrolledWindow)"""
 
385
        # Model: [ icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local), fileid ]
407
386
        self.scrolledwindow_right = gtk.ScrolledWindow()
408
387
        self.scrolledwindow_right.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
409
388
        
411
390
        self.treeview_right.connect("button-press-event", self.signal.on_treeview_right_button_press_event)
412
391
        self.treeview_right.connect("row-activated", self.signal.on_treeview_right_row_activated)
413
392
        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)
 
393
 
 
394
        # Move olive/__init__.py _load_right List creation here
499
395
    
500
396
    def set_view_to_localbranch(self, notbranch=False):
501
397
        """ Change the sensitivity of gui items to reflect the fact that the path is a branch or not"""
556
452
        self.tb_pull.set_sensitive(False)
557
453
        self.tb_push.set_sensitive(False)
558
454
        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()