Ejemplo n.º 1
0
 def activate(self):
     self._pages = {}
     self._schedule_refresh()
     self._update_time_changed_handle = self._gconf_client.notify_add(
         self._gconf_key + "/update_time", self._update_time_changed)
     self._urls_changed_handle = self._gconf_client.notify_add(
         self._gconf_key + "/urls", self._urls_changed)
     g15scheduler.schedule("LoadFeeds", 0, self._load_feeds)
Ejemplo n.º 2
0
    def activate(self):
        g15plugin.G15Plugin.activate(self)

        self._active = True
        self._event_days = None
        self._calendar_date = None
        self._page = None
        self._theme = g15theme.G15Theme(os.path.join(os.path.dirname(__file__),
                                                     "default"),
                                        auto_dirty=False)
        self._loaded = 0

        # Backend
        self._account_manager = g15accounts.G15AccountManager(
            CONFIG_PATH, CONFIG_ITEM_NAME)

        # Calendar
        self._calendar = Calendar()

        # Menu
        self._menu = g15theme.Menu("menu")
        self._menu.focusable = True
        self._menu.focused_component = True

        # Page
        self._page = g15theme.G15Page(
            name,
            self.screen,
            on_shown=self._on_shown,
            on_hidden=self._on_hidden,
            theme_properties_callback=self._get_properties,
            thumbnail_painter=self._paint_thumbnail,
            originating_plugin=self)
        self._page.set_title(_("Calendar"))
        self._page.set_theme(self._theme)
        self._page.focused_component = self._calendar
        self._calendar.set_focused(True)

        # List for account changes
        self._account_manager.add_change_listener(self._accounts_changed)
        self.screen.key_handler.action_listeners.append(self)

        # Run first load in thread
        self._page.add_child(self._menu)
        self._page.add_child(self._calendar)
        self._page.add_child(
            g15theme.MenuScrollbar("viewScrollbar", self._menu))
        self.screen.add_page(self._page)
        g15scheduler.schedule("CalendarFirstLoad", 0, self._redraw)

        # Listen for changes in the network state
        self.screen.service.network_manager.listeners.append(
            self._network_state_changed)

        # Config changes
        self.watch("twenty_four_hour_times", self._config_changed)
Ejemplo n.º 3
0
 def paint(self, canvas):
     self._paint_video_image(canvas)
     canvas.save()        
     if self._sidebar_offset < 0 and self._sidebar_offset > -(self.theme.bounds[2]):
         self._sidebar_offset -= 5
     canvas.translate(self._sidebar_offset, 0)
     g15theme.G15Page.paint(self, canvas)
     canvas.restore()
     if self._sidebar_offset < 0 and self._sidebar_offset > -(self.theme.bounds[2]):
         g15scheduler.schedule("RepaintVideoOverly", 0.1, self.redraw)
Ejemplo n.º 4
0
    def _mainLoop(self): 
        """
        Private
        =======

        Called by timeout in comeToLife. Keeps looping on timeout. This is the heart of the app.
        
        """
        if self.pauseapp: return True
        self.owner._tick()
        self._screen.redraw()
        if not self.stack.quitApp:
            g15scheduler.schedule("ThingPaint", self.owner.speed / 1000.0, self._mainLoop)
Ejemplo n.º 5
0
    def _mainLoop(self):
        """
        Private
        =======

        Called by timeout in comeToLife. Keeps looping on timeout. This is the heart of the app.
        
        """
        if self.pauseapp: return True
        self.owner._tick()
        self._screen.redraw()
        if not self.stack.quitApp:
            g15scheduler.schedule("ThingPaint", self.owner.speed / 1000.0, self._mainLoop)
Ejemplo n.º 6
0
Archivo: voip.py Proyecto: FPar/gnome15
 def _attempt_connection(self):
     try:
         if self._raise_timer is not None:
             self._raise_timer.cancel()
         # For now, TS3 only backend
         self.backend = get_backend("teamspeak3").create_backend()
         self.set_icon(self.backend.get_icon())
         if self.backend.start(self):
             self.show_menu()
             self._connected = True
         else:
             self._connection_timer = g15scheduler.schedule("ReconnectVoip", 5, self._attempt_connection)
     except Exception as e:
         logger.debug("Error connecting. Will retry...", exc_info = e)
         self._connection_timer = g15scheduler.schedule("ReconnectVoip", 5, self._attempt_connection)
