Ejemplo n.º 1
0
 def __init__(self, screen, theme):
     self.theme = theme
     self.entry_theme = g15theme.G15Theme(os.path.dirname(__file__), screen,
                                          "entry")
     self.separator_theme = g15theme.G15Theme(os.path.dirname(__file__),
                                              screen, "separator")
     self.screen = screen
Ejemplo n.º 2
0
 def activate(self):
     self._active = True
     self._page = None
     self._theme = g15theme.G15Theme(os.path.join(os.path.dirname(__file__), "default"), auto_dirty = False)
     self._loaded = 0
     
     self.pie_data = []
     
     # Backend
     self._account_manager = g15accounts.G15AccountManager(CONFIG_PATH, CONFIG_ITEM_NAME)
     self._account_manager.add_change_listener(self._accounts_changed)
     
     # Menu
     self._menu = g15theme.Menu("menu")
     self._menu.focusable = True
     self._menu.on_selected = self._on_menu_selected
     
     # Page
     self._page = g15theme.G15Page(name, self._screen, theme_properties_callback = self._get_properties,
                                  thumbnail_painter = self._paint_thumbnail,
                                  originating_plugin = self)
     self._page.set_title(_("Google Analytics"))
     self._page.set_theme(self._theme)
     self._screen.key_handler.action_listeners.append(self)
     self._page.add_child(G15VisitsGraph("visitsGraph", self))
     self._page.add_child(self._menu)
     self._page.add_child(g15theme.MenuScrollbar("viewScrollbar", self._menu))
     self._screen.add_page(self._page)
     self._schedule_refresh(0)
Ejemplo n.º 3
0
    def __init__(self, plugin, url):

        self._gconf_client = plugin._gconf_client
        self._gconf_key = plugin._gconf_key
        self._screen = plugin._screen
        self._icon_surface = None
        self._icon_embedded = None
        self._selected_icon_embedded = None
        self.url = url
        self.index = -1
        self._menu = g15theme.Menu("menu")
        self._menu.on_selected = self._on_selected
        g15theme.G15Page.__init__(
            self,
            "Feed " + str(plugin._page_serial),
            self._screen,
            thumbnail_painter=self._paint_thumbnail,
            theme=g15theme.G15Theme(self, "menu-screen"),
            theme_properties_callback=self._get_theme_properties,
            originating_plugin=plugin)
        self.add_child(self._menu)
        self.add_child(g15theme.MenuScrollbar("viewScrollbar", self._menu))
        plugin._page_serial += 1
        self._reload()
        self._screen.add_page(self)
        self._screen.redraw(self)
Ejemplo n.º 4
0
 def __init__(self, gconf_client, gconf_key, screen, backend, buddy,
              plugin):
     g15theme.G15Page.__init__(self,
                               _("Actions"),
                               screen,
                               priority=g15screen.PRI_HIGH,
                               theme=g15theme.G15Theme(
                                   os.path.join(g15globals.themes_dir,
                                                "default"), "menu-screen"),
                               originating_plugin=plugin)
     self.theme_properties = {
         "title": _("Actions"),
         "icon":
         backend.get_icon() if buddy.avatar is None else buddy.avatar,
         "alt_title": buddy.nickname
     }
     self.menu = g15theme.Menu("menu")
     self.get_screen().add_page(self)
     self.add_child(self.menu)
     self.menu.add_child(KickBuddyMenuItem(buddy, backend))
     self.menu.add_child(BanBuddyMenuItem(buddy, backend))
     ctrl = screen.driver.get_control("backlight_colour")
     if ctrl is not None:
         self.menu.add_child(
             BuddyBacklightMenuItem(gconf_client, gconf_key, buddy, backend,
                                    ctrl, plugin))
     self.menu.add_child(ReturnMenuItem())
     self.add_child(g15theme.MenuScrollbar("viewScrollbar", self.menu))
Ejemplo n.º 5
0
 def _show_keyhelp(self):
     self._keyhelp = g15theme.Component("glasspane")
     self._keyhelp.get_theme_properties = self._get_theme_properties
     page = self.screen.get_visible_page()
     page.add_child(self._keyhelp)
     self._keyhelp.set_theme(g15theme.G15Theme(os.path.join(os.path.dirname(__file__), "default")))
     page.redraw()
