Esempio n. 1
0
	def on_menuitem_select (self, id):
		"""Called when a menuitem is selected."""
		if id == "at_runtime":
			screenlets.show_message(self, 'This is an example on a menu created at runtime')
		if id == "at_xml":
			screenlets.show_message(self, 'This is an example on a menu created in the menu.xml')
		pass
Esempio n. 2
0
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 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())
Esempio n. 5
0
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 find_first_karamba_theme(self):
		themename = ''
		for findtheme in os.listdir(self.mypath):
			if str(findtheme).lower().endswith('.theme'):
				if themename == '':
					if not os.path.isfile(self.mypath + themename[:-6] + '.py'):
						themename = findtheme
					else: 
						screenlets.show_message(self,'Compatibility for this karamba theme is not yet implemented')
						return False
			if themename != '':
				self.loadkaramba(self.mypath + themename)
	def on_menuitem_select (self, id):
		"""Called when a menuitem is selected."""
		if id == "at_runtime":
			screenlets.show_message(self, 'This is an example on a menu created at runtime')
		if id == "at_xml":
			screenlets.show_message(self, 'This is an example on a menu created in the menu.xml')
		if id[:11] == "changetheme":
			# make first letter uppercase (workaround for xml-menu)

			self.karambafile = self.get_screenlet_dir() +id[11:]
			
			self.loadkaramba(self.karambafile)
 def on_mouse_down(self, event):
     if self.on:
         self.started = datetime.datetime.now()
         self.image = 'stop.png'
         self.on = False
     else:
         if self.started:
             length = datetime.datetime.now() - self.started
             screenlets.show_message(None, '%s seconds' %
                                     length.seconds, 'Time')
             self.started = None
         self.image = 'start.png'
         self.on = True
	def show_edit_dialog(self):
		# create dialog
		dialog = gtk.Dialog(_("Theme name to save?"), self.window)
		dialog.resize(300, 100)
		dialog.add_buttons(gtk.STOCK_OK, gtk.RESPONSE_OK, 
			gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
		entrybox = gtk.Entry()
		entrybox.set_text(str(_('New theme name...')))
		dialog.vbox.add(entrybox)
		entrybox.show()	
		# run dialog
		response = dialog.run()
		if response == gtk.RESPONSE_OK:
			try:
				os.mkdir(os.environ['HOME'] + '/.screenlets/FolderView/themes/' + entrybox.get_text())
			except:
				screenlets.show_message(None,_('Theme not created'))
			f = open(os.environ['HOME'] + '/.screenlets/FolderView/themes/' + entrybox.get_text() + '/theme.conf' , 'w')
			if f:
				f.write('[Theme]' + '\n')
				f.write('name	= ' + entrybox.get_text() +'\n')
				f.write('author	= ' + os.environ['USER'] +'\n')
				f.write('versio = ' + '1.0' + '\n')
				f.write('info	= ' + 'Created automaticly' + '\n')
				f.write('[Options]' + '\n')
				f.write('shadow_color=' + str(self.shadow_color).replace('[','(').replace(']',')') + '\n')
				f.write('pericons=' + str(self.pericons) + '\n')
				f.write('height=' + str(self.height) + '\n')
				f.write('font=' +  str(self.font) + '\n')
				f.write('title_font=' + str(self.title_font) + '\n')
				f.write('frame_color=' + str(self.frame_color).replace('[','(').replace(']',')') + '\n')
				f.write('width=' + str(self.width) + '\n')
				f.write('border_color=' + str(self.border_color).replace('[','(').replace(']',')') + '\n')
				f.write('show_title=' + str(self.show_title) + '\n')
				f.write('expand=' + str(self.expand) +'\n')
				f.write('banner_size=' + str(self.banner_size) + '\n')

				f.write('border_size_selected=' + str(self.border_size_selected) + '\n')
				f.write('frame_color_selected=' + str(self.frame_color_selected).replace('[','(').replace(']',')') + '\n')
				f.write('shadow_size=' + str(self.shadow_size) + '\n')
				f.write('border_size=' + str(self.border_size) + '\n')

				f.write('rounda=' + str(self.rounda) + '\n')
				f.write('color_text=' + str(self.color_text).replace('[','(').replace(']',')') + '\n')
				f.write('color_title=' + str(self.color_title).replace('[','(').replace(']',')') + '\n')
				f.write('icon_size=' + str(self.icon_size) + '\n')
				f.write('full_path=' + str(self.full_path) + '\n')

				f.close()
				screenlets.show_message(None,_('Theme saved in ~/.screenlets/FolderView/themes'))
		dialog.hide()
Esempio n. 10
0
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
Esempio n. 11
0
	def on_mouse_down (self, event):
		"""Called when a buttonpress-event occured in Screenlet's window. 
		Returning True causes the event to be not further propagated."""
		
		try:
			if event.button ==1:
				x1 = 0
				y1 = 0
				for line in self.karamba_mouse_data:
					if line.lower().startswith('<group>'):
						a = line.split(' ')
								
						x1 = int(a[1][2:]) 
						y1 = int(a[2][2:])
	
					elif line.lower().startswith('</group>'):
						
								
						x1 = 0
						y1 = 0
					
					elif line.lower().startswith("clickarea"):
						a = line.split(' ')
						
	
						x = x1 + int(a[1][2:])	
						y = y1 + int(a[2][2:])
						w = int(a[3][2:])
						h = int(a[4][2:])
						a[5] = line[line.lower().find('sensor=program'):]
					

						a[6] = line[line.lower().find('onclick='):]
						try:a[7] = line[line.lower().find('program='):]
						except:pass
					
						if a[5].lower().startswith('sensor=program') or a[6].lower().startswith('onclick='):
						
							if self.mousex >= x and self.mousex <= (x + w) and self.mousey >= y and self.mousey <= (y+h):
								
								b =  a[6][9:][:a[6][9:].find(chr(34))]
								if b.startswith('kdialog'):
									screenlets.show_message(self,commands.getoutput(a[7][9:][:a[7][9:].find(chr(34))]))
								else:
									os.system(a[6][9:][:a[6][9:].find(chr(34))])
	
		except: pass
		return False
    def menuitem_callback(self, widget, id):
        screenlets.Screenlet.menuitem_callback(self, widget, id)

        if id == "events":
            screenlets.show_message(self,self.event1)
            self.redraw_canvas()
        if id=="icspath":
            self.show_edit_dialog()



        if id == "mini":
            self.showevents = not self.showevents
            self.redraw_canvas()

        if id=="update":

            self.update()
    def on_menuitem_select(self, id):
        """handle MenuItem-events in right-click menu"""
        if id == "next":
            # TODO: use DBus-call for this
            # self.switch_hide_show()

            self.set_image(self.fetch_image())
            self.redraw_canvas()

        if id == "visit":
            # TODO: use DBus-call for this
            # self.switch_hide_show()
            if self.engine1 == "Flickr":
                os.system("firefox " + self.url + " &")
            elif self.engine1 == "directory":
                os.system("gnome-open " + chr(34) + self.img_name + chr(34) + " &")

        if id == "wall":
            # TODO: use DBus-call for this
            # self.switch_hide_show()
            if self.engine1 == "directory":
                os.system(
                    "gconftool-2 -t string -s /desktop/gnome/background/picture_filename "
                    + chr(34)
                    + self.img_name
                    + chr(34)
                )
                os.system("gconftool-2 -t bool -s /desktop/gnome/background/draw_background False")
                os.system("gconftool-2 -t bool -s /desktop/gnome/background/draw_background True")
            elif self.engine1 == "Flickr":
                screenlets.show_message(self, "Can only set wallpaper to local images")

        if id == "start":
            self.slide = True
            self.update()
        if id == "stop":
            self.slide = False

        if id[:7] == "Install":
            # TODO: use DBus-call for this
            self.show_install_dialog()
            self.update()
	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 toggle_tray (self, widget):
		"""Callback for handling changes to the tray-CheckButton."""
		ini = utils.IniReader()
		if ini.load (DIR_USER + '/config.ini'):
			r = ''
			if ini.get_option('Lock', section='Options') != None:
				r = r +  'Lock=' + str(ini.get_option('Lock', section='Options')) + '\n'
				
			if ini.get_option('Sticky', section='Options') != None:
				r = r +  'Sticky=' + str(ini.get_option('Sticky', section='Options')) + '\n'
				
			if ini.get_option('Widget', section='Options') != None:
				r = r +  'Sticky=' + str(ini.get_option('Sticky', section='Options')) + '\n'
				
			if ini.get_option('Keep_above', section='Options') != None:
				r = r +  'Keep_above=' + str(ini.get_option('Keep_above', section='Options')) + '\n'
		
			if ini.get_option('Keep_below', section='Options') != None:
				r = r +  'Keep_below=' + str(ini.get_option('Keep_below', section='Options')) + '\n'

			if ini.get_option('draw_buttons', section='Options') != None:
				r = r +  'draw_buttons=' + str(ini.get_option('draw_buttons', section='Options')) + '\n'

		f = open(DIR_USER + '/config.ini', 'w')
		DIR_USER + '/config.ini'
		f.write("[Options]\n")
		f.write("show_in_tray="+str(widget.get_active())+"\n")
		f.write(r)
		f.close()
		os.system('pkill -f screenlets-daemon.py') #restart the daemon
		os.system(screenlets.INSTALL_PREFIX + \
				'/share/screenlets-manager/screenlets-daemon.py &')
		screenlets.show_message(None, _('Screenlets-Manager must now be restarted'))
		try:
			os.system('screenlets-manager &')	
		except:
			pass
		self.delete_event(self.window, None)		
	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())
	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_install_theme_dialog (self):
		"""Craete/Show the install-dialog."""
		# create filter
		flt = gtk.FileFilter()
		flt.add_pattern('*.tar.bz2')
		flt.add_pattern('*.tar.gz')
		flt.add_pattern('*.zip')
		try: os.system('rm -rf /tmp/screenlets/install-temp')
		except:pass
		# 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 new theme for the selected Screenlet')))
		dlg.set_filter(flt)
		# run
		resp		= dlg.run()
		filename	= dlg.get_filename()
		dlg.destroy()
		if resp == gtk.RESPONSE_OK:
			# create new installer
			
			# try installing and show result dialog
			self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
			print _('Installing %s') % filename
			result = False
			info = self.get_selection()
			basename	= os.path.basename(filename)
			ext	= str(filename)[len(str(filename)) -3:]
	
			tar_opts = 'xfz'
			if ext == 'bz2':
				tar_opts = 'xfj'
			x = 0
			y = 0
			
			if not info.system:
				install_dir = DIR_USER + '/' 
				themes_dir = DIR_USER + '/' + info.name + '/themes/'
				install_prefix = ''
			else:
				if not screenlets.show_question(None, _("You are about to install a theme in root mode. Continue only if you have gksudo installed, do you wish to continue?")):
					self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))	
					result = False
				themes_dir = screenlets.INSTALL_PREFIX + '/share/screenlets' + '/'  + info.name + '/themes/'
				install_dir = screenlets.INSTALL_PREFIX + '/share/screenlets' + '/' 
				install_prefix = 'gksudo '

			if not os.path.isdir('/tmp/screenlets/'):
				os.system('mkdir ' + '/tmp/screenlets/')
		
			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))
			try:
				print os.listdir(tmpdir)[0]
			except:				
				screenlets.show_message(None, _("Error Found"))				
				self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))	
				result = False #is it a valid folder?
				
			if not os.path.exists(tmpdir + os.listdir(tmpdir)[0]):	
				screenlets.show_message(None, _("Theme install error 1 found - Theme not installed , maybe a package error "))				
				self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))	
				result = False #is it a valid folder?

			if os.listdir(tmpdir)[0] == 'themes': 
				install_dir = install_dir + info.name
				print _("list contains themes folder")
			elif os.listdir(tmpdir)[0] == info.name:
				print _("list contains the screenlet name folder")
				install_dir = install_dir
				if os.path.exists(tmpdir + os.listdir(tmpdir)[0] + '/'+ info.name + 'Screenlet.py') and os.path.isfile(tmpdir + os.listdir(tmpdir)[0] + '/'+ info.name + 'Screenlet.py'):
					screenlets.show_message(None, _("This package seams to contain a full Screenlet and not just a theme, please use the screenlet install instead"))
					self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))			
					return False
			else:
				z =0 
				for f in os.listdir(tmpdir + os.listdir(tmpdir)[0]):
					f = str(f).lower()
					
					if f.endswith('png') or f.endswith('svg'):
						if not f.startswith('icon'):
							z=z+1
				if z == 0:
					screenlets.show_message(None, _("This package doesnt seem to contain a theme"))
					self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))	
					return False
				install_dir = install_dir + info.name + '/themes/'
				print _("only contains the themes folders")
						
			os.system('rm -rf %s/install-temp' % screenlets.DIR_TMP)

			for f in os.listdir(themes_dir):
				x= x +1
			if install_prefix != '':
				os.system(install_prefix +chr(34) +'tar '+tar_opts+' '+ chr(39)+ filename + chr(39)+ ' -C ' + chr(39) + install_dir + chr(39)+chr(34))
			else:
				os.system('tar '+tar_opts+' '+ chr(39)+ filename + chr(39)+ ' -C ' + chr(39) + install_dir + chr(39))

 #% (tar_opts, chr(39)+ filename + chr(39), chr(39) + screenlets.INSTALL_PREFIX + '/share/screenlets' + '/' + info.name + '/themes/'+ chr(39)))
			for f in os.listdir(themes_dir):
				y= y +1

			if y > x:
				
				screenlets.show_message(None, _("Theme installed , please restart %s") % info.name )
				self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))	
				result = True

			else:
				screenlets.show_message(None, _("Theme install error 2 found - Theme not installed or already installed"))
				self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))	
				result = False
		else:
			self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))	
			result = False
	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()
