示例#1
0
    def edit_config(self, widget):
        core.logINFO("edit config ..", "BarManager")

        if not self.bar_conf:
            self.bar_conf = barconf.Conf(self)
        else:
            self.bar_conf.window.present()
示例#2
0
    def __init__(self, cfg_file):
        core.logINFO('init ..', 'BarManager')
        self.cfg_file = cfg_file

        ## Init some var.
        self.plg_mgr = None
        self.tooltip = None
        self.bar_conf = None
        self.win = None

        self.init_flag = False
        self.bar_hidden = False
        self.mouse_over = False
        self.can_hide = True

        self.last_event_time = None

        if desktop.HAS_WNCK:
            self.wnck = desktop.Wnck(self)
        else:
            self.wnck = None

        self.get_screen_size()

        ## Load user/default config
        self.load_config()
        self.create_menu()
示例#3
0
    def __init__(self, cfg_file):
        core.logINFO("init ..", "BarManager")
        self.cfg_file = cfg_file

        ## Init some var.
        self.plg_mgr = None
        self.tooltip = None
        self.bar_conf = None
        self.win = None

        self.init_flag = False
        self.bar_hidden = False
        self.mouse_over = False
        self.can_hide = True

        self.last_event_time = None

        if desktop.HAS_WNCK:
            self.wnck = desktop.Wnck(self)
        else:
            self.wnck = None

        self.get_screen_size()

        ## Load user/default config
        self.load_config()
        self.create_menu()
示例#4
0
    def edit_config(self, widget):
        core.logINFO('edit config ..', 'BarManager')

        if not self.bar_conf:
            self.bar_conf = barconf.Conf(self)
        else:
            self.bar_conf.window.present()
示例#5
0
 def run(self):
     core.logINFO("run ..", "BarManager")
     try:
         gtk.main()
     except KeyboardInterrupt:
         # ctrl-c
         ## FIXME!! what to do now ? try to close adeskbar nicely ..
         self.doquit()
示例#6
0
 def run(self):
     core.logINFO('run ..', 'BarManager')
     try:
         gtk.main()
     except KeyboardInterrupt:
         # ctrl-c
         ## FIXME!! what to do now ? try to close adeskbar nicely ..
         self.doquit()
示例#7
0
    def update_all(self):
        core.logINFO("update_all ..", "BarManager")

        self.init_bar_pos()
        self.set_geometry()
        self.reposition()
        self.draw_bg()
        self.update()
示例#8
0
    def restart(self, widget=None):
        core.logINFO('restart', 'BarManager')

        self.win.hide()
        for index in self.plg_mgr.plugins:
            self.plg_mgr.plugins[index].destroy()
        self.win.destroy()
        self.load_config()
示例#9
0
    def update_all(self):
        core.logINFO('update_all ..', 'BarManager')

        self.init_bar_pos()
        self.set_geometry()
        self.reposition()
        self.draw_bg()
        self.update()
示例#10
0
    def restart(self, widget=None):
        core.logINFO("restart", "BarManager")

        self.win.hide()
        for index in self.plg_mgr.plugins:
            self.plg_mgr.plugins[index].destroy()
        self.win.destroy()
        self.load_config()
示例#11
0
    def set_below_or_above(self):
        core.logINFO("set_below_or_above ..", "BarManager")

        if self.cfg["keep_below"]:
            self.win.set_keep_below(True)
            self.win.set_keep_above(False)
        else:
            self.win.set_keep_above(True)
            self.win.set_keep_below(False)
示例#12
0
 def create_bar(self):
     """ create and configure gtk.Window (bar) """
     core.logINFO('create_bar', 'bar')
     self.win = ui.Window()
     self.win.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
     self.win.set_title("ADeskBar")
     self.win.set_name("ADeskBar")
     self.is_composited = self.win.is_composited()
     self.set_geometry()
示例#13
0
 def set_below_or_above(self):
     core.logINFO('set_below_or_above ..', 'BarManager')
     
     if self.cfg['keep_below']:
         self.win.set_keep_below(True)
         self.win.set_keep_above(False)
     else:
         self.win.set_keep_above(True)
         self.win.set_keep_below(False)
示例#14
0
    def set_below_or_above(self):
        core.logINFO('set_below_or_above ..', 'BarManager')

        if self.cfg['keep_below']:
            self.win.set_keep_below(True)
            self.win.set_keep_above(False)
        else:
            self.win.set_keep_above(True)
            self.win.set_keep_below(False)
示例#15
0
    def doquit(self, widget=None, data=None):
        core.logINFO('quit ..', 'BarManager')

        ## FIXME!! what to do now ? try to close adeskbar nicely ..
        self.win.hide()
        for ind in self.plg_mgr.plugins:
            self.plg_mgr.plugins[ind].stop()
        self.win.destroy()
        gtk.main_quit()
示例#16
0
    def bar_move(self):
        core.logINFO("bar move ..", "BarManager")

        if self.bar_hidden:
            self.win.move(int(self.bar_hide_x), int(self.bar_hide_y))
        else:
            self.win.move(int(self.bar_pos_x), int(self.bar_pos_y))
        self.update()
        self.update_strut(self.win)
示例#17
0
    def bar_move(self):
        core.logINFO('bar move ..', 'BarManager')

        if self.bar_hidden:
            self.win.move(int(self.bar_hide_x), int(self.bar_hide_y))
        else:
            self.win.move(int(self.bar_pos_x), int(self.bar_pos_y))
        self.update()
        self.update_strut(self.win)
