Exemplo n.º 1
0
    def build_widget(self):
        w = gtk.ScrolledWindow()
        w.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        c = gtkhtml2.View()
        c.document = gtkhtml2.Document()

        def request_url(document, url, stream):
            print "request url", url, stream
            pass

        def link_clicked(document, link):
            u = self.get_url()
            if u:
                url = urllib.basejoin(u, link)
            else:
                url = link
            self.set_url(url)
            return True

        c.document.connect('link-clicked', link_clicked)
        c.document.connect('request-url', request_url)

        c.get_vadjustment().set_value(0)
        w.set_hadjustment(c.get_hadjustment())
        w.set_vadjustment(c.get_vadjustment())
        c.document.clear()
        c.set_document(c.document)
        w.add(c)
        self.component = c
        return w
Exemplo n.º 2
0
    def __init__(self, plide_main):
        self.plide_main = plide_main

        ## List of back and forward pages
        self.back_pages = []
        self.fwd_pages = []
        self.cur_page = None

        ## Connect back and forward buttons to event handlers
        plide_main.w_help_back.connect("clicked", self.go_back)
        plide_main.w_help_forward.connect("clicked", self.go_forward)

        ## Set up HTML document
        self.doc = gtkhtml2.Document()
        self.doc.connect("request-url", self.request_url)
        self.doc.connect("link-clicked", self.link_clicked)

        ## Set up HTML viewer widget
        self.view = gtkhtml2.View()
        self.view.set_property("can-focus", False)
        self.view.set_document(self.doc)
        self.view.set_magnification(1.0)
        self.view.show_all()

        plide_main.w_help_scrolledwindow.add(self.view)
Exemplo n.º 3
0
    def do_init(self):
        self.fetcher = Fetcher(self)
        self.doc = gtkhtml2.Document()
        self.doc.connect('request-url', self.cb_request_url)
        self.doc.connect('link-clicked', self.cb_link_clicked)
        self.view = gtkhtml2.View()
        self.view.connect('on-url', self.ro)
        self.view.set_document(self.doc)
        self.view.set_size_request(400, 300)
        self.swin = gtk.ScrolledWindow()
        self.swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.swin.add(self.view)

        self.win = gtk.VBox()

        hb = gtk.HBox()
        toolbar = gtkextra.Toolbar()
        hb.pack_start(toolbar.win, expand=False)

        toolbar.add_button('left', self.cb_back_clicked, 'Back')
        toolbar.add_button('close', self.cb_stop_clicked, 'Stop')

        self.location = gtk.Entry()
        hb.pack_start(self.location)

        self.location.connect('activate', self.cb_url_entered)

        self.win.pack_start(hb, expand=False)
        self.win.pack_start(self.swin)

        self.urlqueue = []
        self.urlqueueposition = 0
Exemplo n.º 4
0
 def __init__(self, manager=None):
     super(web_client, self).__init__()
     self.__view = gtkhtml2.View()
     self.add(self.__view)
     self.__document = gtkhtml2.Document()
     self.__view.set_document(self.__document)
     self.__document.connect('request-url', self.cb_request_url)
     self.__document.connect('link-clicked', self.cb_link_clicked)
     self.__current_url = None
     self.__current_mark = None
     self.__fetching_url = None
     self.__fetching_mark = None
     self.__manager = manager
    def getHtmlFilterResultsWidget(self):
        """ Return a treeview widget for filter results """

        html = gtkhtml2.View()

        # some default settings
        html._htmlTemplate = None

        document = gtkhtml2.Document()
        document.open_stream('text/html')
        document.write_stream('<html></html>')
        document.close_stream()
        html.set_document(document)
        return html
Exemplo n.º 6
0
    def __init__(self):
        gtk.Window.__init__(self)
        self.connect("delete_event", self.on_delete)

        doc = gtkhtml2.Document()
        doc.clear()
        doc.open_stream("text/html")
        #doc.write_stream(open("/home/knaka/buildcfg-fuji/license.desktop_companion.ia32/EULA.html").read())
        doc.write_stream("<html><body>Hello World!</body></html>")
        doc.close_stream()

        view = gtkhtml2.View()
        view.set_document(doc)
        #view.connect('request_object', request_object)

        self.add(view)
Exemplo n.º 7
0
    def activate(self, window):
