Skip to content

Commit

Permalink
feat: Use AdwDialog + other newer widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
sungsphinx committed Jul 28, 2024
1 parent 2d1840a commit e78d499
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 89 deletions.
9 changes: 4 additions & 5 deletions vanilla_installer/defaults/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,12 +512,12 @@ def __on_window_active(self, widget, value):

def __on_btn_cancel_clicked(self, widget):
self.__partition_selector.cleanup()
self.destroy()
self.force_close()

def __on_btn_apply_clicked(self, widget):
self.__parent.set_partition_recipe(self.partition_recipe)
self.emit("partitioning-set", "")
self.destroy()
self.force_close()

def set_btn_apply_sensitive(self, val):
self.btn_apply.set_sensitive(val)
Expand Down Expand Up @@ -553,7 +553,7 @@ def partition_recipe(self):


@Gtk.Template(resource_path="/org/vanillaos/Installer/gtk/dialog-disk-confirm.ui")
class VanillaDefaultDiskConfirmModal(Adw.Window):
class VanillaDefaultDiskConfirmModal(Adw.Dialog):
__gtype_name__ = "VanillaDefaultDiskConfirmModal"

btn_cancel = Gtk.Template.Child()
Expand All @@ -563,7 +563,6 @@ class VanillaDefaultDiskConfirmModal(Adw.Window):
def __init__(self, window, partition_recipe, **kwargs):
super().__init__(**kwargs)
self.__window = window
self.set_transient_for(self.__window)
self.default_width, self.default_height = self.get_default_size()

# signals
Expand Down Expand Up @@ -631,7 +630,7 @@ def __on_btn_cancel_clicked(self, widget):

def __on_btn_apply_clicked(self, widget):
self.__window.next()
self.destroy()
self.force_close()


@Gtk.Template(resource_path="/org/vanillaos/Installer/gtk/default-disk.ui")
Expand Down
4 changes: 2 additions & 2 deletions vanilla_installer/defaults/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_finals(self):
return {}

def __on_recovery_clicked(self, row):
VanillaRecoveryDialog(self.__window).show()
VanillaRecoveryDialog().present(self.__window)

def __on_poweroff_clicked(self, row):
VanillaPoweroffDialog(self.__window).show()
VanillaPoweroffDialog().present(self.__window)
20 changes: 10 additions & 10 deletions vanilla_installer/gtk/dialog-disk-confirm.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0" />
<template class="VanillaDefaultDiskConfirmModal" parent="AdwWindow">
<template class="VanillaDefaultDiskConfirmModal" parent="AdwDialog">
<property name="title" translatable="yes">Confirm Changes</property>
<property name="modal">true</property>
<property name="deletable">false</property>
<property name="default-width">500</property>
<property name="default-height">650</property>
<property name="can-close">false</property>
<property name="content-width">500</property>
<property name="content-height">650</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar">
<property name="show-start-title-buttons">false</property>
<property name="show-end-title-buttons">false</property>
<child type="start">
<object class="GtkButton" id="btn_cancel">
<property name="label" translatable="yes">Cancel</property>
</object>
</child>
</object>
</child>
<child>
<property name="content">
<object class="AdwStatusPage">
<property name="title" translatable="yes">Confirm Changes</property>
<property name="description" translatable="yes">The following changes will be made to your disk. Please review them carefully.</property>
Expand Down Expand Up @@ -49,7 +49,7 @@
</object>
</child>
</object>
</child>
</property>
</object>
</child>
</template>
Expand Down
20 changes: 10 additions & 10 deletions vanilla_installer/gtk/dialog-disk.ui
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<template class="VanillaDefaultDiskPartModal" parent="AdwWindow">
<template class="VanillaDefaultDiskPartModal" parent="AdwDialog">
<property name="title" translatable="yes">Configure Disk</property>
<property name="modal">true</property>
<property name="deletable">false</property>
<property name="default-width">650</property>
<property name="default-height">850</property>
<property name="can-close">false</property>
<property name="content-width">650</property>
<property name="content-height">850</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar">
<property name="show-start-title-buttons">false</property>
<property name="show-end-title-buttons">false</property>
<child type="start">
<object class="GtkButton" id="btn_cancel">
<property name="label" translatable="yes">Cancel</property>
Expand All @@ -27,9 +27,9 @@
</child>
</object>
</child>
<child>
<property name="content">
<object class="AdwToastOverlay" id="group_partitions"></object>
</child>
</property>
</object>
</child>
</template>
Expand Down
7 changes: 3 additions & 4 deletions vanilla_installer/gtk/dialog-output.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0" />
<template class="VanillaDialogOutput" parent="AdwWindow">
<template class="VanillaDialogOutput" parent="AdwDialog">
<property name="title" translatable="yes">Log</property>
<property name="modal">true</property>
<property name="default-width">500</property>
<property name="default-height">500</property>
<property name="content-width">500</property>
<property name="content-height">500</property>
<child>
<object class="AdwBin">
<property name="child">
Expand Down
20 changes: 7 additions & 13 deletions vanilla_installer/gtk/dialog-poweroff.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0"/>
<template class="VanillaPoweroffDialog" parent="AdwWindow">
<template class="VanillaPoweroffDialog" parent="AdwDialog">
<property name="title" translatable="yes">Power Off</property>
<property name="default-width">500</property>
<property name="modal">true</property>
<property name="content-width">500</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwHeaderBar">
<style>
<class name="flat"/>
</style>
</object>
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar" />
</child>
<child>
<property name="content">
<object class="AdwPreferencesPage">
<child>
<object class="AdwPreferencesGroup">
Expand Down Expand Up @@ -71,7 +65,7 @@
</object>
</child>
</object>
</child>
</property>
</object>
</child>
</template>
Expand Down
20 changes: 7 additions & 13 deletions vanilla_installer/gtk/dialog-recovery.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0"/>
<template class="VanillaRecoveryDialog" parent="AdwWindow">
<template class="VanillaRecoveryDialog" parent="AdwDialog">
<property name="title" translatable="yes">Recovery</property>
<property name="default-width">500</property>
<property name="modal">true</property>
<property name="content-width">500</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwHeaderBar">
<style>
<class name="flat"/>
</style>
</object>
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar" />
</child>
<child>
<property name="content">
<object class="AdwPreferencesPage">
<child>
<object class="AdwPreferencesGroup">
Expand Down Expand Up @@ -108,7 +102,7 @@
</object>
</child>
</object>
</child>
</property>
</object>
</child>
</template>
Expand Down
20 changes: 7 additions & 13 deletions vanilla_installer/gtk/dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,23 @@
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0"/>
<template class="VanillaDialog" parent="AdwWindow">
<template class="VanillaDialog" parent="AdwDialog">
<property name="title" translatable="yes">Showing Information</property>
<property name="default-width">500</property>
<property name="modal">True</property>
<property name="content-width">500</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwHeaderBar">
<style>
<class name="flat"/>
</style>
</object>
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar" />
</child>
<child>
<property name="content">
<object class="GtkLabel" id="label_text">
<property name="margin-top">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-bottom">20</property>
<property name="wrap">True</property>
</object>
</child>
</property>
</object>
</child>
</template>
Expand Down
3 changes: 1 addition & 2 deletions vanilla_installer/layouts/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ def __next_step(self, widget):

