[gnome-games/wip/exalm/gtk4: 9/48] message-dialog: Don't subclass GtkMessageDialog
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/gtk4: 9/48] message-dialog: Don't subclass GtkMessageDialog
- Date: Wed, 21 Aug 2019 22:47:59 +0000 (UTC)
commit 2bc0555414c5fb0f1c406857f3e902de428314c8
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Mon Aug 19 15:22:56 2019 +0500
message-dialog: Don't subclass GtkMessageDialog
We cannot do this in GTK4. Because of that, reimplement this type of
dialog and only subclass GtkDialog.
This introduces a deprecation that will be fixed in later commits.
data/org.gnome.Games.gresource.xml | 1 +
data/ui/message-dialog.ui | 62 +++++++++++++++++++++++++++++
data/ui/quit-dialog.ui | 4 --
data/ui/reset-controller-mapping-dialog.ui | 6 +--
data/ui/resume-dialog.ui | 4 --
data/ui/resume-failed-dialog.ui | 4 --
src/ui/message-dialog.vala | 45 ++++++++++++++++++++-
src/ui/reset-controller-mapping-dialog.vala | 2 +-
8 files changed, 109 insertions(+), 19 deletions(-)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index b30c6da1..a7403025 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -30,6 +30,7 @@
<file preprocess="xml-stripblanks">ui/keyboard-mapper.ui</file>
<file preprocess="xml-stripblanks">ui/keyboard-tester.ui</file>
<file preprocess="xml-stripblanks">ui/media-menu-button.ui</file>
+ <file preprocess="xml-stripblanks">ui/message-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/platforms-view.ui</file>
<file preprocess="xml-stripblanks">ui/platform-list-item.ui</file>
<file preprocess="xml-stripblanks">ui/preferences-page.ui</file>
diff --git a/data/ui/message-dialog.ui b/data/ui/message-dialog.ui
new file mode 100644
index 00000000..e653ad82
--- /dev/null
+++ b/data/ui/message-dialog.ui
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="gtk40">
+ <template class="GamesMessageDialog" parent="GtkDialog">
+ <property name="title"></property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="destroy-with-parent">True</property>
+ <property name="type-hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">20</property>
+ <property name="border-width">0</property>
+ <child>
+ <object class="GtkBox" id="box">
+ <property name="visible">True</property>
+ <property name="margin-start">30</property>
+ <property name="margin-end">30</property>
+ <property name="spacing">30</property>
+ <property name="border-width">5</property>
+ <child>
+ <object class="GtkBox" id="message_area">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">10</property>
+ <property name="hexpand">True</property>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="halign">center</property>
+ <property name="valign">start</property>
+ <property name="wrap">True</property>
+ <property name="max-width-chars">60</property>
+ <style>
+ <class name="title"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="secondary_label">
+ <property name="visible">False</property>
+ <property name="margin-bottom">2</property>
+ <property name="halign">center</property>
+ <property name="valign">start</property>
+ <property name="vexpand">True</property>
+ <property name="wrap">True</property>
+ <property name="max-width-chars">60</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+ <object class="GtkBox" id="title_box">
+ <property name="visible">True</property>
+ <property name="height-request">16</property>
+ </object>
+</interface>
diff --git a/data/ui/quit-dialog.ui b/data/ui/quit-dialog.ui
index 0be85c2a..7201a896 100644
--- a/data/ui/quit-dialog.ui
+++ b/data/ui/quit-dialog.ui
@@ -2,10 +2,6 @@
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="GamesQuitDialog" parent="GamesMessageDialog">
- <property name="modal">True</property>
- <property name="destroy-with-parent">True</property>
- <property name="type-hint">dialog</property>
- <property name="message-type">question</property>
<property name="text" translatable="yes">Are you sure you want to quit?</property>
<property name="secondary-text" translatable="yes">All unsaved progress will be lost.</property>
<child type="action">
diff --git a/data/ui/reset-controller-mapping-dialog.ui b/data/ui/reset-controller-mapping-dialog.ui
index 3a281424..ebaf79be 100644
--- a/data/ui/reset-controller-mapping-dialog.ui
+++ b/data/ui/reset-controller-mapping-dialog.ui
@@ -1,11 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.24"/>
- <template class="GamesResetControllerMappingDialog" parent="GtkMessageDialog">
- <property name="modal">True</property>
- <property name="destroy-with-parent">True</property>
- <property name="type-hint">dialog</property>
- <property name="message-type">question</property>
+ <template class="GamesResetControllerMappingDialog" parent="GamesMessageDialog">
<property name="text" translatable="yes">Factory reset mapping for this controller?</property>
<property name="secondary-text" translatable="yes">Your mapping will be lost.</property>
<child type="action">
diff --git a/data/ui/resume-dialog.ui b/data/ui/resume-dialog.ui
index 7cd533f7..f42c2860 100644
--- a/data/ui/resume-dialog.ui
+++ b/data/ui/resume-dialog.ui
@@ -2,10 +2,6 @@
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="GamesResumeDialog" parent="GamesMessageDialog">
- <property name="modal">True</property>
- <property name="destroy-with-parent">True</property>
- <property name="type-hint">dialog</property>
- <property name="message-type">question</property>
<property name="text" translatable="yes">Resume last game?</property>
<child type="action">
<object class="GtkButton" id="button_reset">
diff --git a/data/ui/resume-failed-dialog.ui b/data/ui/resume-failed-dialog.ui
index f24fecaa..b35eb483 100644
--- a/data/ui/resume-failed-dialog.ui
+++ b/data/ui/resume-failed-dialog.ui
@@ -2,10 +2,6 @@
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="GamesResumeFailedDialog" parent="GamesMessageDialog">
- <property name="modal">True</property>
- <property name="destroy-with-parent">True</property>
- <property name="type-hint">dialog</property>
- <property name="message-type">question</property>
<property name="text" translatable="yes">Resuming failed. Do you want to restart the game?</property>
<child type="action">
<object class="GtkButton" id="button_cancel">
diff --git a/src/ui/message-dialog.vala b/src/ui/message-dialog.vala
index 7a9a743e..6896d011 100644
--- a/src/ui/message-dialog.vala
+++ b/src/ui/message-dialog.vala
@@ -1,6 +1,49 @@
// This file is part of GNOME Games. License: GPL-3.0+.
-private class Games.MessageDialog : Gtk.MessageDialog {
+[GtkTemplate (ui = "/org/gnome/Games/ui/message-dialog.ui")]
+private class Games.MessageDialog : Gtk.Dialog {
+ [GtkChild]
+ private Gtk.Label label;
+ [GtkChild]
+ private Gtk.Label secondary_label;
+ [GtkChild]
+ private Gtk.Box title_box;
+
+ private string _text;
+ public string text {
+ get { return _text; }
+ set {
+ _text = value;
+ label.label = value;
+ }
+ }
+
+ private string _secondary_text;
+ public string? secondary_text {
+ get { return _secondary_text; }
+ set {
+ _secondary_text = value;
+ secondary_label.label = value;
+ secondary_label.visible = (value != null);
+ }
+ }
+
+ construct {
+ // FIXME: There's no way to avoid this in GTK3
+ var action_area = get_action_area () as Gtk.ButtonBox;
+ action_area.set_layout (Gtk.ButtonBoxStyle.EXPAND);
+ }
+
+ static construct {
+ set_css_name ("messagedialog");
+ }
+
+ public override void constructed () {
+ base.constructed ();
+
+ set_titlebar (title_box);
+ }
+
public bool gamepad_button_press_event (Manette.Event event) {
if (!visible)
return false;
diff --git a/src/ui/reset-controller-mapping-dialog.vala b/src/ui/reset-controller-mapping-dialog.vala
index ab6b5959..64d3dbc8 100644
--- a/src/ui/reset-controller-mapping-dialog.vala
+++ b/src/ui/reset-controller-mapping-dialog.vala
@@ -1,5 +1,5 @@
// This file is part of GNOME Games. License: GPL-3.0+.
[GtkTemplate (ui = "/org/gnome/Games/ui/reset-controller-mapping-dialog.ui")]
-public class Games.ResetControllerMappingDialog : Gtk.MessageDialog {
+private class Games.ResetControllerMappingDialog : MessageDialog {
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]