Ejemplo n.º 7
0
 def _schedule_refresh(self):
     """
     When viewing applications, we don't refresh, just rely on BAMF 
     events when BAMF is available
     """
     if not self._mode == "applications" or self.bamf_matcher is None:
         self._timer = g15scheduler.schedule("ProcessesRefresh", 5.0, self._refresh)
Ejemplo n.º 8
0
 def _do_redraw(self):
     if self._page is not None:
         self._do_draw()
         self._page.SetThemeProperty("remaining",
                                     str(self._get_remaining()))
         self._redraw_timer = g15scheduler.schedule("Notification", 0.1,
                                                    self._do_redraw)
Ejemplo n.º 9
0
 def _loc_changed(self, client, connection_id, entry, *args):
     if not entry.get_key().endswith(
             "/theme") and not entry.get_key().endswith("/enabled"):
         if self._config_change_handle is not None:
             self._config_change_handle.cancel()
         self._config_change_handle = g15scheduler.schedule(
             "ApplyConfig", 3.0, self._config_changed)
Ejemplo n.º 10
0
 def _mouse_move(self):
     if self.move_x != 0 or self.move_y != 0:        
         if self.move_x != 0:
             g15uinput.emit(g15uinput.MOUSE, g15uinput.REL_X, self.move_x)        
         if self.move_y != 0:
             g15uinput.emit(g15uinput.MOUSE, g15uinput.REL_Y, self.move_y)
         self.timer = g15scheduler.schedule("MouseMove", 0.05, self._mouse_move)
Ejemplo n.º 11
0
 def _mouse_move(self):
     if self.move_x != 0 or self.move_y != 0:        
         if self.move_x != 0:
             g15uinput.emit(g15uinput.MOUSE, g15uinput.REL_X, self.move_x)        
         if self.move_y != 0:
             g15uinput.emit(g15uinput.MOUSE, g15uinput.REL_Y, self.move_y)
         self.timer = g15scheduler.schedule("MouseMove", 0.05, self._mouse_move)
Ejemplo n.º 12
0
 def run(self):
     try :
         while not self._stop:
             if self._poll.poll(5):
                 if self._stop:
                     break
                 g15scheduler.schedule("popupVolume", 0, self._volume._popup)
                 if not self._open.read():
                     break
     finally:
         try :
             self._poll.unregister(self._open)
         except Exception as e:
             logger.debug("Error when unregistering", exc_info = e)
             pass
         self._open.close()
Ejemplo n.º 13
0
 def activate(self):
     g15plugin.G15Plugin.activate(self)
     
     self._active = True
     self._event_days = None
     self._calendar_date = None
     self._page = None
     self._theme = g15theme.G15Theme(os.path.join(os.path.dirname(__file__), "default"), auto_dirty = False)
     self._loaded = 0
     
     # Backend
     self._account_manager = g15accounts.G15AccountManager(CONFIG_PATH, CONFIG_ITEM_NAME)
     
     # Calendar
     self._calendar = Calendar()
     
     # Menu
     self._menu = g15theme.Menu("menu")
     self._menu.focusable = True
     self._menu.focused_component = True
     
     # Page
     self._page = g15theme.G15Page(name, self.screen, on_shown = self._on_shown, \
                                  on_hidden = self._on_hidden, theme_properties_callback = self._get_properties,
                                  thumbnail_painter = self._paint_thumbnail, 
                                  originating_plugin = self)
     self._page.set_title(_("Calendar"))
     self._page.set_theme(self._theme)
     self._page.focused_component = self._calendar
     self._calendar.set_focused(True)
     
     # List for account changes        
     self._account_manager.add_change_listener(self._accounts_changed)
     self.screen.key_handler.action_listeners.append(self)
     
     # Run first load in thread
     self._page.add_child(self._menu)
     self._page.add_child(self._calendar)
     self._page.add_child(g15theme.MenuScrollbar("viewScrollbar", self._menu))
     self.screen.add_page(self._page)
     g15scheduler.schedule("CalendarFirstLoad", 0, self._redraw)
     
     # Listen for changes in the network state
     self.screen.service.network_manager.listeners.append(self._network_state_changed)
     
     # Config changes
     self.watch("twenty_four_hour_times", self._config_changed)
Ejemplo n.º 14
0
 def _schedule_refresh(self):
     """
     When viewing applications, we don't refresh, just rely on BAMF 
     events when BAMF is available
     """
     if not self._mode == "applications" or self.bamf_matcher is None:
         self._timer = g15scheduler.schedule("ProcessesRefresh", 5.0,
                                             self._refresh)
