示例#1
0
    def save(self):
        """ save config to file"""
        Core.logINFO("save ..", 'config')

        str_cfg = '## ADeskBar config\n\n'
        str_cfg += '[CONFIG]\n'

        for key in self.config:
            if '_rgb' in key:
                continue
            val = self.config[key]
            str_cfg += '    ' + key + ' = ' + str(val) + '\n'

        str_cfg += '\n'

        for ind in self.l_ind:

            str_cfg += '[LAUNCHER/%s]\n' % ind
            #~ if 'launcher' in self.launcher[ind]:
            #~ self.launcher[ind].pop('launcher')
            for key in self.launcher[ind]:
                str_cfg += '    %s = %s\n' % (key, self.launcher[ind][key])
            str_cfg += '\n'

        str_cfg += '\n'

        for ind in self.drawer:
            if not ind in self.launcher:
                continue
            str_cfg += '[DRAWER/%s]\n' % ind
            for drawer in self.drawer[ind]:
                str_cfg += "    %s ## %s ## %s\n" % (drawer[0], drawer[1],
                                                     drawer[2])
            str_cfg += '\n'

        str_cfg += '\n'

        home = os.environ['HOME']
        if not os.path.exists("%s/.config/adeskbar" % home):
            os.makedirs("%s/.config/adeskbar" % home)

        if self.cfg_file == None or self.cfg_file == 'None':
            self.cfg_file = 'default'

        src = "%s/.config/adeskbar/%s.cfg" % (home, self.cfg_file)
        Core.logINFO("  -- %s" % src)

        configfile = open(src, 'w')
        configfile.write(str_cfg)
        configfile.close()
示例#2
0
    def save(self):
        """ save config to file"""
        Core.logINFO("save ..", 'config')
        
        str_cfg = '## ADeskBar config\n\n'
        str_cfg += '[CONFIG]\n'

        for key in self.config:
            if '_rgb' in key:
                continue
            val = self.config[key]
            str_cfg += '    ' + key + ' = ' + str(val) + '\n'

        str_cfg += '\n'

        for ind in self.l_ind:

            str_cfg += '[LAUNCHER/%s]\n' % ind
            #~ if 'launcher' in self.launcher[ind]:
                #~ self.launcher[ind].pop('launcher')
            for key in self.launcher[ind]:
                str_cfg += '    %s = %s\n' % (key, self.launcher[ind][key])
            str_cfg += '\n'

        str_cfg += '\n'

        for ind in self.drawer:
            if not ind in self.launcher:
                continue
            str_cfg += '[DRAWER/%s]\n' % ind
            for drawer in self.drawer[ind]:
                str_cfg += "    %s ## %s ## %s\n" % (drawer[0], drawer[1], drawer[2])
            str_cfg += '\n'

        str_cfg += '\n'

        home = os.environ['HOME']
        if not os.path.exists("%s/.config/adeskbar" % home):
            os.makedirs("%s/.config/adeskbar" % home)

        if self.cfg_file == None or self.cfg_file == 'None':
            self.cfg_file = 'default'

        src = "%s/.config/adeskbar/%s.cfg" % (home, self.cfg_file)
        Core.logINFO("  -- %s" % src )

        configfile =  open(src, 'w')
        configfile.write(str_cfg)
        configfile.close()
 def run(self, cmd, with_term):
     assert type(cmd) == str
     if len(cmd) > 0 and cmd[0] == '!':
         try:
             cmd, argv = cmd[1:].split(' ', 1)
         except:
             cmd = cmd[1:]
             argv = None
         if cmd in self.cmds:
             self.cmds[cmd](argv)
         else:
             Core.logINFO('Command "{0}" not implemented.'.format(cmd))
     else:
         if with_term:
             cmd = 'x-terminal-emulator -e {0}'.format(cmd)
         Core.launch_command(cmd)