示例#18
0
    def doquit(self, widget=None, data=None):
        core.logINFO("quit ..", "BarManager")

        ## FIXME!! what to do now ? try to close adeskbar nicely ..
        self.win.hide()
        for ind in self.plg_mgr.plugins:
            self.plg_mgr.plugins[ind].stop()
        self.win.destroy()
        gtk.main_quit()
示例#19
0
    def update_strut(self, widget):
        core.logINFO('update structure ..', 'BarManager')

        # window need to be realize before change strut
        if widget.window == None:
            return

        # reset struct
        widget.window.property_change("_NET_WM_STRUT", "CARDINAL", 32,
                                      gtk.gdk.PROP_MODE_REPLACE, [0, 0, 0, 0])

        # only set strut if "panel" mode
        if not (self.cfg['fixed_mode'] and self.cfg['reserve_space']):
            return

        x, y, w, h = widget.get_allocation()

        if self.cfg['position'] == "bottom" or self.cfg['position'] == "top":
            h = self.cfg['icon_size'] + 2 * self.cfg['padding']
        else:
            w = self.cfg['icon_size'] + 2 * self.cfg['padding']

        if self.cfg['auto_hide'] and self.bar_hidden:
            if self.cfg['position'] == "bottom" or self.cfg[
                    'position'] == "top":
                h = self.cfg['hidden_size']
            else:
                w = self.cfg['hidden_size']

        if self.cfg['position'] == "bottom":
            if not self.bar_hidden and not self.cfg['bar_style'] == 0:
                h += self.cfg['offset_pos']
            widget.window.property_change("_NET_WM_STRUT", "CARDINAL", 32,
                                          gtk.gdk.PROP_MODE_REPLACE,
                                          [0, 0, 0, h])

        elif self.cfg['position'] == "top":
            if not self.bar_hidden and not self.cfg['bar_style'] == 0:
                h += self.cfg['offset_pos']
            widget.window.property_change("_NET_WM_STRUT", "CARDINAL", 32,
                                          gtk.gdk.PROP_MODE_REPLACE,
                                          [0, 0, h, 0])

        elif self.cfg['position'] == "left":
            if not self.bar_hidden and not self.cfg['bar_style'] == 0:
                w += self.cfg['offset_pos']
            widget.window.property_change("_NET_WM_STRUT", "CARDINAL", 32,
                                          gtk.gdk.PROP_MODE_REPLACE,
                                          [w, 0, 0, 0])

        elif self.cfg['position'] == "right":
            if not self.bar_hidden and not self.cfg['bar_style'] == 0:
                w += self.cfg['offset_pos']
            widget.window.property_change("_NET_WM_STRUT", "CARDINAL", 32,
                                          gtk.gdk.PROP_MODE_REPLACE,
                                          [0, w, 0, 0])
示例#20
0
    def toggle_hidden(self, widget=None, event=None):
        core.logINFO("toggle_hidden", "BarManager")

        if self.bar_hidden:
            self.bar_hidden = False
            self.bar_move()
        elif self.cfg["auto_hide"] == 1:  # autohide
            self.bar_hide()
        elif self.cfg["auto_hide"] == 2:  # intellihide
            self.check_window_state()
示例#21
0
    def toggle_hidden(self, widget=None, event=None):
        core.logINFO('toggle_hidden', 'BarManager')

        if self.bar_hidden:
            self.bar_hidden = False
            self.bar_move()
        elif self.cfg['auto_hide'] == 1:  # autohide
            self.bar_hide()
        elif self.cfg['auto_hide'] == 2:  # intellihide
            self.check_window_state()
示例#22
0
    def create_bar(self):
        """ create and configure gtk.Window (bar) """
        core.logINFO("create bar ..", "BarManager")

        self.win = ui.Window()
        self.win.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
        self.win.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.ENTER_NOTIFY | gtk.gdk.LEAVE_NOTIFY)
        self.win.set_title("ADeskBar")
        self.win.set_name("ADeskBar")
        self.is_composited = self.win.is_composited()
示例#23
0
    def update_strut(self, widget):
        core.logINFO('update structure ..', 'BarManager')
        
        # window need to be realize before change strut
        if widget.window == None:
            return        
        
        # reset struct
        widget.window.property_change("_NET_WM_STRUT", "CARDINAL", 32, 
                                      gtk.gdk.PROP_MODE_REPLACE, [0,0,0,0])
        
        # only set strut if "panel" mode
        if not (self.cfg['fixed_mode'] and  self.cfg['reserve_space']):
            return

        x, y, w, h = widget.get_allocation()

        if self.cfg['position'] == "bottom" or self.cfg['position'] == "top":
            h = self.cfg['icon_size'] + 2*self.cfg['padding']
        else:
            w = self.cfg['icon_size'] + 2*self.cfg['padding']

        if self.cfg['auto_hide'] and self.bar_hidden:
            if self.cfg['position'] == "bottom" or self.cfg['position'] == "top":
                h = self.cfg['hidden_size']
            else:
                w = self.cfg['hidden_size']
                
        if self.cfg['position'] == "bottom":
            if not self.bar_hidden and not self.cfg['bar_style'] == 0: 
                h += self.cfg['offset_pos'] 
            widget.window.property_change("_NET_WM_STRUT", "CARDINAL", 
                                          32, gtk.gdk.PROP_MODE_REPLACE, 
                                          [0,0,0,h])

        elif self.cfg['position'] == "top":
            if not self.bar_hidden and not self.cfg['bar_style'] == 0:
                h += self.cfg['offset_pos'] 
            widget.window.property_change("_NET_WM_STRUT", "CARDINAL", 
                                          32, gtk.gdk.PROP_MODE_REPLACE, 
                                          [0,0,h,0])

        elif self.cfg['position'] == "left":
            if not self.bar_hidden and not self.cfg['bar_style'] == 0:
                w += self.cfg['offset_pos'] 
            widget.window.property_change("_NET_WM_STRUT", "CARDINAL", 
                                          32, gtk.gdk.PROP_MODE_REPLACE, 
                                          [w,0,0,0])

        elif self.cfg['position'] == "right":
            if not self.bar_hidden and not self.cfg['bar_style'] == 0:
                w += self.cfg['offset_pos'] 
            widget.window.property_change("_NET_WM_STRUT", "CARDINAL", 
                                          32, gtk.gdk.PROP_MODE_REPLACE, 
                                          [0,w,0,0])
