[gnome-games] ui: Add video preference page



commit 01c64c7d86b51308b22340f00c59161a2685183b
Author: theawless <theawless gmail com>
Date:   Thu Feb 23 03:36:52 2017 +0530

    ui: Add video preference page
    
    Add a page to the preferences window to allow user to view and change
    video settings. This will be displayed in a subsequent commit.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777987

 data/Makefile.am                   |    1 +
 data/org.gnome.Games.gresource.xml |    1 +
 data/ui/preferences-page-video.ui  |   53 ++++++++++++++++++++++++++++++++++++
 po/POTFILES.in                     |    2 +
 src/Makefile.am                    |    1 +
 src/ui/preferences-page-video.vala |   49 +++++++++++++++++++++++++++++++++
 6 files changed, 107 insertions(+), 0 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 9275284..df280e5 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -33,6 +33,7 @@ EXTRA_DIST = \
        ui/media-selector.ui \
        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 \
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index 6745d99..16214f2 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -19,6 +19,7 @@
     <file preprocess="xml-stripblanks">ui/media-selector.ui</file>
     <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>
diff --git a/data/ui/preferences-page-video.ui b/data/ui/preferences-page-video.ui
new file mode 100644
index 0000000..50b473e
--- /dev/null
+++ b/data/ui/preferences-page-video.ui
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GamesPreferencesPageVideo" parent="GtkBin">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkScrolledWindow">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <child>
+          <object class="GtkViewport">
+            <property name="can_focus">False</property>
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkFrame">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="border_width">12</property>
+                <property name="valign">start</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <object class="GtkAlignment">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="top_padding">12</property>
+                    <child>
+                      <object class="GtkListBox" id="filter_list_box">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="selection_mode">none</property>
+                        <signal name="row-activated" handler="filter_list_box_row_activated"/>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Filter</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index eadd6c6..a013d5e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,6 +11,7 @@ data/org.gnome.Games.gschema.xml
 [type: gettext/glade]data/ui/empty-collection.ui
 [type: gettext/glade]data/ui/media-menu-button.ui
 [type: gettext/glade]data/ui/preferences-page-plugins.ui
+[type: gettext/glade]data/ui/preferences-page-video.ui
 [type: gettext/glade]data/ui/preferences-window.ui
 [type: gettext/glade]data/ui/quit-dialog.ui
 [type: gettext/glade]data/ui/remote-display.ui
@@ -49,4 +50,5 @@ src/ui/application-window.vala
 src/ui/error-display.vala
 src/ui/media-selector.vala
 src/ui/preferences-page-plugins.vala
+src/ui/preferences-page-video.vala
 src/utils/cue-sheet/cue-sheet.vala
diff --git a/src/Makefile.am b/src/Makefile.am
index 5aff69f..f5009fe 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -117,6 +117,7 @@ gnome_games_SOURCES = \
        ui/preferences-page.vala \
        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 \
diff --git a/src/ui/preferences-page-video.vala b/src/ui/preferences-page-video.vala
new file mode 100644
index 0000000..d84e681
--- /dev/null
+++ b/src/ui/preferences-page-video.vala
@@ -0,0 +1,49 @@
+// This file is part of GNOME Games. License: GPLv3
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-video.ui")]
+private class Games.PreferencesPageVideo: Gtk.Bin, PreferencesPage {
+       public string title {
+               get { return _("Video"); }
+       }
+
+       private string _filter_active;
+       public string filter_active {
+               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 ();
+                       }
+                       _filter_active = value;
+               }
+
+               get {
+                       return _filter_active;
+               }
+       }
+
+       // same as video-filters in gschema
+       private string[] filter_display_names = { _("Smooth"), _("Sharp") };
+       private string[] filter_names = { "smooth", "sharp" };
+       [GtkChild]
+       private Gtk.ListBox filter_list_box;
+       private Settings settings;
+
+       construct {
+               foreach (var filter_display_name in filter_display_names) {
+                       var switch_item = new PreferencesSwitchItem (filter_display_name);
+                       filter_list_box.add (switch_item);
+               }
+               settings = new Settings ("org.gnome.Games");
+               settings.bind ("video-filter", this, "filter-active",
+                              SettingsBindFlags.DEFAULT);
+       }
+
+       [GtkCallback]
+       private void filter_list_box_row_activated (Gtk.ListBoxRow row_item) {
+               filter_active = filter_names[row_item.get_index ()];
+       }
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]