From 0dba648b481fbe913b26224dcc27cb09047a8c9b Mon Sep 17 00:00:00 2001 From: 0xMRTT <0xMRTT@proton.me> Date: Mon, 22 May 2023 21:49:35 +0200 Subject: [PATCH] wip: add image size --- data/ui/window.blp | 32 ++++++++++++++++++++++++++++++++ src/main.py | 1 - src/window.py | 11 +++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/data/ui/window.blp b/data/ui/window.blp index 84cfc9d..a1b610f 100644 --- a/data/ui/window.blp +++ b/data/ui/window.blp @@ -89,6 +89,38 @@ template $ImaginerWindow : Adw.ApplicationWindow { }; } } + + Adw.ActionRow image_size { + title: _("Image Size"); + + Gtk.Box { + orientation: horizontal; + spacing: 4; + valign: center; + + Gtk.SpinButton image_width_spinbutton { + tooltip-text: _("Image Width"); + adjustment: Gtk.Adjustment image_width_adjustment { + lower: 1; + upper: 8192; + step-increment: 1; + page-increment: 5; + }; + value-changed => on_image_width_changed(); + } + + Gtk.SpinButton image_height_spinbutton { + tooltip-text: _("Image Height"); + adjustment: Gtk.Adjustment image_height_adjustment { + lower: 1; + upper: 8192; + step-increment: 1; + page-increment: 5; + }; + value-changed => on_image_height_changed(); + } + } + } } Adw.PreferencesGroup { diff --git a/src/main.py b/src/main.py index ef29103..76c0fa6 100644 --- a/src/main.py +++ b/src/main.py @@ -84,7 +84,6 @@ class KillableThread(threading.Thread): class ImaginerApplication(Adw.Application): """The main application singleton class.""" - def __init__(self): super().__init__( application_id="page.codeberg.Imaginer.Imaginer", diff --git a/src/window.py b/src/window.py index 0d22ce1..64fd36c 100644 --- a/src/window.py +++ b/src/window.py @@ -36,6 +36,8 @@ class ImaginerWindow(Adw.ApplicationWindow): negative_prompt = Gtk.Template.Child() menu = Gtk.Template.Child() label_output = Gtk.Template.Child() + image_width_spinbutton = Gtk.Template.Child() + image_height_spinbutton = Gtk.Template.Child() def __init__(self, **kwargs): super().__init__(**kwargs) @@ -59,3 +61,12 @@ class ImaginerWindow(Adw.ApplicationWindow): self.settings.bind( "is-fullscreen", self, "fullscreened", Gio.SettingsBindFlags.DEFAULT ) + + @Gtk.Template.Callback() + def on_image_width_changed(self, widget): + self.app.width = self.image_width_spinbutton.get_value_as_int() + + + @Gtk.Template.Callback() + def on_image_height_changed(self, widget): + self.app.height = self.image_height_spinbutton.get_value_as_int()