示例#24
0
 def load_plugin(self, p, settings=None):
     """ load plugin as widget """
     try:
         core.logINFO(("Loading plugin '%s' ..") % (p), 'bar')
         exec("import plugins.%s as plugin" % p)
         widget = plugin.Plugin(self.bar, settings)
     except Exception as e:
         core.logINFO(("EE : Unable to load plugin '%s': %s") % (p, e), 'bar')
         traceback.print_exc()
         return None
     return widget
示例#25
0
    def create_bar(self):
        """ create and configure gtk.Window (bar) """
        core.logINFO('create bar ..', 'BarManager')

        self.win = ui.Window()
        self.win.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
        self.win.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.ENTER_NOTIFY
                            | gtk.gdk.LEAVE_NOTIFY)
        self.win.set_title("ADeskBar")
        self.win.set_name("ADeskBar")
        self.is_composited = self.win.is_composited()
示例#26
0
    def resize_and_seticon(self, data=None):
        core.logINFO("resize and seticon ..", "BarManager")

        # resize and update icon for all plugins
        for ind in self.plg_mgr.plugins:
            self.plg_mgr.plugins[ind].resize()
            self.plg_mgr.plugins[ind].set_icon()
            self.plg_mgr.plugins[ind].restart()
        self.update_all()

        ## call from timer ..
        return False
示例#27
0
    def resize_and_seticon(self, data=None):
        core.logINFO('resize and seticon ..', 'BarManager')

        # resize and update icon for all plugins
        for ind in self.plg_mgr.plugins:
            self.plg_mgr.plugins[ind].resize()
            self.plg_mgr.plugins[ind].set_icon()
            self.plg_mgr.plugins[ind].restart()
        self.update_all()

        ## call from timer ..
        return False
示例#28
0
    def connect_event(self):
        core.logINFO("init bar callback ..", "BarManager")

        ## Window callback
        self.win.connect("button_press_event", self.bar_released)
        self.win.connect("leave-notify-event", self.bar_leave_notify)
        self.win.connect("enter-notify-event", self.bar_enter_notify)
        self.win.connect("expose-event", self.expose)
        self.win.connect("screen-changed", self.screen_changed)
        self.win.connect("size-allocate", self.win_size_allocate)
        self.win.connect("realize", self.update_strut)
        self.win.connect("composited-changed", self.composite_changed)
示例#29
0
    def connect_event(self):
        core.logINFO('init bar callback ..', 'BarManager')

        ## Window callback
        self.win.connect("button_press_event", self.bar_released)
        self.win.connect("leave-notify-event", self.bar_leave_notify)
        self.win.connect("enter-notify-event", self.bar_enter_notify)
        self.win.connect('expose-event', self.expose)
        self.win.connect('screen-changed', self.screen_changed)
        self.win.connect('size-allocate', self.win_size_allocate)
        self.win.connect("realize", self.update_strut)
        self.win.connect("composited-changed", self.composite_changed)
示例#30
0
    def set_geometry(self):
        core.logINFO('set geometry ..', 'BarManager')

        if self.cfg['fixed_mode']:
            screen_width, screen_height = gtk.gdk.screen_width(
            ), gtk.gdk.screen_height()
            padding = max(
                self.cfg['padding'],
                self.cfg['icon_size'] * self.cfg['zoom_factor'] -
                self.cfg['icon_size'])
            min_size = int(padding + self.cfg['padding'] +
                           self.cfg['icon_size'])

            if self.cfg['position'] == "bottom" or self.cfg[
                    'position'] == "top":
                req_size = int(screen_width * self.cfg['fixed_size'] / 100.0)
                self.win.set_geometry_hints(None,
                                            min_width=req_size,
                                            min_height=min_size,
                                            max_width=req_size,
                                            max_height=min_size,
                                            base_width=-1,
                                            base_height=-1,
                                            width_inc=-1,
                                            height_inc=-1,
                                            min_aspect=-1.0,
                                            max_aspect=-1.0)
            else:
                req_size = int(screen_height * self.cfg['fixed_size'] / 100.0)
                self.win.set_geometry_hints(None,
                                            min_width=min_size,
                                            min_height=req_size,
                                            max_width=min_size,
                                            max_height=req_size,
                                            base_width=-1,
                                            base_height=-1,
                                            width_inc=-1,
                                            height_inc=-1,
                                            min_aspect=-1.0,
                                            max_aspect=-1.0)
        else:
            self.win.set_geometry_hints(None,
                                        min_width=-1,
                                        min_height=-1,
                                        max_width=-1,
                                        max_height=-1,
                                        base_width=-1,
                                        base_height=-1,
                                        width_inc=-1,
                                        height_inc=-1,
                                        min_aspect=-1.0,
                                        max_aspect=-1.0)
