/[ascend]/trunk/pygtk/moduleview.py
ViewVC logotype

Diff of /trunk/pygtk/moduleview.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2707 by sreenatha, Tue Feb 26 01:56:46 2013 UTC revision 2708 by jpye, Sun Aug 18 03:26:09 2013 UTC
# Line 1  Line 1 
1  import gtk  import gtk
2  import pango  import pango
3  import ascpy  import ascpy
 import gtksourceview2 as gtksourceview  
4  import os  import os
5    
6    HAVE_SOURCEVIEW=0
7    try:
8        from gtksourceview2 import Buffer as MyBuffer, View as MyView, language_manager_get_default
9        # Ensure that the ascend.lang settings are accessible for gtksourceview
10    
11        # TODO move this to ascdev / ascend scripts, it shouldn't be here as
12        # it contains assumptions about the filesystem layout.
13    
14        mgr = language_manager_get_default()
15        _op = mgr.get_search_path()
16        if os.path.join('..','tools','gtksourceview-2.0') not in _op:
17            _op.append(os.path.join('..','tools','gtksourceview-2.0'))
18            mgr.set_search_path(_op)
19        lang = mgr.get_language('ascend')
20        HAVE_SOURCEVIEW=1
21    except ImportError,e:
22        MyBuffer = gtk.TextBuffer
23        MyView = gtk.TextView
24    
25  class ModuleView:  class ModuleView:
26      def __init__(self,browser,builder, library):      def __init__(self,browser,builder, library):
27          """Set up the 'modules' tab, set up column types."""          """Set up the 'modules' tab, set up column types."""
# Line 204  class ViewModel: Line 222  class ViewModel:
222          window.add(box)          window.add(box)
223          box.show()          box.show()
224                    
         #Get the ASCEND language  
         mgr = gtksourceview.language_manager_get_default()  
         op = mgr.get_search_path()  
         if os.path.join('..','tools','gtksourceview-2.0') not in op:  
             op.append(os.path.join('..','tools','gtksourceview-2.0'))  
             mgr.set_search_path(op)  
         lang = mgr.get_language('ascend')  
   
225          # TODO add status bar where this message can be reported?          # TODO add status bar where this message can be reported?
226          if lang is None:          if not HAVE_SOURCEVIEW or lang is None:
227              print "UNABLE TO LOCATE ASCEND LANGUAGE DESCRIPTION for gtksourceview"              print "UNABLE TO LOCATE ASCEND LANGUAGE DESCRIPTION for gtksourceview"
228    
229          #Creating a ScrolledWindow for the textview widget          #Creating a ScrolledWindow for the textview widget
230          scroll = gtk.ScrolledWindow()          scroll = gtk.ScrolledWindow()
231          scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)          scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
232          view = gtksourceview.View()          view = MyView()
233          view.set_editable(False)          view.set_editable(False)
234          buff = gtksourceview.Buffer()          buff = MyBuffer()
235          buff.set_language(lang)          if HAVE_SOURCEVIEW:
236          buff.set_highlight_syntax(True)              buff.set_language(lang)
237                buff.set_highlight_syntax(True)
238          view.set_buffer(buff)          view.set_buffer(buff)
239          scroll.add(view)          scroll.add(view)
240    

Legend:
Removed from v.2707  
changed lines
  Added in v.2708

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22