Ejemplo n.º 1
0
    def _init_ui(self):
        logger.info("Initialising GTK UI")
        self.area = VirtualLCD(self)
        # self.area.connect("expose_event", self._expose)
        self.hboxes = []
        self.buttons = {}
        zoomed_size = self.get_zoomed_size()
        self.area.set_size_request(zoomed_size[0], zoomed_size[1])
        self.vbox = gtk.VBox()
        self.vbox.add(self.area)
        rows = gtk.VBox()
        for row in self.get_key_layout():
            hbox = gtk.HBox()
            for key in row:
                key_text = " ".join(g15driver.get_key_names(list(key)))
                g_button = gtk.Button(key_text)
                g_button.connect("pressed", self._simulate_key, key,
                                 g15driver.KEY_STATE_DOWN)
                g_button.connect("released", self._simulate_key, key,
                                 g15driver.KEY_STATE_UP)
                hbox.add(g_button)
                self.buttons[key] = g_button
            rows.add(hbox)

        self.event_box = gtk.EventBox()
        self.event_box.add(rows)
        self.vbox.add(self.event_box)

        # self.main_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.main_window = gtk.Window(gtk.WindowType.TOPLEVEL)
        self.main_window.set_title("Gnome15")
        self.main_window.set_icon_from_file(
            g15icontools.get_app_icon(self.conf_client, "gnome15"))
        self.main_window.add(self.vbox)
        self.main_window.connect("delete-event", self._window_closed)

        control = self.get_control_for_hint(g15driver.HINT_DIMMABLE)
        if control:
            if isinstance(control.value, int):
                v = (65535 / control.upper) * control.value
                # self.event_box.modify_bg(gtk.STATE_NORMAL, gdk.Color(v, v, v))
                self.event_box.modify_bg(gtk.StateType.NORMAL,
                                         gdk.Color(v, v, v))
            else:
                # self.event_box.modify_bg(
                #     gtk.STATE_NORMAL,
                #     gdk.Color(
                #         control.value[0] << 8,
                #         control.value[1] << 8,
                #         control.value[2] << 8)
                # )
                self.event_box.modify_bg(
                    gtk.StateType.NORMAL,
                    gdk.Color(control.value[0] << 8, control.value[1] << 8,
                              control.value[2] << 8))

        self.main_window.show_all()
        logger.info("Initialised GTK UI")
        self.connected = True
        logger.info("Connected")
Ejemplo n.º 2
0
 def _done_recording(self, state):
     if self._record_keys != None:
         record_keys = self._record_keys    
         self._halt_recorder()   
           
         active_profile = g15profile.get_active_profile(self._screen.device)
         key_name = ", ".join(g15driver.get_key_names(record_keys))
         if len(self._script_model) == 0:  
             self.icon = "edit-delete"
             self._message = key_name + " deleted"
             active_profile.delete_macro(state, self._screen.get_memory_bank(), record_keys)  
             self._screen.redraw(self._page)   
         else:
             macro_script = ""
             for row in self._script_model:
                 if len(macro_script) != 0:                    
                     macro_script += "\n"
                 macro_script += row[0] + " " + row[1]       
             self.icon = "tag-new"   
             self._message = key_name + " created"
             memory = self._screen.get_memory_bank()
             macro = active_profile.get_macro(state, memory, record_keys)
             if macro:
                 macro.type = g15profile.MACRO_SCRIPT
                 macro.macro = macro_script
                 macro.save()
             else:                
                 active_profile.create_macro(memory, record_keys, key_name, g15profile.MACRO_SCRIPT, macro_script, state)
             self._redraw()
         self._hide_recorder(3.0)    
     else:
         self._hide_recorder()
