hid search entry for time being; code cleanup
This commit is contained in:
parent
764a74d0e6
commit
05cd00ba15
1
src/.python-version
Normal file
1
src/.python-version
Normal file
@ -0,0 +1 @@
|
|||||||
|
3.10.4
|
@ -44,39 +44,19 @@ class Controller(ControllerData):
|
|||||||
def set_list_group(self, widget):
|
def set_list_group(self, widget):
|
||||||
group = widget.get_label().strip()
|
group = widget.get_label().strip()
|
||||||
group_items = self.core_widget.get_group(group)
|
group_items = self.core_widget.get_group(group)
|
||||||
grid = self.builder.get_object("programListBttns")
|
grid = self.builder.get_object("program_list_bttns")
|
||||||
|
|
||||||
children = grid.get_children()
|
children = grid.get_children()
|
||||||
for child in children:
|
for child in children:
|
||||||
|
child.disconnect(child.sig_id)
|
||||||
grid.remove(child)
|
grid.remove(child)
|
||||||
|
|
||||||
row = 0
|
row = 0
|
||||||
col = 0
|
col = 0
|
||||||
|
icon_theme = Gtk.IconTheme.get_default()
|
||||||
|
|
||||||
for item in group_items:
|
for item in group_items:
|
||||||
title = item["title"]
|
button = self.generate_app_button(icon_theme, item)
|
||||||
if not item["exec"] in ("", None):
|
|
||||||
exec = item["exec"]
|
|
||||||
else:
|
|
||||||
exec = item["tryExec"]
|
|
||||||
|
|
||||||
button = Gtk.Button(label=title)
|
|
||||||
button.connect("clicked", self.test_exec, exec)
|
|
||||||
if self.show_image:
|
|
||||||
if os.path.exists(item["icon"]):
|
|
||||||
pixbuf = GdkPixbuf.PixbufAnimation.new_from_file(item["icon"]) \
|
|
||||||
.get_static_image() \
|
|
||||||
.scale_simple(64, 64, \
|
|
||||||
GdkPixbuf.InterpType.BILINEAR)
|
|
||||||
|
|
||||||
icon = Gtk.Image.new_from_pixbuf(pixbuf)
|
|
||||||
else:
|
|
||||||
gio_icon = Gio.Icon.new_for_string(item["icon"])
|
|
||||||
icon = Gtk.Image.new_from_gicon(gio_icon, 64)
|
|
||||||
|
|
||||||
button.set_image(icon)
|
|
||||||
button.set_always_show_image(True)
|
|
||||||
|
|
||||||
button.show_all()
|
|
||||||
grid.attach(button, col, row, 1, 1)
|
grid.attach(button, col, row, 1, 1)
|
||||||
|
|
||||||
col += 1
|
col += 1
|
||||||
@ -84,7 +64,54 @@ class Controller(ControllerData):
|
|||||||
col = 0
|
col = 0
|
||||||
row += 1
|
row += 1
|
||||||
|
|
||||||
# grid.add(button)
|
|
||||||
|
|
||||||
|
def generate_app_button(self, icon_theme, item):
|
||||||
|
title = item["title"]
|
||||||
|
exec_str = item[
|
||||||
|
"exec" if not item["exec"] in ("", None) else "tryExec"
|
||||||
|
]
|
||||||
|
|
||||||
|
button = Gtk.Button(label = title)
|
||||||
|
button.sig_id = button.connect("clicked", self.test_exec, exec_str)
|
||||||
|
|
||||||
|
if self.show_image:
|
||||||
|
_icon = item["icon"]
|
||||||
|
|
||||||
|
if os.path.exists(_icon):
|
||||||
|
icon = self.get_icon_from_path(_icon)
|
||||||
|
else:
|
||||||
|
icon = self.get_icon_from_gio(icon_theme, _icon)
|
||||||
|
|
||||||
|
button.set_image(icon)
|
||||||
|
button.set_always_show_image(True)
|
||||||
|
|
||||||
|
button.show_all()
|
||||||
|
return button
|
||||||
|
|
||||||
|
def get_icon_from_path(self, path):
|
||||||
|
pixbuf = GdkPixbuf.PixbufAnimation.new_from_file(path) \
|
||||||
|
.get_static_image() \
|
||||||
|
.scale_simple(32, 32, \
|
||||||
|
GdkPixbuf.InterpType.BILINEAR)
|
||||||
|
|
||||||
|
return Gtk.Image.new_from_pixbuf(pixbuf)
|
||||||
|
|
||||||
|
|
||||||
|
def get_icon_from_gio(self, icon_theme, icon_name):
|
||||||
|
gio_icon = Gio.Icon.new_for_string(icon_name)
|
||||||
|
pixbuf = None
|
||||||
|
|
||||||
|
# Note: https://docs.gtk.org/gtk3/enum.IconSize.html
|
||||||
|
for i in [6, 5, 3, 4, 2, 1]:
|
||||||
|
icon_info = Gtk.IconTheme.lookup_by_gicon(icon_theme, gio_icon, i, Gtk.IconLookupFlags.FORCE_REGULAR)
|
||||||
|
if not icon_info: continue
|
||||||
|
|
||||||
|
pixbuf = icon_info.load_icon().scale_simple(32, 32, 2) # 2 = BILINEAR and is best by default
|
||||||
|
break
|
||||||
|
|
||||||
|
return Gtk.Image.new_from_pixbuf( pixbuf )
|
||||||
|
|
||||||
|
|
||||||
def test_exec(self, widget, _command):
|
def test_exec(self, widget, _command):
|
||||||
command = _command.split("%")[0]
|
command = _command.split("%")[0]
|
||||||
|
@ -25,12 +25,14 @@ def display_manager():
|
|||||||
|
|
||||||
if display_manager() == 'X11':
|
if display_manager() == 'X11':
|
||||||
try:
|
try:
|
||||||
|
#gi.require_version('Keybinder', '3.24')
|
||||||
gi.require_version('Keybinder', '3.0')
|
gi.require_version('Keybinder', '3.0')
|
||||||
from gi.repository import Keybinder
|
from gi.repository import Keybinder
|
||||||
Keybinder.init()
|
Keybinder.init()
|
||||||
Keybinder.set_use_cooked_accelerators(False)
|
Keybinder.set_use_cooked_accelerators(False)
|
||||||
except (ImportError, ValueError):
|
except (ImportError, ValueError) as e:
|
||||||
logger.debug('Unable to load Keybinder module. This means the hide_window shortcut will be unavailable')
|
logger.warning(e)
|
||||||
|
logger.warning('Unable to load Keybinder module. This means the hide_window shortcut will be unavailable')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -52,14 +54,16 @@ class ControllerData:
|
|||||||
|
|
||||||
def setup_toggle_event(self) -> None:
|
def setup_toggle_event(self) -> None:
|
||||||
self.window = settings.get_builder().get_object(f"{app_name.lower()}")
|
self.window = settings.get_builder().get_object(f"{app_name.lower()}")
|
||||||
|
hidebound = None
|
||||||
|
|
||||||
# Attempt to grab a global hotkey for hiding the window.
|
# Attempt to grab a global hotkey for hiding the window.
|
||||||
# If we fail, we'll never hide the window, iconifying instead.
|
# If we fail, we'll never hide the window, iconifying instead.
|
||||||
if self.guake_key and display_manager() == 'X11':
|
if self.guake_key and display_manager() == 'X11':
|
||||||
try:
|
try:
|
||||||
hidebound = Keybinder.bind(self.guake_key, self.on_hide_window)
|
hidebound = Keybinder.bind(self.guake_key, self.on_hide_window)
|
||||||
except (KeyError, NameError):
|
except (KeyError, NameError) as e:
|
||||||
pass
|
logger.warning(e)
|
||||||
|
print( repr(e) )
|
||||||
|
|
||||||
if not hidebound:
|
if not hidebound:
|
||||||
logger.debug('Unable to bind hide_window key, another instance/window has it.')
|
logger.debug('Unable to bind hide_window key, another instance/window has it.')
|
||||||
|
@ -10,9 +10,9 @@ gi.require_version('Wnck', '3.0')
|
|||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
from gi.repository import Wnck
|
from gi.repository import Wnck
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
|
from gi.repository import GdkPixbuf
|
||||||
from xdg.DesktopEntry import DesktopEntry
|
from xdg.DesktopEntry import DesktopEntry
|
||||||
|
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
from .desktop_parsing.app_finder import find_apps
|
from .desktop_parsing.app_finder import find_apps
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ class CoreWidget(Gtk.Box):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(CoreWidget, self).__init__()
|
super(CoreWidget, self).__init__()
|
||||||
self.builder = settings.get_builder()
|
self.builder = settings.get_builder()
|
||||||
self.time_label = self.builder.get_object("timeLabel")
|
self.time_label = self.builder.get_object("time_lbl")
|
||||||
|
|
||||||
self.orientation = 1 # 0 = horizontal, 1 = vertical
|
self.orientation = 1 # 0 = horizontal, 1 = vertical
|
||||||
|
|
||||||
@ -49,6 +49,9 @@ class CoreWidget(Gtk.Box):
|
|||||||
apps = find_apps()
|
apps = find_apps()
|
||||||
self.fill_menu_objects(apps)
|
self.fill_menu_objects(apps)
|
||||||
|
|
||||||
|
search_programs_entry = self.builder.get_object("search_programs_entry")
|
||||||
|
search_programs_entry.hide()
|
||||||
|
|
||||||
|
|
||||||
def fill_menu_objects(self, apps=[]):
|
def fill_menu_objects(self, apps=[]):
|
||||||
for app in apps:
|
for app in apps:
|
||||||
@ -86,10 +89,18 @@ class CoreWidget(Gtk.Box):
|
|||||||
else:
|
else:
|
||||||
group = "Other"
|
group = "Other"
|
||||||
|
|
||||||
self.menu_objects[group].append( {"title": title, "groups": groups,
|
self.menu_objects[group].append(
|
||||||
"comment": comment, "exec": mainExec,
|
{
|
||||||
"tryExec": tryExec, "fileName": fPath.split("/")[-1],
|
"title": title,
|
||||||
"filePath": fPath, "icon": icon})
|
"groups": groups,
|
||||||
|
"comment": comment,
|
||||||
|
"exec": mainExec,
|
||||||
|
"tryExec": tryExec,
|
||||||
|
"fileName": fPath.split("/")[-1],
|
||||||
|
"filePath": fPath,
|
||||||
|
"icon": icon
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def get_group(self, group):
|
def get_group(self, group):
|
||||||
return self.menu_objects[group]
|
return self.menu_objects[group]
|
||||||
@ -107,8 +118,8 @@ class CoreWidget(Gtk.Box):
|
|||||||
def _load_widgets(self):
|
def _load_widgets(self):
|
||||||
widget_grid_container = self.builder.get_object("widget_grid_container")
|
widget_grid_container = self.builder.get_object("widget_grid_container")
|
||||||
|
|
||||||
timeLabelEveBox = self.builder.get_object("timeLabelEveBox")
|
time_lbl_eve_box = self.builder.get_object("time_lbl_eve_box")
|
||||||
timeLabelEveBox.connect("button_release_event", self._toggle_cal_popover)
|
time_lbl_eve_box.connect("button_release_event", self._toggle_cal_popover)
|
||||||
|
|
||||||
widget_grid_container.set_vexpand(True)
|
widget_grid_container.set_vexpand(True)
|
||||||
widget_grid_container.set_hexpand(True)
|
widget_grid_container.set_hexpand(True)
|
||||||
@ -126,9 +137,9 @@ class CoreWidget(Gtk.Box):
|
|||||||
pager = Wnck.Pager.new()
|
pager = Wnck.Pager.new()
|
||||||
|
|
||||||
if self.orientation == 0:
|
if self.orientation == 0:
|
||||||
self.builder.get_object('taskBarWorkspacesHor').add(pager)
|
self.builder.get_object('taskbar_workspaces_hor').add(pager)
|
||||||
else:
|
else:
|
||||||
self.builder.get_object('taskBarWorkspacesVer').add(pager)
|
self.builder.get_object('taskbar_workspaces_ver').add(pager)
|
||||||
|
|
||||||
pager.set_hexpand(True)
|
pager.set_hexpand(True)
|
||||||
pager.show()
|
pager.show()
|
||||||
@ -140,9 +151,9 @@ class CoreWidget(Gtk.Box):
|
|||||||
tasklist.set_grouping(1) # 0 = mever group, 1 auto group, 2 = always group
|
tasklist.set_grouping(1) # 0 = mever group, 1 auto group, 2 = always group
|
||||||
|
|
||||||
if self.orientation == 0:
|
if self.orientation == 0:
|
||||||
self.builder.get_object('taskBarButtonsHor').add(tasklist)
|
self.builder.get_object('taskbar_bttns_hor').add(tasklist)
|
||||||
else:
|
else:
|
||||||
self.builder.get_object('taskBarButtonsVer').add(tasklist)
|
self.builder.get_object('taskbar_bttns_ver').add(tasklist)
|
||||||
|
|
||||||
tasklist.set_vexpand(True)
|
tasklist.set_vexpand(True)
|
||||||
tasklist.set_include_all_workspaces(False)
|
tasklist.set_include_all_workspaces(False)
|
||||||
@ -166,8 +177,8 @@ class CoreWidget(Gtk.Box):
|
|||||||
widget.hide()
|
widget.hide()
|
||||||
|
|
||||||
def _toggle_cal_popover(self, widget, eve):
|
def _toggle_cal_popover(self, widget, eve):
|
||||||
calendarPopup = self.builder.get_object('calendarPopup')
|
calendar_popup = self.builder.get_object('calendar_popup')
|
||||||
if (calendarPopup.get_visible() == False):
|
if (calendar_popup.get_visible() == False):
|
||||||
calendarWid = self.builder.get_object('calendarWid')
|
calendarWid = self.builder.get_object('calendarWid')
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
timeStr = now.strftime("%m/%d/%Y")
|
timeStr = now.strftime("%m/%d/%Y")
|
||||||
@ -177,6 +188,6 @@ class CoreWidget(Gtk.Box):
|
|||||||
year = int(parts[2])
|
year = int(parts[2])
|
||||||
calendarWid.select_day(day)
|
calendarWid.select_day(day)
|
||||||
calendarWid.select_month(month, year)
|
calendarWid.select_month(month, year)
|
||||||
calendarPopup.popup()
|
calendar_popup.popup()
|
||||||
else:
|
else:
|
||||||
calendarPopup.popdown()
|
calendar_popup.popdown()
|
@ -30,7 +30,7 @@ class Window(Gtk.ApplicationWindow):
|
|||||||
self._setup_signals()
|
self._setup_signals()
|
||||||
self._load_widgets(args, unknownargs)
|
self._load_widgets(args, unknownargs)
|
||||||
|
|
||||||
self.show_all()
|
self.show()
|
||||||
|
|
||||||
|
|
||||||
def _setup_styling(self):
|
def _setup_styling(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user