Ejemplo n.º 6
0
    def __init__(self, screen, source, plugin):
        g15theme.G15Page.__init__(self, "videopage-%s" % source.name, screen, \
                                  priority = g15screen.PRI_NORMAL, \
                                  title = source.name, \
                                  theme = g15theme.G15Theme(self, variant = 'mediakeys' if plugin._grabbed_keys else None), thumbnail_painter = self._paint_thumbnail, originating_plugin = plugin)
        self._sidebar_offset = 0
        self._source = source
        self._muted = False
        self._lock = Lock()
        self._plugin = plugin
        self._surface = None
        self._hide_timer = None
        self._screen = screen
        self._full_screen = self._screen.driver.get_size()
        self._aspect = self._full_screen
        self._active = True
        self._frame_index = 1
        self._last_seconds = -1
        self._thumb_icon = g15cairo.load_surface_from_file(icon_path)
        self._setup_gstreamer()
        self.screen.key_handler.action_listeners.append(self)

        def on_delete():
            self._pipeline.set_state(Gst.State.NULL)
            self.screen.key_handler.action_listeners.remove(self)
            self.screen.painters.remove(self.background_painter)
            self._plugin.show_menu()
            self._plugin._release_multimedia_keys()

        self.on_deleted = on_delete
        self.background_painter = G15VideoPainter(self)
        self.screen.painters.append(self.background_painter)
        self._plugin.hide_menu()
Ejemplo n.º 7
0
    def __init__(self, plugin, file_path):

        self._gconf_client = plugin._gconf_client
        self._gconf_key = plugin._gconf_key
        self._screen = plugin._screen
        self._icon_surface = None
        self._icon_embedded = None
        self.plugin = plugin
        self.file_path = file_path
        self.thread = None
        self.index = -1
        self._menu = g15theme.Menu("menu")
        g15theme.G15Page.__init__(
            self,
            os.path.basename(file_path),
            self._screen,
            thumbnail_painter=self._paint_thumbnail,
            theme=g15theme.G15Theme(self, "menu-screen"),
            theme_properties_callback=self._get_theme_properties,
            originating_plugin=plugin)
        self.add_child(self._menu)
        self.add_child(g15theme.MenuScrollbar("viewScrollbar", self._menu))
        self._reload()
        self._screen.add_page(self)
        self._screen.redraw(self)
        self.on_deleted = self._stop
Ejemplo n.º 8
0
 def create_theme(self):
     variant = None
     if self._timer1.get_enabled() and self._timer2.get_enabled():
         variant = "two_timers"
     elif self._timer1.get_enabled() or self._timer2.get_enabled():
         variant = "one_timer"
     return g15theme.G15Theme(self, variant)
Ejemplo n.º 9
0
    def __init__(self, gconf_client, gconf_key, screen, backend, buddy, ctrl,
                 plugin):
        g15theme.G15Page.__init__(self, _("Backlight"), screen, priority=g15screen.PRI_HIGH, \
                                     theme=g15theme.G15Theme(os.path.join(g15globals.themes_dir, "default"), "menu-screen"),
                                     originating_plugin = plugin)
        self.theme_properties = {
            "title": _("Backlight"),
            "icon":
            backend.get_icon() if buddy.avatar is None else buddy.avatar,
            "alt_title": buddy.nickname
        }
        self.menu = g15theme.Menu("menu")
        self.get_screen().add_page(self)
        self.add_child(self.menu)
        self.ctrl = ctrl
        self.acq = None

        sel_color = g15convert.to_rgb(
            g15gconf.get_string_or_default(gconf_client,
                                           get_backlight_key(gconf_key, buddy),
                                           "255,255,255"))
        for i, c in enumerate(colorpicker.COLORS_FULL):
            c = (c[0], c[1], c[2])
            item = ColorMenuItem(gconf_client, gconf_key, c,
                                 colorpicker.COLORS_NAMES[i], buddy, backend)
            self.menu.add_child(item)
            if c == sel_color:
                self.menu.set_selected_item(item)

        self.menu.on_selected = self._handle_selected
        self.on_deleted = self._release_control
        self.menu.add_child(ReturnMenuItem())
        self.add_child(g15theme.MenuScrollbar("viewScrollbar", self.menu))
        self._handle_selected()
Ejemplo n.º 10
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.º 11
0
 def activate(self):
     self.page = g15theme.G15Page(
         id,
         self.screen,
         theme_properties_callback=self._get_theme_properties,
         priority=g15screen.PRI_LOW,
         title=name,
         theme=g15theme.G15Theme(self),
         originating_plugin=plugin)
     self.window = g15gtk.G15OffscreenWindow("offscreenWindow")
     self.page.add_child(self.window)
     GLib.idle_add(self._create_offscreen_window)
