コード例 #1
0
ファイル: __init__.py プロジェクト: adcomp/adeskbar-0.5
    def create_session_button(self):
        if self.plugin.weather == {}:
          return
        if self.plugin.weather == None:
          return

        table = gtk.Table()
        self.box.pack_start(table, False, False)

        label = gtk.Label()
        label.set_alignment(0.98, 0)
        label.set_markup("<b><big><big><span color='#222'>"+self.plugin.weather['current_condition']+"</span></big></big></b>\n\n")
        label.set_justify(gtk.JUSTIFY_RIGHT)
        table.attach(label, 0, 1, 1, 2)

        label = gtk.Label()
        label.set_alignment(0.05, 0.90)
        label.set_markup("<b><big><big><big><big><big><span color='#222'>"+self.plugin.weather['current_temp']+'°'+self.plugin.weather['units_temperature']+'</span></big></big></big></big></big></b>')
        table.attach(label, 0, 1, 1, 2)

        label = gtk.Label()
        label.set_alignment(0.98, 0.90)
        label.set_markup("<span color='#222'>"\
                        +_('Wind : ')+self.plugin.weather['wind_direction']+"\n"\
                        +_('Speed : ')+self.plugin.weather['wind_speed']+' '+self.plugin.weather['units_speed']+"\n"\
                        +_('Humidity : ')+self.plugin.weather['atmosphere_humidity']+'%\n'\
                        +_('Barometer : ')+self.plugin.weather['atmosphere_pressure']+' '+self.plugin.weather['units_pressure']+"\n"\
                        +_('Visibility : ')+self.plugin.weather['atmosphere_visibility']+' '+self.plugin.weather['units_distance']+"\n"\
                        +"\n"\
                        +_('Sunrise : ')+self.plugin.weather['astronomy_sunrise']+"\n"\
                        +_('Sunset : ')+self.plugin.weather['astronomy_sunset']+"\n"\
                        +"</span>")
        label.set_justify(gtk.JUSTIFY_RIGHT)
        table.attach(label, 0, 1, 1, 2)


        image =  gtk.Image()
        pixbuf = Core.pixbuf_from_file('images/plugins/weatheryahoo/big/'+self.plugin.weather['current_code']+self.plugin.isday+'.png', -1, -1) # 250x180
        image.set_from_pixbuf(pixbuf)
        table.attach(image, 0, 1, 1, 2)

        # Tomorrow
        if int(self.plugin.settings['showtomorrow']) == 1:
          label = gtk.Label()
          label.set_alignment(0.98, 0)
          label.set_markup("\n<b><big><big><span color='#222'>"+self.plugin.weather['forecasts'][1]['condition']+"</span></big></big></b>\n\n" \
                        +"\n\n<span color='#222'><b><big>"+_('Day : ')+"<big><big><big>"+self.plugin.weather['forecasts'][1]['high']+'°'+self.plugin.weather['units_temperature']+"</big></big></big></big></b>\n"\
                        +"\n<b><big>"+_('Night : ')+"<big><big><big>"+self.plugin.weather['forecasts'][1]['low']+'°'+self.plugin.weather['units_temperature']+"</big></big></big></big></b></span>")
          label.set_justify(gtk.JUSTIFY_RIGHT)
          table.attach(label, 0, 1, 2, 3)

          image =  gtk.Image()
          pixbuf = Core.pixbuf_from_file('images/plugins/weatheryahoo/big/'+self.plugin.weather['forecasts'][1]['code']+'d.png', -1, -1) # 250x180
          image.set_from_pixbuf(pixbuf)
          table.attach(image, 0, 1, 2, 3)

        self.box.show_all()
コード例 #2
0
ファイル: __init__.py プロジェクト: neokeld/adeskbar-0.5
    def workspace_add(self, screen, space):
        ws_event = gtk.EventBox()
        ws_event.set_visible_window(False)
        ws_event.connect("button-press-event", self.go_to_workspace, space)
        ws_event.connect("enter-notify-event", self.workspace_hover)
        ws_event.connect("leave-notify-event", self.workspace_unhover)

        if self.bar.cfg["position"] == "top" or self.bar.cfg["position"] == "bottom":
            workspace = gtk.HBox(False, 0)
        else:
            workspace = gtk.VBox(False, 0)
        workspace.set_border_width(0)
        workspace.set_spacing(8)

        separator = None

        if len(self.workspaces) > 0 and int(self.settings["show_all_win"]):
            separator = gtk.Image()
            if self.bar.cfg["position"] == "top" or self.bar.cfg["position"] == "bottom":
                img_path = "images/plugins/tasklist/separator_h.png"
            else:
                img_path = "images/plugins/tasklist/separator_v.png"
            pbuf = Core.pixbuf_from_file(img_path)
            separator.set_from_pixbuf(pbuf)
            self.container.pack_start(separator, False, False)
            separator.show()

        ws_event.add(workspace)
        self.workspaces[space] = [workspace, separator, ws_event]

        self.container.pack_start(ws_event, True, True)
        ws_event.show()
        workspace.show()
