WIP: Improve rendering on touch/mobile devices.

This commit is contained in:
Sergio Martínez Portela 2022-03-25 01:47:20 +01:00
parent 259dfd1229
commit 68a2cd9b11

25
main.py
View File

@ -23,7 +23,6 @@ gi.require_version(namespace='Adw', version='1')
from gi.repository import Gtk, Polkit, GObject, Gio, Adw, Gdk from gi.repository import Gtk, Polkit, GObject, Gio, Adw, Gdk
class MainWindow(Gtk.Window): class MainWindow(Gtk.Window):
## Setup ## Setup
@ -46,13 +45,17 @@ class MainWindow(Gtk.Window):
self.header_bar = None self.header_bar = None
self.progress_spinner = None self.progress_spinner = None
self.main_box = Gtk.Box(name='main-box') # self.main_box = Gtk.Box(name='main-box', vexpand=True, hexpand=True)
self.task_list = Gtk.ListBox(name='task-list') self.scrollview = Gtk.ScrolledWindow(vexpand=True, hexpand=True)
self.main_box.props.valign = Gtk.Align.CENTER self.task_list = Gtk.ListBox(name='task-list')
self.main_box.props.halign = Gtk.Align.CENTER self.scrollview.set_child(self.task_list)
self.main_box.append(self.task_list)
self.set_child(self.main_box) # self.main_box.props.valign = Gtk.Align.CENTER
# self.main_box.props.halign = Gtk.Align.CENTER
# self.main_box.append(self.scrollview)
# self.set_child(self.main_box)
self.set_child(self.scrollview)
self.loading += 1 self.loading += 1
self.task_manager.get_task_list(self.on_task_list_ready) self.task_manager.get_task_list(self.on_task_list_ready)
@ -72,12 +75,14 @@ class MainWindow(Gtk.Window):
clock_button.connect("clicked", self.on_clock_button_clicked) clock_button.connect("clicked", self.on_clock_button_clicked)
hbox.append(clock_button) hbox.append(clock_button)
task_name_label = Gtk.Entry(text=task.title, width_chars=max(MIN_TITLE_WIDTH_CHARS, len(task.title))) # task_name_label = Gtk.Entry(text=task.title, width_chars=max(MIN_TITLE_WIDTH_CHARS, len(task.title)))
task_name_label = Gtk.Label()
task_name_label.set_text(task.title)
task_name_label.props.css_classes = ('task-name',) task_name_label.props.css_classes = ('task-name',)
hbox.append(task_name_label) hbox.append(task_name_label)
row.set_child(hbox) row.set_child(hbox)
return row return row
def on_ready(self): def on_ready(self):
@ -132,7 +137,7 @@ class Application(Gtk.Application):
def main(): def main():
""" Run the main application""" """ Run the main application"""
GObject.threads_init() # GObject.threads_init()
logging.basicConfig(level=logging.INFO, format="%(levelname)-8s %(message)s") logging.basicConfig(level=logging.INFO, format="%(levelname)-8s %(message)s")
app = Application() app = Application()
return app.run(sys.argv) return app.run(sys.argv)