Commit 9dd82ddd authored by GabMus's avatar GabMus

added big monitor thumbnail option, improved monitors flowbox, fixed previous window size saving

parent eb3ee26d
Pipeline #71666158 passed with stage
in 50 seconds
......@@ -21,16 +21,17 @@ class HydraPaperAppWindow(Gtk.ApplicationWindow):
self.stack_switcher.set_stack(self.main_stack)
self.monitors_flowbox = HydraPaperMonitorsFlowbox()
self.monitors_flowbox.set_hexpand(False)
self.monitors_flowbox.set_halign(Gtk.Align.CENTER)
self.container_box.pack_start(self.monitors_flowbox, False, False, 6)
self.container_box.pack_start(self.main_stack, True, True, 0)
self.add(self.container_box)
self.set_titlebar(self.headerbar)
# self.connect('destroy', self.destroy)
# Why this -52?
# because every time a new value is saved, for some reason
# it's the actual value +52 out of nowhere
# this makes the window ACTUALLY preserve its old size
self.resize(
self.confman.conf['windowsize']['width'],
self.confman.conf['windowsize']['height']
self.confman.conf['windowsize']['width']-52,
self.confman.conf['windowsize']['height']-52
)
self.size_allocation = self.get_allocation()
self.connect('size-allocate', self.update_size_allocation)
......
......@@ -40,6 +40,11 @@ class ConfManagerSignaler(GObject.Object):
GObject.SIGNAL_RUN_FIRST,
None,
(str,)
),
'hydrapaper_reload_monitor_thumbs': (
GObject.SIGNAL_RUN_FIRST,
None,
(str,)
)
}
......@@ -57,6 +62,7 @@ class ConfManager(metaclass=Singleton):
'favorites': [],
'favorites_in_mainview': True,
'folders_popover_full_path': False,
'big_monitor_thumbnails': True,
'windowsize': {
'width': 600,
'height': 400
......
......@@ -26,6 +26,7 @@ class HydraPaperMonitorsFlowboxItem(Gtk.FlowBoxChild):
self.show_all()
def set_picture(self, n_wp=None):
wp_size = 256 if self.confman.conf['big_monitor_thumbnails'] else 64
if n_wp and is_image(n_wp):
self.monitor.wallpaper = n_wp
if self.monitor.wallpaper and is_image(self.monitor.wallpaper):
......@@ -38,7 +39,7 @@ class HydraPaperMonitorsFlowboxItem(Gtk.FlowBoxChild):
if not isfile(thumb_path):
thumb_path = self.monitor.wallpaper
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
thumb_path, 64, 64, True
thumb_path, wp_size, wp_size, True
)
self.image.set_from_pixbuf(pixbuf)
else:
......@@ -54,8 +55,12 @@ class HydraPaperMonitorsFlowbox(Gtk.FlowBox):
self.monitors = build_monitors_from_gdk()
self.set_min_children_per_line(4)
self.set_max_children_per_line(7)
self.set_min_children_per_line(1)
self.set_max_children_per_line(len(self.monitors))
self.set_halign(Gtk.Align.FILL)
self.set_hexpand(True)
self.set_homogeneous(False)
self.set_vexpand(False)
self.set_activate_on_single_click(
self.confman.conf['selection_mode']
)
......@@ -63,6 +68,10 @@ class HydraPaperMonitorsFlowbox(Gtk.FlowBox):
'hydrapaper_flowbox_wallpaper_selected',
self.change_selected_wp
)
self.confman.connect(
'hydrapaper_reload_monitor_thumbs',
self.reload_children_pictures
)
self.populate()
def populate(self):
......@@ -73,6 +82,10 @@ class HydraPaperMonitorsFlowbox(Gtk.FlowBox):
)
self.select_child(self.get_children()[0])
def reload_children_pictures(self, *args):
for c in self.get_children():
c.set_picture()
def load_from_config(self):
for m in self.monitors:
if m.name in self.confman.conf['monitors'].keys():
......
......@@ -151,12 +151,40 @@ class GeneralPreferencesPage(Handy.PreferencesPage):
remove(f)
class ViewPreferencesPage(Handy.PreferencesPage):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_title(_('View'))
self.set_icon_name('applications-graphics-symbolic')
self.view_preferences_group = Handy.PreferencesGroup()
self.view_preferences_group.set_title(_('View Settings'))
toggle_settings = [
{
'title': _('Use big thumbnails for the monitors previews'),
'conf_key': 'big_monitor_thumbnails',
'signal': 'hydrapaper_reload_monitor_thumbs'
}
]
for s in toggle_settings:
row = PreferencesToggleRow(s['title'], s['conf_key'], s['signal'])
self.view_preferences_group.add(row)
self.add(self.view_preferences_group)
self.show_all()
class HydraPaperSettingsWindow(Handy.PreferencesWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.general_page = GeneralPreferencesPage()
self.add(self.general_page)
self.pages = [
GeneralPreferencesPage(),
ViewPreferencesPage()
]
for p in self.pages:
self.add(p)
# values copied from libhandy demo
# https://source.puri.sm/Librem5/libhandy/blob/master/examples/hdy-demo-preferences-window.ui
self.set_default_size(640, 700)
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment