Esempio n. 1
0
    def new_from_file(cls, builder_file_name):
        """Return a fully-instantiated Gtk.Builder instance from specified ui
        file

        :param builder_file_name: The name of the builder file, without extension.
            Assumed to be in the 'ui' directory under the data path.
        """
        # Look for the ui file that describes the user interface.
        ui_filename = get_asset(f'ui/{builder_file_name}.ui')
        if not os.path.exists(ui_filename):
            ui_filename = None

        builder = cls()
        builder.set_translation_domain('ulauncher')
        builder.add_from_file(ui_filename)
        return builder
Esempio n. 2
0
    def create_item_widgets(items, query):
        results = []
        for index, result in enumerate(items):
            glade_filename = get_asset(f"ui/{result.UI_FILE}.ui")
            if not os.path.exists(glade_filename):
                glade_filename = None

            builder = Gtk.Builder()
            builder.set_translation_domain('ulauncher')
            builder.add_from_file(glade_filename)

            item_frame = builder.get_object('item-frame')
            item_frame.initialize(builder, result, index, query)

            results.append(item_frame)

        return results
Esempio n. 3
0
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
# pylint: disable=wrong-import-position
from gi.repository import Gtk, Gdk, GObject
from ulauncher.config import get_asset

logger = logging.getLogger()

FORBIDDEN_ACCEL_KEYS = ('Delete', 'Page_Down', 'Page_Up', 'Home', 'End', 'Up',
                        'Down', 'Left', 'Right', 'Return', 'BackSpace',
                        'Alt_L', 'Alt_R', 'Shift_L', 'Shift_R', 'Control_L',
                        'Control_R', 'space', 'Escape', 'Tab', 'Insert')


@Gtk.Template(filename=get_asset("ui/hotkey_dialog.ui"))
class HotkeyDialog(Gtk.Window):
    __gtype_name__ = "HotkeyDialog"
    _accel_name = None
    _display_name = None
    __gsignals__ = {
        # parameters: <hotkey-value (str)>, <hotkey-display-value (str)>
        'hotkey-set': (GObject.SignalFlags.RUN_LAST, GObject.TYPE_NONE,
                       (GObject.TYPE_STRING, GObject.TYPE_STRING))
    }
    _hotkey_input: Gtk.Entry  # Have to be declared on a separate line for some reason
    _hotkey_input = Gtk.Template.Child("hotkey_input")

    @Gtk.Template.Callback()
    def on_destroy(self, *args):
        self.hide()
Esempio n. 4
0
 def _render_prefs_icon(self):
     prefs_pixbuf = load_icon(get_asset('icons/gear.svg'),
                              16 * get_scaling_factor())
     prefs_image = Gtk.Image.new_from_pixbuf(prefs_pixbuf)
     self.prefs_btn.set_image(prefs_image)
Esempio n. 5
0
from ulauncher.ui.ItemNavigation import ItemNavigation
from ulauncher.modes.ModeHandler import ModeHandler
from ulauncher.modes.apps.AppResult import AppResult
from ulauncher.utils.Settings import Settings
from ulauncher.utils.decorator.singleton import singleton
from ulauncher.utils.timer import timer
from ulauncher.utils.wm import get_monitor, get_scaling_factor
from ulauncher.utils.icon import load_icon
from ulauncher.utils.environment import IS_X11_COMPATIBLE
from ulauncher.utils.Theme import Theme, load_available_themes
from ulauncher.api.shared.query import Query

logger = logging.getLogger()


@Gtk.Template(filename=get_asset("ui/ulauncher_window.ui"))
class UlauncherWindow(Gtk.ApplicationWindow):
    __gtype_name__ = "UlauncherWindow"
    input: Gtk.Entry  # These have to be declared on a separate line for some reason
    prefs_btn: Gtk.Button
    result_box: Gtk.Box
    scroll_container: Gtk.ScrolledWindow
    window_body: Gtk.Box

    input = Gtk.Template.Child("input")
    prefs_btn = Gtk.Template.Child("prefs_btn")
    result_box = Gtk.Template.Child("result_box")
    scroll_container = Gtk.Template.Child("result_box_scroll_container")
    window_body = Gtk.Template.Child("body")
    results_nav = None
    settings = Settings.get_instance()
Esempio n. 6
0
import logging
import mimetypes
from os.path import join
from functools import lru_cache

import gi
gi.require_version('Gtk', '3.0')
gi.require_version('GdkPixbuf', '2.0')
# pylint: disable=wrong-import-position
from gi.repository import Gtk, GdkPixbuf
from ulauncher.config import get_asset

icon_theme = Gtk.IconTheme.get_default()
logger = logging.getLogger()

DEFAULT_EXE_ICON = get_asset("icons/executable.png")


def get_icon_path(icon, size=32, base_path=""):
    """
    :param str icon:
    :rtype: str
    """
    try:
        if icon and isinstance(icon, str):
            if icon.startswith("/"):
                return icon

            if "/" in icon or mimetypes.guess_type(icon)[0]:
                return join(base_path, icon)
Esempio n. 7
0
 def __init__(self, result: Decimal = None, error: str = 'Unknown error'):
     self.result = result
     self.error = error
     self.name = f'{Decimal(self.result):n}' if self.result is not None else 'Error!'
     self.description = 'Enter to copy to the clipboard' if self.result is not None else error
     self.icon = get_asset('icons/calculator.png')