Ejemplo n.º 12
0
    def __init__(self, gconf_client, gconf_key, screen, backend, buddy_menu,
                 plugin):
        g15theme.G15Page.__init__(self,
                                  _("Settings"),
                                  screen,
                                  priority=g15screen.PRI_HIGH,
                                  theme=g15theme.G15Theme(
                                      os.path.join(g15globals.themes_dir,
                                                   "default"), "menu-screen"),
                                  originating_plugin=plugin)
        me = backend.get_me()
        self.theme_properties = {
            "title": _("Settings"),
            "icon": backend.get_icon() if me.avatar is None else me.avatar,
            "alt_title": me.nickname
        }
        self.menu = g15theme.Menu("menu")
        self.get_screen().add_page(self)
        self.add_child(self.menu)

        self.menu.add_child(
            SelectChannelMenuItem(gconf_client, gconf_key, backend, plugin))

        self.menu.add_child(
            g15theme.MenuItem('audio-status',
                              True,
                              _('Audio'),
                              activatable=False))
        self.menu.add_child(AudioInputMenuItem(backend))
        self.menu.add_child(AudioOutputMenuItem(backend))

        self.menu.add_child(
            g15theme.MenuItem('select-status',
                              True,
                              _('Select Status'),
                              activatable=False))
        self.menu.add_child(OnLineStatusMenuItem(backend))
        self.menu.add_child(AwayStatusMenuItem(backend))

        self.menu.add_child(
            g15theme.MenuItem('select-mode',
                              True,
                              _('Select Buddy List Mode'),
                              activatable=False))
        for i in MODE_LIST:
            self.menu.add_child(
                SelectModeMenuItem(gconf_client, gconf_key, i, MODES[i][1],
                                   backend, buddy_menu))

        self.menu.add_child(ReturnMenuItem())
        self.add_child(g15theme.MenuScrollbar("viewScrollbar", self.menu))
Ejemplo n.º 13
0
 def __init__(self, screen):
     g15theme.G15Page.__init__(self, id, screen, title=name, theme=g15theme.G15Theme(self),
                               thumbnail_painter=self._paint_thumbnail)
     self._sidebar_offset = 0
     self._muted = False
     self._lock = Lock()
     self._surface = None
     self._hide_timer = None
     self._screen = screen
     self._full_screen = self._screen.driver.get_size()
     self._aspect = self._full_screen
     self._playing = None
     self._active = True
     self._frame_index = 1
     self._frame_wait = 0.04
     self._thumb_icon = g15cairo.load_surface_from_file(
         g15icontools.get_icon_path(["media-video", "emblem-video", "emblem-videos", "video", "video-player"]))
Ejemplo n.º 14
0
 def __init__(self, gconf_client, gconf_key, screen, backend, plugin):
     g15theme.G15Page.__init__(self, _("Server/Channel"), screen, priority=g15screen.PRI_HIGH, \
                                  theme=g15theme.G15Theme(os.path.join(g15globals.themes_dir, "default"), "menu-screen"),
                                  originating_plugin = plugin)
     self.theme_properties = {
         "title": _("Server/Channel"),
         "icon": backend.get_icon(),
         "alt_title": ''
     }
     self.menu = g15theme.Menu("menu")
     self.get_screen().add_page(self)
     self.add_child(self.menu)
     for c in backend.get_channels():
         self.menu.add_child(c)
         if c == backend.get_current_channel():
             self.menu.set_selected_item(c)
     self.menu.add_child(ReturnMenuItem())
     self.add_child(g15theme.MenuScrollbar("viewScrollbar", self.menu))
Ejemplo n.º 15
0
 def __init__(self, plugin, url):
     self.launchpad = plugin.launchpad
     self.gconf_client = plugin.gconf_client
     self.gconf_key = plugin.gconf_key
     self.screen = plugin.screen
     self.theme = g15theme.G15Theme(
         os.path.join(os.path.dirname(__file__), "default"), self.screen)
     self.url = url
     self.index = -1
     self.selected_entry = None
     self.reload()
     self.page = self.screen.new_page(
         self.paint,
         id="PPA " + str(plugin.page_serial),
         thumbnail_painter=self.paint_thumbnail)
     plugin.page_serial += 1
     self.screen.redraw(self.page)
     self.project = self.launchpad.projects[self.url]
     print self.project
