summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fdfeb87)
raw | patch | inline | side by side (parent: fdfeb87)
author | Frederick Akalin <akalin@akalin.cx> | |
Fri, 5 Oct 2007 07:20:49 +0000 (00:20 -0700) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Tue, 16 Oct 2007 01:27:41 +0000 (21:27 -0400) |
Added support for gtksourceview2 module (pygtksourceview 1.90.x) in
gitview. Also refactored code that creates the source buffer and view.
Signed-off-by: Frederick Akalin <akalin@akalin.cx>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
gitview. Also refactored code that creates the source buffer and view.
Signed-off-by: Frederick Akalin <akalin@akalin.cx>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
contrib/gitview/gitview | patch | blob | history |
index 593176662050f0c84897759ab7d80f31aabfae53..449ee69bf48d41424e058b7bc61fd8ccc69c341d 100755 (executable)
--- a/contrib/gitview/gitview
+++ b/contrib/gitview/gitview
import string
import fcntl
+try:
+ import gtksourceview2
+ have_gtksourceview2 = True
+except ImportError:
+ have_gtksourceview2 = False
+
try:
import gtksourceview
have_gtksourceview = True
except ImportError:
have_gtksourceview = False
- print "Running without gtksourceview module"
+
+if not have_gtksourceview2 and not have_gtksourceview:
+ print "Running without gtksourceview2 or gtksourceview module"
re_ident = re.compile('(author|committer) (?P<ident>.*) (?P<epoch>\d+) (?P<tz>[+-]\d{4})')
return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(secs))
+def get_source_buffer_and_view():
+ if have_gtksourceview2:
+ buffer = gtksourceview2.Buffer()
+ slm = gtksourceview2.LanguageManager()
+ gsl = slm.get_language("diff")
+ buffer.set_highlight_syntax(True)
+ buffer.set_language(gsl)
+ view = gtksourceview2.View(buffer)
+ elif have_gtksourceview:
+ buffer = gtksourceview.SourceBuffer()
+ slm = gtksourceview.SourceLanguagesManager()
+ gsl = slm.get_language_from_mime_type("text/x-patch")
+ buffer.set_highlight(True)
+ buffer.set_language(gsl)
+ view = gtksourceview.SourceView(buffer)
+ else:
+ buffer = gtk.TextBuffer()
+ view = gtk.TextView(buffer)
+ return (buffer, view)
+
class CellRendererGraph(gtk.GenericCellRenderer):
"""Cell renderer for directed graph.
hpan.pack1(scrollwin, True, True)
scrollwin.show()
- if have_gtksourceview:
- self.buffer = gtksourceview.SourceBuffer()
- slm = gtksourceview.SourceLanguagesManager()
- gsl = slm.get_language_from_mime_type("text/x-patch")
- self.buffer.set_highlight(True)
- self.buffer.set_language(gsl)
- sourceview = gtksourceview.SourceView(self.buffer)
- else:
- self.buffer = gtk.TextBuffer()
- sourceview = gtk.TextView(self.buffer)
-
+ (self.buffer, sourceview) = get_source_buffer_and_view()
sourceview.set_editable(False)
sourceview.modify_font(pango.FontDescription("Monospace"))
vbox.pack_start(scrollwin, expand=True, fill=True)
scrollwin.show()
- if have_gtksourceview:
- self.message_buffer = gtksourceview.SourceBuffer()
- slm = gtksourceview.SourceLanguagesManager()
- gsl = slm.get_language_from_mime_type("text/x-patch")
- self.message_buffer.set_highlight(True)
- self.message_buffer.set_language(gsl)
- sourceview = gtksourceview.SourceView(self.message_buffer)
- else:
- self.message_buffer = gtk.TextBuffer()
- sourceview = gtk.TextView(self.message_buffer)
+ (self.message_buffer, sourceview) = get_source_buffer_and_view()
sourceview.set_editable(False)
sourceview.modify_font(pango.FontDescription("Monospace"))