示例#31
0
    def set_geometry(self):
        core.logINFO("set geometry ..", "BarManager")

        if self.cfg["fixed_mode"]:
            screen_width, screen_height = gtk.gdk.screen_width(), gtk.gdk.screen_height()
            padding = max(self.cfg["padding"], self.cfg["icon_size"] * self.cfg["zoom_factor"] - self.cfg["icon_size"])
            min_size = int(padding + self.cfg["padding"] + self.cfg["icon_size"])

            if self.cfg["position"] == "bottom" or self.cfg["position"] == "top":
                req_size = int(screen_width * self.cfg["fixed_size"] / 100.0)
                self.win.set_geometry_hints(
                    None,
                    min_width=req_size,
                    min_height=min_size,
                    max_width=req_size,
                    max_height=min_size,
                    base_width=-1,
                    base_height=-1,
                    width_inc=-1,
                    height_inc=-1,
                    min_aspect=-1.0,
                    max_aspect=-1.0,
                )
            else:
                req_size = int(screen_height * self.cfg["fixed_size"] / 100.0)
                self.win.set_geometry_hints(
                    None,
                    min_width=min_size,
                    min_height=req_size,
                    max_width=min_size,
                    max_height=req_size,
                    base_width=-1,
                    base_height=-1,
                    width_inc=-1,
                    height_inc=-1,
                    min_aspect=-1.0,
                    max_aspect=-1.0,
                )
        else:
            self.win.set_geometry_hints(
                None,
                min_width=-1,
                min_height=-1,
                max_width=-1,
                max_height=-1,
                base_width=-1,
                base_height=-1,
                width_inc=-1,
                height_inc=-1,
                min_aspect=-1.0,
                max_aspect=-1.0,
            )
示例#32
0
    def bar_hide(self):
        core.logINFO("bar hide ..", "BarManager")

        if not self.can_hide:
            return
        if self.cfg["smooth_hide"]:
            self.count = 14  ## 500 / 35 ms
            self.countdown = self.count
            self.moving = True
            self.timer_smooth_hide = gobject.timeout_add(35, self.on_timeout_hide)
        else:
            self.bar_hidden = True
            self.bar_move()
示例#33
0
    def check_window_state(self):
        core.logINFO('check_window_state ..', 'BarManager')

        if not self.init_flag:
            return

        if not (self.cfg['auto_hide'] == 2 and self.wnck):
            return

        if self.wnck.current_state and not self.bar_hidden and not self.always_visible:
            self.bar_hide()
        elif self.bar_hidden and not self.wnck.current_state:
            self.bar_hidden = False
            self.bar_move()
示例#34
0
    def check_window_state(self):
        core.logINFO("check_window_state ..", "BarManager")

        if not self.init_flag:
            return

        if not (self.cfg["auto_hide"] == 2 and self.wnck):
            return

        if self.wnck.current_state and not self.bar_hidden and not self.always_visible:
            self.bar_hide()
        elif self.bar_hidden and not self.wnck.current_state:
            self.bar_hidden = False
            self.bar_move()
示例#35
0
    def bar_hide(self):
        core.logINFO('bar hide ..', 'BarManager')

        if not self.can_hide:
            return
        if self.cfg['smooth_hide']:
            self.count = 14  ## 500 / 35 ms
            self.countdown = self.count
            self.moving = True
            self.timer_smooth_hide = gobject.timeout_add(
                35, self.on_timeout_hide)
        else:
            self.bar_hidden = True
            self.bar_move()
示例#36
0
    def bar_released(self, widget, event):
        core.logINFO("bar released ..", "BarManager")

        ## FIXME! avoid double callback (I don't know why I receive twice)
        if self.last_event_time == event.time:
            return False
        self.last_event_time = event.time

        if event.button == 3:  # right click
            self.create_menu()
            # ~ if event.state == gtk.gdk.CONTROL_MASK | gtk.gdk.MOD2_MASK:
            self.popupMenu.popup(None, None, None, event.button, event.time)

        elif event.button == 2:  # middle click
            self.always_visible = not self.always_visible

        elif event.button == 1 and self.bar_hidden:  # left click
            self.toggle_hidden()
示例#37
0
    def bar_released(self, widget, event):
        core.logINFO('bar released ..', 'BarManager')

        ## FIXME! avoid double callback (I don't know why I receive twice)
        if self.last_event_time == event.time:
            return False
        self.last_event_time = event.time

        if event.button == 3:  # right click
            self.create_menu()
            #~ if event.state == gtk.gdk.CONTROL_MASK | gtk.gdk.MOD2_MASK:
            self.popupMenu.popup(None, None, None, event.button, event.time)

        elif event.button == 2:  # middle click
            self.always_visible = not self.always_visible

        elif event.button == 1 and self.bar_hidden:  # left click
            self.toggle_hidden()
示例#38
0
    def load_plugin(self, index, launcher, is_plugin = False):
        """ load plugin as widget """
        
        try:
            
            if is_plugin:
                exec("import plugins.%s as plugin" % launcher['cmd'][1:])
            else:
                exec("import plugins.launcher as plugin")
                
            widget = plugin.Plugin(self.bar, launcher)
            
        except Exception as e:
            traceback.print_exc()
            core.logINFO('error while loading %s ...' % launcher['cmd'])
            return None

        return widget