コード例 #3
0
    def new_entry(self, position=-1, insertAfter=True):
        self.grab_focus()
        model = self.get_model()
        try:
            position = self.get_cursor()[0][0]
            try:
                iter = model.get_iter(position)
            except ValueError:
                print("> Empty list ?")
                iter = model.get_iter()

            if (insertAfter == True):
                item = model.insert_after(iter)
            else:
                item = model.insert_before(iter)
        except TypeError:
            print "typeError _ treeview"
            item = model.append(None)
            self.grab_focus()

        icon_path = ''
        icon = ''
        model.set_value(item, ID_NAME, '')
        model.set_value(item, ID_CMD, '')
        model.set_value(item, ID_IMG, icon_path)
        model.set_value(item, ID_ICON, Core.pixbuf_from_file(icon,32,32))
        ## Set focus to new entry and edit
        path = model.get_path(model.get_iter(position+1))
        self.set_cursor(path)
コード例 #4
0
    def workspace_add(self, screen, space):
        ws_event =  gtk.EventBox()
        ws_event.set_visible_window(False)
        ws_event.connect("button-press-event", self.go_to_workspace, space)
        ws_event.connect('enter-notify-event', self.workspace_hover)
        ws_event.connect('leave-notify-event', self.workspace_unhover)

        if self.bar.cfg['position'] == 'top' or self.bar.cfg['position'] == 'bottom':
            workspace = gtk.HBox(False, 0)
        else:
            workspace = gtk.VBox(False, 0)
        workspace.set_border_width(0)
        workspace.set_spacing(8)

        separator = None

        if len(self.workspaces) > 0 and int(self.settings['show_all_win']):
            separator = gtk.Image()
            if self.bar.cfg['position'] == 'top' or self.bar.cfg['position'] == 'bottom':
                img_path = 'images/plugins/tasklist/separator_h.png'
            else:
                img_path = 'images/plugins/tasklist/separator_v.png'
            pbuf = Core.pixbuf_from_file(img_path)
            separator.set_from_pixbuf(pbuf)
            self.container.pack_start(separator, False, False)
            separator.show()

        ws_event.add(workspace)
        self.workspaces[space] = [workspace, separator, ws_event]

        self.container.pack_start(ws_event, True, True)
        ws_event.show()
        workspace.show()
コード例 #5
0
    def __init__(self, plugin, bar):
        UI.PopupWindow.__init__(self, bar, plugin)

        box = gtk.HBox(False, 4)
        box.set_border_width(2)
        self.add(box)

        self.entry = gtk.Entry()
        self.entry.x_done = False
        self.entry.set_name("TextBox")
        self.entry.set_width_chars(25)
        self.entry.connect("button-press-event", self.manage_click)
        self.entry.connect("activate", self.go)
        box.pack_start(self.entry, True)

        btn = gtk.Button()
        btn.set_name("EdgeButton")
        btn.connect("clicked", self.go)
        # ~ btn.set_label("Search")
        btn.set_relief(gtk.RELIEF_NONE)
        btn.set_border_width(0)
        btn.set_focus_on_click(False)
        btn.set_property("can-focus", False)

        image = gtk.Image()
        pixbuf = Core.pixbuf_from_file("images/plugins/searchbox.png", 24, 24)
        image.set_from_pixbuf(pixbuf)
        btn.add(image)

        box.pack_end(btn, False)
        box.show_all()
