Example #1
0
    def getDesktopNames(self):
        """ Populate the desktop obj with the names of each desktop """
        if not DESKTOP:
            return

        if SHADOWS:
            shadow = self.getColor(DESKTOP_SHADOW_COLOR)
        else:
            shadow = None

        color = self.getColor(DESKTOP_COLOR)
        desktop = self.panel[DESKTOP]
        desktop.names = []
        desktop.total = self.root.get_full_property(self._DESKTOP_COUNT, 0).value[0]

        if DESKTOP_NAMES:
            names = DESKTOP_NAMES
        else:
            names = self.root.get_full_property(self._DESKTOP_NAMES, 0)
            if hasattr(names, "value"):
                names = names.value.split("\x00")
            else:
                names = []
                for x in range(desktop.total):
                    names.append(str(x))

        if len(names) < desktop.total:
            for x in range(len(names), desktop.total):
                names.append(str(x))

        for name in names:
            obj = Obj(name=name, width=ppfontsize(name), color=color, shadow=shadow)
            desktop.names.append(obj)
Example #2
0
    def getDesktopNames(self):
        #-------------------------
        """ Populate the desktop obj with the names of each desktop """
        if not DESKTOP:
            return

        if SHADOWS:
            shadow = self.getColor(DESKTOP_SHADOW_COLOR)
        else:
            shadow = None

        color = self.getColor(DESKTOP_COLOR)
        desktop = self.panel[DESKTOP]
        desktop.names = []
        desktop.total = self.root.get_full_property(self._DESKTOP_COUNT,
                                                    0).value[0]

        if DESKTOP_NAMES:
            names = DESKTOP_NAMES
        else:
            names = self.root.get_full_property(self._DESKTOP_NAMES, 0)
            if hasattr(names, "value"):
                names = names.value.split("\x00")
            else:
                names = []
                for x in range(desktop.total):
                    names.append(str(x))

        if len(names) < desktop.total:
            for x in range(len(names), desktop.total):
                names.append(str(x))

        for name in names:
            obj = Obj(name=name,
                      width=ppfontsize(name),
                      color=color,
                      shadow=shadow)
            desktop.names.append(obj)