示例#39
0
    def set_geometry(self):
        core.logINFO('set geometry ..', 'BarManager')
        
        if self.cfg['fixed_mode']:
            screen_width, screen_height = gtk.gdk.screen_width(), gtk.gdk.screen_height()
            padding = max(self.cfg['padding'], self.cfg['icon_size'] * self.cfg['zoom_factor'] - self.cfg['icon_size'])
            min_size = int(padding + self.cfg['padding'] + self.cfg['icon_size'])

            if self.cfg['position'] == "bottom" or self.cfg['position'] == "top":
                req_size = int(screen_width * self.cfg['fixed_size']/100.0)
                self.win.set_geometry_hints(None, min_width=req_size, 
                                            min_height=min_size, 
                                            max_width=req_size, 
                                            max_height=min_size, 
                                            base_width=-1, 
                                            base_height=-1, 
                                            width_inc=-1, 
                                            height_inc=-1, 
                                            min_aspect=-1.0, 
                                            max_aspect=-1.0)
            else:
                req_size = int(screen_height * self.cfg['fixed_size']/100.0)
                self.win.set_geometry_hints(None, min_width=min_size, 
                                            min_height=req_size, 
                                            max_width=min_size, 
                                            max_height=req_size, 
                                            base_width=-1, 
                                            base_height=-1, 
                                            width_inc=-1, 
                                            height_inc=-1, 
                                            min_aspect=-1.0, 
                                            max_aspect=-1.0)
        else:
            self.win.set_geometry_hints(None, min_width=-1, min_height=-1, 
                                        max_width=-1, max_height=-1, 
                                        base_width=-1, base_height=-1, 
                                        width_inc=-1, height_inc=-1, 
                                        min_aspect=-1.0, max_aspect=-1.0)
示例#40
0
    def reposition(self):
        core.logINFO("reposition ..", "BarManager")

        if self.cfg["fixed_mode"]:

            if self.cfg["position"] == "bottom" or self.cfg["position"] == "top":
                req_size = int(self.monitor_w * self.cfg["fixed_size"] / 100.0)
                self.win.resize(req_size, 1)
            else:
                req_size = int(self.monitor_h * self.cfg["fixed_size"] / 100.0)
                self.win.resize(1, req_size)
        else:
            self.win.resize(1, 1)

        self.bar_move()
        self.toggle_hidden()

        # Intellihide
        if self.wnck:
            self.check_window_state()

        self.update()
        return False
示例#41
0
    def reposition(self):
        core.logINFO('reposition ..', 'BarManager')

        if self.cfg['fixed_mode']:

            if self.cfg['position'] == "bottom" or self.cfg[
                    'position'] == "top":
                req_size = int(self.monitor_w * self.cfg['fixed_size'] / 100.0)
                self.win.resize(req_size, 1)
            else:
                req_size = int(self.monitor_h * self.cfg['fixed_size'] / 100.0)
                self.win.resize(1, req_size)
        else:
            self.win.resize(1, 1)

        self.bar_move()
        self.toggle_hidden()

        # Intellihide
        if self.wnck:
            self.check_window_state()

        self.update()
        return False
示例#42
0
    def load_config(self):
        self.cfg, self.launcher, self.drawer = config.read(self.cfg_file)

        ## If intellihide and wnck loaded
        if self.cfg['auto_hide'] == 2 and not self.wnck:
            # no wnck module ? fallback to autohide
            core.logINFO('intellihide : no wnck module found .. fallback to autohide', 'bar')
            self.cfg['auto_hide'] = 1
            self.wnck = None

        self.zoom_size = self.cfg['icon_size'] * self.cfg['zoom_factor'] * 1.0

        # timer for leave_bar callback
        self.timer_auto_hide = None
        # timer for smooth_hidding
        self.timer_smooth_hide = None

        # use for animate hiding
        self.moving = False
        self.count = 0
        self.countdown = 0
        self.timer_anim = None

        # middle click - Toggle always visible
        self.always_visible = False

        # launcher ( for mouseover/click )
        self.focus = None
        self.widget_pressed = False
        self.anim = 1
        self.fade = True
        self.anim_cpt = 0
        self.anim_flag = True

        # flag for plugin
        self.opened_popup = None
        self.lock_auto_hide = False

        ## convert color hex->rgb
        self.cfg['bg_color_rgb'] = core.hex2rgb(self.cfg['background_color'])
        self.cfg['border_color_rgb'] = core.hex2rgb(self.cfg['border_color'])
        self.cfg['bg_color_sub_rgb'] = core.hex2rgb(self.cfg['bg_color_sub'])
        self.cfg['border_color_sub_rgb'] = core.hex2rgb(self.cfg['border_color_sub'])
        self.cfg['bg_gradient_color_rgb'] = core.hex2rgb(self.cfg['background_gradient_color'])
        
        self.pixbuf_glow = gtk.gdk.pixbuf_new_from_file('images/pixmaps/button.png')
        self.pixbuf_pressed = gtk.gdk.pixbuf_new_from_file('images/pixmaps/launcher.png')

        ## Create main bar
        self.create_bar()
        self.set_below_or_above()

        ## tooltip
        if self.tooltip:
            self.tooltip.destroy()
            self.tooltip = None

        if self.cfg['tooltips']:
            self.tooltip = ui.TooltipWindow(self)

        # create a new plugin manager
        self.plg_mgr = PluginManager(self)
        
        # and start to pack plugin ..
        for ind in self.cfg['ind_launcher']:
            self.plg_mgr.append(ind, self.launcher[ind])
        self.plg_mgr.run()

        # start bar callback
        self.init_bar_callback()

        ## FIXME!
        ## gtk.Window doesn't stick after reload config ?!
        self.win.realize()
        self.win.stick()
        self.reposition()
        self.win.show_all()

        # init all plugins
        self.plg_mgr.on_init()

        ## FIXME!!
        # sometimes reposition doesn't work :/ .. quick hack
        gobject.timeout_add(500, self.reposition)

        if DEBUG and not 1:
            for index in self.plg_mgr.index:
                print ('------------------------------------')
                for val in self.plg_mgr.plugins[index].settings:
                    print ('%s = %s' % (val, self.plg_mgr.plugins[index].settings[val]))

                print ('widget :', self.plg_mgr.plugins[index])
                print ('index :', self.plg_mgr.plugins[index].index)
                print ('------------------------------------\n')