if ws.get("message", None):
dialog = VanillaDialog(
self.__window,
ws.get("title", "No selection"),
ws.get("message"),
)
dialog.show()
dialog.present(self.__window)
self.__window.next()

def get_finals(self):
Expand Down
3 changes: 1 addition & 2 deletions vanilla_installer/layouts/yes_no.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ def __on_info(self, _):
return

dialog = VanillaDialog(
self.__window,
self.__step["buttons"]["info"]["title"],
self.__step["buttons"]["info"]["text"],
)
dialog.show()
dialog.present(self.__window)

def get_finals(self):
return {
Expand Down
4 changes: 2 additions & 2 deletions vanilla_installer/views/done.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ def __on_close_clicked(self, button):

def __on_log_clicked(self, button):
if self.__terminal:
dialog = VanillaDialogOutput(self.__window, self.__terminal)
dialog.present()
dialog = VanillaDialogOutput(self.__terminal)
dialog.present(self.__window)
5 changes: 2 additions & 3 deletions vanilla_installer/windows/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@


@Gtk.Template(resource_path="/org/vanillaos/Installer/gtk/dialog.ui")
class VanillaDialog(Adw.Window):
class VanillaDialog(Adw.Dialog):
__gtype_name__ = "VanillaDialog"

label_text = Gtk.Template.Child()

def __init__(self, window, title, text, **kwargs):
def __init__(self, title, text, **kwargs):
super().__init__(**kwargs)
self.set_transient_for(window)
self.set_title(title)
self.label_text.set_text(text)
5 changes: 2 additions & 3 deletions vanilla_installer/windows/dialog_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@


@Gtk.Template(resource_path="/org/vanillaos/Installer/gtk/dialog-output.ui")
class VanillaDialogOutput(Adw.Window):
class VanillaDialogOutput(Adw.Dialog):
__gtype_name__ = "VanillaDialogOutput"

main_box = Gtk.Template.Child()

def __init__(self, window, terminal, **kwargs):
def __init__(self, terminal, **kwargs):
super().__init__(**kwargs)
self.set_transient_for(window)

self.main_box.append(terminal)
7 changes: 3 additions & 4 deletions vanilla_installer/windows/dialog_poweroff.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@


@Gtk.Template(resource_path="/org/vanillaos/Installer/gtk/dialog-poweroff.ui")
class VanillaPoweroffDialog(Adw.Window):
class VanillaPoweroffDialog(Adw.Dialog):
__gtype_name__ = "VanillaPoweroffDialog"

row_poweroff = Gtk.Template.Child()
row_reboot = Gtk.Template.Child()
row_firmware_setup = Gtk.Template.Child()

def __init__(self, window, **kwargs):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.set_transient_for(window)

# signals
self.row_poweroff.connect("activated", self.__on_poweroff)
Expand All @@ -48,4 +47,4 @@ def __on_reboot(self, btn):
subprocess.call(["systemctl", "reboot"])

def __on_firmware_setup(self, row):
subprocess.call(["systemctl", "reboot", "--firmware-setup"])
subprocess.call(["systemctl", "reboot", "--firmware-setup"])
5 changes: 2 additions & 3 deletions vanilla_installer/windows/dialog_recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


@Gtk.Template(resource_path="/org/vanillaos/Installer/gtk/dialog-recovery.ui")
class VanillaRecoveryDialog(Adw.Window):
class VanillaRecoveryDialog(Adw.Dialog):
__gtype_name__ = "VanillaRecoveryDialog"

row_console = Gtk.Template.Child()
Expand All @@ -30,9 +30,8 @@ class VanillaRecoveryDialog(Adw.Window):
row_handbook = Gtk.Template.Child()
row_web = Gtk.Template.Child()

def __init__(self, window, **kwargs):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.set_transient_for(window)

# signals
self.row_console.connect("activated", self.__on_console_activated)
Expand Down

0 comments on commit e78d499

Please sign in to comment.