Exemple #1
0
    def __init__(self, parent, driver, gconf_client, gconf_key):
        self._gconf_client = gconf_client
        self._gconf_key = gconf_key

        widget_tree = Gtk.Builder()
        widget_tree.add_from_file(
            os.path.join(os.path.dirname(__file__), "sense.ui"))

        # Feeds
        self.sensor_model = widget_tree.get_object("SensorModel")
        self.reload_model()
        self.sensor_list = widget_tree.get_object("SensorList")
        self.enabled_renderer = widget_tree.get_object("EnabledRenderer")
        self.label_renderer = widget_tree.get_object("LabelRenderer")

        # Lines
        self.interval_adjustment = widget_tree.get_object("IntervalAdjustment")
        self.interval_adjustment.set_value(
            g15gconf.get_float_or_default(self._gconf_client,
                                          "%s/interval" % self._gconf_key, 10))

        # Connect to events
        self.interval_adjustment.connect("value-changed",
                                         self.interval_changed)
        self.label_renderer.connect("edited", self.label_edited)
        self.enabled_renderer.connect("toggled", self.sensor_toggled)

        # Show dialog
        self.dialog = widget_tree.get_object("SenseDialog")
        self.dialog.set_transient_for(parent)

        self.dialog.run()
        self.dialog.hide()
Exemple #2
0
 def __init__(self, parent, driver, gconf_client, gconf_key):
     self._gconf_client = gconf_client
     self._gconf_key = gconf_key
     
     widget_tree = gtk.Builder()
     widget_tree.add_from_file(os.path.join(os.path.dirname(__file__), "sense.ui"))
     
     # Feeds
     self.sensor_model = widget_tree.get_object("SensorModel")
     self.reload_model()
     self.sensor_list = widget_tree.get_object("SensorList")
     self.enabled_renderer = widget_tree.get_object("EnabledRenderer")
     self.label_renderer = widget_tree.get_object("LabelRenderer")
     
     # Lines
     self.interval_adjustment = widget_tree.get_object("IntervalAdjustment")
     self.interval_adjustment.set_value(g15gconf.get_float_or_default(self._gconf_client, "%s/interval" % self._gconf_key, 10))
     
     # Connect to events
     self.interval_adjustment.connect("value-changed", self.interval_changed)
     self.label_renderer.connect("edited", self.label_edited)
     self.enabled_renderer.connect("toggled", self.sensor_toggled)
     
     # Show dialog
     self.dialog = widget_tree.get_object("SenseDialog")
     self.dialog.set_transient_for(parent)
     
     self.dialog.run()
     self.dialog.hide()
Exemple #3
0
 def __init__(self, gconf_key, gconf_client, screen):
     self.gconf_client = gconf_client
     self.gconf_key = gconf_key
     g15plugin.G15RefreshingPlugin.__init__(
         self, gconf_client, gconf_key, screen, ICON, id, name,
         g15gconf.get_float_or_default(self.gconf_client,
                                       self.gconf_key + "/refresh_interval",
                                       10.0))
     self.hidden = False
Exemple #4
0
 def _load_configuration(self):
     self.use_vnstat = g15gconf.get_bool_or_default(
         self.gconf_client, self.gconf_key + "/use_vnstat",
         os.path.isfile("/usr/bin/vnstat"))
     self.networkdevice = g15gconf.get_string_or_default(
         self.gconf_client, self.gconf_key + "/networkdevice", 'lo')
     self.loadpage = g15gconf.get_string_or_default(
         self.gconf_client, self.gconf_key + "/vnstat_view", "vnstat_daily")
     self.refresh_interval = g15gconf.get_float_or_default(
         self.gconf_client, self.gconf_key + "/refresh_interval", 10.0)