def save(cfg_file, config_data, ind_launcher, launchers, drawers):
    """ save config to file"""
    Core.logINFO("save ..", "config")

    str_cfg = "## ADeskBar config\n"

    str_cfg += "[CONFIG]\n"
    for item in config_data:
        val = config_data[item]
        str_cfg += str(item) + "=" + str(val) + "\n"

    str_cfg += "\n"

    for ind in ind_launcher:
        str_cfg += "[LAUNCHER/%s]\n" % ind
        if "launcher" in launchers[ind]:
            launchers[ind].pop("launcher")
        for key in launchers[ind]:
            str_cfg += "%s=%s\n" % (key, launchers[ind][key])
        str_cfg += "\n"

    str_cfg += "\n"

    for ind in drawers:
        str_cfg += "[DRAWER/%s]\n" % ind
        for drawer in drawers[ind]:
            str_cfg += "%s##%s##%s\n" % (drawer[0], drawer[1], drawer[2])
        str_cfg += "\n"

    str_cfg += "\n"

    home = os.environ["HOME"]
    if not os.path.exists("%s/.config/adeskbar" % home):
        os.makedirs("%s/.config/adeskbar" % home)

    if cfg_file == None or cfg_file == "None":
        cfg_file = "default"

    src = "%s/.config/adeskbar/%s.cfg" % (home, cfg_file)

    configfile = open(src, "w")
    configfile.write(str_cfg)
    configfile.close()
示例#5
0
import adesk.ui as UI

import locale
import gettext

## Translation
locale.setlocale(locale.LC_ALL, "")
gettext.bindtextdomain("adeskbar", "./locale")
gettext.bind_textdomain_codeset("adeskbar", "UTF-8")
gettext.textdomain("adeskbar")
_ = gettext.gettext

try:
    import alsaaudio as alsa
except:
    Core.logINFO('Plugin "volume" need python-alsaaudio')
    Core.logINFO(' -- debian/ubuntu : "sudo apt-get install python-alsaaudio"')

INC = 5


class Plugin(Plg.Plugin):
    def __init__(self, bar, settings):
        Plg.Plugin.__init__(self, bar, settings)

        ## FIXME!! check if settings for card_index/control
        if not "card_index" in self.settings:
            self.settings["card_index"] = 0
        if not "control" in self.settings:
            self.settings["control"] = "Master"
示例#6
0
#
##

import os
import time
import gtk
import pango

import adesk.plugin as Plg
import adesk.core as Core
import adesk.draw

try:
    import wnck
except:
    Core.logINFO('Plugin "tasklist" need python-wnck')
    Core.logINFO(' -- debian/mint/ubuntu: "sudo apt-get install python-wnck"')
    Core.logINFO(' -- fedora: "sudo yum install gnome-python2-libwnck"')

def_settings = {
    "desktop_color": "#EEEEEE",
    "desktop_font": "Sans Bold 12",
    "show_desk_pos": 0,
    "show_desk_name": 0,
    "show_all_win": 1,
    "active_color": "#7F7F7F",
    "padding": 10,
    "opacity": 32767,
}

