Пример #1
0
	def __update(self):
		try:
			self._doc = xml.dom.minidom.parse(join(dirname(__file__),("dates_id"+str(adesklets.get_id())+".xml")))
		except IOError:
			self._doc =  xml.dom.minidom.Document()
			self._doc.appendChild(self._doc.createElement("datenotes"))
			temp = open(join(dirname(__file__),("dates_id"+str(adesklets.get_id())+".xml")),"w")
			temp.write(self._doc.toxml())
			temp.close()
		self._root = self._doc.getElementsByTagName("datenotes")[0]
		self.remove_whitespace_nodes(self._doc)
Пример #2
0
    def ready(self):
        # need this when adesklets is ready for me

        # I have an ID?
        self.ID = adesklets.get_id()

        # width and height of the window
        self.w = self.config['width']
        self.h = self.config['height']

        # set up a custom right-click menu
        adesklets.menu_add_separator()
        adesklets.menu_add_submenu('Configure')
        adesklets.menu_add_item('EditConfigFile')
        adesklets.menu_add_item('ToggleSecondHand')
        adesklets.menu_end_submenu()

        # set up the initial display window
        adesklets.context_set_image(0)
        #adesklets.context_set_color(0,0,0,0)
        #adesklets.context_set_blend(False)
        adesklets.window_resize(self.w, self.h)
        adesklets.window_set_transparency(True)

        # get a buffer for later
        self.buffer = adesklets.create_image(self.w, self.h)

        # load skin from config file (+ render refresh)
        self.loadSkin(self.config['skin'])

        # cross your fingers!
        adesklets.window_show()
Пример #3
0
	def __save(self):
		self.remove_whitespace_nodes(self._doc)
		temp = open(join(dirname(__file__),("dates_id"+str(adesklets.get_id())+".xml")), "w")
		temp.write(self._doc.toxml())
		temp.close()
		self._doc.unlink()
		self.__update()
Пример #4
0
	def ready(self):
		# Do initialisation stuff here
		# Get the config file
		self.config=Config(adesklets.get_id(),
						   join(self.basedir,'config.txt'))

		# Send the config data to the Calendar class
		self.calendar_desklet = CalendarDesklet(self.config)
		self.calendar_desklet()

		# Start up datesnotes class
		self.datenotes = DateNotes()

		# Set up initial date values
		self.day, self.month, self.year = 0,0,0
Пример #5
0
    def _get_config(self):
        """
        Load up the config file and its values
        """
        if self.config is None:
                self.config = Config(adesklets.get_id(),
                        join(self.basedir, 'config.txt'))

        config = self.config
        color = config.get('color')
        (self.red, self.green, self.blue) = self._parse_color(color)
        self.alpha = config.get('alpha')
        self.displays = config.get('displays')
        self.caps = config.get('caps')
        self.sizeX = config.get('width')
        self.sizeY = config.get('height')
Пример #6
0
    def ready(self):
        """
        Get everything ready to be drawn
        """
        # load the config, and set the text color and alpha
        self.id = adesklets.get_id()
        self.config = None
        self.buffer = None
        self._get_config()

        adesklets.context_set_color(self.red, self.green,\
            self.blue, self.alpha)

        adesklets.context_set_anti_alias(True)
        adesklets.window_resize(self.sizeX, self.sizeY)
        adesklets.window_set_transparency(True)
        adesklets.window_show()
Пример #7
0
    def ready(self):
        # real initialization takes place here
        #
        #self.logfile.write("Entering Ready")
        print self._basedir
        self.config = Config(adesklets.get_id(),join(self._basedir,"config.txt"))
        self._layout = ""
        self.lastClickTime = time()
        
        adesklets.window_resize(self.config['width'],self.config['height'])
        adesklets.window_set_transparency(True)
        

        self.renderFlag()
        

        adesklets.window_show()
Пример #8
0
    def ready(self):
        # Real initialisation take place here.
        #
        self.config=Config(adesklets.get_id(),
                           join(self.basedir,'config.txt'))

        # Load all the icons, and retrieve size
        #
        for icon, caption, command in self.config['icons']:
            adesklets.context_set_image(
                adesklets.load_image(join(self.basedir,'icons',icon)))
            self.icons.append((caption, command,
                               adesklets.context_get_image(),
                               adesklets.image_get_width(),
                               adesklets.image_get_height()))
     
        # Compute the window size
        #
        self._window_width=((self.config['icon_spacing']+
                             self.config['icon_min_width'])*len(self.icons)+
                            (self.config['icon_max_width']-
                             self.config['icon_min_width'])+
                            self.config['icon_spacing'])
        self._window_height=self.config['icon_max_height']
        
        # Set the icon buffer
        #
        self._buffer_icons=adesklets.create_image(self._window_width,
                                                  self._window_height)

        # Load the caption font (if needed), adjusting
        # the window size appropriately
        #
        if self.config['caption_font']:
            adesklets.context_set_font(
                adesklets.load_font('%s/%s' %
                                    (self.config['caption_font'],
                                     str(self.config['caption_size']))))
            dummy, self._caption_height = adesklets.get_text_size('x')
            self._window_height+=self._caption_height

            # Create the caption buffer
            #
            self._buffer_caption=adesklets.create_image(self._window_width,
                                                        self._caption_height)

            # Compute and save final caption color once and for all
            #
            color_base=self.config.color(self.config['caption_color'])
            self._caption_color = color_base + [255]

            # Prepare the fade-in effect
            #
            if self.config['caption_fade_in']:
                adesklets.start_recording()
                time_step = (float(self.config['caption_fade_in_duration'])/
                             self.config['caption_fade_in_steps'])
                fade_step = int(250/self.config['caption_fade_in_steps'])
                for i in range(self.config['caption_fade_in_steps']):
                    adesklets.time_gate((i+1)*time_step)
                    adesklets.context_set_image('$buffer')
                    adesklets.context_set_color(0,0,0,0)
                    adesklets.image_fill_rectangle('$x',0,
                                                   '$width','$height')
                    adesklets.context_set_color(*(color_base+[fade_step*i+5]))
                    adesklets.text_draw('$x',0,'$text')
                    adesklets.context_set_image(0)
                    adesklets.blend_image_onto_image('$buffer',1,
                                                     '$x',0,'$width','$height',
                                                     '$x','$y','$width','$height')
                self._fadein = adesklets.stop_recording()
                adesklets.play_set_abort_on_events(True)
                
            # Set the 'y' and 'buffer' variables once and for all
            #
            if self.config['caption_above']:
                adesklets.set('y',0)
            else:
                adesklets.set('y',self.config['icon_max_height'])
            adesklets.set('buffer',self._buffer_caption)
        else:
            self._caption_height=0
    
        # Resize the window
        #
        adesklets.window_resize(self._window_width,self._window_height)
        adesklets.context_set_image(0)
        
        # Finish setting things up, then display the window
        #
        adesklets.context_set_blend(False)
        adesklets.window_set_transparency(True)
        adesklets.menu_add_separator()
        adesklets.menu_add_item('Configure')
        self._display_icons()
        adesklets.window_show()