[gnome-games] ui: Drop MessageDialog
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] ui: Drop MessageDialog
- Date: Thu, 15 Oct 2020 23:40:23 +0000 (UTC)
commit 4345c54ee6a0e999a201d1c29aecf5c73a6b157a
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Oct 16 04:07:50 2020 +0500
ui: Drop MessageDialog
Move the single function it had to DisplayView, there's no reason it has
to be a method.
data/ui/quit-dialog.ui | 2 +-
data/ui/restart-dialog.ui | 2 +-
data/ui/resume-dialog.ui | 2 +-
data/ui/resume-failed-dialog.ui | 2 +-
src/meson.build | 1 -
src/ui/display-view.vala | 33 +++++++++++++++++++++++++++++----
src/ui/message-dialog.vala | 25 -------------------------
src/ui/quit-dialog.vala | 2 +-
src/ui/restart-dialog.vala | 2 +-
src/ui/resume-dialog.vala | 2 +-
src/ui/resume-failed-dialog.vala | 2 +-
11 files changed, 37 insertions(+), 38 deletions(-)
---
diff --git a/data/ui/quit-dialog.ui b/data/ui/quit-dialog.ui
index 0be85c2a..23cb7a86 100644
--- a/data/ui/quit-dialog.ui
+++ b/data/ui/quit-dialog.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.24"/>
- <template class="GamesQuitDialog" parent="GamesMessageDialog">
+ <template class="GamesQuitDialog" parent="GtkMessageDialog">
<property name="modal">True</property>
<property name="destroy-with-parent">True</property>
<property name="type-hint">dialog</property>
diff --git a/data/ui/restart-dialog.ui b/data/ui/restart-dialog.ui
index a1eb075a..9592ffdc 100644
--- a/data/ui/restart-dialog.ui
+++ b/data/ui/restart-dialog.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.24"/>
- <template class="GamesRestartDialog" parent="GamesMessageDialog">
+ <template class="GamesRestartDialog" parent="GtkMessageDialog">
<property name="modal">True</property>
<property name="destroy-with-parent">True</property>
<property name="type-hint">dialog</property>
diff --git a/data/ui/resume-dialog.ui b/data/ui/resume-dialog.ui
index 7cd533f7..466c1e8f 100644
--- a/data/ui/resume-dialog.ui
+++ b/data/ui/resume-dialog.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.24"/>
- <template class="GamesResumeDialog" parent="GamesMessageDialog">
+ <template class="GamesResumeDialog" parent="GtkMessageDialog">
<property name="modal">True</property>
<property name="destroy-with-parent">True</property>
<property name="type-hint">dialog</property>
diff --git a/data/ui/resume-failed-dialog.ui b/data/ui/resume-failed-dialog.ui
index f24fecaa..70c56c0c 100644
--- a/data/ui/resume-failed-dialog.ui
+++ b/data/ui/resume-failed-dialog.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.24"/>
- <template class="GamesResumeFailedDialog" parent="GamesMessageDialog">
+ <template class="GamesResumeFailedDialog" parent="GtkMessageDialog">
<property name="modal">True</property>
<property name="destroy-with-parent">True</property>
<property name="type-hint">dialog</property>
diff --git a/src/meson.build b/src/meson.build
index 762d68ba..c4ee634c 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -143,7 +143,6 @@ vala_sources = [
'ui/keyboard-tester.vala',
'ui/konami-code.vala',
'ui/media-menu-button.vala',
- 'ui/message-dialog.vala',
'ui/platform-list-item.vala',
'ui/platforms-page.vala',
'ui/preferences-page.vala',
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index f63c8548..1f369eb5 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -282,16 +282,16 @@ private class Games.DisplayView : Gtk.Box, UiView {
public bool gamepad_button_press_event (Manette.Event event) {
if (resume_dialog != null)
- return resume_dialog.is_active && resume_dialog.gamepad_button_press_event (event);
+ return handle_dialog_gamepad_button_press_event (resume_dialog, event);
if (resume_failed_dialog != null)
- return resume_failed_dialog.is_active &&
resume_failed_dialog.gamepad_button_press_event (event);
+ return handle_dialog_gamepad_button_press_event (resume_failed_dialog, event);
if (quit_dialog != null)
- return quit_dialog.is_active && quit_dialog.gamepad_button_press_event (event);
+ return handle_dialog_gamepad_button_press_event (quit_dialog, event);
if (restart_dialog != null)
- return restart_dialog.is_active && restart_dialog.gamepad_button_press_event (event);
+ return handle_dialog_gamepad_button_press_event (restart_dialog, event);
if (!window.is_active || !window.get_mapped ())
return false;
@@ -742,4 +742,29 @@ private class Games.DisplayView : Gtk.Box, UiView {
is_fullscreen = false;
settings.set_boolean ("fullscreen", false);
}
+
+ private bool handle_dialog_gamepad_button_press_event (Gtk.Dialog dialog, Manette.Event event) {
+ if (!visible)
+ return false;
+
+ if (!dialog.is_active)
+ return false;
+
+ uint16 button;
+ if (!event.get_button (out button))
+ return false;
+
+ switch (button) {
+ case EventCode.BTN_A:
+ dialog.response (Gtk.ResponseType.ACCEPT);
+
+ return true;
+ case EventCode.BTN_B:
+ dialog.response (Gtk.ResponseType.CANCEL);
+
+ return true;
+ default:
+ return false;
+ }
+ }
}
diff --git a/src/ui/quit-dialog.vala b/src/ui/quit-dialog.vala
index c2c4483d..82b89d78 100644
--- a/src/ui/quit-dialog.vala
+++ b/src/ui/quit-dialog.vala
@@ -1,5 +1,5 @@
// This file is part of GNOME Games. License: GPL-3.0+.
[GtkTemplate (ui = "/org/gnome/Games/ui/quit-dialog.ui")]
-private class Games.QuitDialog : MessageDialog {
+private class Games.QuitDialog : Gtk.MessageDialog {
}
diff --git a/src/ui/restart-dialog.vala b/src/ui/restart-dialog.vala
index 0da61e9d..260c6b35 100644
--- a/src/ui/restart-dialog.vala
+++ b/src/ui/restart-dialog.vala
@@ -1,5 +1,5 @@
// This file is part of GNOME Games. License: GPL-3.0+.
[GtkTemplate (ui = "/org/gnome/Games/ui/restart-dialog.ui")]
-private class Games.RestartDialog : MessageDialog {
+private class Games.RestartDialog : Gtk.MessageDialog {
}
diff --git a/src/ui/resume-dialog.vala b/src/ui/resume-dialog.vala
index aa11d2b7..41065755 100644
--- a/src/ui/resume-dialog.vala
+++ b/src/ui/resume-dialog.vala
@@ -1,5 +1,5 @@
// This file is part of GNOME Games. License: GPL-3.0+.
[GtkTemplate (ui = "/org/gnome/Games/ui/resume-dialog.ui")]
-private class Games.ResumeDialog : MessageDialog {
+private class Games.ResumeDialog : Gtk.MessageDialog {
}
diff --git a/src/ui/resume-failed-dialog.vala b/src/ui/resume-failed-dialog.vala
index b3d0b01f..461c2368 100644
--- a/src/ui/resume-failed-dialog.vala
+++ b/src/ui/resume-failed-dialog.vala
@@ -1,5 +1,5 @@
// This file is part of GNOME Games. License: GPL-3.0+.
[GtkTemplate (ui = "/org/gnome/Games/ui/resume-failed-dialog.ui")]
-private class Games.ResumeFailedDialog : MessageDialog {
+private class Games.ResumeFailedDialog : Gtk.MessageDialog {
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]