示例#7
0
    def read(self):
        Core.logINFO("read ..", 'config')

        home = os.environ['HOME']

        ## custom config
        if os.access("%s/.config/adeskbar/%s.cfg" % (home, self.cfg_file),
                     os.F_OK | os.R_OK):
            Core.logINFO(
                "config = %s/.config/adeskbar/%s.cfg" % (home, self.cfg_file),
                'config')
            conf_path = "%s/.config/adeskbar/%s.cfg" % (home, self.cfg_file)

        ## read default config
        elif os.access("default.cfg", os.F_OK | os.R_OK):
            Core.logINFO("config = default.cfg", 'config')
            conf_path = 'default.cfg'

        ## no config ? exit !
        else:
            Core.logINFO("ERROR : can't read config !!!", 'config')
            #~ Core.show_msg("Sorry, but can't read config !!!")
            #~ sys.exit()
            return

        f = open(conf_path, 'r')

        current_cat = None
        current_ind = None
        error_config = False

        for line in f:

            ## empty or comment ..
            if line == '\n' or line[0] == '#':
                continue

            try:
                line = line.strip('\n')
                line = line.strip()

                ## check if is a category
                if line[0] == '[':
                    current_cat = line[1:-1]

                    if '/' in current_cat:
                        tmp = current_cat.split('/')
                        current_cat = tmp[0]
                        current_ind = tmp[1]

                        if current_cat == 'LAUNCHER':
                            self.launcher[current_ind] = {}
                            self.l_ind.append(current_ind)

                    else:
                        current_ind = None

                    continue

                if current_cat == 'CONFIG':
                    tmp = line.split('=', 1)
                    key = tmp[0].strip()
                    self.config[key] = tmp[1].strip()

                elif current_cat == 'LAUNCHER':
                    tmp = line.split('=', 1)
                    key = tmp[0].strip()
                    self.launcher[current_ind][key] = tmp[1].strip()

                elif current_cat == 'DRAWER':
                    (cmd, icon, desc) = line.split('##')
                    if not current_ind in self.drawer:
                        self.drawer[current_ind] = []
                    self.drawer[current_ind].append(
                        (cmd.strip(), icon.strip(), desc.strip()))

            except Exception, e:
                print 'Error while parsing self.config file ..'
                traceback.print_exc()
                error_config = True
def read(cfg_file):
    Core.logINFO("read ..", "config")
    CONFIG = {}
    LAUNCHER = {}
    DRAWER = {}

    CONFIG["ind_launcher"] = []

    ## FIXME! default connfig
    CONFIG["fade_hidden"] = False
    CONFIG["icon_space"] = 10
    CONFIG["show_border"] = 1
    CONFIG["smooth_hide"] = 1
    CONFIG["background_color"] = "#333333"
    CONFIG["bg_color_sub"] = "#EEEEEE"
    CONFIG["border_color_sub"] = "#7F7F7F"
    CONFIG["bar_size"] = 100
    CONFIG["rounded_corner"] = 15
    CONFIG["icon_size"] = 36
    CONFIG["hidden_size"] = 5
    CONFIG["opacity"] = 70
    CONFIG["border_color"] = "#313335"
    CONFIG["padding"] = 4
    CONFIG["zoom_factor"] = 1.2
    CONFIG["keep_below"] = False
    CONFIG["offset_pos"] = 4
    CONFIG["align"] = "center"
    CONFIG["timer"] = 1
    CONFIG["bg_gradient"] = True
    CONFIG["auto_hide"] = 2
    CONFIG["auto_raise"] = 1
    CONFIG["offset_align"] = 0
    CONFIG["position"] = "bottom"
    CONFIG["tooltips"] = True
    CONFIG["fixed_size"] = 100
    CONFIG["fixed_mode"] = True
    CONFIG["reserve_space"] = False

    ## new in v0.3.9
    CONFIG["background_gradient_color"] = "#333333"
    ## new in v0.4
    CONFIG["bar_style"] = 0
    CONFIG["icons_effects"] = 3

    home = os.environ["HOME"]

    ## custom config
    if os.access("%s/.config/adeskbar/%s.cfg" % (home, cfg_file), os.F_OK | os.R_OK):
        Core.logINFO("config = %s/.config/adeskbar/%s.cfg" % (home, cfg_file), "config")
        conf_path = "%s/.config/adeskbar/%s.cfg" % (home, cfg_file)

    ## read default config
    elif os.access("default.cfg", os.F_OK | os.R_OK):
        Core.logINFO("config = default.cfg", "config")
        conf_path = "default.cfg"

    ## no config ? exit !
    else:
        Core.logINFO("ERROR : can't read config !!!", "config")
        # ~ Core.show_msg("Sorry, but can't read config !!!")
        sys.exit()
    del home

    f = open(conf_path, "r")

    current_cat = None
    current_sub = None
    error_config = False

    for line in f:
        if line == "\n" or line[0] == "#":
            continue
        try:
            line = line.strip("\n")

            ## check if is a category
            if line[0] == "[":
                current_cat = line[1:-1]
                if "/" in current_cat:
                    tmp = current_cat.split("/")
                    current_cat = tmp[0]
                    current_sub = tmp[1]
                    if current_cat == "LAUNCHER":
                        LAUNCHER[current_sub] = {}
                        CONFIG["ind_launcher"].append(current_sub)
                else:
                    current_sub = None
                continue

            if current_cat == "CONFIG":
                tmp = line.split("=", 1)
                key = tmp[0]
                CONFIG[key] = tmp[1]

            elif current_cat == "LAUNCHER":
                tmp = line.split("=", 1)
                key = tmp[0]
                LAUNCHER[current_sub][key] = tmp[1]

            elif current_cat == "DRAWER":
                (cmd, icon, desc) = line.split("##")
                if not current_sub in DRAWER:
                    DRAWER[current_sub] = []
                DRAWER[current_sub].append((cmd.strip(), icon.strip(), desc.strip()))

        except Exception, e:
            traceback.print_exc()
            error_config = True
