Exemple #1
0
    def get_theme_properties(self):
        props = g15plugin.G15MenuPlugin.get_theme_properties(self)
        props["mode"] = MODES[self.menu.mode][1]
        props["name"] = self.backend.get_name(
        ) if self.backend is not None else ""
        props["channel"] = self.backend.get_current_channel(
        ).name if self.backend is not None else ""

        if self.menu.get_showing_count() == 0:
            if self.menu.mode == MODE_ALL:
                props["emptyMessage"] = _("Nobody connected")
            elif self.menu.mode == MODE_ONLINE:
                props["emptyMessage"] = _("Nobody online")
            elif self.menu.mode == MODE_TALKING:
                props["emptyMessage"] = _("Nobody talking")
        else:
            props["emptyMessage"] = ""

        # Get what mode to switch to
        mode_index = MODE_LIST.index(self.menu.mode) + 1
        if mode_index >= len(MODE_LIST):
            mode_index = 0

        props["list"] = MODES[MODE_LIST[mode_index]][0]

        talking_buddy = self.backend.get_talking()
        me = self.backend.get_me()

        props[
            "talking"] = talking_buddy.nickname if talking_buddy is not None else ""
        props[
            "talking_avatar"] = talking_buddy.avatar if talking_buddy is not None else (
                me.avatar if me is not None and me.avatar is not None else
                self.backend.get_icon())
        props["talking_avatar_icon"] = g15icontools.get_icon_path(
            RECORD_ICONS) if talking_buddy is not None else None

        if self.screen.device.bpp == 1:
            props[
                "talking_icon"] = MONO_RECORD_ICON if me is not None and me.talking else ""
            props[
                "input_muted_icon"] = MONO_MIC_MUTED if me is not None and me.input_muted else MONO_MIC_UNMUTED
            props[
                "output_muted_icon"] = MONO_SPKR_MUTED if me is not None and me.output_muted else MONO_SPKR_UNMUTED
            props[
                "status_icon"] = MONO_ONLINE if me is not None and not me.away else MONO_AWAY
        else:
            props["status_icon"] = g15icontools.get_icon_path(
                "user-available"
                if me is not None and not me.away else "user-away")
            props["input_muted_icon"] = g15icontools.get_icon_path(
                MUTED_ICONS
                if me is not None and me.input_muted else UNMUTED_ICONS)
            props["output_muted_icon"] = g15icontools.get_icon_path(
                "audio-volume-muted"
                if me is not None and me.output_muted else "audio-volume-high")
            props["talking_icon"] = g15icontools.get_icon_path(
                RECORD_ICONS) if me is not None and me.talking else ""

        return props
Exemple #2
0
    def get_theme_properties(self):
        item_properties = g15theme.MenuItem.get_theme_properties(self)

        if self.away and isinstance(self.away, str):
            item_properties["item_name"] = "%s - %s" % (self.nickname,
                                                        self.away)
        else:
            item_properties["item_name"] = self.nickname

        item_properties["item_alt"] = ""
        item_properties["item_type"] = ""

        if self.get_screen().device.bpp == 1:
            item_properties[
                "item_talking_icon"] = MONO_RECORD_ICON if self.talking else ""
            item_properties[
                "item_input_muted_icon"] = MONO_MIC_MUTED if self.input_muted else MONO_MIC_UNMUTED
            item_properties[
                "item_output_muted_icon"] = MONO_SPKR_MUTED if self.output_muted else MONO_SPKR_UNMUTED
            item_properties[
                "item_icon"] = MONO_ONLINE if not self.away else MONO_AWAY
        else:
            item_properties[
                "item_input_muted_icon"] = g15icontools.get_icon_path(
                    MUTED_ICONS if self.input_muted else UNMUTED_ICONS)
            item_properties[
                "item_output_muted_icon"] = g15icontools.get_icon_path(
                    "audio-volume-muted" if self.
                    output_muted else "audio-volume-high")
            item_properties["item_icon"] = g15icontools.get_icon_path(
                "user-available" if not self.away else "user-away")
            item_properties["item_talking_icon"] = g15icontools.get_icon_path(
                RECORD_ICONS) if self.talking else ""

        return item_properties
Exemple #3
0
 def get_theme_properties(self):        
     item_properties = g15theme.MenuItem.get_theme_properties(self)       
     item_properties["item_name"] = self.account.name
     if self.error != None:
         item_properties["item_alt"] = _("Error")
     else: 
         if self.count > 0:
             item_properties["item_alt"] = "%d" % ( self.count )
         else:
             item_properties["item_alt"] = _("None")
     item_properties["item_type"] = ""
     
     if self.refreshing:
         if self.plugin.screen.driver.get_bpp() == 1:
             item_properties["item_icon"] =  os.path.join(os.path.dirname(__file__), "mono-mail-refresh.gif")
         else:
             item_properties["item_icon"] =  g15icontools.get_icon_path(["view-refresh", "stock_refresh", "gtk-refresh", "view-refresh-symbolic"])
     elif self.error is not None:            
         if self.plugin.screen.driver.get_bpp() == 1:
             item_properties["item_icon"] = os.path.join(os.path.dirname(__file__), "mono-mail-error.gif")
         else:
             item_properties["item_icon"] =  g15icontools.get_icon_path("new-messages-red")
     else:
         if self.count > 0:
             if self.plugin.screen.driver.get_bpp() == 1:
                 item_properties["item_icon"] = os.path.join(os.path.dirname(__file__), "mono-mail-new.gif")
             else:                        
                 item_properties["item_icon"] =  g15icontools.get_icon_path("indicator-messages-new")
         else:
             if self.plugin.screen.driver.get_bpp() == 1:
                 item_properties["item_icon"] = ""
             else:
                 item_properties["item_icon"] =  g15icontools.get_icon_path("indicator-messages")
     
     return item_properties