示例#43
0
    def win_size_allocate(self, widget, allocation):
        core.logINFO("window size allocate ..", "BarManager")

        self.init_bar_pos()
        self.bar_move()
示例#44
0
    def composite_changed(self, widget):
        core.logINFO('composite changed', 'BarManager')

        self.is_composited = self.win.is_composited()
        self.update_all()
示例#45
0
    def init_bar_pos(self):
        core.logINFO("init bar position ..", "BarManager")

        self.bar_width, self.bar_height = self.get_size()

        if not self.is_composited:
            bar_size = 1
        else:
            bar_size = self.cfg["bar_size"] / 100.0

        if self.cfg["position"] == "bottom":
            if self.cfg["bar_style"] == 0:
                self.bar_pos_y = self.monitor_h - self.bar_height + 1
            else:
                self.bar_pos_y = self.monitor_h - self.bar_height - self.cfg["offset_pos"]

            if self.cfg["align"] == "start":
                self.bar_pos_x = 0 + self.cfg["offset_align"]
            elif self.cfg["align"] == "center":
                self.bar_pos_x = (self.monitor_w - self.bar_width) // 2
            elif self.cfg["align"] == "end":
                self.bar_pos_x = self.monitor_w - self.bar_width - self.cfg["offset_align"]

            self.bar_hide_y = self.monitor_h - self.cfg["hidden_size"]
            self.bar_hide_x = self.bar_pos_x

            ## for expose
            self.draw_height = (2 * self.cfg["padding"] + self.cfg["icon_size"]) * bar_size
            self.draw_width = self.bar_width
            self.draw_x = 0
            self.draw_y = self.bar_height - (2 * self.cfg["padding"] + self.cfg["icon_size"]) * bar_size

        elif self.cfg["position"] == "top":
            if self.cfg["bar_style"] == 0:
                self.bar_pos_y = -1
            else:
                self.bar_pos_y = self.cfg["offset_pos"]

            if self.cfg["align"] == "start":
                self.bar_pos_x = self.cfg["offset_align"]
            elif self.cfg["align"] == "center":
                self.bar_pos_x = (self.monitor_w - self.bar_width) // 2
            elif self.cfg["align"] == "end":
                self.bar_pos_x = self.monitor_w - self.bar_width - self.cfg["offset_align"]

            self.bar_hide_y = self.cfg["hidden_size"] - self.bar_height
            self.bar_hide_x = self.bar_pos_x

            ## for expose
            self.draw_height = (2 * self.cfg["padding"] + self.cfg["icon_size"]) * bar_size
            self.draw_width = self.bar_width
            self.draw_x, self.draw_y = 0, 0

        elif self.cfg["position"] == "left":
            if self.cfg["bar_style"] == 0:
                self.bar_pos_x = -1
            else:
                self.bar_pos_x = self.cfg["offset_pos"]

            if self.cfg["align"] == "start":
                self.bar_pos_y = 0 + self.cfg["offset_align"]
            elif self.cfg["align"] == "center":
                self.bar_pos_y = (self.monitor_h - self.bar_height) // 2
            elif self.cfg["align"] == "end":
                self.bar_pos_y = self.monitor_h - self.bar_height - self.cfg["offset_align"]

            self.bar_hide_y = self.bar_pos_y
            self.bar_hide_x = -self.bar_width + self.cfg["hidden_size"]

            ## for expose
            self.draw_height = self.bar_height
            self.draw_width = (2 * self.cfg["padding"] + self.cfg["icon_size"]) * bar_size
            self.draw_x, self.draw_y = 0, 0

        elif self.cfg["position"] == "right":
            if self.cfg["bar_style"] == 0:
                self.bar_pos_x = self.monitor_w - self.bar_width + 1
            else:
                self.bar_pos_x = self.monitor_w - self.bar_width - self.cfg["offset_pos"]

            if self.cfg["align"] == "start":
                self.bar_pos_y = 0 + self.cfg["offset_align"]
            elif self.cfg["align"] == "center":
                self.bar_pos_y = (self.monitor_h - self.bar_height) // 2
            elif self.cfg["align"] == "end":
                self.bar_pos_y = self.monitor_h - self.bar_height - self.cfg["offset_align"]

            self.bar_hide_y = self.bar_pos_y
            self.bar_hide_x = self.monitor_w - self.cfg["hidden_size"]

            ## for expose
            self.draw_height = self.bar_height
            self.draw_width = (2 * self.cfg["padding"] + self.cfg["icon_size"]) * bar_size
            self.draw_x = self.bar_width - (2 * self.cfg["padding"] + self.cfg["icon_size"]) * bar_size
            self.draw_y = 0

        self.draw_width = int(self.draw_width)
        self.draw_height = int(self.draw_height)
        self.draw_x = int(self.draw_x + self.monitor_x)
        self.draw_y = int(self.draw_y + self.monitor_y)

        self.bg_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, self.bar_width, self.bar_height)
        self.draw_bg()
        self.init_flag = True