Ejemplo n.º 15
0
 def set_status(self, new_status):        
     if new_status != self.status:
         logger.info("Playback status changed to %s", new_status)
         self.status = new_status
         if self.status == "Playing":
             g15scheduler.schedule("playbackStarted", 1.0, self._playback_started)
         elif self.status == "Paused":
             self.cancel_redraw()
             if self.page != None:
                 logger.info("Paused.")
                 self.load_song_details()
                 self.screen.set_priority(self.page, g15screen.PRI_HIGH, revert_after = 3.0)
             else:
                 self.show_page()
         elif self.status == "Stopped":
             self.cancel_redraw()
             self.hide_page()
Ejemplo n.º 16
0
 def run(self):
     try:
         while not self._stop:
             if self._poll.poll(5):
                 if self._stop:
                     break
                 g15scheduler.schedule("popupVolume", 0,
                                       self._volume._popup)
                 if not self._open.read():
                     break
     finally:
         try:
             self._poll.unregister(self._open)
         except Exception as e:
             logger.debug("Error when unregistering", exc_info=e)
             pass
         self._open.close()
Ejemplo n.º 17
0
 def _schedule_refresh(self):
     if self.schedule_on_gobject:
         self.timer = GObject.timeout_add(int(self.get_next_tick() * 1000),
                                          self._refresh)
     else:
         self.timer = g15scheduler.schedule("%s-Redraw" % self.page_id,
                                            self.get_next_tick(),
                                            self._refresh)
Ejemplo n.º 18
0
 def _attempt_connection(self):
     try:
         if self._raise_timer is not None:
             self._raise_timer.cancel()
         # For now, TS3 only backend
         self.backend = get_backend("teamspeak3").create_backend()
         self.set_icon(self.backend.get_icon())
         if self.backend.start(self):
             self.show_menu()
             self._connected = True
         else:
             self._connection_timer = g15scheduler.schedule(
                 "ReconnectVoip", 5, self._attempt_connection)
     except Exception as e:
         logger.debug("Error connecting. Will retry...", exc_info=e)
         self._connection_timer = g15scheduler.schedule(
             "ReconnectVoip", 5, self._attempt_connection)
Ejemplo n.º 19
0
 def set_status(self, new_status):        
     if new_status != self.status:
         logger.info("Playback status changed to %s", new_status)
         self.status = new_status
         if self.status == "Playing":
             g15scheduler.schedule("playbackStarted", 1.0, self._playback_started)
         elif self.status == "Paused":
             self.cancel_redraw()
             if self.page != None:
                 logger.info("Paused.")
                 self.load_song_details()
                 self.screen.set_priority(self.page, g15screen.PRI_HIGH, revert_after = 3.0)
             else:
                 self.show_page()
         elif self.status == "Stopped":
             self.cancel_redraw()
             self.hide_page()
Ejemplo n.º 20
0
 def _hide_sidebar(self, after = 0.0):
     if after == 0.0:
         self._sidebar_offset = -1    
         self._hide_timer = None
     else:    
         self._sidebar_offset = 0 
         if self._hide_timer != None:
             self._hide_timer.cancel()
         self._hide_timer = g15scheduler.schedule("HideSidebar", after, self._hide_sidebar)
Ejemplo n.º 21
0
 def _hide_sidebar(self, after = 0.0):
     if after == 0.0:
         self._sidebar_offset = -1    
         self._hide_timer = None
         self.redraw()
     else:    
         self._sidebar_offset = 0 
         self._cancel_hide()
         self._hide_timer = g15scheduler.schedule("HideSidebar", after, self._hide_sidebar)
Ejemplo n.º 22
0
Archivo: im.py Proyecto: FPar/gnome15
 def _name_owner_changed(self, name, old_owner, new_owner):
     """
     If the change is a telepathy connection, determine if it is
     a connection that is to be removed, or a new connection to
     be added
     """
     if name.startswith("org.freedesktop.Telepathy.Connection"):
         logger.info("Telepathy Name owner changed for %s from %s to %s",
                     name,
                     old_owner,
                     new_owner)
         connected = self.menu.is_connected(name)
         if new_owner == "" and connected:
             logger.info("Removing %s", name)
             g15scheduler.schedule("RemoveConnection", 5.0, self.menu.remove_connection, name)
         elif old_owner == "" and not connected:
             logger.info("Adding %s", name)
             g15scheduler.schedule("NewConnection", 5.0, self.menu.new_connection, name, self._session_bus)