示例#9
0
 def destroy(self):
     Core.logINFO("attempt to cleanly close, in such a way that the icons do not get an X window error")
     self.systray.cleanup()
示例#10
0
# -*- coding: utf-8 -*-
#
# ADeskBar - "Show Desktop" plugin
#
##

import adesk.plugin as Plg
import adesk.core as Core

try:
    import wnck
except:
    Core.logINFO('Plugin "showdesktop" need python-wnck')
    Core.logINFO(' -- debian/ubuntu : "sudo apt-get install python-wnck"')

class Plugin(Plg.Plugin):

    def __init__(self, bar, settings):
        Plg.Plugin.__init__(self, bar, settings)

    def onClick(self, widget, event):
        screen = wnck.screen_get_default()
        # showing windows = not showing desktop
        showing_windows = not screen.get_showing_desktop()
        screen.toggle_showing_desktop(showing_windows)

    def resize(self):
        self.set_size_request(self.cfg['icon_size'], self.cfg['icon_size'])
示例#11
0
#
##

import gtk
import gobject
import os
import re

import adesk.plugin as Plg
import adesk.core as Core
import adesk.ui as UI

try:
    import power
except:
    Core.logINFO('Plugin "battery" needs python-power => 1.5')
    Core.logINFO(' -- github: https://github.com/oskarirauta/Power')

class Plugin(Plg.Plugin):
    def __init__(self, bar, settings):
        Plg.Plugin.__init__(self, bar, settings)

        self.can_zoom = True
        self.battery = Battery(self, bar)

    def onClick(self, widget, event):
        self.battery.update_status()
        self.battery.toggle()

    def resize(self):
        self.set_size_request(self.cfg['icon_size'], self.cfg['icon_size'])
示例#12
0
 def destroy(self):
     Core.logINFO(
         "attempt to cleanly close, in such a way that the icons do not get an X window error"
     )
     self.systray.cleanup()
