/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: Jelmer Vernooij
  • Date: 2011-04-06 14:53:44 UTC
  • Revision ID: jelmer@samba.org-20110406145344-m6s0i7q7ssjwhmwq
Support use without gtk.Spinner, which is only available in pygtk >= 2.22.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import os
18
18
import re
19
19
import sys
 
20
import inspect
20
21
try:
21
22
    from xml.etree.ElementTree import Element, SubElement, tostring
22
23
except ImportError:
40
41
    urlutils,
41
42
    workingtree,
42
43
)
43
 
from bzrlib.diff import show_diff_trees, internal_diff
 
44
from bzrlib.diff import show_diff_trees
44
45
from bzrlib.patches import parse_patches
45
46
from bzrlib.trace import warning
46
47
from bzrlib.plugins.gtk import _i18n
47
48
from bzrlib.plugins.gtk.window import Window
48
 
from dialog import error_dialog, info_dialog, warning_dialog
 
49
from bzrlib.plugins.gtk.dialog import (
 
50
    error_dialog,
 
51
    info_dialog,
 
52
    warning_dialog,
 
53
    )
49
54
 
50
55
 
51
56
def fallback_guess_language(slm, content_type):
104
109
        :param buf: a gtksourceview2.Buffer object.
105
110
        """
106
111
        GEDIT_SCHEME_PATH = '/apps/gedit-2/preferences/editor/colors/scheme'
 
112
        GEDIT_USER_STYLES_PATH = os.path.expanduser('~/.gnome2/gedit/styles')
107
113
 
108
114
        client = gconf.client_get_default()
109
115
        style_scheme_name = client.get_string(GEDIT_SCHEME_PATH)
110
116
        if style_scheme_name is not None:
111
 
            style_scheme = gtksourceview2.StyleSchemeManager().get_scheme(style_scheme_name)
112
 
            
113
 
            buf.set_style_scheme(style_scheme)
 
117
            style_scheme_mgr = gtksourceview2.StyleSchemeManager()
 
118
            style_scheme_mgr.append_search_path(GEDIT_USER_STYLES_PATH)
 
119
            
 
120
            style_scheme = style_scheme_mgr.get_scheme(style_scheme_name)
 
121
            
 
122
            if style_scheme is not None:
 
123
                buf.set_style_scheme(style_scheme)
114
124
 
115
125
    @classmethod
116
126
    def apply_colordiff_colors(klass, buf):
524
534
 
525
535
class DiffController(object):
526
536
 
527
 
    def __init__(self, path, patch, window=None):
 
537
    def __init__(self, path, patch, window=None, allow_dirty=False):
528
538
        self.path = path
529
539
        self.patch = patch
 
540
        self.allow_dirty = allow_dirty
530
541
        if window is None:
531
542
            window = DiffWindow(operations=self._provide_operations())
532
543
            self.initialize_window(window)
538
549
 
539
550
    def get_diff_sections(self):
540
551
        yield "Complete Diff", None, ''.join(self.patch)
541
 
        for patch in parse_patches(self.patch):
 
552
        # allow_dirty was added to parse_patches in bzrlib 2.2b1
 
553
        if 'allow_dirty' in inspect.getargspec(parse_patches).args:
 
554
            patches = parse_patches(self.patch, allow_dirty=self.allow_dirty)
 
555
        else:
 
556
            patches = parse_patches(self.patch)
 
557
        for patch in patches:
542
558
            oldname = patch.oldname.split('\t')[0]
543
559
            newname = patch.newname.split('\t')[0]
544
560
            yield oldname, newname, str(patch)