コード例 #6
0
ファイル: config.py プロジェクト: hackur/adeskbar-0.5
    def new_entry(self, position=-1, insertAfter=True):
        self.grab_focus()
        model = self.get_model()
        try:
            position = self.get_cursor()[0][0]
            try:
                iter = model.get_iter(position)
            except ValueError:
                print("> Empty list ?")
                iter = model.get_iter()

            if (insertAfter == True):
                item = model.insert_after(iter)
            else:
                item = model.insert_before(iter)
        except TypeError:
            print "typeError _ treeview"
            item = model.append(None)
            self.grab_focus()

        icon_path = ''
        icon = ''
        model.set_value(item, ID_NAME, '')
        model.set_value(item, ID_CMD, '')
        model.set_value(item, ID_IMG, icon_path)
        model.set_value(item, ID_ICON, Core.pixbuf_from_file(icon, 32, 32))
        ## Set focus to new entry and edit
        path = model.get_path(model.get_iter(position + 1))
        self.set_cursor(path)
コード例 #7
0
ファイル: __init__.py プロジェクト: adcomp/adeskbar-0.5
 def create_session_button(self):
     for action in ('lockscreen', 'logout', 'reboot', 'shutdown', 'hibernate', 'suspend'):
         if not self.plugin.settings[action] == '':
             
             if self.plugin.settings['show_label']:
                 label = '<b>%s</b>\n<small>%s</small>' % (session[action][0], session[action][1])
                 pixbuf = Core.get_pixbuf_icon(session[action][2], self.plugin.settings['icon_size'])
                 if pixbuf == None:
                    pixbuf = Core.pixbuf_from_file('images/plugins/session/'+session[action][2]+'.png', self.plugin.settings['icon_size'], self.plugin.settings['icon_size'])
                 button = Core.image_button(label, pixbuf, self.plugin.settings['icon_size'])
             else:
                 button = gtk.Button()
                 button.set_relief(gtk.RELIEF_NONE)
                 img = gtk.Image()
                 pixbuf = Core.get_pixbuf_icon(session[action][2], self.plugin.settings['icon_size'])
                 if pixbuf == None:
                    pixbuf = Core.pixbuf_from_file('images/plugins/session/'+session[action][2]+'.png', self.plugin.settings['icon_size'], self.plugin.settings['icon_size'])
                 img.set_from_pixbuf(pixbuf)
                 button.add(img)
             button.connect("button-release-event", self.onClicked, self.plugin.settings[action])
             self.box.pack_start(button, False)
             self.buttons.append(button)
             
     self.box.show_all()
コード例 #8
0
    def create_session_button(self):
        for action in ('lockscreen', 'logout', 'reboot', 'shutdown',
                       'hibernate', 'suspend'):
            if not self.plugin.settings[action] == '':

                if self.plugin.settings['show_label']:
                    label = '<b>%s</b>\n<small>%s</small>' % (
                        session[action][0], session[action][1])
                    pixbuf = Core.get_pixbuf_icon(
                        session[action][2], self.plugin.settings['icon_size'])
                    if pixbuf == None:
                        pixbuf = Core.pixbuf_from_file(
                            'images/plugins/session/' + session[action][2] +
                            '.png', self.plugin.settings['icon_size'],
                            self.plugin.settings['icon_size'])
                    button = Core.image_button(
                        label, pixbuf, self.plugin.settings['icon_size'])
                else:
                    button = gtk.Button()
                    button.set_relief(gtk.RELIEF_NONE)
                    img = gtk.Image()
                    pixbuf = Core.get_pixbuf_icon(
                        session[action][2], self.plugin.settings['icon_size'])
                    if pixbuf == None:
                        pixbuf = Core.pixbuf_from_file(
                            'images/plugins/session/' + session[action][2] +
                            '.png', self.plugin.settings['icon_size'],
                            self.plugin.settings['icon_size'])
                    img.set_from_pixbuf(pixbuf)
                    button.add(img)
                button.connect("button-release-event", self.onClicked,
                               self.plugin.settings[action])
                self.box.pack_start(button, False)
                self.buttons.append(button)

        self.box.show_all()
コード例 #9
0
ファイル: __init__.py プロジェクト: neokeld/adeskbar-0.5
    def __init__(self, plugin):
        gtk.EventBox.__init__(self)
        self.set_border_width(0)
        self.set_visible_window(False)
        self.is_active = False

        self.plg = plugin
        self.cfg = plugin.bar.cfg

        ## FIXME! quick hack for tooltip
        self.tooltip = ""
        self.is_visible = False

        self.pixbuf_origin = None
        self.pixbuf = None
        self.pixbuf_over = Core.pixbuf_from_file("./images/plugins/tasklist/button.png")
