def post_show_init(self, widget): if utils.RUNNING_HILDON: logging.debug("Hildon: Not using ajax view") self._USING_AJAX = False else: self._USING_AJAX = True if utils.HAS_GCONF: try: import gconf except: from gnome import gconf self._conf = gconf.client_get_default() self._conf.notify_add("/desktop/gnome/interface/font_name", self._gconf_reset_moz_font) self._reset_moz_font() utils.init_gtkmozembed() gtkmozembed.set_profile_path(self._home, "gecko") gtkmozembed.push_startup() self._moz = gtkmozembed.MozEmbed() self._moz.connect("new-window", self._new_window) self._moz.connect("link-message", self._link_message) self._moz.connect("open-uri", self._link_clicked) self._moz.connect("realize", self._realize, True) self._moz.connect("unrealize", self._realize, False) self._moz.connect("js-status", self._console_message) widget.add_with_viewport(self._moz) self._moz.show()
def __init__ (self, **keyword_args): # init stuff screenlets.Screenlet.__init__(self, width=325, height=370,uses_theme=True, is_widget=False, is_sticky=True,is_sizable=False, **keyword_args) self.add_options_group('Options', 'CPU-Graph specific options') self.add_option(BoolOption('Options', 'show_frame', self.show_frame, 'Show frame border', 'Show frame border arround the widget ...')) self.add_option(ColorOption('Options','rgba_color', self.rgba_color , 'Frame color', 'The color of the frame border')) self.add_option(IntOption('Options', 'set_width', self.set_width, 'Width', 'Custom width', min=10, max=gtk.gdk.screen_width())) self.add_option(IntOption('Options', 'set_height', self.set_height, 'Height', 'Custom height', min=10, max=gtk.gdk.screen_height())) #self.add_option(IntOption('Options', 'border_width', self.border_width, 'Frame border width', 'The width of the frame border', min=1, max=8)) self.disable_option('scale') self.theme_name = 'default' self.box = gtk.VBox(False, 0) if hasattr(gtkmozembed, 'set_profile_path'): gtkmozembed.set_profile_path(self.mypath,'mozilla') else: gtkmozembed.gtk_moz_embed_set_profile_path(self.mypath ,'mozilla') self.moz = gtkmozembed.MozEmbed() self.box.pack_start(self.moz, False, False, 0) self.window.add(self.box) self.window.show_all()
def main(): logging.basicConfig(level=logging.DEBUG) oddir = os.path.expanduser('~/.od/') odwidgets = os.path.join(oddir, 'widgets') try: os.makedirs(odwidgets) except: pass from pyonlinedesktop.firefox import FirefoxProfile ffp = FirefoxProfile() gtkmozembed.set_profile_path(oddir, 'widgets') shutil.copy(ffp.path_join('cookies.txt'), odwidgets) widget_environ = WidgetEnvironment() widget_environ['google_apps_auth_path'] = '' win = gtk.Window() vb = gtk.VBox() win.set_deletable(False) for url in sys.argv[1:]: metadata = WidgetParser(url, urllib2.urlopen(url), widget_environ) widget = Gadget(metadata, widget_environ) vb.add(widget) #win.set_title(widget.get_title()) win.add(vb) win.show_all() gtk.main()
def post_show_init(self, widget): if utils.RUNNING_HILDON: logging.debug("Hildon: Not using ajax view") self._USING_AJAX = False else: self._USING_AJAX = True if utils.HAS_GCONF: try: import gconf except: from gnome import gconf self._conf = gconf.client_get_default() self._conf.notify_add('/desktop/gnome/interface/font_name',self._gconf_reset_moz_font) self._reset_moz_font() utils.init_gtkmozembed() gtkmozembed.set_profile_path(self._home, 'gecko') gtkmozembed.push_startup() self._moz = gtkmozembed.MozEmbed() self._moz.connect("new-window", self._new_window) self._moz.connect("link-message", self._link_message) self._moz.connect("open-uri", self._link_clicked) self._moz.connect("realize", self._realize, True) self._moz.connect("unrealize", self._realize, False) self._moz.connect("js-status", self._console_message) widget.add_with_viewport(self._moz) self._moz.show()
def __init__(self, **kwargs): self._profile = kwargs.get('profile', self.DEFAULT_PROFILE) self._profileDir = kwargs.get('profileDir', self._get_profile_subdir()) log.info("Configuring Mozilla profile dir") self._create_prefs_js() gtkmozembed.set_profile_path(self._profileDir, self._profile)
def __init__(self): self.moz = gtkmozembed.MozEmbed() win = gtk.Window() win.set_default_size(800, 800) win.add(self.moz) gtkmozembed.set_profile_path("/tmp", "foobar") win.show_all() self.moz.load_url('http://hatfull12.bio.pitt.edu:8080') data = '<html><head><title>Hello</title></head><body>pygtk dev</body></html>' self.moz.render_data(data, long(len(data)), 'file:///', 'text/html')
def __init__(self): self.moz = gtkmozembed.MozEmbed() win = gtk.Window() win.set_default_size(800,800) win.add(self.moz) gtkmozembed.set_profile_path("/tmp", "foobar") win.show_all() self.moz.load_url('http://hatfull12.bio.pitt.edu:8080') data = '<html><head><title>Hello</title></head><body>pygtk dev</body></html>' self.moz.render_data(data, long(len(data)), 'file:///', 'text/html')
def start(self): def on_destroy(mozembed): gtk.main_quit() def on_resize(mozembed): size = self.win.get_size() width = size[0] height = size[1] if self.site_config.has_key("width") and self.site_config["width"] == width and self.site_config.has_key("height") and self.site_config["height"] == height: return self.site_config["width"] = width self.site_config["height"] = height config.save_site_config(self.site_config, None) def on_open_uri(mozembed, uri): print "Requested URI: " + uri return False def on_new_window(mozembed, retval, chromemask): url = mozembed.get_link_message() if not url: print "ERROR: new-window without URL" return None print "Calling default web browser: " + url webbrowser.open(url) return None site_dir = config.get_site_dir(self.site) print "Starting site: " + site_dir self.updateSelf() gtkmozembed.set_profile_path(site_dir, "profile") self.mozembed = gtkmozembed.MozEmbed() self.mozembed.load_url(self.url) self.mozembed.connect("open-uri", on_open_uri) self.mozembed.connect("new-window", on_new_window) self.mozembed.show() self.win = gtk.Window() self.win.set_title(self.title) self.win.set_default_size(self.width, self.height) self.win.set_position(gtk.WIN_POS_CENTER) icon_path = config.get_site_icon_path(self.site) if icon_path: self.win.set_icon_from_file(icon_path) self.win.set_icon_name(config.get_site_icon_name(self.site)) self.win.add(self.mozembed) self.win.connect("destroy", on_destroy) self.win.connect('check-resize', on_resize) self.win.show_all() gtk.main()
def init_gecko_browser(self): """ Initialize a Gecko web browser Python GtkMozembed Reference Manual: http://www.pygtk.org/pygtkmozembed/index.html """ import gtkmozembed if hasattr(gtkmozembed, 'set_profile_path'): gtkmozembed.set_profile_path(self.get_screenlet_dir(), self.gecko_browser_profile) else: gtkmozembed.gtk_moz_embed_set_profile_path(self.get_screenlet_dir(), self.gecko_browser_profile) self.gecko_browser = gtkmozembed.MozEmbed()
def __init__(self, app, profile_path): gtkmozembed.push_startup() gtkmozembed.set_profile_path(profile_path, "odfmobile_browser_profile") gtkmozembed.MozEmbed.__init__(self) self.app = app # Conect events self.connect("open-uri", self.filter_browser_url) self.connect("net-start", self.browser_start) self.connect("net-state", self.browser_state) self.connect("net-stop", self.browser_stop) self.set_size_request(24, 0)
def main(): """ Entry point for GtkMozEmbed Websnap. """ try: opts, args = getopt.getopt (sys.argv[1:], "ho:vu:", ["height=", "width=", "help", "output=", "url="]) except getopt.GetoptError : # print help information and exit: usage() sys.exit(2) WIDTH = 90 HEIGHT = 68 URL = '' OUTPUT = 'websnap.png' for o, a in opts: if o == "-v": verbose = True if o in ("-h", "--help"): usage() sys.exit() if o in ("-o", "--output"): OUTPUT = a if o in ("-u", "--url"): URL = a if o in ("--width"): WIDTH = a if o in ("--height"): HEIGHT = a if URL == '': # print help information and exit: usage() sys.exit(2) try: HomeDir = os.environ["HOME"] except KeyError: raise "No Home Directory, please set HOME environment variable." ProfileDir = HomeDir + "/.gtkmozwebsnap/" print "Note: a mozilla profile has been created in : " + ProfileDir gtkmozembed.set_profile_path(ProfileDir, "helpsys") window = PyGtkMozWebsnap(URL,WIDTH,HEIGHT,OUTPUT) window.parent.connect("destroy", __windowExit) gtk.main()
def build_widget(self): w = gtkmozembed.MozEmbed() # A profile must be initialized, cf # http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq19.018.htp gtkmozembed.set_profile_path("/tmp", "foobar") def update_location(c): if self.notify: self.notify(url=self.get_url()) return False def update_label(c): if self.notify: self.notify(label=c.get_link_message()) return False w.connect('location', update_location) w.connect('link-message', update_label) self.component = w return w
def build_widget(self): w=gtkmozembed.MozEmbed() # A profile must be initialized, cf # http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq19.018.htp gtkmozembed.set_profile_path("/tmp", "foobar") def update_location(c): if self.notify: self.notify(url=self.get_url()) return False def update_label(c): if self.notify: self.notify(label=c.get_link_message()) return False w.connect('location', update_location) w.connect('link-message', update_label) self.component=w return w
def prepare_browser(self): self.pyjama.preferences.register_plugin("Mozplug", self.create_preferences, self.save_preferences) profdir = os.path.join(self.home, "mozplug") profile = "default" prefsPath = os.path.join(profdir, profile, "prefs.js") self.pyjama.Events.connect_event("showing_artist_page", self.ev_artistpage) self.pyjama.Events.connect_event("showing_album_page", self.ev_albumpage) prefsContent = """ user_pref("browser.link.open_newwindow", 1); user_pref("browser.link.open_newwindow.restriction", 0); user_pref("browser.link.open_external", 1); user_pref("capability.policy.default.Window.open", "noAccess"); user_pref("security.warn_entering_secure", false); user_pref("security.warn_entering_weak", false); user_pref("security.warn_viewing_mixed", false); user_pref("security.warn_leaving_secure", false); user_pref("security.warn_submit_insecure", false); user_pref("security.warn_entering_secure.show_once", false); user_pref("security.warn_entering_weak.show_once", false); user_pref("security.warn_viewing_mixed.show_once", false); user_pref("security.warn_leaving_secure.show_once", false); user_pref("security.warn_submit_insecure.show_once", false); user_pref("security.enable_java", true); user_pref("browser.xul.error_pages.enabled", false); user_pref("general.useragent.vendor", "%s"); user_pref("general.useragent.vendorSub", "%s"); user_pref("general.useragent.vendorComment", "%s"); user_pref("modules.plugins.mimetype.application/x-shockwave-flash", ""); """ % ( "Pyjama", self.pyjama.version, "Python Jamendo Audioplayer", ) if os.path.exists(os.path.join(self.home, "mozplug", "default")) == False: os.makedirs(os.path.join(self.home, "mozplug", "default")) functions.preparedirs(set_privilegs=True) f = open(prefsPath, "wt") f.write(prefsContent) f.close() self.mozillaWidget = gtkmozembed.MozEmbed() gtkmozembed.set_profile_path(profdir, profile) self.mozillaWidget.connect("location", self.ev_location_changed) self.mozillaWidget.connect("link_message", self.ev_link_message) self.mozillaWidget.connect("new-window", self.ev_new_window) self.mozillaWidget.connect("progress", self.ev_progress) self.mozillaWidget.show() toolbar = gtk.Toolbar() toolbar.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR) toolbar.set_style(gtk.TOOLBAR_BOTH_HORIZ) toolbar.show() ## Back-button self.back = gtk.ToolButton() # x.set_label("") # home.set_is_important(True) self.back.set_stock_id(gtk.STOCK_GO_BACK) self.back.set_tooltip_text("Show previous page") self.back.connect("clicked", self.cb_toolbutton_clicked, "back") toolbar.insert(self.back, -1) self.back.show() ## Home-button home = gtk.ToolButton() # x.set_label("") # home.set_is_important(True) home.set_stock_id(gtk.STOCK_HOME) home.set_tooltip_text("View Jamendo's start page") home.connect("clicked", self.cb_toolbutton_clicked, "home") toolbar.insert(home, -1) home.show() ## forward-button self.forward = gtk.ToolButton() # x.set_label("") # home.set_is_important(True) self.forward.set_stock_id(gtk.STOCK_GO_FORWARD) self.forward.set_tooltip_text("Show next page in history") self.forward.connect("clicked", self.cb_toolbutton_clicked, "fwd") toolbar.insert(self.forward, -1) self.forward.show() ## address bar self.addressbar = gtk.ToolItem() self.addressbar.entry = gtk.Entry() self.addressbar.entry.set_size_request(300, -1) self.addressbar.entry.connect("key-press-event", self.cb_entry_keypress) self.addressbar.add(self.addressbar.entry) self.addressbar.entry.show() self.addressbar.show() toolbar.insert(self.addressbar, -1) ## go-button self.go = gtk.ToolButton() # x.set_label("") # home.set_is_important(True) self.go.set_stock_id(gtk.STOCK_OK) self.go.set_tooltip_text("Navigate to this page") self.go.connect("clicked", self.cb_toolbutton_clicked, "go") toolbar.insert(self.go, -1) self.go.show() ## Space space_fs = gtk.ToolItem() space_fs.set_expand(True) toolbar.insert(space_fs, -1) space_fs.show() ## Hide-button x = gtk.ToolButton() x.set_label("Hide this browser") x.set_is_important(True) x.set_stock_id(gtk.STOCK_GO_DOWN) x.set_tooltip_text("Hide this browser again") x.connect("clicked", self.cb_toolbutton_clicked, "hide") toolbar.insert(x, -1) x.show() self.frame = gtk.Frame(FRAME_STRING) self.frame.show() self.vbox = gtk.VBox(False) self.vbox.pack_start(toolbar, False, True) self.vbox.pack_start(self.mozillaWidget, True, True) self.statusbar = WebStatusBar() self.statusbar.show() self.vbox.pack_start(self.statusbar, False, False) self.frame.add(self.vbox)
m = re.search('(?<=v=).{11}',URL) id = m.group(0) # html code to render on the small web browser data ='<object width="100%" height="100%" data="http://www.youtube.com/swf/l.swf?video_id='+id+'&rel=1&iurl=null&color1=0x2b405b&color2=0x6b8ab6&autoplay=1" type="application/x-shockwave-flash"> <param name="allowFullScreen" value="true" /> <param name="src" value="http://www.youtube.com/swf/l.swf?video_id='+id+'&rel=1&iurl=null&color1=0x2b405b&color2=0x6b8ab6&autoplay=1" /> <param name="allowfullscreen" value="true" /></object>' def CloseWindow(caller_widget): """Close the window and exit the app""" gtk.main_quit() win = gtk.Window() win.set_title("Small Web Browser") win.set_position(gtk.WIN_POS_NONE) # general put the window on the top left corner win.set_resizable(True) # resizable window win.connect("destroy", CloseWindow) gtkmozembed.set_profile_path("/tmp", "simple_browser_user") mozbrowser = gtkmozembed.MozEmbed() # gtkmozembed win.add(mozbrowser) win.show_all() mozbrowser.set_size_request(272,223) #size of the window # show the video on the small web browser mozbrowser.render_data(data, long(len(data)), 'file:///', 'text/html') gtk.main()
frame.show() editor.show_all() # First draw everything, then add the content editor.load_html(t2thtml) import gtkmozembed win = gtk.Window() # Create a new GTK window called 'win' win.set_title("Simple Web Browser") # Set the title of the window win.set_position(gtk.WIN_POS_CENTER) # Position the window in the centre of the screen #win.connect("destroy", CloseWindow) # Connect the 'destroy' event to the #'CloseWindow' function, so that the app will quit properly when we press the close button # Create the browser widget gtkmozembed.set_profile_path("/tmp", "simple_browser_user") # Set a temporary Mozilla profile (works around some bug) mozbrowser = gtkmozembed.MozEmbed() # Create the browser widget # Set-up the browser widget before we display it win.add(mozbrowser) # Add the 'mozbrowser' widget to the main window 'win' mozbrowser.load_url('file:///home/jendrik/projects/Tests/complete_txt2tags_test.html') # Load a web page mozbrowser.set_size_request(600,400) # Attempt to set the size of the browser widget to 600x400 pixels mozbrowser.show() # Try to show the browser widget before we show the window, #so that the window appears at the correct size (600x400) win.show() gtk.main()
width -= 16 pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,width,height) pixbuf.get_from_drawable(window,self.widget.get_colormap(),0,0,0,0,width,height) pixbuf.save("screenshot.png","png") thumb = PIL.Image.open(file("screenshot.png")) thumb.thumbnail((133,100),PIL.Image.ANTIALIAS) thumb.save(file("screenshot-thumb.png","w")) print "Wrote screenshot.png and screenshot-thumb.png" gtk.main_quit() return True def __windowExit(widget, data=None): gtk.main_quit() if __name__ == "__main__": #try: #HomeDir = sys.argv[2] #except KeyError: #raise "No Home Directory, Don't Know What to Do" ProfileDir = sys.argv[2] + "/.gtkmozembedexample/" print "Note: a mozilla profile has been created in : " + ProfileDir gtkmozembed.set_profile_path(ProfileDir, "helpsys") window = PyGtkMozExample(URL=sys.argv[1]) window.parent.connect("destroy", __windowExit) gtk.main()
width -= 16 pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,width,height) pixbuf.get_from_drawable(window,self.widget.get_colormap(),0,0,0,0,width,height) pixbuf.save("screenshot.png","png") thumb = PIL.Image.open(file("screenshot.png")) thumb.thumbnail((133,100),PIL.Image.ANTIALIAS) thumb.save(file("screenshot-thumb.png","w")) print "Wrote screenshot.png and screenshot-thumb.png" gtk.main_quit() return True def __windowExit(widget, data=None): gtk.main_quit() if __name__ == "__main__": try: HomeDir = os.environ["HOME"] except KeyError: raise "No Home Directory, Don't Know What to Do" ProfileDir = HomeDir + "/.gtkmozembedexample/" print "Note: a mozilla profile has been created in : " + ProfileDir gtkmozembed.set_profile_path(ProfileDir, "helpsys") window = PyGtkMozExample(URL='portal') window.parent.connect("destroy", __windowExit) gtk.main()