示例#46
0
    def win_size_allocate(self, widget, allocation):
        core.logINFO('window size allocate ..', 'BarManager')

        self.init_bar_pos()
        self.bar_move()
示例#47
0
    def load_config(self):
        core.logINFO("load config", "BarManager")

        ## read config
        self.configuration = config.Config(self.cfg_file)
        self.configuration.read()

        self.cfg = self.configuration.config
        self.launcher = self.configuration.launcher
        self.drawer = self.configuration.drawer

        if DEBUG:
            print "CONFIG ---------------------------------------------"
            for key in self.cfg:
                print key, self.cfg[key]
            print

            print "LAUNCHER -------------------------------------------"
            for key in self.launcher:
                print key, self.launcher[key]
            print

            print "DRAWNER --------------------------------------------"
            for key in self.drawer:
                print key, self.drawer[key]

        ## If intellihide and wnck loaded
        if self.cfg["auto_hide"] == 2 and not self.wnck:
            # no wnck module ? fallback to autohide
            core.logINFO("intellihide : no wnck module found ..", "bar")
            core.logINFO("-- fallback to autohide")
            self.cfg["auto_hide"] = 1
            self.wnck = None

        self.zoom_size = self.cfg["icon_size"] * self.cfg["zoom_factor"] * 1.0

        # timer for leave_bar callback
        self.timer_auto_hide = None
        # timer for smooth_hidding
        self.timer_smooth_hide = None

        # use for animate hiding
        self.moving = False
        self.count = 0
        self.countdown = 0
        self.timer_anim = None

        # middle click - Toggle always visible
        self.always_visible = False

        # launcher ( for mouseover/click )
        self.focus = None
        self.widget_pressed = False
        self.anim = 1
        self.fade = True
        self.anim_cpt = 0
        self.anim_flag = True

        # flag for plugin
        self.opened_popup = None
        self.lock_auto_hide = False

        self.pixbuf_glow = gtk.gdk.pixbuf_new_from_file("./images/pixmaps/button.png")
        self.pixbuf_pressed = gtk.gdk.pixbuf_new_from_file("./images/pixmaps/launcher.png")

        ## Create main bar
        self.create_bar()
        self.set_below_or_above()

        ## tooltip
        if self.tooltip:
            self.tooltip.destroy()
            self.tooltip = None

        if self.cfg["tooltips"]:
            self.tooltip = ui.TooltipWindow(self)

        # create a new plugin manager
        self.plg_mgr = pluginmanager.PluginManager(self)

        for ind in self.configuration.l_ind:
            self.plg_mgr.append(ind, self.launcher[ind])
        self.plg_mgr.run()

        ## bar callback
        self.connect_event()

        ## gtk.Window doesn't stick after reload config ?!
        self.win.realize()
        self.win.stick()
        self.win.show_all()

        # init all plugins
        self.plg_mgr.on_init()

        self.set_geometry()
        # sometimes reposition doesn't work :/ .. quick hack
        gobject.idle_add(self.reposition)
示例#48
0
    def load_config(self):
        core.logINFO('load config', 'BarManager')

        ## read config
        self.configuration = config.Config(self.cfg_file)
        self.configuration.read()

        self.cfg = self.configuration.config
        self.launcher = self.configuration.launcher
        self.drawer = self.configuration.drawer

        if DEBUG:
            print 'CONFIG ---------------------------------------------'
            for key in self.cfg:
                print key, self.cfg[key]
            print

            print 'LAUNCHER -------------------------------------------'
            for key in self.launcher:
                print key, self.launcher[key]
            print

            print 'DRAWNER --------------------------------------------'
            for key in self.drawer:
                print key, self.drawer[key]

        ## If intellihide and wnck loaded
        if self.cfg['auto_hide'] == 2 and not self.wnck:
            # no wnck module ? fallback to autohide
            core.logINFO('intellihide : no wnck module found ..', 'bar')
            core.logINFO('-- fallback to autohide')
            self.cfg['auto_hide'] = 1
            self.wnck = None

        self.zoom_size = self.cfg['icon_size'] * self.cfg['zoom_factor'] * 1.0

        # timer for leave_bar callback
        self.timer_auto_hide = None
        # timer for smooth_hidding
        self.timer_smooth_hide = None

        # use for animate hiding
        self.moving = False
        self.count = 0
        self.countdown = 0
        self.timer_anim = None

        # middle click - Toggle always visible
        self.always_visible = False

        # launcher ( for mouseover/click )
        self.focus = None
        self.widget_pressed = False
        self.anim = 1
        self.fade = True
        self.anim_cpt = 0
        self.anim_flag = True

        # flag for plugin
        self.opened_popup = None
        self.lock_auto_hide = False

        self.pixbuf_glow = gtk.gdk.pixbuf_new_from_file(
            './images/pixmaps/button.png')
        self.pixbuf_pressed = gtk.gdk.pixbuf_new_from_file(
            './images/pixmaps/launcher.png')

        ## Create main bar
        self.create_bar()
        self.set_below_or_above()

        ## tooltip
        if self.tooltip:
            self.tooltip.destroy()
            self.tooltip = None

        if self.cfg['tooltips']:
            self.tooltip = ui.TooltipWindow(self)

        # create a new plugin manager
        self.plg_mgr = pluginmanager.PluginManager(self)

        for ind in self.configuration.l_ind:
            self.plg_mgr.append(ind, self.launcher[ind])
        self.plg_mgr.run()

        ## bar callback
        self.connect_event()

        ## gtk.Window doesn't stick after reload config ?!
        self.win.realize()
        self.win.stick()
        self.win.show_all()

        # init all plugins
        self.plg_mgr.on_init()

        self.set_geometry()
        # sometimes reposition doesn't work :/ .. quick hack
        gobject.idle_add(self.reposition)
