Added Workspace number with icons in dock
This commit is contained in:
1 parent
5f4bb8d342
commit
0d57188da8
2 files changed
+45
-5
No files matched your search
+34
-4
@@ -2,6 +2,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import cairo
|
import cairo
|
||||||
|
from fabric.widgets.widget import Widget
|
||||||
from gi.repository import Gdk, GLib, Gtk
|
from gi.repository import Gdk, GLib, Gtk
|
||||||
|
|
||||||
import config.data as data
|
import config.data as data
|
||||||
@@ -17,7 +18,9 @@ from fabric.utils.helpers import get_desktop_applications
|
|||||||
from fabric.widgets.box import Box
|
from fabric.widgets.box import Box
|
||||||
from fabric.widgets.button import Button
|
from fabric.widgets.button import Button
|
||||||
from fabric.widgets.eventbox import EventBox
|
from fabric.widgets.eventbox import EventBox
|
||||||
|
from fabric.widgets.overlay import Overlay
|
||||||
from fabric.widgets.image import Image
|
from fabric.widgets.image import Image
|
||||||
|
from fabric.widgets.label import Label
|
||||||
from fabric.widgets.revealer import Revealer
|
from fabric.widgets.revealer import Revealer
|
||||||
from modules.corners import MyCorner
|
from modules.corners import MyCorner
|
||||||
from utils.icon_resolver import IconResolver
|
from utils.icon_resolver import IconResolver
|
||||||
@@ -351,8 +354,9 @@ class Dock(Window):
|
|||||||
self.app_map = {app.name: app for app in self._all_apps if app.name}
|
self.app_map = {app.name: app for app in self._all_apps if app.name}
|
||||||
self.app_identifiers = self._build_app_identifiers_map()
|
self.app_identifiers = self._build_app_identifiers_map()
|
||||||
|
|
||||||
def create_button(self, app_identifier, instances):
|
def create_button(self, app_identifier, instances, workspace: str):
|
||||||
desktop_app = self.find_app(app_identifier)
|
desktop_app = self.find_app(app_identifier)
|
||||||
|
# print("Creating button for app identifier:", app_identifier)
|
||||||
icon_img = None
|
icon_img = None
|
||||||
display_name = None
|
display_name = None
|
||||||
|
|
||||||
@@ -425,7 +429,18 @@ class Dock(Window):
|
|||||||
button.connect("drag-data-get", self.on_drag_data_get)
|
button.connect("drag-data-get", self.on_drag_data_get)
|
||||||
button.connect("drag-data-received", self.on_drag_data_received)
|
button.connect("drag-data-received", self.on_drag_data_received)
|
||||||
button.connect("enter-notify-event", self._on_child_enter)
|
button.connect("enter-notify-event", self._on_child_enter)
|
||||||
return button
|
overlay = Overlay(
|
||||||
|
overlays=Label(
|
||||||
|
label=workspace,
|
||||||
|
name="dock-app-overlay-label",
|
||||||
|
h_align="end",
|
||||||
|
v_align="start",
|
||||||
|
visible=bool(workspace),
|
||||||
|
),
|
||||||
|
child=button,
|
||||||
|
name="dock-app-overlay",
|
||||||
|
)
|
||||||
|
return overlay
|
||||||
|
|
||||||
def handle_app(self, app_identifier, instances, desktop_app=None):
|
def handle_app(self, app_identifier, instances, desktop_app=None):
|
||||||
if not instances:
|
if not instances:
|
||||||
@@ -613,10 +628,23 @@ class Dock(Window):
|
|||||||
used_window_classes.add(matched_class)
|
used_window_classes.add(matched_class)
|
||||||
used_window_classes.add(self._normalize_window_class(matched_class))
|
used_window_classes.add(self._normalize_window_class(matched_class))
|
||||||
|
|
||||||
pinned_buttons.append(self.create_button(app_data_item, instances))
|
workspace = (
|
||||||
|
str(instances[0].get("workspace", {}).get("id", ""))
|
||||||
|
if instances
|
||||||
|
else ""
|
||||||
|
)
|
||||||
|
pinned_buttons.append(
|
||||||
|
self.create_button(app_data_item, instances, workspace)
|
||||||
|
)
|
||||||
|
|
||||||
open_buttons = []
|
open_buttons = []
|
||||||
for class_name, instances in running_windows.items():
|
for class_name, instances in running_windows.items():
|
||||||
|
# print(class_name, instances)
|
||||||
|
workspace = (
|
||||||
|
str(instances[0].get("workspace", {}).get("id", ""))
|
||||||
|
if instances
|
||||||
|
else ""
|
||||||
|
)
|
||||||
if class_name not in used_window_classes:
|
if class_name not in used_window_classes:
|
||||||
app = None
|
app = None
|
||||||
app = self.app_identifiers.get(class_name)
|
app = self.app_identifiers.get(class_name)
|
||||||
@@ -642,7 +670,9 @@ class Dock(Window):
|
|||||||
identifier = app_data_obj
|
identifier = app_data_obj
|
||||||
else:
|
else:
|
||||||
identifier = class_name
|
identifier = class_name
|
||||||
open_buttons.append(self.create_button(identifier, instances))
|
open_buttons.append(
|
||||||
|
self.create_button(identifier, instances, workspace)
|
||||||
|
)
|
||||||
|
|
||||||
children = pinned_buttons
|
children = pinned_buttons
|
||||||
separator_orientation = (
|
separator_orientation = (
|
||||||
|
|||||||
+11
-1
@@ -1,5 +1,5 @@
|
|||||||
#dock {
|
#dock {
|
||||||
background-color: alpha(var(--shadow), 0.4);
|
background-color: alpha(#fff, 0.05);
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
margin: 8px 8px 5px 8px;
|
margin: 8px 8px 5px 8px;
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
@@ -7,6 +7,16 @@
|
|||||||
/* transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); */
|
/* transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#dock-app-overlay {
|
||||||
|
}
|
||||||
|
#dock-app-overlay label {
|
||||||
|
background-color: alpha(#000, 0.5);
|
||||||
|
font-size: 12px;
|
||||||
|
font-family: "SF Pro Rounded";
|
||||||
|
margin-top: 20px;
|
||||||
|
min-width: 17px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
#dock.vertical {
|
#dock.vertical {
|
||||||
margin: 8px 0 8px 8px;
|
margin: 8px 0 8px 8px;
|
||||||
border-radius: 20px 0 0 20px;
|
border-radius: 20px 0 0 20px;
|
||||||
|
|||||||
Reference in new issue
Block a user