Esempio n. 20
0
	def on_key_down(self, keycode, keyvalue, event):
		"""Called when a keypress-event occured in Screenlet's window."""
		key = gtk.gdk.keyval_name(event.keyval)
		
		if key == "Return" or key == "Tab":
			screenlets.show_message(self, 'This is the ' + self.__name__ +'\n' + 'It is installed in ' + self.__path__)
Esempio n. 21
0
	def loadkaramba(self,filename):
		if os.path.isfile(filename[:-6] +'.py'):
			screenlets.show_message(self,'This karamba theme will not work because its not supported yet')
			return False
		self.font = 'Sans'
		self.font_backup = 'Sans'
		self.font_size = 7
		self.font_size_backup = 7
		self.font_color_backup = (1,1,1,1)
		k_data = []
		k_mouse_data =[]
		f = open (filename,'r')
		tmp = f.readlines(2500)
		f.close()
		for line in tmp:
			line = line.replace('       ',' ')
			line = line.replace('      ',' ')	
			line = line.replace('     ',' ')
			line = line.replace('    ',' ')
			line = line.replace('	',' ')
			line = line.replace('  ',' ')
			line = line.replace("  x",' x')
			line = line.replace("  X",' X')
			line = line.replace("  y",' y')
			line = line.replace("  Y",' Y')	


			line = line.replace("  h",' h')
			line = line.replace("  H",' H')
			line = line.replace("  w",' w')
			line = line.replace("  W",' W')	
			line = line.replace("kwrite",'gedit')		
			line = line.replace("~/.superkaramba/",self.mypath )		
						
			
			
			#########################
			#karamba general settings
			#########################
			if line.lower().startswith("x") or line.lower().startswith('<group>') or line.lower().startswith('</group>') or  line.lower().startswith("clickarea"):
				
				k_mouse_data.append(line)
			if not line.lower().startswith("clickarea"):
				if not len(line) < 1 or not line.startswith('#'):
					k_data.append(line)
					
			if line.lower().startswith("karamba"):
				general = line.split(' ')
				for a in general:
					
					#if a.lower().startswith("x"): # X
					#	self.x = int(a[2:])
					#elif a.lower().startswith("y"): # Y
					#	self.y = int(a[2:])
					a.replace(' ','')
					if a.lower().startswith("w="): #WIDTH
						self.karamba_width = int(a[2:])
					elif a.lower().startswith("h="): #HEIGHT
						self.karamba_height = int(a[2:])
						
					#elif a.lower().startswith("locked="): #locked
						
					#	self.lock_position = self.strtobool(a[7:])

		self.karamba_data = k_data
		self.karamba_mouse_data = k_mouse_data
		self.height = self.karamba_height
		self.width = int(self.karamba_width)
	
		self.has_karamba_theme = True
		self.redraw_canvas()
		self.update_shape()			