Example #3
0
    def updatePanel(self, root, win, panel):
        """ Redraw the panel """
        tasks = panel[TASKS].tasks  # all tasks
        visible = []  # visible tasks
        curr_x = 0
        space = P_WIDTH
        cdt = self.getDesktop()
        clock = None
        desktop = None
        tray = None
        launcher = None

        if CLOCK:
            clock = panel[CLOCK]
            clock.name = self.getClockData()
            clock.width = ppfontsize(clock.name) + 2
            space -= clock.width + P_SPACER * 2
        if DESKTOP:
            desktop = panel[DESKTOP]
            space -= desktop.names[cdt].width + P_SPACER * 2
        if LAUNCHER and panel[LAUNCHER].tasks:
            launcher = panel[LAUNCHER]
            space -= len(launcher.order) * APPL_I_WIDTH + 2
        if TRAY and panel[TRAY].tasks:
            tray = panel[TRAY]
            space -= 2
            for t in panel[TRAY].tasks.values():
                if TRAY_I_WIDTH:
                    t.width = TRAY_I_WIDTH
                    space -= t.width
                else:
                    try:
                        t.width = t.obj.get_wm_normal_hints().min_width
                        space -= t.width
                    except:
                        pass
        if TASKS and tasks:
            for task in panel[TASKS].order:
                t = tasks[task]
                t.visible = 0
                if not t.hidden:
                    if SHOWALL or (t.desk == cdt or t.desk == 0xffffffffL):
                        t.visible = 1
                    if SHOWMINIMIZED and self._HIDDEN not in t.state:
                        t.visible = 0
                    if t.visible:
                        visible.append(task)

        # Clear the panel and add the objects
        self.updateBackground(root, win)
        self.clearPanel(0, 0, 0, 0)

        for section in panel["sections"]:
            if panel[section].id == "tasks" and TASKS:
                if not visible:
                    curr_x += space
                else:
                    final_x = curr_x + space
                    if T_FILL:
                        limit = space / float(len(visible)) - P_SPACER * 2
                    else:
                        limit = T_WIDTH - P_SPACER * 2 if float(len(visible)) * (
                        T_WIDTH + P_SPACER * 2) < space else space / float(len(visible)) - P_SPACER * 2
                    if APPICONS:
                        limit -= I_WIDTH + P_SPACER
                    if limit < 1:
                        limit = 1
                    for v in range(len(visible)):
                        t = tasks[visible[v]]
                        t.x1 = curr_x
                        curr_x += P_SPACER
                        if self.getIcon(t, curr_x):
                            curr_x += I_WIDTH + P_SPACER
                        self.drawText(t, curr_x, limit)
                        curr_x += limit + P_SPACER
                        t.x2 = curr_x
                        if v < len(visible) and SHOWLINES:
                            win.poly_segment(self.lgc, [(curr_x, 0, curr_x, P_HEIGHT)])
                    curr_x = final_x
                if SHOWLINES and not panel[section].last:
                    win.poly_segment(self.lgc, [(curr_x, 0, curr_x, P_HEIGHT)])
            elif panel[section].id == "clock":
                clock.x1 = curr_x
                curr_x += P_SPACER
                self.drawText(clock, curr_x, 0)
                curr_x += clock.width + P_SPACER
                clock.x2 = curr_x
                if SHOWLINES and not clock.last:
                    win.poly_segment(self.lgc, [(curr_x, 0, curr_x, P_HEIGHT)])
            elif panel[section].id == "desktop":
                desk = panel[section].names[cdt]
                desktop.x1 = curr_x
                curr_x += P_SPACER
                self.drawText(desk, curr_x, 0)
                curr_x += desk.width + P_SPACER
                desktop.x2 = curr_x
                if SHOWLINES and not desktop.last:
                    win.poly_segment(self.lgc, [(curr_x, 0, curr_x, P_HEIGHT)])
            elif panel[section].id == "tray" and tray:
                curr_x += 2
                for tid in tray.order:
                    t = tray.tasks[tid]
                    t.x = curr_x
                    t.y = (P_HEIGHT - t.height) / 2
                    t.obj.configure(onerror=self.error, x=curr_x, y=t.y,
                                    width=t.width, height=t.height)
                    t.obj.map(onerror=self.error)
                    curr_x += t.width
                curr_x += 1
                if SHOWLINES and not tray.last:
                    win.poly_segment(self.lgc, [(curr_x, 0, curr_x, P_HEIGHT)])
            elif panel[section].id == "launcher" and launcher:
                curr_x += 2
                for app in launcher.order:
                    a = launcher.tasks[app]
                    a.x1 = curr_x
                    if self.getIcon(a, curr_x, 1):
                        curr_x += APPL_I_WIDTH
                    a.x2 = curr_x
                curr_x += 1
                if SHOWLINES and not launcher.last:
                    win.poly_segment(self.lgc, [(curr_x, 0, curr_x, P_HEIGHT)])