Ejemplo n.º 23
0
 def _hide_sidebar(self, after=0.0):
     if after == 0.0:
         self._sidebar_offset = -1
         self._hide_timer = None
     else:
         self._sidebar_offset = 0
         if self._hide_timer is not None:
             self._hide_timer.cancel()
         self._hide_timer = g15scheduler.schedule("HideSidebar", after, self._hide_sidebar)
Ejemplo n.º 24
0
 def _schedule_redraw(self):
     if self.screen.is_visible(self._page):
         if self._timer is not None:
             self._timer.cancel()
         
         """
         Because the calendar page also displays a clock, we want to
         redraw at second zero of every minute
         """
         self._timer = g15scheduler.schedule("CalRedraw", 60 - time.gmtime().tm_sec, self._redraw)
Ejemplo n.º 25
0
 def _schedule_redraw(self):
     if self.screen.is_visible(self._page):
         if self._timer is not None:
             self._timer.cancel()
         
         """
         Because the calendar page also displays a clock, we want to
         redraw at second zero of every minute
         """
         self._timer = g15scheduler.schedule("CalRedraw", 60 - time.gmtime().tm_sec, self._redraw)
Ejemplo n.º 26
0
 def _name_owner_changed(self, name, old_owner, new_owner):
     """
     If the change is a telepathy connection, determine if it is
     a connection that is to be removed, or a new connection to
     be added
     """
     if name.startswith("org.freedesktop.Telepathy.Connection"):
         logger.info("Telepathy Name owner changed for %s from %s to %s",
                     name, old_owner, new_owner)
         connected = self.menu.is_connected(name)
         if new_owner == "" and connected:
             logger.info("Removing %s", name)
             g15scheduler.schedule("RemoveConnection", 5.0,
                                   self.menu.remove_connection, name)
         elif old_owner == "" and not connected:
             logger.info("Adding %s", name)
             g15scheduler.schedule("NewConnection", 5.0,
                                   self.menu.new_connection, name,
                                   self._session_bus)
Ejemplo n.º 27
0
 def properties_changed_handler(self, something, properties, list):
     logger.info("Properties changed, '%s' scheduling a reload", str(properties))
     
     if "PlaybackStatus" in properties:
         self.set_status(properties["PlaybackStatus"])
         
     # Check if the track has changed
     meta = {}
     if "Metadata" in properties:
         meta = properties["Metadata"]
     if ( "xesam:url" in meta and meta["xesam:url"] != self.playing_uri ) or \
         ( "mpris:trackid" in meta and meta["mpris:trackid"] != self.playing_track_id ) or \
         ( "xesam:title" in meta and meta["xesam:title"] != self.playing_track_id ) or \
         ( "xesam:artist" in meta and meta["xesam:artist"] != self.playing_track_id ) or \
         ( "xesam:album" in meta and meta["xesam:album"] != self.playing_track_id ):
         
         """
         This doesn't seem right, but it stops the hanging problem when notify-lcd is enabled and 
         tracks change
         """            
         g15scheduler.schedule("loadMeta", 1.0, self.reset_elapsed)
         
     if "Volume" in properties:
         self.volume = int(properties["Volume"] * 100)
          
     if self.last_properties == None:
         self.last_properties = dict(properties)
     else:
         for key in properties:
             self.last_properties[key] = properties[key]
             
     if "Metadata" in self.last_properties:
         """
         This doesn't seem right, but it stops the hanging problem when notify-lcd is enabled and 
         tracks change
         """            
         g15scheduler.schedule("loadMeta", 1.0, self.load_meta)