Ejemplo n.º 16
0
 def _reload_theme(self):
     self.theme = g15theme.G15Theme(
         os.path.join(os.path.dirname(__file__), "default"), self.screen)
Ejemplo n.º 17
0
 def _reload_theme(self):
     text = self._gconf_client.get_string(self._gconf_key + "/message_text")
     variant = ""
     if text == None or text == "":
         variant = "nobody"
     self._theme = g15theme.G15Theme(self, variant)
Ejemplo n.º 18
0
 def _reload_theme(self):
     variant = None
     self.theme = g15theme.G15Theme(
         os.path.join(os.path.dirname(__file__), "default"), variant)
Ejemplo n.º 19
0
 def on_configure(self):
     self.set_theme(
         g15theme.G15Theme(self.parent.get_theme().dir,
                           "message-menu-entry"))
Ejemplo n.º 20
0
 def _reload_theme(self):
     variant = None
     if self.display_date:
         variant = "with-date"
     self.theme = g15theme.G15Theme(
         os.path.join(os.path.dirname(__file__), "default"), variant)
Ejemplo n.º 21
0
    def _notify(self):
        if len(self._message_queue) != 0:
            logger.debug("Displaying first message in queue of %d",
                         len(self._message_queue))
            message = self._message_queue[0]

            # Which theme variant should we use
            self._last_variant = ""
            if message.body == None or message.body == "":
                self._last_variant = "nobody"

            self._current_message = message

            # Get the page

            if self._page == None:
                logger.debug("Creating new notification message page")
                self._control_values = []
                for c in self._screen.driver.get_controls():
                    if c.hint & g15driver.HINT_DIMMABLE != 0:
                        self._control_values.append(c.value)

                if self._screen.driver.get_bpp() != 0:
                    logger.debug("Creating notification message page")
                    self._page = g15theme.G15Page(id, self._screen, priority=g15screen.PRI_HIGH, title = name, \
                                                  theme_properties_callback = self._get_theme_properties, \
                                                  theme = g15theme.G15Theme(self, self._last_variant),
                                                  originating_plugin = self)
                    self._page.on_deleted = self._page_deleted
                    self._screen.add_page(self._page)
            else:
                logger.debug("Raising notification message page")
                self._page.set_theme(
                    g15theme.G15Theme(self, self._last_variant))
                self._screen.raise_page(self._page)

            self._start_timer(message)
            self._do_redraw()

            # Play sound
            if self.enable_sounds and "sound-file" in message.hints and (
                    not "suppress-sound" in message.hints
                    or not message.hints["suppress-sound"]):
                logger.debug("Will play sound", message.hints["sound-file"])
                os.system("aplay '%s' &" % message.hints["sound-file"])

            control = self._screen.driver.get_control_for_hint(
                g15driver.HINT_DIMMABLE)
            if control and self.blink_keyboard_backlight:
                acquired_control = self._screen.driver.acquire_control(
                    control,
                    release_after=3.0,
                    val=self.keyboard_backlight_color
                    if self.change_keyboard_backlight_color else control.value)
                acquired_control.blink(delay=self.blink_delay / 1000.0)
            elif control and self.change_keyboard_backlight_color:
                acquired_control = self._screen.driver.acquire_control(
                    control,
                    release_after=3.0,
                    val=self.keyboard_backlight_color)

            if self.blink_memory_bank:
                acquired_control = self._screen.driver.acquire_control_with_hint(
                    g15driver.HINT_MKEYS,
                    release_after=3.0,
                    val=g15driver.MKEY_LIGHT_1 | g15driver.MKEY_LIGHT_2
                    | g15driver.MKEY_LIGHT_3 | g15driver.MKEY_LIGHT_MR)
                acquired_control.blink(delay=self.blink_delay / 1000.0)
Ejemplo n.º 22
0
 def on_configure(self):
     self.set_theme(
         g15theme.G15Theme(
             self.parent.get_theme().dir,
             "menu-entry" if self.group else "menu-child-entry"))
Ejemplo n.º 23
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)
Ejemplo n.º 24
0
 def on_configure(self):  
     self.set_theme(g15theme.G15Theme(os.path.join(os.path.dirname(__file__), "default"), "cell"))
Ejemplo n.º 25
0
 def activate(self):
     self._theme = g15theme.G15Theme(self)
     self._screen.key_handler.action_listeners.append(self) 
     self._listener = MacroRecorderScreenChangeListener(self)
     self._screen.add_screen_change_listener(self._listener)