示例#13
0
    def __init__(self, display, error, plugin, bar):
        gtk.Widget.__init__(self)

        # Define widget value and set to default
        self.curr_x = 1
        self.curr_y = 1

        # references to Xlib
        self.dsp = display.Display()
        self.scr = self.dsp.screen()
        self.root = self.scr.root
        self.error = error.CatchError()

        self.plugin = plugin
        self.bar = bar

        # Is the Xwindow realized yet? if not, can cause problems with certain functions
        self.realized = 0

        ourmask = (X.ButtonPressMask | X.ButtonReleaseMask | X.ExposureMask)

        # Create an X window to hold icons
        self.wind = self.root.create_window(0,
                                            0,
                                            1,
                                            10,
                                            0,
                                            self.scr.root_depth,
                                            window_class=X.InputOutput,
                                            visual=X.CopyFromParent,
                                            colormap=X.CopyFromParent,
                                            event_mask=ourmask)

        self.wind.change_property(self.dsp.intern_atom("_NET_WM_DESKTOP"),
                                  Xatom.CARDINAL, 32, [0xffffffffL])

        # set background colour to match the screenlet background
        col = hex(string.atoi(BG_COLOR[1:], 16))
        self.intColour = int(col, 16)
        self.wind.change_attributes(background_pixel=self.intColour)

        # Create an empty Object, this will contain all the data on icons
        # to be added, and all currently managed
        self.tray = Obj(id="tray",
                        tasks={},
                        order=[],
                        first=0,
                        last=0,
                        window=self.wind)

        # Create a non-visible window to be the selection owner
        self._OPCODE = self.dsp.intern_atom("_NET_SYSTEM_TRAY_OPCODE")
        self.manager = self.dsp.intern_atom("MANAGER")
        self.selection = self.dsp.intern_atom("_NET_SYSTEM_TRAY_S%d" %
                                              self.dsp.get_default_screen())

        self.selowin = self.scr.root.create_window(-1, -1, 1, 1, 0,
                                                   self.scr.root_depth)
        owner = self.dsp.get_selection_owner(self.selection)

        if owner != X.NONE:
            Core.logINFO("Another System Tray is already running")
            print "Another System Tray is already running"

        else:
            self.selowin.set_selection_owner(self.selection, X.CurrentTime)
            self.tr__sendEvent(
                self.root, self.manager,
                [X.CurrentTime, self.selection, self.selowin.id],
                (X.StructureNotifyMask))

            self.tr__setProps(self.dsp, self.wind)
            # Set a list of Properties that we'll need

            self.dsp.flush()
            # Show the window and flush the display
            plugin.trayWorks(self)
示例#14
0
import adesk.core as Core
import adesk.ui as UI

import gtk
import gobject
import sys
from gtk import gdk
import cairo
import string

try:
    from Xlib import X, display, error, Xatom, Xutil
    import Xlib.protocol.event
    from Xlib.protocol import request, rq
except:
    Core.logINFO('Plugin "systray" need python-xlib')
    Core.logINFO(' -- debian/ubuntu : "sudo apt-get install python-xlib"')

SIZE = 24
OFFSET = 2

BORDER = 2

SPACE = 2

HIGH = 1
ICONSIZE = 24
CUSTOM_Y = 2


class Plugin(Plg.PluginContainer):
示例#15
0
#
##

import gtk
import gobject
import os
import re

import adesk.plugin as Plg
import adesk.core as Core
import adesk.ui as UI

try:
    import power
except:
    Core.logINFO('Plugin "battery" needs python-power => 1.5')
    Core.logINFO(' -- github: https://github.com/oskarirauta/Power')


class Plugin(Plg.Plugin):
    def __init__(self, bar, settings):
        Plg.Plugin.__init__(self, bar, settings)

        self.can_zoom = True
        self.battery = Battery(self, bar)

    def onClick(self, widget, event):
        self.battery.update_status()
        self.battery.toggle()

    def resize(self):
示例#16
0
import adesk.core as Core
import adesk.ui as UI

import gtk
import gobject
import sys
from gtk import gdk
import cairo
import string

try:
    from Xlib import X, display, error, Xatom, Xutil
    import Xlib.protocol.event
    from Xlib.protocol import request, rq
except:
    Core.logINFO('Plugin "systray" need python-xlib')
    Core.logINFO(' -- debian/ubuntu : "sudo apt-get install python-xlib"')

SIZE = 24
OFFSET = 2

BORDER = 2

SPACE = 2

HIGH = 1
ICONSIZE = 24
CUSTOM_Y = 2

class Plugin(Plg.PluginContainer):
    