コード例 #10
0
    def __init__(self, plugin):
        gtk.EventBox.__init__(self)
        self.set_border_width(0)
        self.set_visible_window(False)
        self.is_active = False
        
        self.plg = plugin
        self.cfg = plugin.bar.cfg

        ## FIXME! quick hack for tooltip
        self.tooltip = ''
        self.is_visible = False
        
        self.pixbuf_origin = None
        self.pixbuf = None
        self.pixbuf_over = Core.pixbuf_from_file('./images/plugins/tasklist/button.png')
コード例 #11
0
ファイル: plugin.py プロジェクト: adcomp/adeskbar-0.5
    def set_icon(self, path_icon=None, is_separator=False):
        #~ print 'set_icon :', path_icon
        if path_icon == '':
            path_icon = 'images/def_icon.png'

        if not path_icon:
            path_icon = self.current_icon

        w = h = self.cfg['icon_size']
        self.pixbuf = None

        if is_separator:
            if self.cfg['position'] == 'bottom' or self.cfg['position'] == 'top':
                w = w // 4
            else:
                h = h // 4

        if not path_icon:
            self.pixbuf = Core.pixbuf_from_file('images/def_icon.png', w, h)
            self.pixbuf_zoom = Core.pixbuf_from_file('images/def_icon.png', self.bar.zoom_size, self.bar.zoom_size)
            self.current_icon = 'images/def_icon.png'
            
        ## real path .. load from file
        elif path_icon[0] == '/' or ( len(path_icon) > 7 and path_icon[:7] == 'images/'):
            self.pixbuf = Core.pixbuf_from_file(path_icon, w, h)
            self.pixbuf_zoom = Core.pixbuf_from_file(path_icon, self.bar.zoom_size, self.bar.zoom_size)
            self.current_icon = path_icon
            
        ## load from icon theme
        elif ICON_THEME.has_icon(path_icon):
            
            ## FIX : gio.Error: Error opening file: No such file or directory
            try:
                self.pixbuf = ICON_THEME.load_icon(path_icon, self.cfg['icon_size'], gtk.ICON_LOOKUP_USE_BUILTIN)
                self.pixbuf = self.pixbuf.scale_simple(self.cfg['icon_size'], self.cfg['icon_size'], gtk.gdk.INTERP_BILINEAR)
                #~ self.pixbuf_zoom = ICON_THEME.load_icon(path_icon, int(self.bar.zoom_size), gtk.ICON_LOOKUP_USE_BUILTIN)
                self.pixbuf_zoom = self.pixbuf.scale_simple(int(self.bar.zoom_size), int(self.bar.zoom_size), gtk.gdk.INTERP_BILINEAR)
                self.current_icon = path_icon
            except:
                pass

        ## check if pixbuf is ok
        if not self.pixbuf:
            self.pixbuf = Core.pixbuf_from_file('images/def_icon.png', w, h)
            self.pixbuf_zoom = Core.pixbuf_from_file('images/def_icon.png', self.bar.zoom_size, self.bar.zoom_size)
            self.current_icon = 'images/def_icon.png'

        if self.bar.init_flag:
            self.bar.update()