Ejemplo n.º 3
0
 def _done_recording(self, state):
     if self._record_keys != None:
         record_keys = self._record_keys    
         self._halt_recorder()   
           
         active_profile = g15profile.get_active_profile(self._screen.device)
         key_name = ", ".join(g15driver.get_key_names(record_keys))
         if len(self._script_model) == 0:  
             self.icon = "edit-delete"
             self._message = key_name + " deleted"
             active_profile.delete_macro(state, self._screen.get_memory_bank(), record_keys)  
             self._screen.redraw(self._page)   
         else:
             macro_script = ""
             for row in self._script_model:
                 if len(macro_script) != 0:                    
                     macro_script += "\n"
                 macro_script += row[0] + " " + row[1]       
             self.icon = "tag-new"   
             self._message = key_name + " created"
             memory = self._screen.get_memory_bank()
             macro = active_profile.get_macro(state, memory, record_keys)
             if macro:
                 macro.type = g15profile.MACRO_SCRIPT
                 macro.macro = macro_script
                 macro.save()
             else:                
                 active_profile.create_macro(memory, record_keys, key_name, g15profile.MACRO_SCRIPT, macro_script, state)
             self._redraw()
         self._hide_recorder(3.0)    
     else:
         self._hide_recorder()
Ejemplo n.º 4
0
 def get_theme_properties(self):       
     item_properties = g15theme.MenuItem.get_theme_properties(self)
     item_properties["item_name"] = self.macro.name
     item_properties["item_type"] = ""        
     item_properties["item_key"] = ",".join(g15driver.get_key_names(self.macro.keys))
     for r in range(0, len(self.macro.keys)):
         item_properties["icon%d" % (r + 1)] = os.path.join(g15globals.image_dir, "key-%s.png" % self.macro.keys[r])
     return item_properties
Ejemplo n.º 5
0
 def get_theme_properties(self):       
     item_properties = g15theme.MenuItem.get_theme_properties(self)
     item_properties["item_name"] = self.macro.name
     item_properties["item_type"] = ""        
     item_properties["item_key"] = ",".join(g15driver.get_key_names(self.macro.keys))
     for r in range(0, len(self.macro.keys)):
         item_properties["icon%d" % (r + 1)] = os.path.join(g15globals.image_dir, "key-%s.png" % self.macro.keys[r])
     return item_properties
Ejemplo n.º 6
0
 def _init_ui(self):
     logger.info("Initialising GTK UI")
     self.area = VirtualLCD(self)
     #self.area.connect("expose_event", self._expose)
     self.hboxes = []
     self.buttons = {}
     zoomed_size = self.get_zoomed_size()
     self.area.set_size_request(zoomed_size[0], zoomed_size[1])        
     self.vbox = gtk.VBox ()            
     self.vbox.add(self.area)
     rows = gtk.VBox()
     for row in self.get_key_layout():
         hbox = gtk.HBox()
         for key in row:
             key_text = " ".join(g15driver.get_key_names(list(key)))
             g_button = gtk.Button(key_text)
             g_button.connect("pressed", self._simulate_key, key, g15driver.KEY_STATE_DOWN)
             g_button.connect("released", self._simulate_key, key, g15driver.KEY_STATE_UP)
             hbox.add(g_button)
             self.buttons[key] = g_button
         rows.add(hbox)
         
     self.event_box = gtk.EventBox()
     self.event_box.add(rows)
     self.vbox.add(self.event_box)
     
     self.main_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
     self.main_window.set_title("Gnome15") 
     self.main_window.set_icon_from_file(g15icontools.get_app_icon(self.conf_client, "gnome15"))
     self.main_window.add(self.vbox)
     self.main_window.connect("delete-event", self._window_closed)
     
     control = self.get_control_for_hint(g15driver.HINT_DIMMABLE) 
     if control:       
         if isinstance(control.value, int):
             v = ( 65535 / control.upper ) * control.value
             self.event_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(v, v, v))
         else:
             self.event_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(control.value[0] << 8, control.value[1] << 8, control.value[2] << 8))
     
     self.main_window.show_all()
     logger.info("Initialised GTK UI")
     self.connected = True
     logger.info("Connected")
Ejemplo n.º 7
0
 def _modify_button(self, id, lights, mask):
     on = lights & mask != 0
     c = self.buttons[id]
     key_text = " ".join(g15driver.get_key_names(list(id)))
     c.set_label("*%s" % key_text if on else "%s" % key_text)
Ejemplo n.º 8
0
 def _modify_button(self, id, lights, mask):
     on = lights & mask != 0
     c = self.buttons[id]
     key_text = " ".join(g15driver.get_key_names(list(id)))
     c.set_label("*%s" % key_text if on else "%s" % key_text)