[gnome-games/wip/exalm/cleanups: 5/9] Prefer properties over methods



commit 3d5473a68dbd9dbb4f5a1967e81a4bce4d431e0a
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Tue Sep 11 14:16:20 2018 +0500

    Prefer properties over methods
    
    Follow the coding style described in CodingStyle.txt

 src/ui/application-window.vala           | 18 +++++++++---------
 src/ui/application.vala                  |  8 ++++----
 src/ui/collection-header-bar.vala        |  2 +-
 src/ui/collection-icon-view.vala         |  2 +-
 src/ui/display-header-bar.vala           |  4 ++--
 src/ui/gamepad-configurer.vala           | 17 +++++++----------
 src/ui/keyboard-configurer.vala          | 17 +++++++----------
 src/ui/preferences-page-controllers.vala |  4 ++--
 src/ui/preferences-window.vala           |  2 +-
 9 files changed, 34 insertions(+), 40 deletions(-)
---
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index d5fbcb09..bc932f1b 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -18,8 +18,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
 
                        switch (ui_state) {
                        case UiState.COLLECTION:
-                               content_box.set_visible_child (collection_box);
-                               header_bar.set_visible_child (collection_header_bar);
+                               content_box.visible_child = collection_box;
+                               header_bar.visible_child = collection_header_bar;
 
                                is_fullscreen = false;
 
@@ -30,8 +30,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
 
                                break;
                        case UiState.DISPLAY:
-                               content_box.set_visible_child (display_box);
-                               header_bar.set_visible_child (display_header_bar);
+                               content_box.visible_child = display_box;
+                               header_bar.visible_child = display_header_bar;
 
                                search_mode = false;
 
@@ -154,7 +154,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                inhibit_cookie = 0;
                inhibit_flags = 0;
 
-               set_show_menubar (false); // Essential, see bug #771683
+               show_menubar = false; // Essential, see bug #771683
 
                if (Config.PROFILE == "Devel")
                        get_style_context ().add_class ("devel");
@@ -388,7 +388,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                        return false;
 
                resume_dialog = new ResumeDialog ();
-               resume_dialog.set_transient_for (this);
+               resume_dialog.transient_for = this;
 
                cancellable.cancelled.connect (() => {
                        resume_dialog.destroy ();
@@ -429,7 +429,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                        return;
 
                resume_failed_dialog = new ResumeFailedDialog ();
-               resume_failed_dialog.set_transient_for (this);
+               resume_failed_dialog.transient_for = this;
 
                cancellable.cancelled.connect (() => {
                        resume_failed_dialog.destroy ();
@@ -471,7 +471,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                        return false;
 
                quit_dialog = new QuitDialog ();
-               quit_dialog.set_transient_for (this);
+               quit_dialog.transient_for = this;
 
                cancellable.cancelled.connect (() => {
                        quit_dialog.destroy ();
@@ -521,7 +521,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                if (monitor == null)
                        return null;
 
-               return monitor.get_geometry ();
+               return monitor.geometry;
        }
 
        private bool store_window_size () {
diff --git a/src/ui/application.vala b/src/ui/application.vala
index ba58ae08..421d410a 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -177,7 +177,7 @@ public class Games.Application : Gtk.Application {
                chooser.select_multiple = true;
 
                var filter = new Gtk.FileFilter ();
-               chooser.set_filter (filter);
+               chooser.filter = filter;
                foreach (var mime_type in game_collection.get_accepted_mime_types ())
                        filter.add_mime_type (mime_type);
 
@@ -382,9 +382,9 @@ public class Games.Application : Gtk.Application {
 
        private void about () {
                Gtk.AboutDialog dialog = new Gtk.AboutDialog ();
-               dialog.set_destroy_with_parent (true);
-               dialog.set_transient_for (window);
-               dialog.set_modal (true);
+               dialog.destroy_with_parent = true;
+               dialog.transient_for = window;
+               dialog.modal = true;
 
                dialog.program_name = _("GNOME Games") + Config.NAME_SUFFIX;
                dialog.logo_icon_name = Config.APPLICATION_ID;
diff --git a/src/ui/collection-header-bar.vala b/src/ui/collection-header-bar.vala
index 5e98107d..f2195538 100644
--- a/src/ui/collection-header-bar.vala
+++ b/src/ui/collection-header-bar.vala
@@ -8,7 +8,7 @@ private class Games.CollectionHeaderBar : Gtk.HeaderBar {
                get { return _viewstack; }
                set {
                        _viewstack = value;
-                       view_switcher.set_stack (_viewstack);
+                       view_switcher.stack = _viewstack;
                }
        }
 
diff --git a/src/ui/collection-icon-view.vala b/src/ui/collection-icon-view.vala
index 49d62e83..6944814e 100644
--- a/src/ui/collection-icon-view.vala
+++ b/src/ui/collection-icon-view.vala
@@ -132,7 +132,7 @@ private class Games.CollectionIconView : Gtk.Bin {
 
        public void reset_scroll_position () {
                var adjustment = scrolled_window.get_vadjustment ();
-               adjustment.set_value (0);
+               adjustment.value = 0;
        }
 
        public bool has_game_selected () {
diff --git a/src/ui/display-header-bar.vala b/src/ui/display-header-bar.vala
index 419dc7ac..e92d2634 100644
--- a/src/ui/display-header-bar.vala
+++ b/src/ui/display-header-bar.vala
@@ -35,8 +35,8 @@ private class Games.DisplayHeaderBar : Gtk.HeaderBar {
                settings = new Settings ("org.gnome.Games");
 
                media_selector = new MediaSelector ();
-               media_selector.set_relative_to (media_button);
-               media_button.set_popover (media_selector);
+               media_selector.relative_to = media_button;
+               media_button.popover = media_selector;
        }
 
        [GtkCallback]
diff --git a/src/ui/gamepad-configurer.vala b/src/ui/gamepad-configurer.vala
index c124c2ea..627d0d6b 100644
--- a/src/ui/gamepad-configurer.vala
+++ b/src/ui/gamepad-configurer.vala
@@ -66,18 +66,18 @@ private class Games.GamepadConfigurer : Gtk.Box {
                set {
                        _state = value;
                        immersive_mode = (state == State.CONFIGURE);
+                       back_button.visible = (state == State.TEST);
+                       cancel_button.visible = (state == State.CONFIGURE);
+                       action_bar.visible = (state == State.TEST);
 
                        switch (value) {
                        case State.TEST:
                                reset_button.set_sensitive (device.has_user_mapping ());
 
-                               back_button.show ();
-                               cancel_button.hide ();
-                               action_bar.show ();
                                /* translators: testing a gamepad, %s is its name */
                                header_bar.title = _("Testing %s").printf (device.get_name ());
                                header_bar.get_style_context ().remove_class ("selection-mode");
-                               stack.set_visible_child_name ("gamepad_tester");
+                               stack.visible_child = gamepad_tester_holder;
 
                                tester.start ();
                                mapper.stop ();
@@ -85,13 +85,10 @@ private class Games.GamepadConfigurer : Gtk.Box {
 
                                break;
                        case State.CONFIGURE:
-                               back_button.hide ();
-                               cancel_button.show ();
-                               action_bar.hide ();
                                /* translators: configuring a gamepad, %s is its name */
                                header_bar.title = _("Configuring %s").printf (device.get_name ());
                                header_bar.get_style_context ().add_class ("selection-mode");
-                               stack.set_visible_child_name ("gamepad_mapper");
+                               stack.visible_child = gamepad_mapper_holder;
 
                                tester.stop ();
                                mapper.start ();
@@ -163,12 +160,12 @@ private class Games.GamepadConfigurer : Gtk.Box {
 
        private void reset_mapping () {
                var message_dialog = new ResetControllerMappingDialog ();
-               message_dialog.set_transient_for ((Gtk.Window) get_toplevel ());
+               message_dialog.transient_for = (Gtk.Window) get_toplevel ();
                message_dialog.response.connect ((response) => {
                        switch (response) {
                                case Gtk.ResponseType.ACCEPT:
                                        device.remove_user_mapping ();
-                                       reset_button.set_sensitive (false);
+                                       reset_button.sensitive = false;
 
                                        break;
                                default:
diff --git a/src/ui/keyboard-configurer.vala b/src/ui/keyboard-configurer.vala
index 34ccddb0..e9a34692 100644
--- a/src/ui/keyboard-configurer.vala
+++ b/src/ui/keyboard-configurer.vala
@@ -57,17 +57,17 @@ private class Games.KeyboardConfigurer : Gtk.Box {
                set {
                        _state = value;
                        immersive_mode = (state == State.CONFIGURE);
+                       back_button.visible = (state == State.TEST);
+                       cancel_button.visible = (state == State.CONFIGURE);
+                       action_bar.visible = (state == State.TEST);
 
                        switch (value) {
                        case State.TEST:
                                reset_button.set_sensitive (!mapping_manager.is_default ());
 
-                               back_button.show ();
-                               cancel_button.hide ();
-                               action_bar.show ();
                                header_bar.title = _("Testing Keyboard");
                                header_bar.get_style_context ().remove_class ("selection-mode");
-                               stack.set_visible_child_name ("keyboard_tester");
+                               stack.visible_child = keyboard_tester_holder;
 
                                tester.start ();
                                mapper.stop ();
@@ -75,12 +75,9 @@ private class Games.KeyboardConfigurer : Gtk.Box {
 
                                break;
                        case State.CONFIGURE:
-                               back_button.hide ();
-                               cancel_button.show ();
-                               action_bar.hide ();
                                header_bar.title = _("Configuring Keyboard");
                                header_bar.get_style_context ().add_class ("selection-mode");
-                               stack.set_visible_child_name ("keyboard_mapper");
+                               stack.visible_child = keyboard_mapper_holder;
 
                                tester.stop ();
                                mapper.start ();
@@ -156,12 +153,12 @@ private class Games.KeyboardConfigurer : Gtk.Box {
 
        private void reset_mapping () {
                var message_dialog = new ResetControllerMappingDialog ();
-               message_dialog.set_transient_for ((Gtk.Window) get_toplevel ());
+               message_dialog.transient_for = (Gtk.Window) get_toplevel ();
                message_dialog.response.connect ((response) => {
                        switch (response) {
                                case Gtk.ResponseType.ACCEPT:
                                        mapping_manager.delete_mapping ();
-                                       reset_button.set_sensitive (false);
+                                       reset_button.sensitive = false;
 
                                        break;
                                default:
diff --git a/src/ui/preferences-page-controllers.vala b/src/ui/preferences-page-controllers.vala
index 8a68073c..a90b8a72 100644
--- a/src/ui/preferences-page-controllers.vala
+++ b/src/ui/preferences-page-controllers.vala
@@ -107,7 +107,7 @@ private class Games.PreferencesPageControllers: Gtk.Stack, PreferencesPage {
                immersive_mode_binding = configurer.bind_property ("immersive-mode", this, "immersive-mode",
                                                                   BindingFlags.SYNC_CREATE);
                extra_stack_child_holder.pack_start (configurer);
-               set_visible_child_name ("extra_stack_child");
+               visible_child_name = "extra_stack_child";
        }
 
        private void on_back (Object? emitter) {
@@ -121,7 +121,7 @@ private class Games.PreferencesPageControllers: Gtk.Stack, PreferencesPage {
 
                header_bar = default_header_bar;
                immersive_mode = false;
-               set_visible_child_name ("main_stack_child");
+               visible_child_name = "main_stack_child";
                extra_stack_child_holder.foreach ((child) => child.destroy ());
        }
 }
diff --git a/src/ui/preferences-window.vala b/src/ui/preferences-window.vala
index 77fb3ce1..94177222 100644
--- a/src/ui/preferences-window.vala
+++ b/src/ui/preferences-window.vala
@@ -57,7 +57,7 @@ private class Games.PreferencesWindow : Gtk.Window {
        }
 
        private void visible_child_changed () {
-               var page = (PreferencesPage) stack.get_visible_child ();
+               var page = (PreferencesPage) stack.visible_child;
                if (page == null) {
                        right_header_bar = null;
 


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