コード例 #12
0
    def __init__(self, conf, ind):
        gtk.Frame.__init__(self)
        self.conf = conf
        self.ind = ind

        self.set_border_width(5)
        framebox = gtk.VBox(False, 0)
        framebox.set_border_width(5)
        framebox.set_spacing(10)
        self.add(framebox)

        for key in settings:
            if not key in conf.launcher[ind]:
                conf.launcher[ind][key] = settings[key]

        self.settings = conf.launcher[ind]

        mixerbox = gtk.HBox(False, 0)
        framebox.pack_start(mixerbox)

        label = gtk.Label("Mixer :")
        label.set_alignment(0, 0.5)

        self.mixer = gtk.combo_box_entry_new_text()

        mixer_list = (
            "aumix",
            "xfce4-mixer",
            "xterm -e alsamixer",
            "alsamixergui",
            "gamix",
            "gmixer",
            "gnome-alsamixer",
            "gnome-volume-control",
            "pavucontrol",
        )

        if not conf.launcher[ind]["mixer"] in mixer_list:
            mixer_list = (conf.launcher[ind]["mixer"],) + mixer_list

        ind_mixer = 0  # FIXME !!
        for mixer in mixer_list:
            self.mixer.append_text(mixer)
            if mixer == conf.launcher[ind]["mixer"]:
                self.mixer.set_active(ind_mixer)
            ind_mixer += 1

        self.mixer.child.connect("changed", self.changed_mixer)

        mixerbox.pack_start(label)
        mixerbox.pack_start(self.mixer)

        self.alsactrl = AlsaControl(int(self.settings["card_index"]), self.settings["control"])

        """ Initialize treeview with mixers """
        self.liststore = gtk.ListStore(bool, str, int)
        for mixer in self.alsactrl.get_mixers():
            active = mixer == self.settings["control"]
            if active:
                self.liststore.append([active, mixer, pango.WEIGHT_BOLD])
            else:
                self.liststore.append([active, mixer, pango.WEIGHT_NORMAL])

        self.treeview = gtk.TreeView(self.liststore)
        self.treeview.set_headers_visible(False)

        cell1 = gtk.CellRendererToggle()
        cell1.set_radio(True)
        cell1.set_property("activatable", True)
        cell1.connect("toggled", self.on_treeview_toggled, self.liststore)
        column1 = gtk.TreeViewColumn()
        column1.pack_start(cell1, True)
        column1.add_attribute(cell1, "active", 0)
        self.treeview.append_column(column1)

        cell2 = gtk.CellRendererText()
        column2 = gtk.TreeViewColumn()
        column2.pack_start(cell2, True)
        column2.add_attribute(cell2, "text", 1)
        column2.add_attribute(cell2, "weight", 2)
        self.treeview.append_column(column2)

        scrolledwindow = gtk.ScrolledWindow()
        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrolledwindow.add(self.treeview)

        """ Initialize combobox with list of audio cards """
        icon = Core.pixbuf_from_file("images/conf/audio-card.png", 22, 22)

        self.combo_model = gtk.ListStore(int, gtk.gdk.Pixbuf, str)
        cards = self.alsactrl.get_cards()
        for index, card in enumerate(cards):
            if card is not None:
                self.combo_model.append([index, icon, card])

        card_combobox = gtk.ComboBox()
        card_combobox.set_model(self.combo_model)
        card_combobox.set_active(int(self.settings["card_index"]))

        cell1 = gtk.CellRendererPixbuf()
        cell1.set_property("xalign", 0)
        cell1.set_property("xpad", 3)
        card_combobox.pack_start(cell1, False)
        card_combobox.add_attribute(cell1, "pixbuf", 1)

        cell2 = gtk.CellRendererText()
        cell2.set_property("xpad", 10)
        card_combobox.pack_start(cell2, True)
        card_combobox.set_attributes(cell2, text=2)

        card_combobox.connect("changed", self.on_card_combobox_changed)

        framebox.pack_start(card_combobox)
        framebox.pack_end(scrolledwindow, True)
コード例 #13
0
ファイル: plugin.py プロジェクト: hackur/adeskbar-0.5
    def set_icon(self, path_icon=None, is_separator=False):
        #~ print 'set_icon :', path_icon
        if path_icon == '':
            path_icon = 'images/def_icon.png'

        if not path_icon:
            path_icon = self.current_icon

        w = h = self.cfg['icon_size']
        self.pixbuf = None

        if is_separator:
            if self.cfg['position'] == 'bottom' or self.cfg[
                    'position'] == 'top':
                w = w // 4
            else:
                h = h // 4

        if not path_icon:
            self.pixbuf = Core.pixbuf_from_file('images/def_icon.png', w, h)
            self.pixbuf_zoom = Core.pixbuf_from_file('images/def_icon.png',
                                                     self.bar.zoom_size,
                                                     self.bar.zoom_size)
            self.current_icon = 'images/def_icon.png'

        ## real path .. load from file
        elif path_icon[0] == '/' or (len(path_icon) > 7
                                     and path_icon[:7] == 'images/'):
            self.pixbuf = Core.pixbuf_from_file(path_icon, w, h)
            self.pixbuf_zoom = Core.pixbuf_from_file(path_icon,
                                                     self.bar.zoom_size,
                                                     self.bar.zoom_size)
            self.current_icon = path_icon

        ## load from icon theme
        elif ICON_THEME.has_icon(path_icon):

            ## FIX : gio.Error: Error opening file: No such file or directory
            try:
                self.pixbuf = ICON_THEME.load_icon(path_icon,
                                                   self.cfg['icon_size'],
                                                   gtk.ICON_LOOKUP_USE_BUILTIN)
                self.pixbuf = self.pixbuf.scale_simple(self.cfg['icon_size'],
                                                       self.cfg['icon_size'],
                                                       gtk.gdk.INTERP_BILINEAR)
                #~ self.pixbuf_zoom = ICON_THEME.load_icon(path_icon, int(self.bar.zoom_size), gtk.ICON_LOOKUP_USE_BUILTIN)
                self.pixbuf_zoom = self.pixbuf.scale_simple(
                    int(self.bar.zoom_size), int(self.bar.zoom_size),
                    gtk.gdk.INTERP_BILINEAR)
                self.current_icon = path_icon
            except:
                pass

        ## check if pixbuf is ok
        if not self.pixbuf:
            self.pixbuf = Core.pixbuf_from_file('images/def_icon.png', w, h)
            self.pixbuf_zoom = Core.pixbuf_from_file('images/def_icon.png',
                                                     self.bar.zoom_size,
                                                     self.bar.zoom_size)
            self.current_icon = 'images/def_icon.png'

        if self.bar.init_flag:
            self.bar.update()