Exemple #4
0
 def _get_theme_properties(self):
     width_available = self._screen.width
     properties = {}  
     properties["title"] = self._current_message.summary
     properties["message"] = self._current_message.body
     if self._current_message.icon != None and len(self._current_message.icon) > 0:
         icon_path = g15icontools.get_icon_path(self._current_message.icon)
         
         # Workaround on Natty missing new email notification icon (from Evolution)?
         if icon_path == None and self._current_message.icon == "notification-message-email":
             icon_path = g15icontools.get_icon_path([ "applications-email-pane", "mail_new", "mail-inbox", "mail-folder-inbox", "evolution-mail" ])
             
         properties["icon"] = icon_path 
     elif self._current_message.embedded_image != None:
         properties["icon"] = self._current_message.embedded_image            
     if not "icon" in properties or properties["icon"] == None:
         properties["icon"] = g15icontools.get_icon_path(["dialog-info", "stock_dialog-info", "messagebox_info" ])
                 
     properties["next"] = len(self._message_queue) > 1
     action = 1
     for a in self._current_message.actions:
         properties["action%d" % action] = a[1] 
         action += 1
     if len(self._current_message.actions) > 0:        
         properties["action"] = True
         
     time_displayed = time.time() - self._displayed_notification
     remaining = self._current_message.timeout - time_displayed
     remaining_pc = ( remaining / self._current_message.timeout ) * 100.0
     properties["remaining"] = int(remaining_pc) 
     return properties
Exemple #5
0
 def _attention_changed(self, attention):
     self._attention = attention
     if self._attention == 1:
         self._start_blink()
         if self.screen.driver.get_bpp() == 1:
             self.thumb_icon = g15cairo.load_surface_from_file(os.path.join(os.path.dirname(__file__), "mono-mail-new.gif"))
         else:
             self.thumb_icon = g15cairo.load_surface_from_file(g15icontools.get_icon_path("indicator-messages-new"))
         self._popup()
     else:
         self._stop_blink()
         if self.screen.driver.get_bpp() == 16:
             self.thumb_icon = g15cairo.load_surface_from_file(g15icontools.get_icon_path("indicator-messages"))
         self.screen.redraw()
Exemple #6
0
    def refresh(self):
        t_count = 0
        t_errors = 0
        for item in self.items:
            try :
                item.refreshing = True
                self.page.redraw()
                status = self._check_account(item.account)
                item.count  = status[0]
                t_count += item.count
                item.error = None
                item.refreshing = False
            except Exception as e:
                item.refreshing = False
                t_errors += 1
                item.error = e
                item.count = 0
                logger.debug("Error while refreshing item %s", str(item), exc_info = e)
                
        self.total_count = t_count
        self.total_errors = t_errors
        
        if self.total_errors > 0:
            self._stop_blink()
            self.attention = True   
            if self.screen.driver.get_bpp() == 1:
                self.thumb_icon = g15cairo.load_surface_from_file(os.path.join(os.path.dirname(__file__), "mono-mail-error.gif"))
            elif self.screen.driver.get_bpp() > 0:
                self.thumb_icon = g15cairo.load_surface_from_file(g15icontools.get_icon_path(["new-messages-red","messagebox_critical"]))
        else:
            if self.total_count > 0:
                self._start_blink()
                self.attention = True
                if self.screen.driver.get_bpp() == 1:
                    self.thumb_icon = g15cairo.load_surface_from_file(os.path.join(os.path.dirname(__file__), "mono-mail-new.gif"))
                elif self.screen.driver.get_bpp() > 0:
                    self.thumb_icon = g15cairo.load_surface_from_file(g15icontools.get_icon_path(["indicator-messages-new", "mail-message-new"]))
            else:
                self._stop_blink()
                self.attention = False   
                if self.screen.driver.get_bpp() == 1:
                    self.thumb_icon = None
                elif self.screen.driver.get_bpp() > 0:
                    self.thumb_icon = g15cairo.load_surface_from_file(g15icontools.get_icon_path(["indicator-messages", "mail-message"]))

        if self.screen.driver.get_bpp() > 0:        
            self.screen.redraw(self.page)
            
        self.schedule_refresh()
Exemple #7
0
 def _reload(self):
     icons = []
     mime_type = mime.get_type(self.file_path)
     if mime_type != None:
         icons.append(str(mime_type).replace("/","-"))
     icons.append("text-plain")
     icons.append("panel-searchtool")
     icons.append("gnome-searchtool")
     icon = g15icontools.get_icon_path(icons, size=self.plugin._screen.height)
     
     if icon is None:
         self._icon_surface = None
         self._icon_embedded = None
     else:
         try :
             icon_surface = g15cairo.load_surface_from_file(icon)
             self._icon_surface = icon_surface
             self._icon_embedded = g15icontools.get_embedded_image_url(icon_surface)
         except Exception as e:
             logger.warning("Failed to get icon %s", str(icon), exc_info = e)
             self._icon_surface = None
             self._icon_embedded = None
     
     self._stop()
     if os.path.exists(self.file_path):
         self._subtitle =  time.strftime('%Y-%m-%d %H:%M', time.localtime(os.path.getmtime(self.file_path)))
         self._message = ""
         self.thread = G15TailThread(self)
         self.thread.start()
     else:
         self._subtitle = ""
         self._message = "File does not exist"
Exemple #8
0
 def get_theme_properties(self):        
     item_properties = g15theme.MenuItem.get_theme_properties(self)
     item_properties["item_name"] = self.event.summary
     
     start_str = self.event.start_date.strftime("%H:%M")
     end_str = self.event.end_date.strftime("%H:%M")
     
     if not self._same_day(self.event.start_date, self.event.end_date):
         if not self._same_day(self.plugin._calendar_date, self.event.end_date):
             end_str = _(self.event.end_date.strftime("%m/%d"))
         if not self._same_day(self.plugin._calendar_date, self.event.start_date):
             start_str = _(self.event.start_date.strftime("%m/%d"))
     
     
     if self._same_day(self.event.start_date, self.event.end_date) and \
        self.event.start_date.hour == 0 and self.event.start_date.minute == 0 and \
        self.event.end_date.hour == 23 and self.event.end_date.minute == 59:
         item_properties["item_alt"] = _("All Day")
     else:
         item_properties["item_alt"] = "%s-%s" % ( start_str, end_str)
         
     item_properties["item_alarm"] = self.event.alarm  
     if self.event.alarm:          
         if self.get_screen().device.bpp > 1:  
             item_properties["item_icon"] = g15icontools.get_icon_path([ "stock_alarm", "alarm-clock", "alarm-timer", "dialog-warning" ])
         else:  
             item_properties["item_icon"] = os.path.join(os.path.dirname(__file__), 'bell.gif')
     if self.event.alt_icon:
         item_properties["alt_icon"] = self.event.alt_icon
     return item_properties
