Scaling system icons as some do not match expected scale.
This commit is contained in:
parent
fec0d26ab7
commit
d65ea8dec8
|
@ -11,8 +11,8 @@ from gi.repository import Gdk
|
||||||
# Application imports
|
# Application imports
|
||||||
|
|
||||||
|
|
||||||
valid_keyvalue_pat = re.compile(r"[a-z0-9A-Z-_\[\]\(\)\| ]")
|
|
||||||
|
|
||||||
|
valid_keyvalue_pat = re.compile(r"[a-z0-9A-Z-_\[\]\(\)\| ]")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,12 +20,12 @@ class KeyboardSignalsMixin:
|
||||||
""" KeyboardSignalsMixin keyboard hooks controller. """
|
""" KeyboardSignalsMixin keyboard hooks controller. """
|
||||||
|
|
||||||
# TODO: Need to set methods that use this to somehow check the keybindings state instead.
|
# TODO: Need to set methods that use this to somehow check the keybindings state instead.
|
||||||
def unset_keys_and_data(self, widget=None, eve=None):
|
def unset_keys_and_data(self, widget = None, eve = None):
|
||||||
self.ctrl_down = False
|
self.ctrl_down = False
|
||||||
self.shift_down = False
|
self.shift_down = False
|
||||||
self.alt_down = False
|
self.alt_down = False
|
||||||
|
|
||||||
def unmap_special_key(self, keyname):
|
def unmap_special_keys(self, keyname):
|
||||||
if "control" in keyname:
|
if "control" in keyname:
|
||||||
self.ctrl_down = False
|
self.ctrl_down = False
|
||||||
if "shift" in keyname:
|
if "shift" in keyname:
|
||||||
|
@ -35,6 +35,10 @@ class KeyboardSignalsMixin:
|
||||||
|
|
||||||
def on_global_key_press_controller(self, eve, user_data):
|
def on_global_key_press_controller(self, eve, user_data):
|
||||||
keyname = Gdk.keyval_name(user_data.keyval).lower()
|
keyname = Gdk.keyval_name(user_data.keyval).lower()
|
||||||
|
modifiers = Gdk.ModifierType(user_data.get_state() & ~Gdk.ModifierType.LOCK_MASK)
|
||||||
|
|
||||||
|
self.was_midified_key = True if modifiers != 0 else False
|
||||||
|
|
||||||
if keyname.replace("_l", "").replace("_r", "") in ["control", "alt", "shift"]:
|
if keyname.replace("_l", "").replace("_r", "") in ["control", "alt", "shift"]:
|
||||||
if "control" in keyname:
|
if "control" in keyname:
|
||||||
self.ctrl_down = True
|
self.ctrl_down = True
|
||||||
|
@ -43,25 +47,34 @@ class KeyboardSignalsMixin:
|
||||||
if "alt" in keyname:
|
if "alt" in keyname:
|
||||||
self.alt_down = True
|
self.alt_down = True
|
||||||
|
|
||||||
|
|
||||||
def on_global_key_release_controller(self, widget, event):
|
def on_global_key_release_controller(self, widget, event):
|
||||||
"""Handler for keyboard events"""
|
""" Handler for keyboard events """
|
||||||
keyname = Gdk.keyval_name(event.keyval).lower()
|
keyname = Gdk.keyval_name(event.keyval).lower()
|
||||||
|
modifiers = Gdk.ModifierType(event.get_state() & ~Gdk.ModifierType.LOCK_MASK)
|
||||||
|
|
||||||
if keyname.replace("_l", "").replace("_r", "") in ["control", "alt", "shift"]:
|
if keyname.replace("_l", "").replace("_r", "") in ["control", "alt", "shift"]:
|
||||||
self.unmap_special_key(keyname)
|
should_return = self.was_midified_key and (self.ctrl_down or self.shift_down or self.alt_down)
|
||||||
|
self.unmap_special_keys(keyname)
|
||||||
|
|
||||||
|
if should_return:
|
||||||
|
self.was_midified_key = False
|
||||||
|
return
|
||||||
|
|
||||||
mapping = keybindings.lookup(event)
|
mapping = keybindings.lookup(event)
|
||||||
if mapping:
|
logger.debug(f"on_global_key_release_controller > key > {keyname}")
|
||||||
try:
|
logger.debug(f"on_global_key_release_controller > keyval > {event.keyval}")
|
||||||
self.handle_as_controller_scope(mapping)
|
logger.debug(f"on_global_key_release_controller > mapping > {mapping}")
|
||||||
except Exception:
|
|
||||||
self.handle_as_plugin_scope(mapping)
|
|
||||||
else:
|
|
||||||
logger.debug(f"on_global_key_release_controller > key > {keyname}")
|
|
||||||
|
|
||||||
if self.ctrl_down:
|
if mapping:
|
||||||
if keyname in ["1", "kp_1", "2", "kp_2", "3", "kp_3", "4", "kp_4"]:
|
self.handle_mapped_key_event(mapping)
|
||||||
self.builder.get_object(f"tggl_notebook_{keyname.strip('kp_')}").released()
|
else:
|
||||||
|
self.handle_as_key_event_scope(keyname)
|
||||||
|
|
||||||
|
def handle_mapped_key_event(self, mapping):
|
||||||
|
try:
|
||||||
|
self.handle_as_controller_scope(mapping)
|
||||||
|
except Exception:
|
||||||
|
self.handle_as_plugin_scope(mapping)
|
||||||
|
|
||||||
def handle_as_controller_scope(self, mapping):
|
def handle_as_controller_scope(self, mapping):
|
||||||
getattr(self, mapping)()
|
getattr(self, mapping)()
|
||||||
|
@ -73,22 +86,11 @@ class KeyboardSignalsMixin:
|
||||||
sender = ""
|
sender = ""
|
||||||
eve_type = mapping
|
eve_type = mapping
|
||||||
|
|
||||||
self.handle_as_key_event_system(sender, eve_type)
|
self.handle_key_event_system(sender, eve_type)
|
||||||
|
|
||||||
def handle_as_key_event_system(self, sender, eve_type):
|
def handle_as_key_event_scope(self, keyname):
|
||||||
|
if self.ctrl_down and not keyname in ["1", "kp_1", "2", "kp_2", "3", "kp_3", "4", "kp_4"]:
|
||||||
|
self.handle_key_event_system(None, keyname)
|
||||||
|
|
||||||
|
def handle_key_event_system(self, sender, eve_type):
|
||||||
event_system.emit(eve_type)
|
event_system.emit(eve_type)
|
||||||
|
|
||||||
def keyboard_close_tab(self):
|
|
||||||
wid, tid = self.fm_controller.get_active_wid_and_tid()
|
|
||||||
notebook = self.builder.get_object(f"window_{wid}")
|
|
||||||
scroll = self.builder.get_object(f"{wid}|{tid}", use_gtk = False)
|
|
||||||
page = notebook.page_num(scroll)
|
|
||||||
tab = self.get_fm_window(wid).get_tab_by_id(tid)
|
|
||||||
watcher = tab.get_dir_watcher()
|
|
||||||
watcher.cancel()
|
|
||||||
|
|
||||||
self.get_fm_window(wid).delete_tab_by_id(tid)
|
|
||||||
notebook.remove_page(page)
|
|
||||||
if not settings_manager.is_trace_debug():
|
|
||||||
self.fm_controller.save_state()
|
|
||||||
self.set_window_title()
|
|
|
@ -38,6 +38,7 @@ class TabMixin(GridMixin):
|
||||||
scroll, store = self.create_scroll_and_store(tab, wid)
|
scroll, store = self.create_scroll_and_store(tab, wid)
|
||||||
index = notebook.append_page(scroll, tab_widget)
|
index = notebook.append_page(scroll, tab_widget)
|
||||||
notebook.set_tab_detachable(scroll, True)
|
notebook.set_tab_detachable(scroll, True)
|
||||||
|
notebook.set_tab_reorderable(scroll, True)
|
||||||
|
|
||||||
self.fm_controller.set_wid_and_tid(wid, tab.get_id())
|
self.fm_controller.set_wid_and_tid(wid, tab.get_id())
|
||||||
path_entry.set_text(tab.get_current_directory())
|
path_entry.set_text(tab.get_current_directory())
|
||||||
|
@ -46,7 +47,6 @@ class TabMixin(GridMixin):
|
||||||
|
|
||||||
ctx = notebook.get_style_context()
|
ctx = notebook.get_style_context()
|
||||||
ctx.add_class("notebook-unselected-focus")
|
ctx.add_class("notebook-unselected-focus")
|
||||||
notebook.set_tab_reorderable(scroll, True)
|
|
||||||
self.load_store(tab, store)
|
self.load_store(tab, store)
|
||||||
self.set_window_title()
|
self.set_window_title()
|
||||||
self.set_file_watcher(tab)
|
self.set_file_watcher(tab)
|
||||||
|
@ -79,11 +79,12 @@ class TabMixin(GridMixin):
|
||||||
|
|
||||||
self.builder.dereference_object(f"{wid}|{tid}|icon_grid")
|
self.builder.dereference_object(f"{wid}|{tid}|icon_grid")
|
||||||
self.builder.dereference_object(f"{wid}|{tid}")
|
self.builder.dereference_object(f"{wid}|{tid}")
|
||||||
|
icon_grid.set_model(None)
|
||||||
|
|
||||||
store.clear()
|
store.run_dispose()
|
||||||
icon_grid.destroy()
|
icon_grid.run_dispose()
|
||||||
scroll.destroy()
|
scroll.run_dispose()
|
||||||
tab_box.destroy()
|
tab_box.run_dispose()
|
||||||
|
|
||||||
del store
|
del store
|
||||||
del icon_grid
|
del icon_grid
|
||||||
|
|
|
@ -38,6 +38,7 @@ class TabMixin(GridMixin):
|
||||||
scroll, store = self.create_scroll_and_store(tab, wid)
|
scroll, store = self.create_scroll_and_store(tab, wid)
|
||||||
index = notebook.append_page(scroll, tab_widget)
|
index = notebook.append_page(scroll, tab_widget)
|
||||||
notebook.set_tab_detachable(scroll, True)
|
notebook.set_tab_detachable(scroll, True)
|
||||||
|
notebook.set_tab_reorderable(scroll, True)
|
||||||
|
|
||||||
self.fm_controller.set_wid_and_tid(wid, tab.get_id())
|
self.fm_controller.set_wid_and_tid(wid, tab.get_id())
|
||||||
event_system.emit("go_to_path", (tab.get_current_directory(),)) # NOTE: Not efficent if I understand how
|
event_system.emit("go_to_path", (tab.get_current_directory(),)) # NOTE: Not efficent if I understand how
|
||||||
|
@ -47,7 +48,6 @@ class TabMixin(GridMixin):
|
||||||
|
|
||||||
ctx = notebook.get_style_context()
|
ctx = notebook.get_style_context()
|
||||||
ctx.add_class("notebook-unselected-focus")
|
ctx.add_class("notebook-unselected-focus")
|
||||||
notebook.set_tab_reorderable(scroll, True)
|
|
||||||
self.load_store(tab, store)
|
self.load_store(tab, store)
|
||||||
# self.set_window_title()
|
# self.set_window_title()
|
||||||
event_system.emit("set_window_title", (tab.get_current_directory(),))
|
event_system.emit("set_window_title", (tab.get_current_directory(),))
|
||||||
|
@ -81,11 +81,12 @@ class TabMixin(GridMixin):
|
||||||
|
|
||||||
self.builder.dereference_object(f"{wid}|{tid}|icon_grid")
|
self.builder.dereference_object(f"{wid}|{tid}|icon_grid")
|
||||||
self.builder.dereference_object(f"{wid}|{tid}")
|
self.builder.dereference_object(f"{wid}|{tid}")
|
||||||
|
icon_grid.set_model(None)
|
||||||
|
|
||||||
store.clear()
|
store.run_dispose()
|
||||||
icon_grid.destroy()
|
icon_grid.run_dispose()
|
||||||
scroll.destroy()
|
scroll.run_dispose()
|
||||||
tab_box.destroy()
|
tab_box.run_dispose()
|
||||||
|
|
||||||
del store
|
del store
|
||||||
del icon_grid
|
del icon_grid
|
||||||
|
|
|
@ -59,7 +59,7 @@ class IconTreeWidget(Gtk.TreeView):
|
||||||
name = Gtk.CellRendererText()
|
name = Gtk.CellRendererText()
|
||||||
selec = self.get_selection()
|
selec = self.get_selection()
|
||||||
|
|
||||||
self.set_model(store)
|
self.set_model(self._store)
|
||||||
selec.set_mode(3)
|
selec.set_mode(3)
|
||||||
|
|
||||||
column.pack_start(icon, False)
|
column.pack_start(icon, False)
|
||||||
|
|
|
@ -50,8 +50,8 @@ class Icon(DesktopIconMixin, VideoIconMixin, MeshsIconMixin):
|
||||||
|
|
||||||
if not thumbnl:
|
if not thumbnl:
|
||||||
# TODO: Detect if not in a thread and use directly for speed get_system_thumbnail
|
# TODO: Detect if not in a thread and use directly for speed get_system_thumbnail
|
||||||
# thumbnl = self.get_system_thumbnail(full_path, self.sys_icon_wh[0])
|
thumbnl = self.get_system_thumbnail(full_path, self.sys_icon_wh[0])
|
||||||
thumbnl = self._get_system_thumbnail_gtk_thread(full_path, self.sys_icon_wh[0])
|
# thumbnl = self._get_system_thumbnail_gtk_thread(full_path, self.sys_icon_wh[0])
|
||||||
if not thumbnl:
|
if not thumbnl:
|
||||||
raise IconException("No known icons found.")
|
raise IconException("No known icons found.")
|
||||||
|
|
||||||
|
@ -152,11 +152,11 @@ class Icon(DesktopIconMixin, VideoIconMixin, MeshsIconMixin):
|
||||||
gio_file = Gio.File.new_for_path(full_path)
|
gio_file = Gio.File.new_for_path(full_path)
|
||||||
info = gio_file.query_info('standard::icon' , 0, None)
|
info = gio_file.query_info('standard::icon' , 0, None)
|
||||||
icon = info.get_icon().get_names()[0]
|
icon = info.get_icon().get_names()[0]
|
||||||
data = settings_manager.get_icon_theme().lookup_icon(icon , size , 0)
|
data = settings_manager.get_icon_theme().lookup_icon(icon , size, 0)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
icon_path = data.get_filename()
|
icon_path = data.get_filename()
|
||||||
return GdkPixbuf.Pixbuf.new_from_file(icon_path)
|
return GdkPixbuf.Pixbuf.new_from_file_at_size(icon_path, width = size, height = size)
|
||||||
|
|
||||||
raise IconException("No system icon found...")
|
raise IconException("No system icon found...")
|
||||||
except IconException:
|
except IconException:
|
||||||
|
|
Loading…
Reference in New Issue