コード例 #14
0
    def __init__(self, box, conf, ind):

        self.conf = conf
        self.ind = ind

        for key in settings:
            if not key in conf.launcher[ind]:
                conf.launcher[ind][key] = settings[key]

        self.settings = conf.launcher[ind]

        mixerbox = gtk.HBox(False, 0)
        box.pack_start(mixerbox, False, False)

        label = gtk.Label("Mixer :")
        label.set_alignment(0, 0.5)

        self.mixer = gtk.combo_box_entry_new_text()

        mixer_list = ("aumix", "xfce4-mixer", "xterm -e alsamixer",
                      "alsamixergui", "gamix", "gmixer", "gnome-alsamixer",
                      "gnome-volume-control", "pavucontrol")

        if not conf.launcher[ind]['mixer'] in mixer_list:
            mixer_list = (conf.launcher[ind]['mixer'], ) + mixer_list

        ind_mixer = 0  # FIXME !!
        for mixer in mixer_list:
            self.mixer.append_text(mixer)
            if mixer == conf.launcher[ind]['mixer']:
                self.mixer.set_active(ind_mixer)
            ind_mixer += 1

        self.mixer.child.connect('changed', self.changed_mixer)

        mixerbox.pack_start(label)
        mixerbox.pack_start(self.mixer)

        self.alsactrl = AlsaControl(int(self.settings["card_index"]),
                                    self.settings["control"])
        """ Initialize treeview with mixers """
        self.liststore = gtk.ListStore(bool, str, int)
        for mixer in self.alsactrl.get_mixers():
            active = (mixer == self.settings["control"])
            if active:
                self.liststore.append([active, mixer, pango.WEIGHT_BOLD])
            else:
                self.liststore.append([active, mixer, pango.WEIGHT_NORMAL])

        self.treeview = gtk.TreeView(self.liststore)
        self.treeview.set_headers_visible(False)

        cell1 = gtk.CellRendererToggle()
        cell1.set_radio(True)
        cell1.set_property("activatable", True)
        cell1.connect('toggled', self.on_treeview_toggled, self.liststore)
        column1 = gtk.TreeViewColumn()
        column1.pack_start(cell1, True)
        column1.add_attribute(cell1, 'active', 0)
        self.treeview.append_column(column1)

        cell2 = gtk.CellRendererText()
        column2 = gtk.TreeViewColumn()
        column2.pack_start(cell2, True)
        column2.add_attribute(cell2, 'text', 1)
        column2.add_attribute(cell2, 'weight', 2)
        self.treeview.append_column(column2)

        scrolledwindow = gtk.ScrolledWindow()
        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrolledwindow.add(self.treeview)
        """ Initialize combobox with list of audio cards """
        icon = Core.pixbuf_from_file('images/conf/audio-card.png', 22, 22)

        self.combo_model = gtk.ListStore(int, gtk.gdk.Pixbuf, str)
        cards = self.alsactrl.get_cards()
        for index, card in enumerate(cards):
            if card is not None:
                self.combo_model.append([index, icon, card])

        card_combobox = gtk.ComboBox()
        card_combobox.set_model(self.combo_model)
        card_combobox.set_active(int(self.settings["card_index"]))

        cell1 = gtk.CellRendererPixbuf()
        cell1.set_property("xalign", 0)
        cell1.set_property("xpad", 3)
        card_combobox.pack_start(cell1, False)
        card_combobox.add_attribute(cell1, "pixbuf", 1)

        cell2 = gtk.CellRendererText()
        cell2.set_property("xpad", 10)
        card_combobox.pack_start(cell2, True)
        card_combobox.set_attributes(cell2, text=2)

        card_combobox.connect("changed", self.on_card_combobox_changed)

        box.pack_start(card_combobox, False, False)
        box.pack_end(scrolledwindow, True)
