[gnome-games/wip/exalm/cleanups: 3/5] error-info-bar: Don't subclass GtkInfoBar
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/cleanups: 3/5] error-info-bar: Don't subclass GtkInfoBar
- Date: Wed, 29 May 2019 14:03:28 +0000 (UTC)
commit 2f73071be74da0208f379806cd114741f8383345
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Wed May 29 16:49:41 2019 +0500
error-info-bar: Don't subclass GtkInfoBar
GtkInfoBar was made non-derivable in GTK4.
Additionally, setting properties works from template now.
data/ui/error-info-bar.ui | 33 +++++++++++++++++++--------------
src/ui/collection-box.vala | 3 +--
src/ui/error-info-bar.vala | 20 +++++++++-----------
3 files changed, 29 insertions(+), 27 deletions(-)
---
diff --git a/data/ui/error-info-bar.ui b/data/ui/error-info-bar.ui
index 5eb4ec34..c8bec669 100644
--- a/data/ui/error-info-bar.ui
+++ b/data/ui/error-info-bar.ui
@@ -1,21 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.24"/>
- <template class="GamesErrorInfoBar" parent="GtkInfoBar">
+ <template class="GamesErrorInfoBar" parent="GtkBin">
<property name="visible">True</property>
- <property name="revealed">False</property>
- <property name="halign">fill</property>
- <property name="valign">start</property>
- <property name="show-close-button">True</property>
- <property name="message-type">error</property>
- <signal name="response" handler="on_response"/>
- <child internal-child="content_area">
- <object class="GtkBox" id="content_area">
- <child>
- <object class="GtkLabel" id="label">
- <property name="visible">True</property>
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
+ <child>
+ <object class="GtkInfoBar" id="info_bar">
+ <property name="visible">True</property>
+ <property name="revealed">False</property>
+ <property name="halign">fill</property>
+ <property name="valign">start</property>
+ <property name="show-close-button">True</property>
+ <property name="message-type">error</property>
+ <signal name="response" handler="on_response"/>
+ <child internal-child="content_area">
+ <object class="GtkBox" id="content_area">
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">word-char</property>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/src/ui/collection-box.vala b/src/ui/collection-box.vala
index e6d87b38..df373577 100644
--- a/src/ui/collection-box.vala
+++ b/src/ui/collection-box.vala
@@ -65,8 +65,7 @@ private class Games.CollectionBox : Gtk.Box {
}
public void show_error (string error_message) {
- error_info_bar.message = error_message;
- error_info_bar.revealed = true;
+ error_info_bar.show_error (error_message);
}
public bool gamepad_button_press_event (Manette.Event event) {
diff --git a/src/ui/error-info-bar.vala b/src/ui/error-info-bar.vala
index b2812509..5b632511 100644
--- a/src/ui/error-info-bar.vala
+++ b/src/ui/error-info-bar.vala
@@ -1,21 +1,19 @@
// This file is part of GNOME Games. License: GPL-3.0+.
[GtkTemplate (ui = "/org/gnome/Games/ui/error-info-bar.ui")]
-private class Games.ErrorInfoBar : Gtk.InfoBar {
+private class Games.ErrorInfoBar : Gtk.Bin {
+ [GtkChild]
+ private Gtk.InfoBar info_bar;
[GtkChild]
private Gtk.Label label;
- construct {
- show_close_button = true; // FIXME: Why doesn't this work from template?
- message_type = Gtk.MessageType.ERROR; // FIXME: Why doesn't this work from template?
- }
-
- public string message {
- set { label.label = value; }
- }
-
[GtkCallback]
private void on_response () {
- revealed = false;
+ info_bar.revealed = false;
+ }
+
+ public void show_error (string message) {
+ label.label = message;
+ info_bar.revealed = true;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]