Exemple #9
0
    def recalc_progress(self):
        logger.debug("Recalculating progress")
        if not self.duration or self.duration < 1:
            self.song_properties["track_progress_pc"] = "0"
            self.song_properties["time_text"] = self.get_formatted_time(
                self.elapsed)
        else:
            pc = 100 / float(self.duration)
            val = int(pc * self.elapsed)
            self.song_properties["track_progress_pc"] = str(val)
            self.song_properties["time_text"] = self.get_formatted_time(
                self.elapsed) + " of " + self.get_formatted_time(self.duration)

        # Volume Icon
        vol_icon = "audio-volume-muted"
        if self.volume > 0.0 and self.volume < 34.0:
            vol_icon = "audio-volume-low"
        elif self.volume >= 34.0 and self.volume < 67.0:
            vol_icon = "audio-volume-medium"
        elif self.volume >= 67.0:
            vol_icon = "audio-volume-high"
        self.song_properties["vol_icon"] = g15icontools.get_icon_path(
            vol_icon, self.screen.height)

        # For the bars on the G15 (the icon is too small, bars are better)
        for i in range(0, int(self.volume / 10) + 1, 1):
            self.song_properties["bar" + str(i)] = True
Exemple #10
0
    def _get_properties(self):
        properties = {
            "title": self._current_message.summary,
            "message": self._current_message.body
        }
        if self._current_message.icon is not None and len(
                self._current_message.icon) > 0:
            properties["icon"] = g15icontools.get_icon_path(
                self._current_message.icon)
        elif self._current_message.embedded_image is not None:
            properties["icon"] = self._current_message.embedded_image

        if str(len(self._message_queue) > 1):
            properties["next"] = "True"

        action = 1
        for a in self._current_message.actions:
            properties["action%d" % action] = a[1]
            action += 1
        if len(self._current_message.actions) > 0:
            properties["action"] = "True"

        properties["remaining"] = str(self._get_remaining())

        return properties
Exemple #11
0
    def _get_theme_properties(self):

        active_profile = g15profile.get_active_profile(self._screen.device)

        properties = {}
        properties["icon"] = g15icontools.get_icon_path(
            self.icon, self._screen.height)
        properties["memory"] = "M%d" % self._screen.get_memory_bank()

        if active_profile != None:
            properties["profile"] = active_profile.name
            properties["profile_icon"] = active_profile.get_profile_icon_path(
                self._screen.height)

            if self._message == None:
                properties["message"] = _(
                    "Recording on M%s. Type in your macro then press the G-Key to assign it to, or MR to cancel."
                    % self._screen.get_memory_bank())
            else:
                properties["message"] = self._message
        else:
            properties["profile"] = _("No Profile")
            properties["profile_icon"] = ""
            properties["message"] = _(
                "You have no profiles configured. Configure one now using the Macro tool"
            )

        return properties
Exemple #12
0
 def __init__(self):
     g15theme.MenuItem.__init__(self,
                                'return',
                                True,
                                _('Back to previous menu'),
                                icon=g15icontools.get_icon_path(
                                    ['back', 'gtk-go-back-ltr']))
Exemple #13
0
 def get_theme_properties(self):        
     item_properties = g15theme.MenuItem.get_theme_properties(self)
     item_properties["item_name"] = self.event.summary
     
     start_str = self.event.start_date.strftime("%H:%M")
     end_str = self.event.end_date.strftime("%H:%M")
     
     if not self._same_day(self.event.start_date, self.event.end_date):
         if not self._same_day(self.plugin._calendar_date, self.event.end_date):
             end_str = _(self.event.end_date.strftime("%m/%d"))
         if not self._same_day(self.plugin._calendar_date, self.event.start_date):
             start_str = _(self.event.start_date.strftime("%m/%d"))
     
     
     if self._same_day(self.event.start_date, self.event.end_date) and \
        self.event.start_date.hour == 0 and self.event.start_date.minute == 0 and \
        self.event.end_date.hour == 23 and self.event.end_date.minute == 59:
         item_properties["item_alt"] = _("All Day")
     else:
         item_properties["item_alt"] = "%s-%s" % ( start_str, end_str)
         
     item_properties["item_alarm"] = self.event.alarm  
     if self.event.alarm:          
         if self.get_screen().device.bpp > 1:  
             item_properties["item_icon"] = g15icontools.get_icon_path([ "stock_alarm", "alarm-clock", "alarm-timer", "dialog-warning" ])
         else:  
             item_properties["item_icon"] = os.path.join(os.path.dirname(__file__), 'bell.gif')
     if self.event.alt_icon:
         item_properties["alt_icon"] = self.event.alt_icon
     return item_properties
Exemple #14
0
 def get_theme_properties(self):       
     item_properties = g15theme.MenuItem.get_theme_properties(self)
     item_properties["item_name"] = self.mount.get_name()
     item_properties["item_type"] = ""     
     icon_names = []
     icon = self.mount.get_icon()
     if isinstance(icon, gio.FileIcon):
         icon_names.append(icon.get_file().get_path())
     else:
         icon_names += icon.get_names()
         
     icon_names += "gnome-dev-harddisk"
     item_properties["item_icon"] = g15icontools.get_icon_path(icon_names)
     item_properties["disk_usage"] = self.disk_used_pc
     item_properties["sel_disk_usage"] = self.disk_used_pc
     item_properties["disk_used_mb"] =  "%4.2f" % (self.disk_used / 1024.0 / 1024.0 )
     item_properties["disk_free_mb"] =  "%4.2f" % (self.disk_free / 1024.0 / 1024.0 )
     item_properties["disk_size_mb"] =  "%4.2f" % (self.disk_size / 1024.0 / 1024.0 )
     item_properties["disk_used_gb"] =  "%4.1f" % (self.disk_used / 1024.0 / 1024.0 / 1024.0 )
     item_properties["disk_free_gb"] =  "%4.1f" % (self.disk_free / 1024.0 / 1024.0 / 1024.0 )
     item_properties["disk_size_gb"] =  "%4.1f" % (self.disk_size / 1024.0 / 1024.0 / 1024.0 )
     suffix = "G" if self.disk_size >= ( 1 * 1024.0 * 1024.0 * 1024.0 ) else "M"
     item_properties["disk_used"] = "%s %s" % ( item_properties["disk_used_gb"], suffix ) 
     item_properties["disk_free"] = "%s %s" % ( item_properties["disk_free_gb"], suffix )
     item_properties["disk_size"] = "%s %s" % ( item_properties["disk_size_gb"], suffix )
     
     if self._plugin._mode == "free":
         item_properties["item_alt"] = item_properties["disk_free"]
     elif self._plugin._mode == "used":
         item_properties["item_alt"] = item_properties["disk_used"]
     elif self._plugin._mode == "size":
         item_properties["item_alt"] = item_properties["disk_size"]
         
     return item_properties