コード例 #15
0
    def create_session_button(self):
        if self.plugin.weather == {}:
            return
        if self.plugin.weather == None:
            return

        table = gtk.Table()
        self.box.pack_start(table, False, False)

        label = gtk.Label()
        label.set_alignment(0.98, 0)
        label.set_markup("<b><big><big><span color='#222'>" +
                         self.plugin.weather['current_condition'] +
                         "</span></big></big></b>\n\n")
        label.set_justify(gtk.JUSTIFY_RIGHT)
        table.attach(label, 0, 1, 1, 2)

        label = gtk.Label()
        label.set_alignment(0.05, 0.90)
        label.set_markup("<b><big><big><big><big><big><span color='#222'>" +
                         self.plugin.weather['current_temp'] + '°' +
                         self.plugin.weather['units_temperature'] +
                         '</span></big></big></big></big></big></b>')
        table.attach(label, 0, 1, 1, 2)

        label = gtk.Label()
        label.set_alignment(0.98, 0.90)
        label.set_markup("<span color='#222'>"\
                        +_('Wind : ')+self.plugin.weather['wind_direction']+"\n"\
                        +_('Speed : ')+self.plugin.weather['wind_speed']+' '+self.plugin.weather['units_speed']+"\n"\
                        +_('Humidity : ')+self.plugin.weather['atmosphere_humidity']+'%\n'\
                        +_('Barometer : ')+self.plugin.weather['atmosphere_pressure']+' '+self.plugin.weather['units_pressure']+"\n"\
                        +_('Visibility : ')+self.plugin.weather['atmosphere_visibility']+' '+self.plugin.weather['units_distance']+"\n"\
                        +"\n"\
                        +_('Sunrise : ')+self.plugin.weather['astronomy_sunrise']+"\n"\
                        +_('Sunset : ')+self.plugin.weather['astronomy_sunset']+"\n"\
                        +"</span>")
        label.set_justify(gtk.JUSTIFY_RIGHT)
        table.attach(label, 0, 1, 1, 2)

        image = gtk.Image()
        pixbuf = Core.pixbuf_from_file('images/plugins/weatheryahoo/big/' +
                                       self.plugin.weather['current_code'] +
                                       self.plugin.isday + '.png', -1,
                                       -1)  # 250x180
        image.set_from_pixbuf(pixbuf)
        table.attach(image, 0, 1, 1, 2)

        # Tomorrow
        if int(self.plugin.settings['showtomorrow']) == 1:
            label = gtk.Label()
            label.set_alignment(0.98, 0)
            label.set_markup("\n<b><big><big><span color='#222'>"+self.plugin.weather['forecasts'][1]['condition']+"</span></big></big></b>\n\n" \
                          +"\n\n<span color='#222'><b><big>"+_('Day : ')+"<big><big><big>"+self.plugin.weather['forecasts'][1]['high']+'°'+self.plugin.weather['units_temperature']+"</big></big></big></big></b>\n"\
                          +"\n<b><big>"+_('Night : ')+"<big><big><big>"+self.plugin.weather['forecasts'][1]['low']+'°'+self.plugin.weather['units_temperature']+"</big></big></big></big></b></span>")
            label.set_justify(gtk.JUSTIFY_RIGHT)
            table.attach(label, 0, 1, 2, 3)

            image = gtk.Image()
            pixbuf = Core.pixbuf_from_file(
                'images/plugins/weatheryahoo/big/' +
                self.plugin.weather['forecasts'][1]['code'] + 'd.png', -1,
                -1)  # 250x180
            image.set_from_pixbuf(pixbuf)
            table.attach(image, 0, 1, 2, 3)

        self.box.show_all()