Exemple #5
0
    def _load_config(self):
        logger.info("Reloading configuration")
        self.audio_source_index = get_source_index(
            self.gconf_client.get_string(self.gconf_key +
                                         "/audio_source_name"))
        gobject.idle_add(self.set_audio_source)
        self.mode = self.gconf_client.get_string(self.gconf_key + "/mode")
        self.disco = g15gconf.get_bool_or_default(self.gconf_client,
                                                  self.gconf_key + "/disco",
                                                  False)
        self.refresh_interval = 1.0 / g15gconf.get_float_or_default(
            self.gconf_client, self.gconf_key + "/frame_rate", 25.0)
        self.gain = g15gconf.get_float_or_default(self.gconf_client,
                                                  self.gconf_key + "/gain",
                                                  1.0)
        logger.info("Refresh interval is %f", self.refresh_interval)
        self.animate_mkeys = g15gconf.get_bool_or_default(
            self.gconf_client, self.gconf_key + "/animate_mkeys", False)
        if self.mode is None or self.mode == "" or self.mode == "spectrum" or self.mode == "scope":
            self.mode = "default"
        self.paint_mode = self.gconf_client.get_string(self.gconf_key +
                                                       "/paint")
        if self.paint_mode is None or self.mode == "":
            self.paint_mode = "screen"
        self._on_load_theme()

        self.bars = self.gconf_client.get_int(self.gconf_key + "/bars")
        if self.bars == 0:
            self.bars = 16
        self.bar_width = self.gconf_client.get_int(self.gconf_key +
                                                   "/bar_width")
        if self.bar_width == 0:
            self.bar_width = 16
        self.bar_height = self.gconf_client.get_int(self.gconf_key +
                                                    "/bar_height")
        if self.bar_height == 0:
            self.bar_height = 2
        self.rows = self.gconf_client.get_int(self.gconf_key + "/rows")
        if self.rows == 0:
            self.rows = 16
        self.spacing = self.gconf_client.get_int(self.gconf_key + "/spacing")
        self.col1 = g15gconf.get_cairo_rgba_or_default(
            self.gconf_client, self.gconf_key + "/col1", (255, 0, 0, 255))
        self.col2 = g15gconf.get_cairo_rgba_or_default(
            self.gconf_client, self.gconf_key + "/col2", (0, 0, 255, 255))

        self.peak_heights = [0 for i in range(self.bars)]

        paint = self.gconf_client.get_string(self.gconf_key + "/paint")
        if paint != self.last_paint and self.screen.driver.get_bpp() != 0:
            self.last_paint = paint
            self._clear_painter()
            if paint == "screen":
                if self.page is None:
                    self.page = g15theme.G15Page(id,
                                                 self.screen,
                                                 title=name,
                                                 painter=self.painter.paint,
                                                 on_shown=self.on_shown,
                                                 on_hidden=self.on_hidden,
                                                 originating_plugin=self)
                    self.screen.add_page(self.page)
                else:
                    self.screen.set_priority(self.page,
                                             g15screen.PRI_HIGH,
                                             revert_after=3.0)
            elif paint == "foreground":
                self.painter.place = g15screen.FOREGROUND_PAINTER
                self._activate_painter()
                self.hide_page()
            elif paint == "background":
                self.painter.place = g15screen.BACKGROUND_PAINTER
                self._activate_painter()
                self.hide_page()

                # Acquire the backlight control if appropriate
        control = self.screen.driver.get_control_for_hint(
            g15driver.HINT_DIMMABLE)
        if control:
            if self.disco and self.painter.backlight_acquisition is None:
                self.painter.backlight_acquisition = self.screen.driver.acquire_control(
                    control)
            elif not self.disco and self.painter.backlight_acquisition is not None:
                self.painter._release_backlight_acquisition()

        # Acquire the M-Key lights control if appropriate
        if self.animate_mkeys and self.painter.mkey_acquisition is None:
            self.painter.mkey_acquisition = self.screen.driver.acquire_control_with_hint(
                g15driver.HINT_MKEYS)
        elif not self.animate_mkeys and self.painter.mkey_acquisition is not None:
            self.painter._release_mkey_acquisition()