Ejemplo n.º 28
0
    def properties_changed_handler(self, something, properties, list):
        logger.info("Properties changed, '%s' scheduling a reload",
                    str(properties))

        if "PlaybackStatus" in properties:
            self.set_status(properties["PlaybackStatus"])

        # Check if the track has changed
        meta = {}
        if "Metadata" in properties:
            meta = properties["Metadata"]
        if ( "xesam:url" in meta and meta["xesam:url"] != self.playing_uri ) or \
            ( "mpris:trackid" in meta and meta["mpris:trackid"] != self.playing_track_id ) or \
            ( "xesam:title" in meta and meta["xesam:title"] != self.playing_track_id ) or \
            ( "xesam:artist" in meta and meta["xesam:artist"] != self.playing_track_id ) or \
            ( "xesam:album" in meta and meta["xesam:album"] != self.playing_track_id ):
            """
            This doesn't seem right, but it stops the hanging problem when notify-lcd is enabled and 
            tracks change
            """
            g15scheduler.schedule("loadMeta", 1.0, self.reset_elapsed)

        if "Volume" in properties:
            self.volume = int(properties["Volume"] * 100)

        if self.last_properties == None:
            self.last_properties = dict(properties)
        else:
            for key in properties:
                self.last_properties[key] = properties[key]

        if "Metadata" in self.last_properties:
            """
            This doesn't seem right, but it stops the hanging problem when notify-lcd is enabled and 
            tracks change
            """
            g15scheduler.schedule("loadMeta", 1.0, self.load_meta)
Ejemplo n.º 29
0
 def _do_activate(self):
     self.volume_monitor = gio.VolumeMonitor()
     for mount in self.volume_monitor.get_mounts():
         if not mount.is_shadowed():
             self._add_mount(mount)
     if len(self.menu.get_children()) > 0:
         self.menu.add_separator()
     for volume in self.volume_monitor.get_volumes():
         if volume.get_mount() == None:
             self._add_volume(volume)
             
     # Watch for changes
     self.volume_monitor.connect("mount_added", self._on_mount_added)
     self.volume_monitor.connect("mount_removed", self._on_mount_removed)
     
     # Refresh disk etc space every minute
     self._handle = g15scheduler.schedule("DiskRefresh", 60.0, self._refresh)
Ejemplo n.º 30
0
 def _schedule_redraw(self):
     if not self.active:
         return
     
     '''
     Determine when to schedule the next redraw for. 
     '''        
     now = datetime.datetime.now()
     if self.display_seconds:
         next_tick = now + datetime.timedelta(0, 1.0)
         next_tick = datetime.datetime(next_tick.year,next_tick.month,next_tick.day,next_tick.hour, next_tick.minute, int(next_tick.second))
     else:
         next_tick = now + datetime.timedelta(0, 60.0)
         next_tick = datetime.datetime(next_tick.year,next_tick.month,next_tick.day,next_tick.hour, next_tick.minute, 0)
     delay = g15pythonlang.total_seconds( next_tick - now )
     
     '''
     Try not to create threads or timers if possible. Use g15scheduler.schedule) instead
     '''
     self.timer = g15scheduler.schedule("ClockRedraw", delay, self._redraw)
Ejemplo n.º 31
0
 def _on_key(app, key):
     if app == self._app_name:
         self._mm_key = None
         if key == "Play":
             self._mm_key = g15driver.G_KEY_PLAY
             self._player_page._play()
         elif key == "Stop":
             self._mm_key = g15driver.G_KEY_STOP
             self._player_page._stop()
         elif key == "Next":
             self._mm_key = g15driver.G_KEY_NEXT
             self._player_page._fwd()
         elif key == "Previous":
             self._mm_key = g15driver.G_KEY_PREV
             self._player_page._rew()
         else:
             logger.warning("Unsupported media key %s", key)
         if self._mm_key_timer is not None:
             self._mm_key_timer.cancel()
             self._mm_key_timer = None
         self._mm_key_timer = g15scheduler.schedule("CancelMMKey", 1.0, self._clear_mm_key)
Ejemplo n.º 32
0
 def _schedule_redraw(self):
     if not self.active:
         return
     '''
     Determine when to schedule the next redraw for. 
     '''
     now = datetime.datetime.now()
     if self.display_seconds:
         next_tick = now + datetime.timedelta(0, 1.0)
         next_tick = datetime.datetime(next_tick.year, next_tick.month,
                                       next_tick.day, next_tick.hour,
                                       next_tick.minute,
                                       int(next_tick.second))
     else:
         next_tick = now + datetime.timedelta(0, 60.0)
         next_tick = datetime.datetime(next_tick.year, next_tick.month,
                                       next_tick.day, next_tick.hour,
                                       next_tick.minute, 0)
     delay = g15pythonlang.total_seconds(next_tick - now)
     '''
     Try not to create threads or timers if possible. Use g15scheduler.schedule) instead
     '''
     self.timer = g15scheduler.schedule("ClockRedraw", delay, self._redraw)
