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

  • Committer: rodney.dawes at canonical
  • Date: 2008-10-25 06:02:09 UTC
  • Revision ID: rodney.dawes@canonical.com-20081025060209-irlizouino63cs1m
        * preferences/__init__.py:
        Remove the dialog separator
        Remove useless extra call to self._create_pages()
        Make the default window size smaller
        Set the default border width on various widgets
        Set the current notebook page to the first one

        * preferences/identity.py:
        Set various border widths appropriately
        Align the labels to the left
        Remove the unneeded bold markup from the labels
        Change the "User Id" label to "E-Mail"
        Align the radio group labels to the top of the groups

        * preferences/plugins.py:
        Set various border widths appropriately
        Set the default paned position to something more sensible
        Set the shadow type on the treeview's scrolled window to in
        Align the Author and Version labels to the left

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
            self.buffer.set_language(gsl)
74
74
            self.buffer.set_highlight(True)
75
75
 
76
 
            sourceview = gtksourceview.SourceView(self.buffer)
 
76
            self.sourceview = gtksourceview.SourceView(self.buffer)
77
77
        else:
78
78
            self.buffer = gtk.TextBuffer()
79
 
            sourceview = gtk.TextView(self.buffer)
 
79
            self.sourceview = gtk.TextView(self.buffer)
80
80
 
81
 
        sourceview.set_editable(False)
82
 
        sourceview.modify_font(pango.FontDescription("Monospace"))
83
 
        self.add(sourceview)
84
 
        sourceview.show()
 
81
        self.sourceview.set_editable(False)
 
82
        self.sourceview.modify_font(pango.FontDescription("Monospace"))
 
83
        self.add(self.sourceview)
 
84
        self.sourceview.show()
85
85
 
86
86
    @staticmethod
87
87
    def apply_gedit_colors(lang):
305
305
        scrollwin.set_shadow_type(gtk.SHADOW_IN)
306
306
        self.pack1(scrollwin)
307
307
        scrollwin.show()
308
 
 
 
308
        
309
309
        self.model = gtk.TreeStore(str, str)
310
310
        self.treeview = gtk.TreeView(self.model)
311
311
        self.treeview.set_headers_visible(False)
330
330
        # text view
331
331
 
332
332
    def set_diff_text_sections(self, sections):
333
 
        self.diff_view = DiffFileView()
 
333
        if getattr(self, 'diff_view', None) is None:
 
334
            self.diff_view = DiffFileView()
 
335
            self.pack2(self.diff_view)
334
336
        self.diff_view.show()
335
 
        self.pack2(self.diff_view)
336
337
        for oldname, newname, patch in sections:
337
338
            self.diff_view._diffs[newname] = str(patch)
338
339
            if newname is None:
346
347
        Compares the two trees and populates the window with the
347
348
        differences.
348
349
        """
349
 
        self.diff_view = DiffView()
350
 
        self.pack2(self.diff_view)
 
350
        if getattr(self, 'diff_view', None) is None:
 
351
            self.diff_view = DiffView()
 
352
            self.pack2(self.diff_view)
351
353
        self.diff_view.show()
352
354
        self.diff_view.set_trees(rev_tree, parent_tree)
353
355
        self.rev_tree = rev_tree
380
382
                self.model.append(titer, [ path, path ])
381
383
 
382
384
        self.treeview.expand_all()
 
385
        self.diff_view.show_diff(None)
383
386
 
384
387
    def set_file(self, file_path):
385
388
        """Select the current file to display"""
402
405
            return
403
406
        elif specific_files == [ "" ]:
404
407
            specific_files = None
405
 
 
 
408
        
406
409
        self.diff_view.show_diff(specific_files)
407
 
 
 
410
    
 
411
    def _on_wraplines_toggled(self, widget=None, wrap=False):
 
412
        """Callback for when the wrap lines checkbutton is toggled"""
 
413
        if wrap or widget.get_active():
 
414
            self.diff_view.sourceview.set_wrap_mode(gtk.WRAP_WORD)
 
415
        else:
 
416
            self.diff_view.sourceview.set_wrap_mode(gtk.WRAP_NONE)
408
417
 
409
418
class DiffWindow(Window):
410
419
    """Diff window.
431
440
        self.vbox = gtk.VBox()
432
441
        self.add(self.vbox)
433
442
        self.vbox.show()
 
443
        self.diff = DiffWidget()
 
444
        self.vbox.pack_end(self.diff, True, True, 0)
 
445
        self.diff.show_all()
 
446
        # Build after DiffWidget to connect signals
 
447
        menubar = self._get_menu_bar()
 
448
        self.vbox.pack_start(menubar, False, False, 0)
434
449
        hbox = self._get_button_bar(operations)
435
450
        if hbox is not None:
436
 
            self.vbox.pack_start(hbox, expand=False, fill=True)
437
 
        self.diff = DiffWidget()
438
 
        self.vbox.add(self.diff)
439
 
        self.diff.show_all()
440
 
 
 
451
            self.vbox.pack_start(hbox, False, True, 0)
 
452
        
 
453
    
 
454
    def _get_menu_bar(self):
 
455
        menubar = gtk.MenuBar()
 
456
        # View menu
 
457
        mb_view = gtk.MenuItem(_i18n("_View"))
 
458
        mb_view_menu = gtk.Menu()
 
459
        mb_view_wrapsource = gtk.CheckMenuItem(_i18n("Wrap _Long Lines"))
 
460
        mb_view_wrapsource.connect('activate', self.diff._on_wraplines_toggled)
 
461
        mb_view_wrapsource.show()
 
462
        mb_view_menu.append(mb_view_wrapsource)
 
463
        mb_view.show()
 
464
        mb_view.set_submenu(mb_view_menu)
 
465
        mb_view.show()
 
466
        menubar.append(mb_view)
 
467
        menubar.show()
 
468
        return menubar
 
469
    
441
470
    def _get_button_bar(self, operations):
442
471
        """Return a button bar to use.
443
472
 
660
689
                    change_type = kind_changed
661
690
                    display_path = (paths[0] + source_marker
662
691
                                    + ' => ' + paths[1] + marker)
663
 
                elif changed_content is True or executables[0] != executables[1]:
 
692
                elif changed_content or executables[0] != executables[1]:
664
693
                    change_type = modified
665
694
                else:
666
695
                    assert False, "How did we get here?"