Exemple #6
0
    def _load_config(self):
        logger.info("Reloading configuration")
        self.audio_source_index = get_source_index(self.gconf_client.get_string(self.gconf_key + "/audio_source_name"))
        gobject.idle_add(self.set_audio_source)
        self.mode = self.gconf_client.get_string(self.gconf_key + "/mode")
        self.disco = g15gconf.get_bool_or_default(self.gconf_client, self.gconf_key + "/disco", False)
        self.refresh_interval = 1.0 / g15gconf.get_float_or_default(self.gconf_client, self.gconf_key + "/frame_rate", 25.0)
        self.gain = g15gconf.get_float_or_default(self.gconf_client, self.gconf_key + "/gain", 1.0)
        logger.info("Refresh interval is %f", self.refresh_interval)
        self.animate_mkeys = g15gconf.get_bool_or_default(self.gconf_client, self.gconf_key + "/animate_mkeys", False)
        if self.mode == None or self.mode == "" or self.mode == "spectrum" or self.mode == "scope":
            self.mode = "default"
        self.paint_mode = self.gconf_client.get_string(self.gconf_key + "/paint")
        if self.paint_mode == None or self.mode == "":
            self.paint_mode = "screen"
        self._on_load_theme()
            
        self.bars = self.gconf_client.get_int(self.gconf_key + "/bars")
        if self.bars == 0:
            self.bars = 16
        self.bar_width = self.gconf_client.get_int(self.gconf_key + "/bar_width")
        if self.bar_width == 0:
            self.bar_width = 16
        self.bar_height = self.gconf_client.get_int(self.gconf_key + "/bar_height")
        if self.bar_height == 0:
            self.bar_height = 2
        self.rows = self.gconf_client.get_int(self.gconf_key + "/rows")
        if self.rows == 0:
            self.rows = 16
        self.spacing = self.gconf_client.get_int(self.gconf_key + "/spacing")
        self.col1 = g15gconf.get_cairo_rgba_or_default(self.gconf_client, self.gconf_key + "/col1", ( 255, 0, 0, 255 ))
        self.col2 = g15gconf.get_cairo_rgba_or_default(self.gconf_client, self.gconf_key + "/col2", ( 0, 0, 255, 255 ))
            
        self.peak_heights = [ 0 for i in range( self.bars ) ]

        paint = self.gconf_client.get_string(self.gconf_key + "/paint")
        if paint != self.last_paint and self.screen.driver.get_bpp() != 0: 
            self.last_paint = paint
            self._clear_painter()
            if paint == "screen":
                if self.page == None:
                    self.page = g15theme.G15Page(id, self.screen, title = name, painter = self.painter.paint, on_shown = self.on_shown, on_hidden = self.on_hidden, originating_plugin = self)
                    self.screen.add_page(self.page)
                else:
                    self.screen.set_priority(self.page, g15screen.PRI_HIGH, revert_after = 3.0)
            elif paint == "foreground":
                self.painter.place = g15screen.FOREGROUND_PAINTER
                self._activate_painter()
                self.hide_page() 
            elif paint == "background":    
                self.painter.place = g15screen.BACKGROUND_PAINTER
                self._activate_painter()
                self.hide_page()            
                
        # Acquire the backlight control if appropriate
        control = self.screen.driver.get_control_for_hint(g15driver.HINT_DIMMABLE)
        if control:
            if self.disco and self.painter.backlight_acquisition is None:
                self.painter.backlight_acquisition = self.screen.driver.acquire_control(control)
            elif not self.disco and self.painter.backlight_acquisition is not None:
                self.painter._release_backlight_acquisition()
                
        # Acquire the M-Key lights control if appropriate
        if self.animate_mkeys and self.painter.mkey_acquisition is None:
            self.painter.mkey_acquisition = self.screen.driver.acquire_control_with_hint(g15driver.HINT_MKEYS)
        elif not self.animate_mkeys and self.painter.mkey_acquisition is not None:
            self.painter._release_mkey_acquisition()
Exemple #7
0
 def get_next_tick(self):
     return g15gconf.get_float_or_default(self.gconf_client,
                                          "%s/interval" % self.gconf_key,
                                          5.0)
Exemple #8
0
 def get_next_tick(self):
     return g15gconf.get_float_or_default(self.gconf_client, "%s/interval" % self.gconf_key, 5.0)
Exemple #9
0
 def _load_configuration(self):
     self.use_vnstat = g15gconf.get_bool_or_default(self.gconf_client, self.gconf_key + "/use_vnstat", os.path.isfile("/usr/bin/vnstat"))
     self.networkdevice = g15gconf.get_string_or_default(self.gconf_client, self.gconf_key + "/networkdevice", 'lo')
     self.loadpage = g15gconf.get_string_or_default(self.gconf_client, self.gconf_key + "/vnstat_view", "vnstat_daily")
     self.refresh_interval = g15gconf.get_float_or_default(self.gconf_client, self.gconf_key + "/refresh_interval", 10.0)
Exemple #10
0
 def __init__(self, gconf_key, gconf_client, screen):
     self.gconf_client = gconf_client
     self.gconf_key = gconf_key
     g15plugin.G15RefreshingPlugin.__init__(self, gconf_client, gconf_key, \
                                            screen, ICON, id, name, g15gconf.get_float_or_default(self.gconf_client, self.gconf_key + "/refresh_interval", 10.0))
     self.hidden = False
Exemple #11
0
def get_float_or_default(gconf_client, key, default=None):
    return g15gconf.get_float_or_default(gconf_client, key, default)