Exemple #15
0
 def get_theme_properties(self):  
     return  {
               "title" : _("Messages"),
               "alt_title" : "",
               "icon" : g15icontools.get_icon_path("indicator-messages-new" if self._attention else "indicator-messages"),
               "attention": self._attention
               }  
Exemple #16
0
 def __init__(self, gconf_key, gconf_client, screen):
     g15plugin.G15Plugin.__init__(self, gconf_client, gconf_key, screen)
     self._timer = None
     self._icon_path = g15icontools.get_icon_path([
         "calendar", "evolution-calendar", "office-calendar",
         "stock_calendar"
     ])
     self._thumb_icon = g15cairo.load_surface_from_file(self._icon_path)
Exemple #17
0
 def _get_theme_properties(self):
     
     properties = {}
     properties["title"] = _("Workstation Locked")
     properties["body"] = self._gconf_client.get_string(self._gconf_key + "/message_text")
     properties["icon"] = g15icontools.get_icon_path("sleep", self._screen.height)
     
     return properties
Exemple #18
0
 def _translate_icon(self, icon, fallback_icon):
     theme_icon = icon
     if theme_icon == None or theme_icon == "":
         return None
     else:
         if not g15gconf.get_bool_or_default(self.gconf_client, "%s/use_theme_icons" % self.gconf_key, True):
             return fallback_icon
         
     if theme_icon != None:
         icon_path = g15icontools.get_icon_path(theme_icon, warning = False, include_missing = False)
         if icon_path == None and theme_icon.endswith("-night"):
             icon_path = g15icontools.get_icon_path(theme_icon[:len(theme_icon) - 6], include_missing = False)
             
         if icon_path != None:
             return icon_path
          
     return g15icontools.get_icon_path(icon)
Exemple #19
0
 def __init__(self, backend):
     g15theme.MenuItem.__init__(
         self,
         'away',
         False,
         _("Away"),
         icon=g15icontools.get_icon_path("user-away"))
     self._backend = backend
Exemple #20
0
 def __init__(self, backend):
     g15theme.MenuItem.__init__(
         self,
         'online',
         False,
         _("Online"),
         icon=g15icontools.get_icon_path("user-available"))
     self._backend = backend
Exemple #21
0
 def get_theme_properties(self):       
     item_properties = g15theme.MenuItem.get_theme_properties(self)
     item_properties["item_name"] = self._mount.get_name()
     icon = self._mount.get_icon()        
     icon_names = [ icon.get_file().get_path() ] if isinstance(icon, gio.FileIcon) else icon.get_names() 
     icon_names += "gnome-dev-harddisk"
     item_properties["item_icon"] = g15icontools.get_icon_path(icon_names)
     return item_properties
Exemple #22
0
 def get_theme_properties(self):       
     item_properties = g15theme.MenuItem.get_theme_properties(self)
     item_properties["item_name"] = self.volume.get_name()
     item_properties["item_alt"] = ""
     item_properties["item_type"] = ""
     
     item_properties["item_icon"] = g15icontools.get_icon_path([ self.volume.get_icon().get_names()[0], "gnome-dev-harddisk" ])
     return item_properties
Exemple #23
0
 def _get_theme_properties(self):
     
     properties = {}
     properties["title"] = _("Workstation Locked")
     properties["body"] = self._gconf_client.get_string(self._gconf_key + "/message_text")
     properties["icon"] = g15icontools.get_icon_path("sleep", self._screen.height)
     
     return properties
Exemple #24
0
    def _reload(self):
        self.feed = feedparser.parse(self.url)
        icon = None
        if "icon" in self.feed["feed"]:
            icon = self.feed["feed"]["icon"]
        elif "image" in self.feed["feed"]:
            img = self.feed["feed"]["image"]
            if "url" in img:
                icon = img["url"]
            elif "link" in img:
                icon = img["link"]

        title = self.feed["feed"]["title"] if "title" in self.feed[
            "feed"] else self.url
        if icon is None and title.endswith("- Twitter Search"):
            title = title[:-16]
            icon = g15icontools.get_icon_path("gnome15")
        if icon is None:
            icon = g15icontools.get_icon_path(
                ["application-rss+xml", "gnome-mime-application-rss+xml"],
                self._screen.height)

        if icon is None:
            self._icon_surface = None
            self._icon_embedded = None
        else:
            try:
                icon_surface = g15cairo.load_surface_from_file(icon)
                self._icon_surface = icon_surface
                self._icon_embedded = g15icontools.get_embedded_image_url(
                    icon_surface)
            except Exception as e:
                logger.warning("Failed to get icon %s", str(icon), exc_info=e)
                self._icon_surface = None
                self._icon_embedded = None
        self.set_title(title)
        self._subtitle = self.feed["feed"][
            "subtitle"] if "subtitle" in self.feed["feed"] else ""
        self._menu.remove_all_children()
        i = 0
        for entry in self.feed.entries:
            self._menu.add_child(
                G15FeedsMenuItem("feeditem-%d" % i, entry, self._gconf_client,
                                 self._gconf_key))
            i += 1
Exemple #25
0
 def __init__(self, gconf_key, gconf_client, screen):
     
     self._screen = screen
     self._gconf_client = gconf_client
     self._gconf_key = gconf_key
     self._timer = None
     self._icon_path = g15icontools.get_icon_path([ "redhat-office", "package_office", "gnome-applications", "xfce-office", "baobab" ])
     self._thumb_icon = g15cairo.load_surface_from_file(self._icon_path)
     self._timer = None