try:
	import gnome.ui
	GNOMEUI = True
except:
	GNOMEUI = False
	
import os
import gobject
import gc

try:
	import gio
	
except:
	screenlets.show_message(None,_('You don\'t have GIO python bindings installed. \nYou need to install python-gobject >= 2.15 .'))
	sys.exit()


#use gettext for translation
import gettext

_ = screenlets.utils.get_translator(__file__)

def tdoc(obj):
	obj.__doc__ = _(obj.__doc__)
	return obj

@tdoc
class FolderViewScreenlet(screenlets.Screenlet):
	"""Display the content of a folder."""
Esempio n. 23
0
from screenlets.options import StringOption , BoolOption , IntOption , FileOption , DirectoryOption , ListOption , AccountOption , TimeOption , FontOption, ColorOption , ImageOption

import cairo
import pango
import sys
import gtk
import gobject
import os
import cgi

is_manager = screenlets.utils.is_manager_running_me()
try:
    from monajat import monajat
except:
    if not is_manager:
        screenlets.show_message(None,"You don't have monajat installed!\nInstall monajat-python.")
        sys.exit()
    else:
        print "You don't have monajat installed!\nInstall monajat-python."
        sys.exit()

class MonajatScreenlet(screenlets.Screenlet):
    """Monajat Screenlet for Islamic supplications"""
    
    __name__ = 'MonajatScreenlet'
    __version__ = '0.1'
    __author__ = 'Muayyad Saleh Alsadi <*****@*****.**>'
    __desc__ = 'Screenlet for periodic Islamic supplications'
    
    #Internals
    __timeout = None
Esempio n. 24
0
from screenlets.options import StringOption, BoolOption, IntOption, FileOption, DirectoryOption, ListOption, AccountOption, TimeOption, FontOption, ColorOption, ImageOption

import cairo
import pango
import sys
import gtk
import gobject
import os
import cgi

is_manager = screenlets.utils.is_manager_running_me()
try:
    from monajat import monajat
except:
    if not is_manager:
        screenlets.show_message(
            None, "You don't have monajat installed!\nInstall monajat-python.")
        sys.exit()
    else:
        print "You don't have monajat installed!\nInstall monajat-python."
        sys.exit()


class MonajatScreenlet(screenlets.Screenlet):
    """Monajat Screenlet for Islamic supplications"""

    __name__ = 'MonajatScreenlet'
    __version__ = '0.1'
    __author__ = 'Muayyad Saleh Alsadi <*****@*****.**>'
    __desc__ = 'Screenlet for periodic Islamic supplications'

    #Internals