refactor(modules): Clean up imports and centralize utilities- Enhancements:
- Remove redundant gi.repository imports - Move common utilities (GLib, GObject, logger, os) into fabric.utils - Centralize GLib usage and reduce namespace pollution
This commit is contained in:
12 files changed
+25
-41
No files matched your search
@@ -1,6 +1,5 @@
|
||||
# Standard library imports
|
||||
import gc
|
||||
import os
|
||||
import re
|
||||
import tempfile
|
||||
import threading
|
||||
@@ -9,7 +8,15 @@ import urllib.request
|
||||
import weakref
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from fabric.utils import bulk_connect, cooldown, invoke_repeater
|
||||
from fabric.utils import (
|
||||
bulk_connect,
|
||||
cooldown,
|
||||
invoke_repeater,
|
||||
GLib,
|
||||
GObject,
|
||||
logger,
|
||||
os,
|
||||
)
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.image import Image
|
||||
@@ -20,8 +27,6 @@ from fabric.widgets.overlay import Overlay
|
||||
from fabric.widgets.scale import Scale
|
||||
from fabric.widgets.stack import Stack
|
||||
from fabric.widgets.wayland import WaylandWindow as Window
|
||||
from gi.repository import GLib, GObject
|
||||
from loguru import logger
|
||||
|
||||
import config.data as data
|
||||
|
||||
@@ -908,8 +913,6 @@ class PlayerBox(Box):
|
||||
# Cancel seek bar timer
|
||||
if self._seekbar_timer_id:
|
||||
try:
|
||||
from gi.repository import GLib
|
||||
|
||||
GLib.source_remove(self._seekbar_timer_id)
|
||||
except Exception:
|
||||
pass
|
||||
@@ -1038,8 +1041,6 @@ class PlayerBox(Box):
|
||||
# Restart timer to ensure it's running with updated metadata
|
||||
if self._seekbar_timer_id:
|
||||
try:
|
||||
from gi.repository import GLib
|
||||
|
||||
GLib.source_remove(self._seekbar_timer_id)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from typing import List
|
||||
|
||||
from fabric.utils import (
|
||||
bulk_connect,
|
||||
)
|
||||
from fabric.utils.helpers import get_relative_path
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.centerbox import CenterBox
|
||||
@@ -14,8 +9,8 @@ from fabric.widgets.image import Image
|
||||
from fabric.widgets.label import Label
|
||||
from fabric.widgets.overlay import Overlay
|
||||
from fabric.widgets.stack import Stack
|
||||
from gi.repository import Gio, GLib, GObject
|
||||
from loguru import logger
|
||||
|
||||
from fabric.utils import GLib, GObject, Gio, logger, bulk_connect, get_relative_path, os
|
||||
|
||||
import config.data as data
|
||||
from services.mpris import MprisPlayer, MprisPlayerManager
|
||||
|
||||
@@ -14,6 +14,7 @@ from services.network import NetworkClient
|
||||
from utils.functions import get_wifi_connecting_icon, get_wifi_icon_for_strength
|
||||
from utils.utils import svg_file
|
||||
from widgets.wifi_password_dialog import WiFiPasswordDialog
|
||||
from gi.repository import NM
|
||||
|
||||
|
||||
class WifiNetworkSlot(Box):
|
||||
@@ -202,7 +203,6 @@ class WifiNetworkSlot(Box):
|
||||
if success:
|
||||
self.is_connected = True
|
||||
# Remove connecting state after a short delay
|
||||
from gi.repository import GLib
|
||||
|
||||
GLib.timeout_add(500, lambda: self._reset_connect_state())
|
||||
|
||||
@@ -544,8 +544,6 @@ class WifiConnections(Box):
|
||||
# Compare SSIDs
|
||||
connection_ssid_bytes = wifi_setting.get_ssid()
|
||||
if connection_ssid_bytes:
|
||||
from gi.repository import NM
|
||||
|
||||
connection_ssid = NM.utils_ssid_to_utf8(
|
||||
connection_ssid_bytes.get_data()
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ from fabric.widgets.box import Box
|
||||
from fabric.widgets.entry import Entry
|
||||
from fabric.widgets.scrolledwindow import ScrolledWindow
|
||||
from fabric.widgets.wayland import WaylandWindow as Window
|
||||
from gi.repository import Gdk, GLib
|
||||
from fabric.utils import Gdk, GLib
|
||||
|
||||
from modules.launcher.plugin_manager import PluginManager
|
||||
from modules.launcher.result import Result
|
||||
|
||||
@@ -6,9 +6,10 @@ from pathlib import Path
|
||||
from typing import Dict, List, Optional
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from fabric.utils import GLib
|
||||
from fabric.utils.helpers import get_relative_path
|
||||
from thefuzz import fuzz
|
||||
|
||||
from fabric.utils.helpers import get_relative_path
|
||||
from modules.launcher.plugin_base import PluginBase
|
||||
from modules.launcher.result import Result
|
||||
|
||||
@@ -739,7 +740,6 @@ class BookmarksPlugin(PluginBase):
|
||||
|
||||
# Reset to trigger word with space
|
||||
try:
|
||||
from gi.repository import GLib
|
||||
|
||||
def reset_and_refresh():
|
||||
# Set text to trigger word
|
||||
@@ -772,7 +772,6 @@ class BookmarksPlugin(PluginBase):
|
||||
|
||||
# Trigger a search to refresh results
|
||||
try:
|
||||
from gi.repository import GLib
|
||||
|
||||
def refresh():
|
||||
self._launcher_instance._perform_search(current_text)
|
||||
|
||||
@@ -7,7 +7,7 @@ import time
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from gi.repository import GdkPixbuf, GLib
|
||||
from fabric.utils import GdkPixbuf, GLib
|
||||
|
||||
from modules.launcher.plugin_base import PluginBase
|
||||
from modules.launcher.result import Result
|
||||
@@ -85,7 +85,6 @@ class ClipboardPlugin(PluginBase):
|
||||
def _force_launcher_refresh(self):
|
||||
"""Force the launcher to refresh its results."""
|
||||
try:
|
||||
from gi.repository import GLib
|
||||
|
||||
def trigger_refresh():
|
||||
try:
|
||||
|
||||
@@ -5,7 +5,8 @@ import time
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from fabric.utils import get_relative_path
|
||||
from fabric.utils import GLib, get_relative_path
|
||||
|
||||
from modules.launcher.plugin_base import PluginBase
|
||||
from modules.launcher.result import Result
|
||||
from services.auth import (
|
||||
@@ -99,8 +100,6 @@ class OTPPlugin(PluginBase):
|
||||
try:
|
||||
import gc
|
||||
|
||||
from gi.repository import GLib
|
||||
|
||||
def do_update():
|
||||
try:
|
||||
for obj in gc.get_objects():
|
||||
@@ -230,8 +229,6 @@ class OTPPlugin(PluginBase):
|
||||
def _trigger_refresh(self):
|
||||
"""Trigger launcher refresh to return to default OTP view."""
|
||||
try:
|
||||
from gi.repository import GLib
|
||||
|
||||
# Use a small delay to ensure the action completes first
|
||||
def trigger_refresh():
|
||||
try:
|
||||
|
||||
@@ -7,7 +7,8 @@ from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from fabric.utils import get_relative_path
|
||||
from fabric.utils import GLib, get_relative_path
|
||||
|
||||
from modules.launcher.plugin_base import PluginBase
|
||||
from modules.launcher.result import Result
|
||||
|
||||
@@ -676,7 +677,6 @@ class PasswordPlugin(PluginBase):
|
||||
|
||||
# Trigger a search to refresh results
|
||||
try:
|
||||
from gi.repository import GLib
|
||||
|
||||
def refresh():
|
||||
self._launcher_instance._perform_search(current_text)
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
import colorsys
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
from typing import Dict, List, Optional
|
||||
from loguru import logger
|
||||
|
||||
from gi.repository import GdkPixbuf
|
||||
|
||||
import config.data as data
|
||||
from fabric.utils.helpers import exec_shell_command_async
|
||||
from fabric.utils import exec_shell_command_async, GdkPixbuf, logger, os, GLib
|
||||
from modules.launcher.plugin_base import PluginBase
|
||||
from modules.launcher.result import Result
|
||||
|
||||
@@ -123,7 +119,6 @@ class WallpaperPlugin(PluginBase):
|
||||
"""Clear the launcher search query and reset to trigger."""
|
||||
try:
|
||||
# Try to access the launcher through the fabric Application
|
||||
from gi.repository import GLib
|
||||
|
||||
from fabric import Application
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Callable, Optional
|
||||
|
||||
from gi.repository import GdkPixbuf, Gtk
|
||||
from fabric.utils import GdkPixbuf, Gtk
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
+1
-1
@@ -1,12 +1,12 @@
|
||||
import json
|
||||
|
||||
from fabric.hyprland.widgets import get_hyprland_connection
|
||||
from fabric.utils import Gdk
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.eventbox import EventBox
|
||||
from fabric.widgets.image import Image
|
||||
from fabric.widgets.label import Label
|
||||
from fabric.widgets.wayland import WaylandWindow as Window
|
||||
from gi.repository import Gdk
|
||||
|
||||
import config.data as data
|
||||
from utils.functions import is_special_workspace
|
||||
|
||||
@@ -7,13 +7,13 @@ from fabric.widgets.button import Button
|
||||
from fabric.widgets.entry import Entry
|
||||
from fabric.widgets.label import Label
|
||||
from fabric.widgets.scrolledwindow import ScrolledWindow
|
||||
from gi.repository import GLib
|
||||
from fabric.utils import GLib
|
||||
|
||||
# Local imports
|
||||
from utils.utils import svg_file
|
||||
from services.todo import get_todo_service
|
||||
from widgets.mousecapture import MouseCapture
|
||||
from widgets.wayland import WaylandWindow as Window
|
||||
from fabric.widgets.wayland import WaylandWindow as Window
|
||||
|
||||
|
||||
class TodoItem(Box):
|
||||
|
||||
Reference in new issue
Block a user