Exemple #26
0
    def set_details(self, icon, summary, body, timeout, actions, hints):
        self.icon = icon
        self.summary = "None" if summary == None else summary
        if body != None and len(body) > 0:
            try:
                self.body = lxml.html.fromstring(body).text_content()
            except Exception as e:
                logger.debug("Could not parse body as html", exc_info=e)
                self.body = body
        else:
            self.body = body
        self.timeout = timeout
        #            if timeout <= 0.0:
        #                timeout = 10.0
        self.timeout = 10.0
        self.actions = []
        i = 0
        if actions != None:
            for j in range(0, len(actions), 2):
                self.actions.append((actions[j], actions[j + 1]))
        self.hints = hints
        self.embedded_image = None

        if "image_path" in self.hints:
            self.icon = self.hints["image_path"]

        if "image_data" in self.hints:
            image_struct = self.hints["image_data"]
            img_width = image_struct[0]
            img_height = image_struct[1]
            img_stride = image_struct[2]
            has_alpha = image_struct[3]
            bits_per_sample = image_struct[4]
            channels = image_struct[5]
            buf = ""
            for b in image_struct[6]:
                buf += chr(b)

            try:
                pixbuf = gtk.gdk.pixbuf_new_from_data(
                    buf, gtk.gdk.COLORSPACE_RGB, has_alpha, bits_per_sample,
                    img_width, img_height, img_stride)
                fh, self.embedded_image = tempfile.mkstemp(suffix=".png",
                                                           prefix="notify-lcd")
                file = os.fdopen(fh)
                file.close()
                pixbuf.save(self.embedded_image, "png")
                self.icon = None
            except Exception as e:
                # Sometimes the image data seems to be bad
                logger.warning("Failed to decode notification image",
                               exc_info=e)

            if self.embedded_image == None and (self.icon == None
                                                or self.icon == ""):
                self.icon = g15icontools.get_icon_path("dialog-information",
                                                       1024)
Exemple #27
0
    def _get_theme_properties(self):

        properties = {
            "title": _("Workstation Locked"),
            "body": self._gconf_client.get_string(self._gconf_key + "/message_text"),
            "icon": g15icontools.get_icon_path("sleep", self._screen.height)
        }

        return properties
Exemple #28
0
 def get_default_cover(self):
     mime_type = mime.get_type(self.playing_uri)
     new_cover_uri = None
     if mime_type != None:
         mime_icon = g15icontools.get_icon_path(str(mime_type).replace("/","-"), size=self.screen.height)
         if mime_icon != None:                    
             new_cover_uri = mime_icon  
     if new_cover_uri != None:
         try :            
             new_cover_uri = "file://" + urllib.pathname2url(new_cover_uri)
         except Exception as e:
             logger.debug("Error getting default cover, using None", exc_info = e)
             new_cover_uri = None
                           
     if new_cover_uri == None:                      
         new_cover_uri = g15icontools.get_icon_path(["audio-player", "applications-multimedia" ], size=self.screen.height)
         
     return new_cover_uri
Exemple #29
0
 def _attention_changed(self, attention):
     self._attention = attention
     if self._attention == 1:
         self._start_blink()
         if self.screen.driver.get_bpp() == 1:
             self.thumb_icon = g15cairo.load_surface_from_file(
                 os.path.join(os.path.dirname(__file__),
                              "mono-mail-new.gif"))
         else:
             self.thumb_icon = g15cairo.load_surface_from_file(
                 g15icontools.get_icon_path("indicator-messages-new"))
         self._popup()
     else:
         self._stop_blink()
         if self.screen.driver.get_bpp() == 16:
             self.thumb_icon = g15cairo.load_surface_from_file(
                 g15icontools.get_icon_path("indicator-messages"))
         self.screen.redraw()
Exemple #30
0
 def get_theme_properties(self):
     p = g15theme.MenuItem.get_theme_properties(self)
     me = self._backend.get_me()
     if self.get_screen().device.bpp == 1:
         p["item_icon"] = MONO_SPKR_MUTED if me.output_muted else MONO_SPKR_UNMUTED
     else:
         p["item_icon"] = g15icontools.get_icon_path("audio-volume-muted" if me.output_muted else "audio-volume-high")
     p["item_name"] = _("Un-mute audio output") if me.output_muted else _("Mute audio output")
     return p
Exemple #31
0
    def Image(self, path, x, y, width, height):
        if not "/" in path:
            path = g15icontools.get_icon_path(path,
                                              width if width != 0 else 128)

        size = None if width == 0 or height == 0 else (width, height)

        img_surface = g15cairo.load_surface_from_file(path, size)
        self._page.image(img_surface, x, y)
Exemple #32
0
 def get_default_cover(self):
     mime_type = mime.get_type(self.playing_uri)
     new_cover_uri = None
     if mime_type != None:
         mime_icon = g15icontools.get_icon_path(str(mime_type).replace("/","-"), size=self.screen.height)
         if mime_icon != None:                    
             new_cover_uri = mime_icon  
     if new_cover_uri != None:
         try :            
             new_cover_uri = "file://" + urllib.pathname2url(new_cover_uri)
         except Exception as e:
             logger.debug("Error getting default cover, using None", exc_info = e)
             new_cover_uri = None
                           
     if new_cover_uri == None:                      
         new_cover_uri = g15icontools.get_icon_path(["audio-player", "applications-multimedia" ], size=self.screen.height)
         
     return new_cover_uri
Exemple #33
0
 def get_theme_properties(self):
     p = g15theme.MenuItem.get_theme_properties(self)
     me = self._backend.get_me()
     if self.get_screen().device.bpp == 1:
         p["item_icon"] = MONO_MIC_MUTED if me.input_muted else MONO_MIC_UNMUTED
     else:
         p["item_icon"] = g15icontools.get_icon_path(MUTED_ICONS if me.input_muted else UNMUTED_ICONS)
     p["item_name"] = _("Un-mute audio input") if me.input_muted else _("Mute audio input")
     return p
Exemple #34
0
 def __init__(self, buddy, backend):
     BuddyActionMenuItem.__init__(
         self,
         'ban',
         _('Ban'),
         buddy,
         backend,
         icon=g15icontools.get_icon_path(
             ['audio-volume-muted-blocked', 'mail_spam', 'stock_spam'],
             include_missing=False))
Exemple #35
0
 def __init__(self, buddy, backend):
     BuddyActionMenuItem.__init__(
         self,
         'kick',
         _('Kick'),
         buddy,
         backend,
         icon=g15icontools.get_icon_path(
             ['force-exit', 'gnome-panel-force-quit'],
             include_missing=False))