Example #4
0
    def updatePanel(self, root, win, panel):
        #---------------------------------------
        """ Redraw the panel """
        tasks = panel[TASKS].tasks  # all tasks
        visible = []  # visible tasks
        curr_x = 0
        space = P_WIDTH
        cdt = self.getDesktop()
        clock = None
        desktop = None
        tray = None
        launcher = None

        if CLOCK:
            clock = panel[CLOCK]
            clock.name = self.getClockData()
            clock.width = ppfontsize(clock.name) + 2
            space -= clock.width + P_SPACER * 2
        if DESKTOP:
            desktop = panel[DESKTOP]
            space -= desktop.names[cdt].width + P_SPACER * 2
        if LAUNCHER and panel[LAUNCHER].tasks:
            launcher = panel[LAUNCHER]
            space -= len(launcher.order) * APPL_I_WIDTH + 2
        if TRAY and panel[TRAY].tasks:
            tray = panel[TRAY]
            space -= 2
            for t in panel[TRAY].tasks.values():
                if TRAY_I_WIDTH:
                    t.width = TRAY_I_WIDTH
                    space -= t.width
                else:
                    try:
                        t.width = t.obj.get_wm_normal_hints().min_width
                        space -= t.width
                    except:
                        pass
        if TASKS and tasks:
            for task in panel[TASKS].order:
                t = tasks[task]
                t.visible = 0
                if not t.hidden:
                    if SHOWALL or (t.desk == cdt or t.desk == 0xffffffffL):
                        t.visible = 1
                    if SHOWMINIMIZED and self._HIDDEN not in t.state:
                        t.visible = 0
                    if t.visible:
                        visible.append(task)

        # Clear the panel and add the objects
        self.updateBackground(root, win)
        self.clearPanel(0, 0, 0, 0)

        for section in panel["sections"]:
            if panel[section].id == "tasks" and TASKS:
                if not visible:
                    curr_x += space
                else:
                    final_x = curr_x + space
                    if T_FILL:
                        limit = space / float(len(visible)) - P_SPACER * 2
                    else:
                        limit = T_WIDTH - P_SPACER * 2 if float(
                            len(visible)) * (T_WIDTH + P_SPACER *
                                             2) < space else space / float(
                                                 len(visible)) - P_SPACER * 2
                    if APPICONS:
                        limit -= I_WIDTH + P_SPACER
                    if limit < 1:
                        limit = 1
                    for v in range(len(visible)):
                        t = tasks[visible[v]]
                        t.x1 = curr_x
                        curr_x += P_SPACER
                        if self.getIcon(t, curr_x):
                            curr_x += I_WIDTH + P_SPACER
                        self.drawText(t, curr_x, limit)
                        curr_x += limit + P_SPACER
                        t.x2 = curr_x
                        if v < len(visible) and SHOWLINES:
                            win.poly_segment(self.lgc,
                                             [(curr_x, 0, curr_x, P_HEIGHT)])
                    curr_x = final_x
                if SHOWLINES and not panel[section].last:
                    win.poly_segment(self.lgc, [(curr_x, 0, curr_x, P_HEIGHT)])
            elif panel[section].id == "clock":
                clock.x1 = curr_x
                curr_x += P_SPACER
                self.drawText(clock, curr_x, 0)
                curr_x += clock.width + P_SPACER
                clock.x2 = curr_x
                if SHOWLINES and not clock.last:
                    win.poly_segment(self.lgc, [(curr_x, 0, curr_x, P_HEIGHT)])
            elif panel[section].id == "desktop":
                desk = panel[section].names[cdt]
                desktop.x1 = curr_x
                curr_x += P_SPACER
                self.drawText(desk, curr_x, 0)
                curr_x += desk.width + P_SPACER
                desktop.x2 = curr_x
                if SHOWLINES and not desktop.last:
                    win.poly_segment(self.lgc, [(curr_x, 0, curr_x, P_HEIGHT)])
            elif panel[section].id == "tray" and tray:
                curr_x += 2
                for tid in tray.order:
                    t = tray.tasks[tid]
                    t.x = curr_x
                    t.y = (P_HEIGHT - t.height) / 2
                    t.obj.configure(onerror=self.error,
                                    x=curr_x,
                                    y=t.y,
                                    width=t.width,
                                    height=t.height)
                    t.obj.map(onerror=self.error)
                    curr_x += t.width
                curr_x += 1
                if SHOWLINES and not tray.last:
                    win.poly_segment(self.lgc, [(curr_x, 0, curr_x, P_HEIGHT)])
            elif panel[section].id == "launcher" and launcher:
                curr_x += 2
                for app in launcher.order:
                    a = launcher.tasks[app]
                    a.x1 = curr_x
                    if self.getIcon(a, curr_x, 1):
                        curr_x += APPL_I_WIDTH
                    a.x2 = curr_x
                curr_x += 1
                if SHOWLINES and not launcher.last:
                    win.poly_segment(self.lgc, [(curr_x, 0, curr_x, P_HEIGHT)])