Skip to content

Commit

Permalink
widgets: PresetDialog: Use Adw.Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelmardojai committed Apr 7, 2024
1 parent c30f566 commit 531024c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
4 changes: 1 addition & 3 deletions blanket/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ def on_reset_volumes(self, _action, _param):

def on_add_preset(self, _action, _param):
dialog = PresetDialog()
dialog.set_transient_for(self.window)
dialog.set_modal(True)
dialog.present()
dialog.present(self.window)

def on_remove_sound(self, _action, name: GLib.Variant):
sound, index = MainPlayer.get().get_by_name(name.get_string())
Expand Down
6 changes: 3 additions & 3 deletions blanket/widgets/preset_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@Gtk.Template(resource_path=f'{RES_PATH}/preset-dialog.ui')
class PresetDialog(Adw.Window):
class PresetDialog(Adw.Dialog):
__gtype_name__ = 'PresetDialog'

headerbar: Adw.HeaderBar = Gtk.Template.Child() # type: ignore
Expand Down Expand Up @@ -71,7 +71,7 @@ def _on_create_preset(self, _button):
# Clear name entry
self.name_entry.set_text('')

self.destroy()
self.close()

def _on_rename_preset(self, _button):
if self.preset:
Expand All @@ -82,7 +82,7 @@ def _on_rename_preset(self, _button):
self.__invalid_name()
return

self.destroy()
self.close()

def __get_name(self):
name = self.name_entry.get_text()
Expand Down
3 changes: 1 addition & 2 deletions blanket/widgets/preset_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def _on_show_rename(self, _button):
window = app.get_active_window() # type: ignore
if window:
dialog = PresetDialog(self.preset)
dialog.set_transient_for(window)
dialog.present()
dialog.present(window)

def _on_delete_preset(self, _button):
app = Gio.Application.get_default()
Expand Down
5 changes: 1 addition & 4 deletions data/resources/preset-dialog.blp
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using Gtk 4.0;
using Adw 1;

template $PresetDialog : Adw.Window {
default-width: 400;
template $PresetDialog : Adw.Dialog {
width-request: 360;
height-request: 220;
modal: true;
destroy-with-parent: true;
focus-widget: name_entry;

Adw.ToolbarView {
Expand Down

0 comments on commit 531024c

Please sign in to comment.