Exemple #36
0
 def get_theme_properties(self):
     props = g15plugin.G15MenuPlugin.get_theme_properties(self)
     props["mode"] = MODES[self.menu.mode][1]
     props["name"] = self.backend.get_name() if self.backend is not None else ""
     props["channel"] = self.backend.get_current_channel().name if self.backend is not None else ""
     
     if self.menu.get_showing_count() == 0:
         if self.menu.mode == MODE_ALL:
             props["emptyMessage"] = _("Nobody connected")
         elif self.menu.mode == MODE_ONLINE:
             props["emptyMessage"] = _("Nobody online")
         elif self.menu.mode == MODE_TALKING:
             props["emptyMessage"] = _("Nobody talking")
     else:
         props["emptyMessage"] = ""
     
     # Get what mode to switch to
     mode_index = MODE_LIST.index(self.menu.mode) + 1
     if mode_index >= len(MODE_LIST):
         mode_index = 0
         
     props["list"] = MODES[MODE_LIST[mode_index]][0]
     
     talking_buddy = self.backend.get_talking()
     me = self.backend.get_me()
     
     props["talking"] = talking_buddy.nickname if talking_buddy is not None else ""
     props["talking_avatar"] = talking_buddy.avatar if talking_buddy is not None else (me.avatar if me is not None and me.avatar is not None else self.backend.get_icon())
     props["talking_avatar_icon"] = g15icontools.get_icon_path(RECORD_ICONS) if talking_buddy is not None else None
     
     if self.screen.device.bpp == 1:
         props["talking_icon"] = MONO_RECORD_ICON if me is not None and me.talking else ""
         props["input_muted_icon"] = MONO_MIC_MUTED if me is not None and me.input_muted else MONO_MIC_UNMUTED
         props["output_muted_icon"] = MONO_SPKR_MUTED if me is not None and me.output_muted else MONO_SPKR_UNMUTED
         props["status_icon"] = MONO_ONLINE if me is not None and not me.away else MONO_AWAY
     else:
         props["status_icon"] = g15icontools.get_icon_path("user-available" if me is not None and not me.away else "user-away")
         props["input_muted_icon"] = g15icontools.get_icon_path(MUTED_ICONS if me is not None and me.input_muted else UNMUTED_ICONS)
         props["output_muted_icon"] = g15icontools.get_icon_path("audio-volume-muted" if me is not None and me.output_muted else "audio-volume-high")
         props["talking_icon"] = g15icontools.get_icon_path(RECORD_ICONS) if me is not None and me.talking else ""
      
     return props
Exemple #37
0
 def _get_theme_properties(self):
     backlight_control = self.screen.driver.get_control_for_hint(g15driver.HINT_DIMMABLE)
     color = backlight_control.value
     properties = {
         "title": "Set Backlight",
         "icon": g15icontools.get_icon_path("system-config-display"),
         "r": color[0],
         "g": color[1],
         "b": color[2],
     }
     return properties
Exemple #38
0
 def activate(self):
     kill_name = str(self.process_id) if isinstance(
         self.process_id, int) else self.process_name
     self.plugin.confirm_screen = g15theme.ConfirmationScreen(
         self.get_screen(),
         _("Kill Process"),
         _("Are you sure you want to kill\n%s") % kill_name,
         g15icontools.get_icon_path("utilities-system-monitor"),
         self.plugin._kill_process,
         self.process_id,
         cancel_callback=self.plugin._cancel_kill)
Exemple #39
0
 def get_theme_properties(self):
     p = g15theme.MenuItem.get_theme_properties(self)
     me = self._backend.get_me()
     if self.get_screen().device.bpp == 1:
         p["item_icon"] = MONO_MIC_MUTED if me.input_muted else MONO_MIC_UNMUTED
     else:
         p["item_icon"] = g15icontools.get_icon_path(
             MUTED_ICONS if me.input_muted else UNMUTED_ICONS)
     p["item_name"] = _("Un-mute audio input") if me.input_muted else _(
         "Mute audio input")
     return p
Exemple #40
0
 def _get_theme_properties(self):
     backlight_control = self.screen.driver.get_control_for_hint(g15driver.HINT_DIMMABLE)
     color = backlight_control.value
     properties = {
                   "title" : "Set Backlight",
                   "icon" : g15icontools.get_icon_path("system-config-display"),
                   "r" : color[0],
                   "g" : color[1],
                   "b" : color[2]
                   }
     return properties
Exemple #41
0
 def get_theme_properties(self):
     return {
         "title":
         _("Messages"),
         "alt_title":
         "",
         "icon":
         g15icontools.get_icon_path("indicator-messages-new" if self.
                                    _attention else "indicator-messages"),
         "attention":
         self._attention
     }
Exemple #42
0
 def get_theme_properties(self):
     p = g15theme.MenuItem.get_theme_properties(self)
     me = self._backend.get_me()
     if self.get_screen().device.bpp == 1:
         p["item_icon"] = MONO_SPKR_MUTED if me.output_muted else MONO_SPKR_UNMUTED
     else:
         p["item_icon"] = g15icontools.get_icon_path(
             "audio-volume-muted" if me.
             output_muted else "audio-volume-high")
     p["item_name"] = _("Un-mute audio output") if me.output_muted else _(
         "Mute audio output")
     return p
Exemple #43
0
    def set_details(self, icon, summary, body, timeout, actions, hints):
        self.icon = icon
        self.summary = "None" if summary == None else summary
        if body != None and len(body) > 0:
            try:
                self.body = lxml.html.fromstring(body).text_content()
            except Exception as e:
                logger.debug("Could not parse body as html", exc_info = e)
                self.body = body
        else:
            self.body = body
        self.timeout = timeout
