示例#1
0
    def check_scratchpad(self, tree):
        content = []

        scratchpad = tree.find_named('__i3_scratch')
        leaves = scratchpad[0].floating_nodes

        for node in leaves:
            aid = node.app_id if node.app_id else node.window_class
            if aid:
                pid = node.pid
                if node.app_id:
                    icon = get_icon(node.app_id)
                elif node.window_class:
                    icon = get_icon(node.window_class)
                else:
                    icon = "icon-missing"

                item = {
                    "aid": aid,
                    "pid": pid,
                    "icon": icon,
                    "name": node.name
                }
                content.append(item)

        if content != self.content:
            self.content = content
            self.build_box()
示例#2
0
 def update_icon(self, win_id, win_name):
     if win_id and win_name:
         icon_from_desktop = get_icon(win_id)
         if icon_from_desktop:
             if "/" not in icon_from_desktop and not icon_from_desktop.endswith(
                     ".svg") and not icon_from_desktop.endswith(".png"):
                 update_image(self.icon, icon_from_desktop, self.settings["image-size"], self.icons_path)
             else:
                 pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_from_desktop, self.settings["image-size"],
                                                                 self.settings["image-size"])
                 self.icon.set_from_pixbuf(pixbuf)
         else:
             image = Gtk.Image()
             update_image(image, win_id, self.settings["image-size"], self.icons_path)
         
         if not self.icon.get_visible():
             self.icon.show()
     else:
         if self.icon.get_visible():
             self.icon.hide()
示例#3
0
    def __init__(self, con, settings, position):
        self.position = position
        self.settings = settings
        Gtk.EventBox.__init__(self)
        check_key(settings, "task-spacing", 0)
        self.box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                           spacing=settings["task-spacing"]
                           if settings["task-spacing"] else 0)
        self.add(self.box)
        self.con = con
        self.pid = con.pid

        self.old_name = ""

        if con.focused:
            self.box.set_property("name", "task-box-focused")
        else:
            self.box.set_property("name", "task-box")

        self.connect('enter-notify-event', self.on_enter_notify_event)
        self.connect('leave-notify-event', self.on_leave_notify_event)
        self.connect('button-press-event', self.on_click, self.box)
        self.add_events(Gdk.EventMask.SCROLL_MASK)
        self.connect('scroll-event', self.on_scroll)

        check_key(settings, "show-app-icon", True)
        if settings["show-app-icon"]:
            name = con.app_id if con.app_id else con.window_class

            icon_from_desktop = get_icon(name)
            if icon_from_desktop:
                if "/" not in icon_from_desktop and not icon_from_desktop.endswith(
                        ".svg") and not icon_from_desktop.endswith(".png"):
                    image = Gtk.Image()
                    update_image(image, icon_from_desktop,
                                 settings["image-size"])
                else:
                    pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                        icon_from_desktop, settings["image-size"],
                        settings["image-size"])
                    image = Gtk.Image.new_from_pixbuf(pixbuf)

                self.box.pack_start(image, False, False, 4)
            else:
                image = Gtk.Image()
                update_image(image, name, settings["image-size"])
                self.box.pack_start(image, False, False, 4)

        if con.name:
            check_key(settings, "name-max-len", 10)
            name = con.name[:settings["name-max-len"]] if len(
                con.name) > settings["name-max-len"] else con.name
            label = Gtk.Label(name)
            self.box.pack_start(label, False, False, 0)

        check_key(settings, "show-layout", True)
        if settings["show-layout"] and con.parent.layout:
            if con.parent.layout == "splith":
                image = Gtk.Image()
                update_image(image, "go-next", 16)
            elif con.parent.layout == "splitv":
                image = Gtk.Image()
                update_image(image, "go-down", 16)
            elif con.parent.layout == "tabbed":
                image = Gtk.Image()
                update_image(image, "view-dual", 16)
            elif con.parent.layout == "stacked":
                image = Gtk.Image()
                update_image(image, "view-paged", 16)
            else:
                image = Gtk.Image()
                update_image(image, "window-new", 16)

            self.box.pack_start(image, False, False, 4)
示例#4
0
    def __init__(self, con, settings, position, icons_path, floating=False):
        self.position = position
        self.settings = settings
        Gtk.EventBox.__init__(self)
        self.box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
        self.add(self.box)
        self.con = con
        self.pid = con.pid
        self.icons_path = icons_path

        self.old_name = ""

        if con.focused:
            self.box.set_property("name", "task-box-focused")
        else:
            self.box.set_property("name", "task-box")

        self.connect('enter-notify-event', self.on_enter_notify_event)
        self.connect('leave-notify-event', self.on_leave_notify_event)
        self.connect('button-press-event', self.on_click, self.box)
        self.add_events(Gdk.EventMask.SCROLL_MASK)
        self.connect('scroll-event', self.on_scroll)

        check_key(settings, "show-app-icon", True)
        if settings["show-app-icon"]:
            name = con.app_id if con.app_id else con.window_class

            icon_from_desktop = get_icon(name)
            if icon_from_desktop:
                if "/" not in icon_from_desktop and not icon_from_desktop.endswith(
                        ".svg") and not icon_from_desktop.endswith(".png"):
                    image = Gtk.Image()
                    update_image(image, icon_from_desktop,
                                 settings["image-size"], icons_path)
                else:
                    try:
                        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                            icon_from_desktop, settings["image-size"],
                            settings["image-size"])
                    except:
                        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                            os.path.join(get_config_dir(),
                                         "icons_light/icon-missing.svg"),
                            settings["image-size"], settings["image-size"])
                    image = Gtk.Image.new_from_pixbuf(pixbuf)

                self.box.pack_start(image, False, False, 4)
            else:
                image = Gtk.Image()
                update_image(image, name, settings["image-size"], icons_path)
                self.box.pack_start(image, False, False, 4)

        if con.name:
            check_key(settings, "show-app-name", True)
            name = con.name[:settings["name-max-len"]] if len(
                con.name) > settings["name-max-len"] else con.name
            if settings["show-app-name"]:
                check_key(settings, "name-max-len", 10)
                label = Gtk.Label(name)
                self.box.pack_start(label, False, False, 0)
            else:
                self.set_tooltip_text(name)

        check_key(settings, "show-layout", True)

        if settings["show-layout"] and con.parent.layout:
            if con.parent.layout == "splith":
                image = Gtk.Image()
                update_image(image, "go-next-symbolic", 16, icons_path)
            elif con.parent.layout == "splitv":
                image = Gtk.Image()
                update_image(image, "go-down-symbolic", 16, icons_path)
            elif con.parent.layout == "tabbed":
                image = Gtk.Image()
                update_image(image, "view-dual-symbolic", 16, icons_path)
            elif con.parent.layout == "stacked":
                image = Gtk.Image()
                update_image(image, "view-paged-symbolic", 16, icons_path)

            if floating:
                image = Gtk.Image()
                update_image(image, "window-pop-out-symbolic", 16, icons_path)

            self.box.pack_start(image, False, False, 4)