示例#17
0
    def __init__(self, display, error, plugin, bar):
        gtk.Widget.__init__(self)

        # Define widget value and set to default
        self.curr_x = 1 
        self.curr_y = 1

        # references to Xlib
        self.dsp = display.Display()      
        self.scr = self.dsp.screen()
        self.root = self.scr.root
        self.error = error.CatchError()

        self.plugin = plugin
        self.bar = bar

        # Is the Xwindow realized yet? if not, can cause problems with certain functions
        self.realized= 0
                                         
        ourmask = (X.ButtonPressMask|X.ButtonReleaseMask|X.ExposureMask)

        # Create an X window to hold icons
        self.wind = self.root.create_window(0, 0, 1, 10,
                0, self.scr.root_depth, window_class=X.InputOutput,
                visual=X.CopyFromParent, colormap=X.CopyFromParent,
                event_mask=ourmask)

        self.wind.change_property(self.dsp.intern_atom("_NET_WM_DESKTOP"), Xatom.CARDINAL, 32, [0xffffffffL])

        # set background colour to match the screenlet background
        col = hex(string.atoi(BG_COLOR[1:],16))
        self.intColour = int(col,16)
        self.wind.change_attributes(background_pixel=self.intColour) 

        # Create an empty Object, this will contain all the data on icons
        # to be added, and all currently managed
        self.tray = Obj(id="tray", tasks={}, order=[],
                    first=0, last=0, window=self.wind)

        # Create a non-visible window to be the selection owner
        self._OPCODE = self.dsp.intern_atom("_NET_SYSTEM_TRAY_OPCODE")
        self.manager = self.dsp.intern_atom("MANAGER")
        self.selection = self.dsp.intern_atom(
            "_NET_SYSTEM_TRAY_S%d" % self.dsp.get_default_screen())
            
        self.selowin = self.scr.root.create_window(-1,
                                  -1, 1, 1, 0, self.scr.root_depth)
        owner = self.dsp.get_selection_owner(self.selection)

        if owner != X.NONE:
            Core.logINFO("Another System Tray is already running")
            print "Another System Tray is already running"

        else:
            self.selowin.set_selection_owner(self.selection, X.CurrentTime)
            self.tr__sendEvent(self.root, self.manager,
                  [X.CurrentTime, self.selection, self.selowin.id],
                  (X.StructureNotifyMask))

            self.tr__setProps(self.dsp, self.wind)
            # Set a list of Properties that we'll need

            self.dsp.flush()
            # Show the window and flush the display
            plugin.trayWorks(self)
示例#18
0
#
##

import os
import time
import gtk
import pango

import adesk.plugin as Plg
import adesk.core as Core
import adesk.draw

try:
    import wnck
except:
    Core.logINFO('Plugin "tasklist" need python-wnck')
    Core.logINFO(' -- debian/ubuntu : "sudo apt-get install python-wnck"')

def_settings = { 
    'desktop_color':'#EEEEEE', 'desktop_font':'Sans Bold 12',
    'show_desk_pos':0, 'show_desk_name':0, 'show_all_win':1,
    'active_color':'#7F7F7F', 'padding':10, 'opacity':32767
    }

class Plugin(Plg.PluginContainer):
    
    def __init__(self, bar, settings):
        Plg.PluginContainer.__init__(self, bar, settings)
        
        self.can_zoom = False
        self.can_show_icon = False
# -*- coding: utf-8 -*-

import gtk
import vte
import os

import adesk.plugin as Plg
import adesk.core as Core
import adesk.ui as UI

try:
    import vte
except:
    Core.logINFO('Plugin "terminal" need python-vte')
    Core.logINFO(' -- debian/ubuntu : "sudo apt-get install python-vte"')


class Plugin(Plg.Plugin):
    def __init__(self, bar, settings):
        Plg.Plugin.__init__(self, bar, settings)
        self.can_zoom = True
        self.settings = settings
        self.terminal = Terminal(self, bar)

    def onClick(self, widget, event):
        self.terminal.toggle()

    def resize(self):
        self.set_size_request(self.cfg["icon_size"], self.cfg["icon_size"])

    def restart(self):
示例#20
0
import adesk.core as Core
import adesk.ui as UI