#            if timeout <= 0.0:
#                timeout = 10.0
        self.timeout = 10.0
        self.actions = []
        i = 0
        if actions != None:
            for j in range(0, len(actions), 2):
                self.actions.append((actions[j], actions[j + 1]))
        self.hints = hints
        self.embedded_image = None
        
        if "image_path" in self.hints:
            self.icon = self.hints["image_path"]
            
        if "image_data" in self.hints:
            image_struct = self.hints["image_data"]
            img_width = image_struct[0]
            img_height = image_struct[1]
            img_stride = image_struct[2]
            has_alpha = image_struct[3]
            bits_per_sample = image_struct[4]
            channels = image_struct[5]
            buf = ""
            for b in image_struct[6]:
                buf += chr(b)
                
            try :
                pixbuf = gtk.gdk.pixbuf_new_from_data(buf, gtk.gdk.COLORSPACE_RGB, has_alpha, bits_per_sample, img_width, img_height, img_stride)
                fh, self.embedded_image = tempfile.mkstemp(suffix=".png",prefix="notify-lcd")
                file = os.fdopen(fh)
                file.close()
                pixbuf.save(self.embedded_image, "png")
                self.icon = None
            except Exception as e:
                # Sometimes the image data seems to be bad
                logger.warn("Failed to decode notification image", exc_info = e)
                
            if self.embedded_image == None and ( self.icon == None or self.icon == "" ):
                self.icon = g15icontools.get_icon_path("dialog-information", 1024)
Exemple #44
0
 def _reload(self):
     self.feed = feedparser.parse(self.url)
     icon = None
     if "icon" in self.feed["feed"]:
         icon = self.feed["feed"]["icon"]
     elif "image" in self.feed["feed"]:
         img = self.feed["feed"]["image"]
         if "url" in img:
             icon = img["url"]
         elif "link" in img:
             icon = img["link"]
             
     title = self.feed["feed"]["title"] if "title" in self.feed["feed"] else self.url
     if icon is None and title.endswith("- Twitter Search"):
         title = title[:-16]
         icon = g15icontools.get_icon_path("gnome15")
     if icon is None:
         icon = g15icontools.get_icon_path(["application-rss+xml","gnome-mime-application-rss+xml"], self._screen.height)
         
     if icon == None:
         self._icon_surface = None
         self._icon_embedded = None
     else:
         try :
             icon_surface = g15cairo.load_surface_from_file(icon)
             self._icon_surface = icon_surface
             self._icon_embedded = g15icontools.get_embedded_image_url(icon_surface)
         except Exception as e:
             logger.warning("Failed to get icon %s", str(icon), exc_info = e)
             self._icon_surface = None
             self._icon_embedded = None
     self.set_title(title)
     self._subtitle = self.feed["feed"]["subtitle"] if "subtitle" in self.feed["feed"] else ""
     self._menu.remove_all_children()
     i = 0
     for entry in self.feed.entries:
         self._menu.add_child(G15FeedsMenuItem("feeditem-%d" % i, entry, self._gconf_client, self._gconf_key))
         i += 1
Exemple #45
0
 def get_theme_properties(self):
     item_properties = g15theme.MenuItem.get_theme_properties(self)
     
     if self.away and isinstance(self.away, str):
         item_properties["item_name"] = "%s - %s" % (self.nickname, self.away)
     else:
         item_properties["item_name"] = self.nickname
     
     item_properties["item_alt"] = ""
     item_properties["item_type"] = ""
     
     if self.get_screen().device.bpp == 1:
         item_properties["item_talking_icon"] = MONO_RECORD_ICON if self.talking else ""
         item_properties["item_input_muted_icon"] = MONO_MIC_MUTED if self.input_muted else MONO_MIC_UNMUTED
         item_properties["item_output_muted_icon"] = MONO_SPKR_MUTED if self.output_muted else MONO_SPKR_UNMUTED
         item_properties["item_icon"] = MONO_ONLINE if not self.away else MONO_AWAY
     else:
         item_properties["item_input_muted_icon"] = g15icontools.get_icon_path(MUTED_ICONS if self.input_muted else UNMUTED_ICONS)
         item_properties["item_output_muted_icon"] = g15icontools.get_icon_path("audio-volume-muted" if self.output_muted else "audio-volume-high")
         item_properties["item_icon"] = g15icontools.get_icon_path("user-available" if not self.away else "user-away")
         item_properties["item_talking_icon"] = g15icontools.get_icon_path(RECORD_ICONS) if self.talking else ""
     
     return item_properties
Exemple #46
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" ]))
Exemple #47
0
 def _check_status(self):
     """
     indicator-messages replaces indicator-me from Oneiric, so we get the current status icon if available
     to show that on the panel too
     """
     self._status_icon = None
     for c in self._messages_menu.menu_map:
         menu_entry = self._messages_menu.menu_map[c]
         if menu_entry.toggle_type == dbusmenu.TOGGLE_TYPE_RADIO and menu_entry.toggle_state == 1:
             icon_name = menu_entry.get_icon_name()
             if icon_name is not None and \
                 icon_name in [ "user-available", "user-away", 
                                 "user-busy", "user-offline", 
                                 "user-invisible", "user-indeterminate" ]:
                 self._status_icon = g15cairo.load_surface_from_file(g15icontools.get_icon_path(icon_name))
Exemple #48
0
 def get_theme_properties(self):
     """
     Render a single menu item
     
     Keyword arguments:
     item -- item object
     selected -- selected item object
     canvas -- canvas to draw on
     properties -- properties to pass to theme
     attribtes -- attributes to pass to theme
     
     """       
     item_properties = g15theme.MenuItem.get_theme_properties(self)
     item_properties["item_name"] = self.alias
     item_properties["item_alt"] = self._get_status_text(self.presence)
     item_properties["item_type"] = ""
     item_properties["item_icon"] = g15icontools.get_icon_path(self._get_status_icon_name(self.presence))
     return item_properties