Ejemplo n.º 33
0
 def _schedule_check(self):
     if self.active == True:
         g15scheduler.schedule("CheckResolution", 10.0, self.load_menu_items)
Ejemplo n.º 34
0
 def _schedule_refresh(self, time):
     self._timer = g15scheduler.schedule("AnalyticsRedraw", time,
                                         self._do_refresh)
Ejemplo n.º 35
0
 def _reload_menu(self):
     g15scheduler.schedule("ReloadProcesses", 0, self._do_reload_menu)
Ejemplo n.º 36
0
 def _start_timer(self, message):
     self._cancel_timer()
     self._displayed_notification = time.time()
     self._timer = g15scheduler.schedule("Notification", message.timeout,
                                         self._hide_notification)
Ejemplo n.º 37
0
Archivo: rss.py Proyecto: FPar/gnome15
 def _schedule_refresh(self):
     schedule_seconds = g15gconf.get_int_or_default(self._gconf_client, "%s/update_time" % self._gconf_key, 60) * 60.0
     self._refresh_timer = g15scheduler.schedule("FeedRefreshTimer", schedule_seconds, self._refresh)
Ejemplo n.º 38
0
 def _config_changed(self, client, connection_id, entry, args):
     if self.config_change_timer is not None:
         self.config_change_timer.cancel()
     self.config_change_timer = g15scheduler.schedule(
         "ConfigReload", 1, self._do_config_changed)
Ejemplo n.º 39
0
 def _do_redraw(self):
     if self._page != None:
         self._screen.redraw(self._page)
         self._redraw_timer = g15scheduler.schedule(
             "Notification", self._screen.service.animation_delay,
             self._do_redraw)
Ejemplo n.º 40
0
 def _do_redraw(self):
     if self._page != None:
         self._do_draw()
         self._page.SetThemeProperty("remaining", str(self._get_remaining()))
         self._redraw_timer = g15scheduler.schedule("Notification", 0.1, self._do_redraw)
Ejemplo n.º 41
0
 def _start_timer(self, message):
     self._cancel_timer() 
     self._displayed_notification = time.time()                       
     self._timer = g15scheduler.schedule("Notification", message.timeout, self._hide_notification)
Ejemplo n.º 42
0
 def comeToLife(self, owner):
     self.owner = owner
     g15scheduler.schedule("ThingPaint", self.owner.speed / 1000.0, self._mainLoop)
Ejemplo n.º 43
0
 def _start_timer(self, message):
     logger.debug("Starting hide timeout")
     self._cancel_timer() 
     self._displayed_notification = time.time()                       
     self._timer = g15scheduler.schedule("Notification", message.timeout, self._hide_notification)
Ejemplo n.º 44
0
 def _reload_menu(self):
     g15scheduler.schedule("ReloadProcesses", 0, self._do_reload_menu)
Ejemplo n.º 45
0
 def config_changed(self, client, connection_id, entry, args):
     if self.change_timer != None:
         self.change_timer.cancel()
     self.change_timer = g15scheduler.schedule("ChangeG15DaemonConfiguration", 3.0, self.update_conf)
Ejemplo n.º 46
0
 def _start_timer(self, message):
     logger.debug("Starting hide timeout")
     self._cancel_timer()
     self._displayed_notification = time.time()
     self._timer = g15scheduler.schedule("Notification", message.timeout,
                                         self._hide_notification)
Ejemplo n.º 47
0
 def comeToLife(self, owner):
     self.owner = owner
     g15scheduler.schedule("ThingPaint", self.owner.speed / 1000.0, self._mainLoop)
Ejemplo n.º 48
0
 def _schedule_next_state(self, when):
     self._destroy_state_change_timer()
     self._state_change_timer = g15scheduler.schedule("PommodoroTimerStateChange",
                                                     when,
                                                     self._state_next)
Ejemplo n.º 49
0
 def _schedule_redraw(self):
     self.timer = g15scheduler.schedule("MPDRedraw", 1, self._redraw)
Ejemplo n.º 50
0
Archivo: rss.py Proyecto: FPar/gnome15
 def activate(self):
     self._pages = {}       
     self._schedule_refresh() 
     self._update_time_changed_handle = self._gconf_client.notify_add(self._gconf_key + "/update_time", self._update_time_changed)
     self._urls_changed_handle = self._gconf_client.notify_add(self._gconf_key + "/urls", self._urls_changed)
     g15scheduler.schedule("LoadFeeds", 0, self._load_feeds)