# Setting up the interface
        self.vpan = gtk.VPaned() # All items are contained inside a vertical paned container
        self.vbox = gtk.VBox(False,3) # Items related to the command title, syntax and description are inside a vbox
        self.vbox.set_border_width(3)
# GTK label for title of the command
        self.title = gtk.Label()
        fonttitle = pango.FontDescription('Lucida Sans Bold 15')
        self.title.modify_font(fonttitle)
        self.title.set_alignment(0,0.5) 

# GTK label for syntax of the command
        self.syntax = gtk.Label("Select any ANSYS command and press F2 to see a short help")
        fontsyntax = pango.FontDescription('Lucida Sans 12')
        self.syntax.modify_font(fontsyntax)
        self.syntax.set_use_markup(True)
        self.syntax.set_alignment(0,0.5)

# GTK label for description of the command
        self.description = gtk.Label()
        self.description.set_alignment(0,0.5)
        
# gtkhtml2 widget to show the html help of the command item
# This cannot be displayed inside a gtk label
        self.htmlView = gtkhtml2.View()
        self.htmlDoc = gtkhtml2.Document()
        self.scrollwin = gtk.ScrolledWindow()
        self.scrollwin.set_policy(gtk.POLICY_NEVER,gtk.POLICY_AUTOMATIC)
        self.htmlView.set_document(self.htmlDoc)

# Put all the command title,syntax items inside the vbox
        self.vbox.pack_start(self.title,False)
        self.vbox.pack_start(self.syntax,False)
        self.vbox.pack_start(self.description,False)
        self.vpan.add1(self.vbox)

# The htmlview item should be put inside a scroll window, otherwise overflowing data will be hidden
        self.scrollwin.add(self.htmlView)
        self.vpan.add2(self.scrollwin)

# Adding everything to the side panel, if you want it in the bottom panel, change side_panel to bottom_panel
        self.sidepanel = window.get_side_panel()
        self.sidepanel.add_item(self.vpan,"Ansys Help", gtk.STOCK_HELP)
        self.vpan.show_all()

# To check what the user is typing, the plugin has to listen to all keypress events happening inside the gedit window
        window.connect("key-press-event",self.keypress)
Exemplo n.º 8
0
 def show_object(self, obj):
     '''Show object in view.'''
     # It doesn't make sense to render something empty
     if not obj.is_text_or_html():
         return
     if not len(obj.get_body()):
         return
     mimeType = 'text/html'
     try:
         document = gtkhtml2.Document()
         document.clear()
         document.open_stream(mimeType)
         document.write_stream(obj.get_body())
         document.close_stream()
         self._renderingWidget.set_document(document)
     except ValueError, ve:
         # I get here when the mime type is an image or something that I can't display
         pass
Exemplo n.º 9
0
    def __init__(self, base, content_type, body):
        import cgi
        import gnome
        import gtk.glade
        import gtkhtml2
        import sys
        import BlipIcons
        import SamplerConfig
        import Paths
        import Signals

        argv = sys.argv
        sys.argv = [sys.argv[0]]
        gnome.program_init('wrapper', SamplerConfig.version)
        sys.argv = argv

        xml = gtk.glade.XML(Paths.glade)
        Signals.autoconnect(self, xml)
        self.__dialog = xml.get_widget('server-message')
        pixmap = self.__dialog.render_icon(BlipIcons.stock[True],
                                           BlipIcons.ICON_SIZE_EMBLEM, '')
        self.__dialog.set_icon(pixmap)

        document = gtkhtml2.Document()
        document.connect('request_url', self.on_request_url)
        document.connect('set_base', self.on_set_base)
        document.connect('link_clicked', self.on_link_clicked)
        document.connect('title_changed', self.on_title_changed)
        document.dialog = self.__dialog
        document.base = ''
        self.on_set_base(document, base)
        [mime_type, options] = cgi.parse_header(content_type)
        document.open_stream(mime_type)
        document.write_stream(body)
        document.close_stream()
        self.__document = document

        view = gtkhtml2.View()
        view.set_document(document)
        port = xml.get_widget('html-scroll')
        port.add(view)
        view.show()