Exemple #49
0
 def _get_theme_properties(self):
     properties = {}
     icon = "audio-volume-muted"
     if not self._mute:
         if self._volume < 34:
             icon = "audio-volume-low"
         elif self._volume < 67:
             icon = "audio-volume-medium"
         else:
             icon = "audio-volume-high"
     else:
         properties [ "muted"] = True
     icon_path = g15icontools.get_icon_path(icon, self._screen.driver.get_size()[0])
     properties["state"] = icon
     properties["icon"] = icon_path
     properties["vol_pc"] = self._volume
     for i in range(0, int( self._volume / 10 ) + 1, 1):            
         properties["bar" + str(i)] = True
     return properties
 def paint_foreground(self, canvas, properties, attributes, args, x_offset, y_offset):  
     items = attributes["items"]
     selected = attributes["selected"]
     
     canvas.save()
     y = y_offset
     
     # How many complete items fit on the screen? Make sure the selected item is visible
     # TODO again, this needs turning into a re-usable component - see menu and rss
     item_height = self.entry_theme.bounds[3]
     max_items = int( ( self.screen.height - y )  / item_height)
     if selected != None:
         sel_index = items.index(selected)
         diff = sel_index + 1 - max_items
         if diff > 0:
             y -= diff  * item_height
     canvas.rectangle(x_offset, y_offset, self.screen.width - ( x_offset * 2 ), self.screen.height - y_offset)
     canvas.clip() 
     
     canvas.translate(x_offset, y)
     for item in items:
         item_properties = {}
         if selected == item:
             item_properties["item_selected"] = True
         item_properties["item_name"] = item.get_label() 
         item_properties["item_alt"] = item.get_right_side_text()
         item_properties["item_type"] = item.get_type()
         icon_name = item.get_icon_name()
         if icon_name != None:
             item_properties["item_icon"] = g15cairo.load_surface_from_file(g15icontools.get_icon_path(self.screen.applet.conf_client, icon_name))
         else:
             item_properties["item_icon"] = item.get_icon()
             
         if item.get_type() == "separator":
             self.separator_theme.draw(canvas, item_properties)
         else:
             self.entry_theme.draw(canvas, item_properties)
         canvas.translate(0, item_height)
         y += item_height
         if y + item_height > self.theme.screen.height:
             break
     canvas.restore() 
Exemple #51
0
 def get_theme_properties(self):
     locked = self.profile.is_active() and g15profile.is_locked(self._plugin.screen.device)
     
     if self.get_screen().device.bpp > 1:
         locked_icon = g15icontools.get_icon_path(["locked","gdu-encrypted-lock",
                                              "status_lock", "stock_lock" ]) 
     else:
         if self.parent.selected == self:
             locked_icon = os.path.join(os.path.dirname(__file__), 'bw-locked-inverted.gif')
         else:
             locked_icon = os.path.join(os.path.dirname(__file__), 'bw-locked.gif')
     
     item_properties = g15theme.MenuItem.get_theme_properties(self)
     item_properties["item_name"] = self.profile.name
     item_properties["item_radio"] = True
     item_properties["item_radio_selected"] = self.profile.is_active()
     item_properties["item_icon"] = self._surface
     item_properties["item_alt_icon"] = locked_icon if locked else "" 
     item_properties["item_alt"] = ""
     return item_properties
Exemple #52
0
 def _get_item_for_bamf_application(self, window):
     view = self._get_bamf_application_object(window)
     item = self._get_menu_item(window)
     try:
         item.process_name = view.Name()
     except dbus.DBusException as e:
         logger.debug("Could not get process_name. Using default", exc_info = e)
         item.process_name = "Unknown"
     try:
         icon_name = view.Icon()
         if icon_name and len(icon_name) > 0:
             icon_path = g15icontools.get_icon_path(icon_name, warning = False)
             if icon_path:
                 item.icon = g15cairo.load_surface_from_file(icon_path, 32)
     except dbus.DBusException as e:
         logger.debug("Could not get icon", exc_info = e)
         pass
             
         
     return item
Exemple #53
0
 def _get_properties(self):
     properties = {}        
     properties["title"] = self._current_message.summary
     properties["message"] = self._current_message.body
     if self._current_message.icon != None and len(self._current_message.icon) > 0:
         properties["icon"] = g15icontools.get_icon_path(self._current_message.icon)
     elif self._current_message.embedded_image != None:
         properties["icon"] = self._current_message.embedded_image
                 
     if str(len(self._message_queue) > 1):
         properties["next"] = "True"
          
     action = 1
     for a in self._current_message.actions:
         properties["action%d" % action] = a[1] 
         action += 1
     if len(self._current_message.actions) > 0:        
         properties["action"] = "True" 
         
     properties["remaining"] = str(self._get_remaining()) 
     
     return properties
Exemple #54
0
    def _get_theme_properties(self):
        
        active_profile = g15profile.get_active_profile(self._screen.device)

        properties = {}
        properties["icon"] = g15icontools.get_icon_path(self.icon, self._screen.height)
        properties["memory"] = "M%d" % self._screen.get_memory_bank()
            
        if active_profile != None:
            properties["profile"] = active_profile.name
            properties["profile_icon"] = active_profile.get_profile_icon_path(self._screen.height)
            
            if self._message == None:
                properties["message"] = _("Recording on M%s. Type in your macro then press the G-Key to assign it to, or MR to cancel." % self._screen.get_memory_bank())
            else:
                properties["message"] = self._message
        else:
            properties["profile"] = _("No Profile")
            properties["profile_icon"] = ""
            properties["message"] = _("You have no profiles configured. Configure one now using the Macro tool")
            
        return properties
Exemple #55
0
    def set_details(self, icon, summary, body, timeout, actions, hints):
        self.icon = icon
        self.summary = "None" if summary == None else summary
        if body != None and len(body) > 0:
            self.body = lxml.html.fromstring(body).text_content()
        else:
            self.body = body
        self.timeout = timeout
#            if timeout <= 0.0:
#                timeout = 10.0
        self.timeout = 10.0
        self.actions = []
        i = 0
        if actions != None:
            for j in range(0, len(actions), 2):
                self.actions.append((actions[j], actions[j + 1]))
        self.hints = hints
        self.embedded_image = None
        
        if self.icon == None or self.icon == "":
            if "image_data" in self.hints:
                image_struct = self.hints["image_data"]
                img_width = image_struct[0]
                img_height = image_struct[1]
                img_stride = image_struct[2]
                has_alpha = image_struct[3]
                bits_per_sample = image_struct[4]
                channels = image_struct[5]
                buf = ""
                for b in image_struct[6]:
                    buf += chr(b)
                pixbuf = gtk.gdk.pixbuf_new_from_data(buf, gtk.gdk.COLORSPACE_RGB, has_alpha, bits_per_sample, img_width, img_height, img_stride)
                fh, self.embedded_image = tempfile.mkstemp(suffix=".png",prefix="notify-lcd")
                file = os.fdopen(fh)
                file.close()
                pixbuf.save(self.embedded_image, "png")
            else:
                self.icon = g15icontools.get_icon_path("dialog-info", 1024)