示例#49
0
    def init_bar_pos(self):
        core.logINFO('init bar position ..', 'BarManager')

        self.bar_width, self.bar_height = self.get_size()

        if not self.is_composited:
            bar_size = 1
        else:
            bar_size = self.cfg['bar_size'] / 100.0

        if self.cfg['position'] == "bottom":
            if self.cfg['bar_style'] == 0:
                self.bar_pos_y = self.monitor_h - self.bar_height + 1
            else:
                self.bar_pos_y = self.monitor_h - self.bar_height - self.cfg[
                    'offset_pos']

            if self.cfg['align'] == "start":
                self.bar_pos_x = 0 + self.cfg['offset_align']
            elif self.cfg['align'] == "center":
                self.bar_pos_x = (self.monitor_w - self.bar_width) // 2
            elif self.cfg['align'] == "end":
                self.bar_pos_x = self.monitor_w - self.bar_width - self.cfg[
                    'offset_align']

            self.bar_hide_y = self.monitor_h - self.cfg['hidden_size']
            self.bar_hide_x = self.bar_pos_x

            ## for expose
            self.draw_height = (2 * self.cfg['padding'] +
                                self.cfg['icon_size']) * bar_size
            self.draw_width = self.bar_width
            self.draw_x = 0
            self.draw_y = self.bar_height - (2 * self.cfg['padding'] +
                                             self.cfg['icon_size']) * bar_size

        elif self.cfg['position'] == "top":
            if self.cfg['bar_style'] == 0:
                self.bar_pos_y = -1
            else:
                self.bar_pos_y = self.cfg['offset_pos']

            if self.cfg['align'] == "start":
                self.bar_pos_x = self.cfg['offset_align']
            elif self.cfg['align'] == "center":
                self.bar_pos_x = (self.monitor_w - self.bar_width) // 2
            elif self.cfg['align'] == "end":
                self.bar_pos_x = self.monitor_w - self.bar_width - self.cfg[
                    'offset_align']

            self.bar_hide_y = self.cfg['hidden_size'] - self.bar_height
            self.bar_hide_x = self.bar_pos_x

            ## for expose
            self.draw_height = (2 * self.cfg['padding'] +
                                self.cfg['icon_size']) * bar_size
            self.draw_width = self.bar_width
            self.draw_x, self.draw_y = 0, 0

        elif self.cfg['position'] == "left":
            if self.cfg['bar_style'] == 0:
                self.bar_pos_x = -1
            else:
                self.bar_pos_x = self.cfg['offset_pos']

            if self.cfg['align'] == "start":
                self.bar_pos_y = 0 + self.cfg['offset_align']
            elif self.cfg['align'] == "center":
                self.bar_pos_y = (self.monitor_h - self.bar_height) // 2
            elif self.cfg['align'] == "end":
                self.bar_pos_y = self.monitor_h - self.bar_height - self.cfg[
                    'offset_align']

            self.bar_hide_y = self.bar_pos_y
            self.bar_hide_x = -self.bar_width + self.cfg['hidden_size']

            ## for expose
            self.draw_height = self.bar_height
            self.draw_width = (2 * self.cfg['padding'] +
                               self.cfg['icon_size']) * bar_size
            self.draw_x, self.draw_y = 0, 0

        elif self.cfg['position'] == "right":
            if self.cfg['bar_style'] == 0:
                self.bar_pos_x = self.monitor_w - self.bar_width + 1
            else:
                self.bar_pos_x = self.monitor_w - self.bar_width - self.cfg[
                    'offset_pos']

            if self.cfg['align'] == "start":
                self.bar_pos_y = 0 + self.cfg['offset_align']
            elif self.cfg['align'] == "center":
                self.bar_pos_y = (self.monitor_h - self.bar_height) // 2
            elif self.cfg['align'] == "end":
                self.bar_pos_y = self.monitor_h - self.bar_height - self.cfg[
                    'offset_align']

            self.bar_hide_y = self.bar_pos_y
            self.bar_hide_x = self.monitor_w - self.cfg['hidden_size']

            ## for expose
            self.draw_height = self.bar_height
            self.draw_width = (2 * self.cfg['padding'] +
                               self.cfg['icon_size']) * bar_size
            self.draw_x = self.bar_width - (2 * self.cfg['padding'] +
                                            self.cfg['icon_size']) * bar_size
            self.draw_y = 0

        self.draw_width = int(self.draw_width)
        self.draw_height = int(self.draw_height)
        self.draw_x = int(self.draw_x + self.monitor_x)
        self.draw_y = int(self.draw_y + self.monitor_y)

        self.bg_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
                                             self.bar_width, self.bar_height)
        self.draw_bg()
        self.init_flag = True
示例#50
0
 def composite_changed(self, widget):
     core.logINFO('composite changed', 'BarManager')
     
     self.is_composited = self.win.is_composited()
     self.update_all()
示例#51
0
    def composite_changed(self, widget):
        core.logINFO("composite changed", "BarManager")

        self.is_composited = self.win.is_composited()
        self.update_all()