Exemplo n.º 10
0
    def setup_startpage(self, show_page=True):
        self.opener = urllib.FancyURLopener()
        self.document = gtkhtml2.Document()
        self.document.connect('request_url', self.__request_url)
        self.document.connect('link_clicked', self.__handle_link)
        self.document.clear()

        self.view = gtkhtml2.View()
        self.view.set_document(self.document)
        self.view.connect('request_object', self.__request_object)
        self.view.connect('on_url', self.__on_url)
        self.view.connect('style-set', self.__style_set)
        try:
            result = locale.getlocale(locale.LC_CTYPE)
            self.lang = result[0]
        except locale.Error:
            self.lang = "C"
        if self.lang == None or self.lang == "":
            self.lang = "C"
        self.lang_root = self.lang.split('_')[0]
        # Load Start Page to setup base URL to allow loading images in other pages
        self.load_startpage(show_page)
Exemplo n.º 11
0
	def post_show_init(self, widget):
		import gtkhtml2
		import SimpleImageCache
		import threading
		
		htmlview = gtkhtml2.View()
		self._document = gtkhtml2.Document()
		self._document.connect("link-clicked", self._link_clicked)
		htmlview.connect("on_url", self._on_url)
		self._document.connect("request-url", self._request_url)
		htmlview.get_vadjustment().set_value(0)
		htmlview.get_hadjustment().set_value(0)
		
		self._document.clear()
		htmlview.set_document(self._document)
		self._htmlview = htmlview
		
		widget.set_property("shadow-type",gtk.SHADOW_IN)
		widget.set_hadjustment(self._htmlview.get_hadjustment())
		widget.set_vadjustment(self._htmlview.get_vadjustment())
		widget.add(self._htmlview)
		self._scrolled_window = widget
Exemplo n.º 12
0
	def __init__(self, anaconda):
		self.currentURI = None
		self.htmlheader = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body bgcolor=\"white\"><pre>"
		self.htmlfooter = "</pre></body></html>"
		self.doc = gtkhtml2.Document()
		self.vue = gtkhtml2.View()
		self.opener = urllib.FancyURLopener()

		# FIXME: these do not work, disabling for FC6   --dcantrell
		#self.doc.connect('request_url', self.requestURLCallBack)
		#self.doc.connect('link_clicked', self.linkClickedCallBack)
		#self.vue.connect('request_object', self.requestObjectCallBack)
		self.topDir = None

		self.width = None
		self.height = None

		self.is_showing = False

		self.anaconda = anaconda
		self.load()
		self.resize()
		self.setupWindow()
Exemplo n.º 13
0
 def populate(self):
     self.fetcher = Fetcher(self)
     self.doc = gtkhtml2.Document()
     self.doc.connect('request-url', self.cb_request_url)
     self.doc.connect('link-clicked', self.cb_link_clicked)
     self.view = gtkhtml2.View()
     self.view.connect('on-url', self.ro)
     self.view.set_document(self.doc)
     self.view.set_size_request(400, 300)
     self.swin = gtk.ScrolledWindow()
     self.swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     self.swin.add(self.view)
     controls = toolbar.Toolbar()
     controls.connect('clicked', self.cb_toolbar_clicked)
     controls.add_button('back', 'left', 'Go back to the previous URL')
     controls.add_button('close', 'close', 'Stop loading the current URL')
     self.bar_area.pack_start(controls, expand=False)
     self.location = gtk.Entry()
     self.bar_area.pack_start(self.location)
     self.location.connect('activate', self.cb_url_entered)
     self.pack_start(self.swin)
     self.urlqueue = []
     self.urlqueueposition = 0
Exemplo n.º 14
0
    except OSError:
        print "failed to open", link
        return
    currentUrl = resolve_uri(link)
    document.clear()
    headers = f.info()
    mime = headers.getheader('Content-type').split(';')[0]
    if mime:
        document.open_stream(mime)
    else:
        document.open_stream('text/plain')
    document.write_stream(f.read())
    document.close_stream()


document = gtkhtml2.Document()
document.connect('request_url', request_url)
document.connect('link_clicked', link_clicked)

document.clear()
document.open_stream('text/html')
document.write_stream(
    '<table><tr><td><a href="http://ultamatix.com"><img src="http://downloadue.info/ultamatix/ultamatix.png" width="60" height="60" /></a></td><td><p> &nbsp; &nbsp; Avant Window Navigator is a dock-like bar which sits at the bottom of the screen. It has support for launchers, task lists, and third party applets. The official applet and plugin repository is in a separate project, awn-extras. The Awn project is the development of the dock, avant-window-navigator, and its corresponding shared library libawn, which is used to develop applets. </p></td></tr></table>'
)
document.close_stream()


def request_object(*args):
    print 'request object', args