def lookup_daemon_autostart (): """Adds Screenlets-daemon to autostart if not already""" if not os.path.isdir(DIR_AUTOSTART): # create autostart directory, if not existent if screenlets.show_question(None, _("There is no existing autostart directory for your user account yet. Do you want me to automatically create it for you?"), _('Error')): print "Auto-create autostart dir ..." os.system('mkdir %s' % DIR_AUTOSTART) if not os.path.isdir(DIR_AUTOSTART): screenlets.show_error(None, _("Automatic creation failed. Please manually create the directory:\n%s") % DIR_AUTOSTART, _('Error')) return False else: screenlets.show_message(None, _("Please manually create the directory:\n%s") % DIR_AUTOSTART) return False starter = '%sScreenlets Daemon.desktop' % (DIR_AUTOSTART) if not os.path.isfile(starter) and os.path.isfile('%sscreenlets-daemon.desktop' % (DIR_AUTOSTART)) == False: print "Create autostarter for: Screenlets Daemon" code = ['[Desktop Entry]'] code.append('Encoding=UTF-8') code.append('Version=1.0') code.append('Name=Screenlets Daemon') code.append('Type=Application') code.append('Exec=%s/share/screenlets-manager/screenlets-daemon.py' % (screenlets.INSTALL_PREFIX)) code.append('X-GNOME-Autostart-enabled=true') f = open(starter, 'w') if f: for l in code: f.write(l + '\n') f.close() return True print 'Failed to create autostarter for %s.' % name return False else: print "Starter already exists." return True
def daemon_check (): print _("checking for running daemon again ...") self.daemon_iface = utils.get_daemon_iface() if self.daemon_iface: print _("DAEMON FOUND - Ending timeout") self.connect_daemon() else: print _("Error: Unable to connect/launch daemon.") screenlets.show_error(None, _("Unable to connect or launch daemon. Some values may be displayed incorrectly."), _('Error'))
def install (self, filename): """Install a screenlet from a given archive-file. Extracts the contents of the archive to the user's screenlet dir.""" installer = install.ScreenletInstaller() result = installer.install(filename) if result: # reload screenlets to add new screenlet to iconview and show result screenlets.show_message(None, installer.get_result_message()) else: screenlets.show_error(None, installer.get_result_message())
def install(self, filename): """Install a screenlet from a given archive-file. Extracts the contents of the archive to the user's screenlet dir.""" installer = install.ScreenletInstaller() result = installer.install(filename) if result: # reload screenlets to add new screenlet to iconview and show result screenlets.show_message(None, installer.get_result_message()) else: screenlets.show_error(None, installer.get_result_message())
def get_more_screenlets_ubuntu(): if not is_screenlets_ppa_enabled(): print "PPA not enabled yet" if screenlets.show_question(None, _('The Screenlets PPA is not listed among Software Sources. Adding this enables installing individual screenlets from Package Manager (or Software Center) and by clicking on an AptURL on web pages like Gnome-look.org. Would you like to add the Screenlets PPA to your system?'), title=_("Do you want to enable the Screenlets PPA?")): result = commands.getstatusoutput('gksudo add-apt-repository ppa:screenlets-dev/ppa && gksudo apt-get update')[0] if result == 0: screenlets.show_message(None, _('The Screenlets PPA added successfully.'), title=_("Success!")) else: screenlets.show_error(None, _('Adding the Screenlets PPA failed.'), title=_("Failed!")) print "show web page anyway" subprocess.Popen(["xdg-open", screenlets.THIRD_PARTY_DOWNLOAD])
def on_menuitem_select(self, id): if id == 'check_mail': self.run_mailcheck() elif id == 'open_client': # TODO: execute e-mail application if self.mail_client != '': os.system(self.mail_client + '&') else: screenlets.show_error(self, _("You have to define an "+\ "eMail-client to be opened by this action (e.g. "+\ "evolution or thunderbird). Go to the Properties in "+\ "the right-click menu to define your client of choice."))
def on_menuitem_select (self, id): if id == 'check_mail': self.run_mailcheck() elif id == 'open_client': # TODO: execute e-mail application if self.mail_client != '': os.system(self.mail_client + '&') else: screenlets.show_error(self, _("You have to define an "+\ "eMail-client to be opened by this action (e.g. "+\ "evolution or thunderbird). Go to the Properties in "+\ "the right-click menu to define your client of choice."))
def menuitem_callback(self, widget, id): screenlets.Screenlet.menuitem_callback(self, widget, id) if id=="Empty": if self.trash_folder is None: screenlets.show_error(None, _("No trash folder found.")) elif screenlets.show_question(self,_('Do you want to permanently remove all the items in your Trash folder?')): if self.trash_folder==self.TRASH_DIRS[0]: os.system('rm -rf ' + os.environ['HOME'] + '/.local/share/Trash/info/*') os.system('rm -rf ' + self.trash_folder + '/*') os.system('rm -rf ' + self.trash_folder + '/*.*') os.system('rm -rf ' + self.trash_folder + '/.*') self.update() elif id=="Open": os.system('xdg-open trash:/// &')
def on_drop (self, x, y, sel_data, timestamp): # If the trash folder doesn't exist then just return # TODO: Create the trash folder when it doesn't exist. if self.trash_folder is None: screenlets.show_error(None, _('File(s) could not be moved to trash.')) return filename = '' # get text from selection data try: txt = unicode.encode(sel_data.get_text(), 'utf-8') except: txt = sel_data.get_text() txta = urllib.unquote(txt) txta = str(txta).split('\n') for txt in txta: if txt and txt != '': # if it is a filename, use it if txt.startswith('file://'): filename = txt[7:] else: screenlets.show_error(self, _('Invalid string: %s.') % txt) else: # else get uri-part of selection uris = sel_data.get_uris() if uris and len(uris)>0: filename = uris[0][7:] if filename != '': if self.trash_folder==self.TRASH_DIRS[0]: infofile=os.environ['HOME'] + '/.local/share/Trash/info/'+ os.path.basename(filename)+'.trashinfo' count=1 while os.path.exists(infofile): count=count+1 infofile=os.environ['HOME'] + '/.local/share/Trash/info/'+ os.path.basename(filename)+'.'+str(count)+'.trashinfo' f=open(infofile, 'w') f.write('[Trash Info]\n') f.write('Path='+filename+'\n') now=datetime.datetime.now() f.write('DeletionDate='+ str(now.strftime("%Y-%m-%dT%H:%M:%S"))) f.close() if count>1: os.system('mv ' + chr(34)+ filename + chr(34) + ' ' + chr(34) + self.trash_folder + '/' + os.path.basename(filename)+'.'+str(count) + chr(34)) else: os.system('mv ' + chr(34)+ filename + chr(34) + ' ' + self.trash_folder) filename = ''
def create_autostarter (name): """Create a .desktop-file for the screenlet with the given name in $HOME/.config/autostart.""" if not os.path.isdir(DIR_AUTOSTART): # create autostart directory, if not existent if screenlets.show_question(None, _("There is no existing autostart directory for your user account yet. Do you want me to automatically create it for you?"), _('Error')): print "Auto-create autostart dir ..." os.system('mkdir %s' % DIR_AUTOSTART) if not os.path.isdir(DIR_AUTOSTART): screenlets.show_error(None, _("Automatic creation failed. Please manually create the directory:\n%s") % DIR_AUTOSTART, _('Error')) return False else: screenlets.show_message(None, _("Please manually create the directory:\n%s") % DIR_AUTOSTART) return False if name.endswith('Screenlet'): name = name[:-9] starter = '%s%sScreenlet.desktop' % (DIR_AUTOSTART, name) for f in os.listdir(DIR_AUTOSTART): a = f.find(name + 'Screenlet') if a != -1: print str(f) + ' duplicate entry' os.system('rm %s%s' % (chr(34)+DIR_AUTOSTART,f+chr(34))) print 'Removed duplicate entry' if not os.path.isfile(starter) and not os.path.exists(xdg_config_home+'/autostart/CalendarScreenlet'): path = find_first_screenlet_path(name) if path: print "Create autostarter for: %s/%sScreenlet.py" % (path, name) code = ['[Desktop Entry]'] code.append('Name=%sScreenlet' % name) code.append('Encoding=UTF-8') code.append('Version=1.0') code.append('Type=Application') code.append('Exec= python -u %s/%sScreenlet.py' % (path, name)) code.append('X-GNOME-Autostart-enabled=true') #print code f = open(starter, 'w') if f: for l in code: f.write(l + '\n') f.close() return True print 'Failed to create autostarter for %s.' % name return False else: print "Starter already exists." return True
def get_info_from_package_name(self, filename): """Return all info we can get from the package-name or return None if something went wrong. If nothing failed, the returned value is a 4-tuple of the form: (name, version, basename, extension).""" base = os.path.basename(filename) ext = str(filename)[len(str(filename)) - 3:] # prepend "tar." if we have a bz2 or gz archive tar_opts = 'xfz' if ext == 'bz2': tar_opts = 'xfj' if ext == 'skz': screenlets.show_error( None, _('This type of karamba theme is not supported yet\n Only older versions can be used' )) return False # extract archive to temporary dir if not os.path.isdir('/tmp/screenlets/'): os.system('mkdir ' + '/tmp/screenlets/') try: os.system('rm -rf /tmp/screenlets/install-temp') except: pass tmpdir = '/tmp/screenlets' + '/install-temp/' os.system('mkdir %s' % tmpdir) os.system('tar %s %s -C %s' % (tar_opts, chr(34) + filename + chr(34), tmpdir)) for dd in os.listdir(tmpdir): if str(dd).endswith('.theme'): os.system('mv ' + tmpdir + ' ' + '/tmp/screenlets/' + dd[:-6]) os.system('mkdir %s' % tmpdir) os.system('mv ' + '/tmp/screenlets/' + dd[:-6] + ' ' + tmpdir) name = dd[:-6] return (name, ext) for d in tmpdir: #for each item in folders if os.path.exists(d) and os.path.isdir(d): #is it a valid folder? for f in os.listdir(tmpdir): name = f try: print name return (name, ext) except: return False
def __setattr__ (self, name, value): screenlets.Screenlet.__setattr__(self, name, value) if name == 'check_interval': self.set_check_interval(value) elif name in ('position_x', 'position_y', 'text_color'): self.redraw_canvas() elif name in ('known_mailcount', 'unchecked_mails'): self.redraw_canvas() elif name == 'backend_type': # FIXME: This is displayed on background, there has to be better way to do it # Can't the backend be restarted right away??? #if self.has_started:screenlets.show_message(self, _('Restart required')) if value == _('POP3'): self.set_backend(mail.POP3Backend) elif value == _('IMAP'): self.set_backend(mail.IMAPBackend) else: screenlets.show_error(self, _('Invalid backend type: %s') % value)
def get_info_from_package_name (self, filename): """Return all info we can get from the package-name or return None if something went wrong. If nothing failed, the returned value is a 4-tuple of the form: (name, version, basename, extension).""" base = os.path.basename(filename) ext = str(filename)[len(str(filename)) -3:] # prepend "tar." if we have a bz2 or gz archive tar_opts = 'xfz' if ext == 'bz2': tar_opts = 'xfj' if ext == 'skz': screenlets.show_error(None,_('This type of karamba theme is not supported yet\n Only older versions can be used')) return False # extract archive to temporary dir if not os.path.isdir('/tmp/screenlets/'): os.system('mkdir ' + '/tmp/screenlets/') try: os.system('rm -rf /tmp/screenlets/install-temp') except: pass tmpdir = '/tmp/screenlets' + '/install-temp/' os.system('mkdir %s' % tmpdir) os.system('tar %s %s -C %s' % (tar_opts, chr(34)+filename+chr(34), tmpdir)) for dd in os.listdir(tmpdir): if str(dd).endswith('.theme'): os.system('mv ' + tmpdir + ' ' + '/tmp/screenlets/' + dd[:-6]) os.system('mkdir %s' % tmpdir) os.system('mv ' + '/tmp/screenlets/' + dd[:-6] + ' '+ tmpdir) name = dd[:-6] return (name, ext) for d in tmpdir : #for each item in folders if os.path.exists(d) and os.path.isdir(d): #is it a valid folder? for f in os.listdir(tmpdir): name = f try: print name return (name, ext) except: return False
def __setattr__(self, name, value): screenlets.Screenlet.__setattr__(self, name, value) if name == 'check_interval': self.set_check_interval(value) elif name in ('position_x', 'position_y', 'text_color'): self.redraw_canvas() elif name in ('known_mailcount', 'unchecked_mails'): self.redraw_canvas() elif name == 'backend_type': # FIXME: This is displayed on background, there has to be better way to do it # Can't the backend be restarted right away??? #if self.has_started:screenlets.show_message(self, _('Restart required')) if value == _('POP3'): self.set_backend(mail.POP3Backend) elif value == _('IMAP'): self.set_backend(mail.IMAPBackend) else: screenlets.show_error(self, _('Invalid backend type: %s') % value)
def delete_selected_screenlet (self): """Delete the selected screenlet from the user's screenlet dir.""" sel = self.view.get_selected_items() if sel and len(sel) > 0 and len(sel[0]) > 0: it = self.model.get_iter(sel[0][0]) if it: info = self.model.get_value(it, 2) if info and not info.system: # delete the file if screenlets.show_question(None, _('Do you really want to permanently uninstall/delete the %sScreenlet from your system?' % info.name), _('Delete Screenlet')): # delete screenlet's directory from userdir os.system('rm -rf %s/%s' % (DIR_USER, info.name)) # remove entry from model self.model.remove(it) if screenlets.show_question(None, _('Do you also want to remove the Screenlet configuration files?')): os.system('rm -rf %s/%s' % (screenlets.DIR_CONFIG, info.name)) os.system('rm -rf %s/%sScreenlet.log' % (screenlets.DIR_CONFIG, info.name)) else: screenlets.show_error(None, _('Can\'t delete system-wide screenlets.')) return False
def drag_data_received (self, widget, dc, x, y, sel_data, info, timestamp): print _("Data dropped ...") filename = '' # get text-elements in selection data try: txt = unicode.encode(sel_data.get_text(), 'utf-8') except: txt = sel_data.get_text() txt = urllib.unquote(txt) if txt: if txt[-1] == '\n': txt = txt[:-1] txt.replace('\n', '\\n') # if it is a filename, use it if txt.startswith('file://'): filename = txt[7:] else: screenlets.show_error(self, _('Invalid string: %s.') % txt) else: # else get uri-part of selection uris = sel_data.get_uris() if uris and len(uris)>0: #print "URIS: "+str(uris ) filename = uris[0][7:] if filename != '': #self.set_image(filename) installer = install.ScreenletInstaller() if not utils.containsAny(filename,'%'): result = installer.install(filename) if result: # reload screenlets to add new screenlet to iconview and show result self.model.clear() self.load_screenlets() screenlets.show_message(None, installer.get_result_message()) else: screenlets.show_error(None, installer.get_result_message()) else: self.show_install_dialog() print _('Please install screenlets from folders without strange characters')
def __init__ (self): # inti props if not os.path.isdir(screenlets.DIR_CONFIG): os.system('mkdir %s' % screenlets.DIR_CONFIG) if not os.path.isdir(DIR_USER): os.system('mkdir %s' % DIR_USER) self.tips = gtk.Tooltips() # create ui and populate it self.create_ui() # populate UI self.load_screenlets() # if we are running as root, show error if USER == 0: screenlets.show_error(None, _("""Important! You are running this application as root user, almost all functionality is disabled. You can use this to install screenlets into the system-wide path."""), _('Warning!')) else: # lookup, connect dameon utils.lookup_daemon_autostart() self.lookup_daemon() self.connect_daemon()
def show_install_dialog (self): """Craete/Show the install-dialog.""" # create filter flt = gtk.FileFilter() flt.add_pattern('*.tar.bz2') flt.add_pattern('*.skz') flt.add_pattern('*.tar.gz') flt.add_pattern('*.zip') # create dialog dlg = gtk.FileChooserDialog(buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) dlg.set_current_folder(os.environ['HOME']) dlg.set_title(_('Install a Screenlet or SuperKaramba theme')) dlg.set_filter(flt) # run resp = dlg.run() filename = dlg.get_filename() dlg.destroy() if resp == gtk.RESPONSE_OK: # create new installer installer = install.ScreenletInstaller() # TEST #print installer.get_info_from_package_name (filename) #return # /TEST # try installing and show result dialog self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) result = installer.install(filename) self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR)) if result: # reload screenlets to add new screenlet to iconview and show result self.model.clear() self.load_screenlets() screenlets.show_message(None, installer.get_result_message()) else: screenlets.show_error(None, installer.get_result_message())
if workarround == "python "+ sys.argv[0] + " &": print 'No workarround will be applied to your sistem , this screenlet will probably not work properly' os.system (workarround) fileObj = open("/tmp/"+ myfile+"running","w") #// open for for write fileObj.write('gtkmozembed bug workarround') fileObj.close() sys.exit() else: pass try: import gtkmozembed except: if sys.argv[0].endswith(myfile):screenlets.show_error(None,"You need Gtkmozembed to run this Screenlet , please install it") else: print "You need Gtkmozembed to run this Screenlet , please install it" #########WORKARROUND FOR GTKOZEMBED BUG BY WHISE################ #Check for internet connection required for web widgets if sys.argv[0].endswith(myfile):# Makes Shure its not the manager running... #os.system('wget www.google.com -O/tmp/index.html &') a = commands.getoutput('wget www.google.com -O/tmp/index.html') if a.find('text/html') == -1: screenlets.show_error(None,"Internet connection is required to use this Screenlet") os.system('rm /tmp/index.html') sys.exit() os.system('rm /tmp/index.html') class WidgetScreenlet (screenlets.Screenlet): """Converted widgets to screenlets engine"""
def show_widget_converter(self): label1 = gtk.Label(_('Convert any webpage widget into a Screenlet.')) label2 = gtk.Label(_('Step 1 : Find the widget you want to convert')) label3 = gtk.Label(_('Step 2 : Copy and Paste the HTML from the widget in the box below')) label4 = gtk.Label(_('Step 3 : Give it a name in the box below and click on Ok to convert')) label5 = gtk.Label(_('The name of the widget')) code = gtk.Entry() name = gtk.Entry() h = gtk.HBox() h1 = gtk.HBox() self.combo1 = combo = gtk.combo_box_new_text() combo.append_text('Google Gadgets') combo.append_text('Yourminis Widgets') combo.append_text('SpringWidgets') combo.append_text('Widgetbox') combo.set_active(0) web = gtk.Button('Go to web page') web.connect('clicked', self.button_clicked, 'widgetsite') label1.show() label2.show() label3.show() label4.show() label5.show() combo.show() name.show() web.show() h.show() h1.show() code.show() dialog = gtk.Dialog(_("Widget converter"), self.window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) #dialog.set_size_request(300, 500) dialog.vbox.pack_start(label1,False,False,20) dialog.vbox.pack_start(label2,True,False,5) h.pack_start(combo,True,True,5) h.pack_start(web,False,False,5) dialog.vbox.pack_start(h,False,False,5) dialog.vbox.pack_start(label3,False,False,10) dialog.vbox.pack_start(code,False,False,5) dialog.vbox.pack_start(label4,False,False,5) h1.pack_start(label5,False,False,5) h1.pack_start(name,True,True,5) dialog.vbox.pack_start(h1,False,False,5) resp = dialog.run() ret = None if resp == gtk.RESPONSE_ACCEPT: if code.get_text() != '': if name.get_text() != '': try: a = name.get_text() a = a.replace(' ','') if os.path.isdir(DIR_USER + '/' + a):#found_path != None: if screenlets.show_question(None,(_("There is already a screenlet with that name installed\nDo you wish to continue?") )): pass else: return False os.system('mkdir ' +DIR_USER + '/' + a) os.system('mkdir ' +DIR_USER + '/' + a + '/themes') os.system('mkdir ' +DIR_USER + '/' + a + '/themes/default') os.system('mkdir ' +DIR_USER + '/' + a + '/mozilla') f = open(DIR_USER + '/' + a + '/' + 'index.html' , 'w') f.write(code.get_text()) f.close() os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/WidgetScreenlet.py ' +DIR_USER + '/' + a + '/' + a + 'Screenlet.py') os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/widget.png ' +DIR_USER + '/' + a + '/icon.png') os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/widget.png ' +DIR_USER + '/' + a + '/themes/default') os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/prefs.js ' +DIR_USER + '/' + a + '/mozilla') enginecopy = open(DIR_USER + '/' + a + '/' + a + 'Screenlet.py','r') enginesave = enginecopy.read() enginesave = enginesave.replace('WidgetScreenlet',a + 'Screenlet') enginecopy.close() enginecopy = open(DIR_USER + '/' + a + '/' + a + 'Screenlet.py','w') enginecopy.write(enginesave) enginecopy.close() screenlets.show_message (None,_("Widget was successfully converted")) self.model.clear() self.load_screenlets() except: screenlets.show_error(None,_("Error converting!!!")) else: screenlets.show_error(None,_("Please specify a name for the widget")) else: screenlets.show_error(None,_("No HTML code found")) dialog.destroy()
def show_webapp(self): label1 = gtk.Label(_('Web Application Url')) label2 = gtk.Label(_('Web Application Name')) code = gtk.Entry() name = gtk.Entry() h = gtk.HBox() h1 = gtk.HBox() h.pack_start(label1,False,False) h.pack_start(code,True,True) h1.pack_start(label2,False,False) h1.pack_start(name,True,True) dialog = gtk.Dialog(_("Install Web Application"),self.window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) label1.show() label2.show() code.show() name.show() h.show() h1.show() dialog.vbox.pack_start(h,False,False,5) dialog.vbox.pack_start(h1,False,False,5) resp = dialog.run() ret = None if resp == gtk.RESPONSE_ACCEPT: if code.get_text() != '': if name.get_text() != '': try: a = name.get_text() a = a.replace(' ','') if os.path.isdir(DIR_USER + '/' + a):#found_path != None: if screenlets.show_question(None,(_("There is already a screenlet with that name installed\nDo you wish to continue?") )): pass else: return False os.system('mkdir ' +DIR_USER + '/' + a) os.system('mkdir ' +DIR_USER + '/' + a + '/themes') os.system('mkdir ' +DIR_USER + '/' + a + '/themes/default') os.system('mkdir ' +DIR_USER + '/' + a + '/mozilla') os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/WebappScreenlet.py ' +DIR_USER + '/' + a + '/' + a + 'Screenlet.py') os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/webapp.png ' +DIR_USER + '/' + a + '/icon.png') os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/webapp.png ' +DIR_USER + '/' + a + '/themes/default') os.system('cp ' + screenlets.INSTALL_PREFIX + '/share/screenlets-manager/prefs.js ' +DIR_USER + '/' + a + '/mozilla') enginecopy = open(DIR_USER + '/' + a + '/' + a + 'Screenlet.py','r') enginesave = enginecopy.read() enginesave = enginesave.replace('WebappScreenlet',a + 'Screenlet') enginesave = enginesave.replace("url = 'myurl'","url = " + chr(34) + code.get_text() + chr(34)) enginecopy.close() enginecopy = open(DIR_USER + '/' + a + '/' + a + 'Screenlet.py','w') enginecopy.write(enginesave) enginecopy.close() screenlets.show_message (None,_("Web Application was successfully installed")) self.model.clear() self.load_screenlets() except: screenlets.show_error(None,_("Error installing!!!")) else: screenlets.show_error(None,_("Please specify a name for the widget")) else: screenlets.show_error(None,_("No HTML code found")) dialog.destroy()
def launch_screenlet(screenlet): """Launches a screenlet""" name = str(screenlet) if not screenlets.launch_screenlet(name): screenlets.show_error(None, _('Failed to add %sScreenlet.') % name)
from screenlets import DefaultMenuItem from screenlets.options import BoolOption, IntOption, ColorOption import cairo import gtk import gobject import commands import sys import os from screenlets import sensors myfile = 'WidgetScreenlet.py' try: import webkit except: if sys.argv[0].endswith(myfile):screenlets.show_error(None,"You need WebKit to run this Screenlet , please install it") else: print "You need WebKit to run this Screenlet , please install it" #Check for internet connection required for web widgets if sys.argv[0].endswith(myfile):# Makes Shure its not the manager running... #os.system('wget www.google.com -O/tmp/index.html &') a = commands.getoutput('wget www.google.com -O/tmp/index.html') if a.find('text/html') == -1: screenlets.show_error(None,"Internet connection is required to use this Screenlet") os.system('rm /tmp/index.html') sys.exit() os.system('rm /tmp/index.html') class WidgetScreenlet (screenlets.Screenlet): """Converted widgets to screenlets engine"""