[gnome-games] ui: Reformat preferences-switch-item
- From: Abhinav Singh <abhinavsingh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] ui: Reformat preferences-switch-item
- Date: Sun, 23 Apr 2017 00:27:31 +0000 (UTC)
commit abb916e68a3efdc56333a94b9123c31d8c80d954
Author: theawless <theawless gmail com>
Date: Wed Apr 12 16:11:13 2017 +0530
ui: Reformat preferences-switch-item
Use properties instead of methods and update their corresponding uses.
Rename preferences-switch-item to checkmark-item.
https://bugzilla.gnome.org/show_bug.cgi?id=780778
data/Makefile.am | 2 +-
data/org.gnome.Games.gresource.xml | 2 +-
...references-switch-item.ui => checkmark-item.ui} | 4 +-
src/Makefile.am | 2 +-
src/ui/checkmark-item.vala | 21 ++++++++++++++++++++
src/ui/preferences-page-video.vala | 11 +++------
src/ui/preferences-switch-item.vala | 21 --------------------
7 files changed, 30 insertions(+), 33 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index f1b1dea..87b56b8 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -25,6 +25,7 @@ EXTRA_DIST = \
gtk/menus.ui \
gtk-style.css \
ui/application-window.ui \
+ ui/checkmark-item.ui \
ui/collection-box.ui \
ui/collection-header-bar.ui \
ui/collection-icon-view.ui \
@@ -41,7 +42,6 @@ EXTRA_DIST = \
ui/preferences-page-plugins-item.ui \
ui/preferences-page-plugins.ui \
ui/preferences-page-video.ui \
- ui/preferences-switch-item.ui \
ui/preferences-window.ui \
ui/quit-dialog.ui \
ui/remote-display.ui \
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index 16214f2..e66ccca 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -5,6 +5,7 @@
<file>gamepads/gamecontrollerdb.txt</file>
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
<file preprocess="xml-stripblanks">ui/application-window.ui</file>
+ <file preprocess="xml-stripblanks">ui/checkmark-item.ui</file>
<file preprocess="xml-stripblanks">ui/collection-box.ui</file>
<file preprocess="xml-stripblanks">ui/collection-header-bar.ui</file>
<file preprocess="xml-stripblanks">ui/collection-icon-view.ui</file>
@@ -20,7 +21,6 @@
<file preprocess="xml-stripblanks">ui/preferences-page-plugins.ui</file>
<file preprocess="xml-stripblanks">ui/preferences-page-plugins-item.ui</file>
<file preprocess="xml-stripblanks">ui/preferences-page-video.ui</file>
- <file preprocess="xml-stripblanks">ui/preferences-switch-item.ui</file>
<file preprocess="xml-stripblanks">ui/preferences-window.ui</file>
<file preprocess="xml-stripblanks">ui/quit-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/remote-display.ui</file>
diff --git a/data/ui/preferences-switch-item.ui b/data/ui/checkmark-item.ui
similarity index 86%
rename from data/ui/preferences-switch-item.ui
rename to data/ui/checkmark-item.ui
index 0039e6f..f52f131 100644
--- a/data/ui/preferences-switch-item.ui
+++ b/data/ui/checkmark-item.ui
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <template class="GamesPreferencesSwitchItem" parent="GtkBox">
+ <template class="GamesCheckmarkItem" parent="GtkBox">
<property name="vexpand">false</property>
<property name="orientation">horizontal</property>
<property name="margin">6</property>
@@ -14,7 +14,7 @@
</object>
</child>
<child>
- <object class="GtkImage" id="select_image">
+ <object class="GtkImage" id="checkmark_image">
<property name="icon-name">object-select-symbolic</property>
<property name="valign">center</property>
</object>
diff --git a/src/Makefile.am b/src/Makefile.am
index 69126be..cc9f9a5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -102,6 +102,7 @@ gnome_games_SOURCES = \
\
ui/application.vala \
ui/application-window.vala \
+ ui/checkmark-item.vala \
ui/collection-box.vala \
ui/collection-icon-view.vala \
ui/collection-header-bar.vala \
@@ -119,7 +120,6 @@ gnome_games_SOURCES = \
ui/preferences-page-plugins.vala \
ui/preferences-page-plugins-item.vala \
ui/preferences-page-video.vala \
- ui/preferences-switch-item.vala \
ui/preferences-window.vala \
ui/quit-dialog.vala \
ui/remote-display.vala \
diff --git a/src/ui/checkmark-item.vala b/src/ui/checkmark-item.vala
new file mode 100644
index 0000000..8382584
--- /dev/null
+++ b/src/ui/checkmark-item.vala
@@ -0,0 +1,21 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/checkmark-item.ui")]
+private class Games.CheckmarkItem: Gtk.Box {
+ [GtkChild]
+ private Gtk.Label title_label;
+ [GtkChild]
+ private Gtk.Image checkmark_image;
+
+ public bool checkmark_visible { set; get; }
+ private Binding checkmark_visible_binding;
+
+ public CheckmarkItem (string name) {
+ title_label.label = name;
+ }
+
+ construct {
+ checkmark_visible_binding = bind_property ("checkmark-visible", checkmark_image, "visible",
+ BindingFlags.DEFAULT);
+ }
+}
diff --git a/src/ui/preferences-page-video.vala b/src/ui/preferences-page-video.vala
index c6a9c1c..7754e59 100644
--- a/src/ui/preferences-page-video.vala
+++ b/src/ui/preferences-page-video.vala
@@ -11,11 +11,8 @@ private class Games.PreferencesPageVideo: Gtk.Bin, PreferencesPage {
set {
for (var i = 0; i < filter_names.length; i++) {
var row_item = filter_list_box.get_row_at_index (i);
- var switch_item = (PreferencesSwitchItem) row_item.get_child ();
- if (value == filter_names[i])
- switch_item.switch_activate ();
- else
- switch_item.switch_deactivate ();
+ var checkmark_item = (CheckmarkItem) row_item.get_child ();
+ checkmark_item.checkmark_visible = (value == filter_names[i]);
}
_filter_active = value;
}
@@ -34,8 +31,8 @@ private class Games.PreferencesPageVideo: Gtk.Bin, PreferencesPage {
construct {
foreach (var filter_display_name in filter_display_names) {
- var switch_item = new PreferencesSwitchItem (filter_display_name);
- filter_list_box.add (switch_item);
+ var checkmark_item = new CheckmarkItem (filter_display_name);
+ filter_list_box.add (checkmark_item);
}
settings = new Settings ("org.gnome.Games");
settings.bind ("video-filter", this, "filter-active",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]