import locale
import gettext
## Translation
locale.setlocale(locale.LC_ALL, '')
gettext.bindtextdomain('adeskbar', './locale')
gettext.bind_textdomain_codeset('adeskbar', 'UTF-8')
gettext.textdomain('adeskbar')
_ = gettext.gettext

try:
    import alsaaudio as alsa
except:
    Core.logINFO('Plugin "volume" need python-alsaaudio')
    Core.logINFO(' -- debian/ubuntu : "sudo apt-get install python-alsaaudio"')

INC = 5


class Plugin(Plg.Plugin):
    def __init__(self, bar, settings):
        Plg.Plugin.__init__(self, bar, settings)

        ## FIXME!! check if settings for card_index/control
        if not 'card_index' in self.settings: self.settings['card_index'] = 0
        if not 'control' in self.settings: self.settings['control'] = 'Master'

        self.volume = Volume(self, bar)
        self.connect('scroll-event', self.on_scroll_event)
示例#21
0
    def read(self):
        Core.logINFO("read ..", 'config')
        
        home = os.environ['HOME']

        ## custom config
        if os.access("%s/.config/adeskbar/%s.cfg" % (home, self.cfg_file), os.F_OK|os.R_OK):
            Core.logINFO("config = %s/.config/adeskbar/%s.cfg" % (home, self.cfg_file), 'config')
            conf_path = "%s/.config/adeskbar/%s.cfg" % (home, self.cfg_file)

        ## read default config
        elif os.access("default.cfg", os.F_OK|os.R_OK):
            Core.logINFO("config = default.cfg", 'config')
            conf_path = 'default.cfg'

        ## no config ? exit !
        else:
            Core.logINFO("ERROR : can't read config !!!", 'config')
            #~ Core.show_msg("Sorry, but can't read config !!!")
            #~ sys.exit()
            return
            

        f = open(conf_path,'r')

        current_cat = None
        current_ind = None
        error_config = False

        for line in f:
            
            ## empty or comment ..
            if line == '\n' or line[0] == '#':
                continue
                
            try:
                line = line.strip('\n')
                line = line.strip()

                ## check if is a category
                if line[0] == '[':
                    current_cat = line[1:-1]

                    if '/' in current_cat:
                        tmp = current_cat.split('/')
                        current_cat = tmp[0]
                        current_ind = tmp[1]
                        
                        if current_cat == 'LAUNCHER':
                            self.launcher[current_ind] = {}
                            self.l_ind.append(current_ind)
                            
                    else:
                        current_ind = None
                        
                    continue

                if current_cat == 'CONFIG':
                    tmp = line.split('=', 1)
                    key = tmp[0].strip()
                    self.config[key] = tmp[1].strip()

                elif current_cat == 'LAUNCHER':
                    tmp = line.split('=', 1)
                    key = tmp[0].strip()
                    self.launcher[current_ind][key] = tmp[1].strip()

                elif current_cat == 'DRAWER':
                    (cmd, icon, desc) = line.split('##')
                    if not current_ind in self.drawer:
                        self.drawer[current_ind] = []
                    self.drawer[current_ind].append((cmd.strip(), icon.strip(), desc.strip()))

            except Exception, e:
                print 'Error while parsing self.config file ..'
                traceback.print_exc()
                error_config = True
示例#22
0
# ADeskBar - "Terminal" plugin
#
##

import gtk
import vte
import os

import adesk.plugin as Plg
import adesk.core as Core
import adesk.ui as UI

try:
    import vte
except:
    Core.logINFO('Plugin "terminal" need python-vte')
    Core.logINFO(' -- debian/ubuntu : "sudo apt-get install python-vte"')

class Plugin(Plg.Plugin):
    
    def __init__(self, bar, settings):
        Plg.Plugin.__init__(self, bar, settings)

        self.terminal = Terminal(self, bar)

    def onClick(self, widget, event):
        self.terminal.toggle()

    def resize(self):
        self.set_size_request(self.cfg['icon_size'], self.cfg['icon_size'])