Ejemplo n.º 51
0
 def _do_redraw(self):
     if self._page != None:
         self._screen.redraw(self._page)
         self._redraw_timer = g15scheduler.schedule("Notification", self._screen.service.animation_delay, self._do_redraw)
Ejemplo n.º 52
0
 def _loc_changed(self, client, connection_id, entry, args):
     if not entry.get_key().endswith("/theme") and not entry.get_key().endswith("/enabled"):
         if self._config_change_handle is not None:
             self._config_change_handle.cancel()
         self._config_change_handle = g15scheduler.schedule("ApplyConfig", 3.0, self._config_changed)
Ejemplo n.º 53
0
 def _schedule_refresh(self):
     schedule_seconds = get_update_time(self.gconf_client,
                                        self.gconf_key) * 60.0
     self.refresh_timer = g15scheduler.schedule("PPARefreshTimer",
                                                schedule_seconds,
                                                self._refresh)
Ejemplo n.º 54
0
 def _on_disconnect(self):
     if not self.is_connected():
         raise Exception("Not connected")
     self._stop_receiving_keys()
     if self.on_close != None:
         g15scheduler.schedule("Close", 0, self.on_close, self)
Ejemplo n.º 55
0
 def _config_changed(self, client, connection_id, entry, args):
     if self.config_change_timer is not None:
         self.config_change_timer.cancel()
     self.config_change_timer = g15scheduler.schedule("ConfigReload", 1, self._do_config_changed)
Ejemplo n.º 56
0
 def _popup(self):
     if not self._activated:
         logger.warning("Cannot popup volume when it is deactivated. This suggests the volume thread has not died.")
         return
     
     if not self._light_controls:
         self._light_controls = self._screen.driver.acquire_control_with_hint(g15driver.HINT_MKEYS)
     if self._lights_timer is not None:
         self._lights_timer.cancel()
     if self._light_controls is not None:
         self._lights_timer = g15scheduler.schedule("ReleaseMKeyLights", 3.0, self._release_lights)
     
     page = self._screen.get_page(id)
     if page == None:
         if self._screen.driver.get_bpp() != 0:
             page = g15theme.G15Page(id, self._screen, priority=g15screen.PRI_HIGH, title="Volume", theme = g15theme.G15Theme(self), \
                                     theme_properties_callback = self._get_theme_properties,
                                     originating_plugin = self)
             self._screen.delete_after(3.0, page)
             self._screen.add_page(page)
     else:
         self._screen.raise_page(page)
         self._screen.delete_after(3.0, page)
     
    
     vol_mixer = self._open_mixer()
     mute_mixer = None
     
     try :
     
         # Handle mute        
         mute = False
         mutes = None
         try :
             mutes = vol_mixer.getmute()
         except alsaaudio.ALSAAudioError as e:
             logger.debug("Could note get mute channel. Trying PCM", exc_info = e)
             # Some pulse weirdness maybe?
             mute_mixer = alsaaudio.Mixer("PCM", cardindex=self.soundcard_index)
             try :
                 mutes = mute_mixer.getmute()
             except alsaaudio.ALSAAudioError as e:
                 logger.warning("No mute switch found", exc_info = e)
         if mutes != None:        
             for ch_mute in mutes:
                 if ch_mute:
                     mute = True
 
         
         # TODO  better way than averaging
         volumes = vol_mixer.getvolume()
     finally :
         vol_mixer.close()
         if mute_mixer:
             mute_mixer.close()
         
     total = 0
     for vol in volumes:
         total += vol
     volume = total / len(volumes)
     
     self._volume = volume              
     
     if self._light_controls is not None:
         if self._volume > 90:
             self._light_controls.set_value(g15driver.MKEY_LIGHT_MR | g15driver.MKEY_LIGHT_1 | g15driver.MKEY_LIGHT_2 | g15driver.MKEY_LIGHT_3)        
         elif self._volume > 75:
             self._light_controls.set_value(g15driver.MKEY_LIGHT_1 | g15driver.MKEY_LIGHT_2 | g15driver.MKEY_LIGHT_3)        
         elif self._volume > 50:
             self._light_controls.set_value(g15driver.MKEY_LIGHT_1 | g15driver.MKEY_LIGHT_2)        
         elif self._volume > 25:
             self._light_controls.set_value(g15driver.MKEY_LIGHT_1)        
         else:
             self._light_controls.set_value(0)
       
     self._mute = mute
     
     self._screen.redraw(page)