From 460f8cc1f9e58f81566f289e5e01e8e598f38228 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 6 Oct 2014 14:48:37 -0500 Subject: replace 'orientation-lock' enum with 'rotation-lock' bool --- src/rotation-lock.cpp | 24 +++++++++++------------- tests/manual | 8 +++----- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/rotation-lock.cpp b/src/rotation-lock.cpp index 3bbe12a..f49b4eb 100644 --- a/src/rotation-lock.cpp +++ b/src/rotation-lock.cpp @@ -30,7 +30,7 @@ public: m_action_group(create_action_group()) { // build the rotation lock icon - auto icon = g_themed_icon_new_with_default_fallbacks("orientation-lock"); + auto icon = g_themed_icon_new_with_default_fallbacks(m_rotation_lock_icon_name); auto icon_deleter = [](GIcon* o){g_object_unref(G_OBJECT(o));}; m_icon.reset(icon, icon_deleter); @@ -65,6 +65,7 @@ private: **** Actions ***/ +#if 0 static gboolean settings_to_action_state(GValue *value, GVariant *variant, gpointer /*unused*/) @@ -89,6 +90,7 @@ private: auto state_is_true = g_variant_get_boolean(g_value_get_variant(value)); return g_variant_new_string(state_is_true ? "PrimaryOrientation" : "none"); } +#endif GSimpleActionGroup* create_action_group() { @@ -99,17 +101,13 @@ private: action = g_simple_action_new_stateful("rotation-lock", nullptr, g_variant_new_boolean(false)); - g_settings_bind_with_mapping(m_settings, "orientation-lock", - action, "state", - G_SETTINGS_BIND_DEFAULT, - settings_to_action_state, - action_state_to_settings, - nullptr, - nullptr); + g_settings_bind(m_settings, "rotation-lock", + action, "state", + G_SETTINGS_BIND_DEFAULT); g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action)); g_object_unref(G_OBJECT(action)); - g_signal_connect_swapped(m_settings, "changed::orientation-lock", - G_CALLBACK(on_orientation_lock_setting_changed), this); + g_signal_connect_swapped(m_settings, "changed::rotation-lock", + G_CALLBACK(on_rotation_lock_setting_changed), this); return group; } @@ -118,7 +116,7 @@ private: **** Phone profile ***/ - static void on_orientation_lock_setting_changed (gpointer gself) + static void on_rotation_lock_setting_changed (gpointer gself) { static_cast(gself)->update_phone_header(); } @@ -143,7 +141,7 @@ private: Header h; h.title = _("Rotation lock"); h.a11y = h.title; - h.is_visible = g_settings_get_enum(m_settings, "orientation-lock") != 0; + h.is_visible = g_settings_get_enum(m_settings, "rotation-lock") != 0; h.icon = m_icon; m_phone->header().set(h); } @@ -153,7 +151,7 @@ private: ***/ static constexpr char const * m_schema_name {"com.ubuntu.touch.system"}; - static constexpr char const * m_orientation_lock_icon_name {"orientation-lock"}; + static constexpr char const * m_rotation_lock_icon_name {"orientation-lock"}; GSettings* m_settings = nullptr; GSimpleActionGroup* m_action_group = nullptr; std::shared_ptr m_phone; diff --git a/tests/manual b/tests/manual index ff283cb..2de2d89 100644 --- a/tests/manual +++ b/tests/manual @@ -1,14 +1,12 @@ Test-case indicator-display/rotation-indicator
-
On the phone, enable the orientation lock in ubuntu-system-settings.
+
On the phone, enable the rotation lock in ubuntu-system-settings.
The rotation lock indicator should appear, and its switch menuitem should be set to 'true'.
-
NOTE: Current builds this is broken, until it is fixed in system settings you can set it with: gsettings set com.ubuntu.touch.system orientation-lock 'LandscapeOrientation'
-
With the orientation locked, click on the indicator's switch menuitem to toggle from locked to unlocked. +
With the rotation locked, click on the indicator's switch menuitem to toggle from locked to unlocked.
The rotation lock indicator should disappear
-
In ubuntu-system-settings, the orientation lock control should change to 'none'.
-
NOTE: Current builds this is broken, until it is fixed in system settings you can get it with: gsettings get com.ubuntu.touch.system orientation-lock
+
In ubuntu-system-settings, the rotation lock control should change to 'none'.
-- cgit v1.2.3 From 5e05830765bdcae09db297918d3aa0620371ccf3 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 6 Oct 2014 14:54:15 -0500 Subject: fix warnings reported by flint++ -- explicit ctors, classes with virtual methods but no virtual dtor, #ifdef include guards --- src/exporter.h | 6 +++++- src/indicator.h | 1 + tests/glib-fixture.h | 9 +++++++++ tests/gtestdbus-fixture.h | 10 ++++++++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/exporter.h b/src/exporter.h index 6367f3a..8867d32 100644 --- a/src/exporter.h +++ b/src/exporter.h @@ -17,6 +17,9 @@ * Charles Kerr */ +#ifndef INDICATOR_DISPLAY_EXPORTER_H +#define INDICATOR_DISPLAY_EXPORTER_H + #include #include @@ -26,7 +29,7 @@ class Exporter { public: - Exporter(const std::shared_ptr& indicator); + explicit Exporter(const std::shared_ptr& indicator); ~Exporter(); core::Signal& name_lost(); @@ -38,3 +41,4 @@ private: Exporter& operator=(const Exporter&) =delete; }; +#endif /* INDICATOR_DISPLAY_EXPORTER_H */ diff --git a/src/indicator.h b/src/indicator.h index dc4df09..d0834fd 100644 --- a/src/indicator.h +++ b/src/indicator.h @@ -52,6 +52,7 @@ public: virtual std::string name() const =0; virtual const core::Property
& header() const =0; virtual std::shared_ptr menu_model() const =0; + virtual ~Profile() =default; protected: Profile() =default; diff --git a/tests/glib-fixture.h b/tests/glib-fixture.h index a8f3a76..d60a038 100644 --- a/tests/glib-fixture.h +++ b/tests/glib-fixture.h @@ -17,6 +17,9 @@ * Charles Kerr */ +#ifndef INDICATOR_TESTS_GLIB_FIXTURE_H +#define INDICATOR_TESTS_GLIB_FIXTURE_H + #include #include @@ -140,4 +143,10 @@ class GlibFixture : public ::testing::Test } GMainLoop * loop; + + public: + + virtual ~GLibFixture() =default; }; + +#endif /* INDICATOR_TESTS_GLIB_FIXTURE_H */ diff --git a/tests/gtestdbus-fixture.h b/tests/gtestdbus-fixture.h index 541050e..c592033 100644 --- a/tests/gtestdbus-fixture.h +++ b/tests/gtestdbus-fixture.h @@ -17,6 +17,9 @@ * Charles Kerr */ +#ifndef INDICATOR_TESTS_GTESTDBUS_FIXTURE_H +#define INDICATOR_TESTS_GTESTDBUS_FIXTURE_H + #include "glib-fixture.h" /*** @@ -27,9 +30,10 @@ class GTestDBusFixture: public GlibFixture { public: - GTestDBusFixture() {} + GTestDBusFixture() =default; + virtual ~GTestDBusFixture() =default; - GTestDBusFixture(const std::vector& service_dirs_in): service_dirs(service_dirs_in) {} + explicit GTestDBusFixture(const std::vector& service_dirs_in): service_dirs(service_dirs_in) {} private: @@ -100,3 +104,5 @@ class GTestDBusFixture: public GlibFixture super::TearDown(); } }; + +#endif /* INDICATOR_TESTS_GTESTDBUS_FIXTURE_H */ -- cgit v1.2.3 From cd87a58b8d7478f00b10465702a169fe92cc2dd7 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 6 Oct 2014 15:01:11 -0500 Subject: fix oops --- tests/glib-fixture.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/glib-fixture.h b/tests/glib-fixture.h index d60a038..a3e9605 100644 --- a/tests/glib-fixture.h +++ b/tests/glib-fixture.h @@ -146,7 +146,7 @@ class GlibFixture : public ::testing::Test public: - virtual ~GLibFixture() =default; + virtual ~GlibFixture() =default; }; #endif /* INDICATOR_TESTS_GLIB_FIXTURE_H */ -- cgit v1.2.3 From 7f952611ac4ef3eaed1eef9bc86be955ff66ef2a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 6 Oct 2014 15:20:50 -0500 Subject: report unexpected g_log() calls via g_print() instead of g_log() :D --- tests/glib-fixture.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/glib-fixture.h b/tests/glib-fixture.h index a3e9605..a5da2f5 100644 --- a/tests/glib-fixture.h +++ b/tests/glib-fixture.h @@ -55,7 +55,7 @@ class GlibFixture : public ::testing::Test if (expected_log[level] != n) for (size_t i=0; i Date: Mon, 6 Oct 2014 15:21:16 -0500 Subject: fix the settings-to-action-state mappings --- src/rotation-lock.cpp | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/rotation-lock.cpp b/src/rotation-lock.cpp index f49b4eb..5fff062 100644 --- a/src/rotation-lock.cpp +++ b/src/rotation-lock.cpp @@ -65,13 +65,11 @@ private: **** Actions ***/ -#if 0 static gboolean settings_to_action_state(GValue *value, GVariant *variant, gpointer /*unused*/) { - bool is_locked = g_strcmp0(g_variant_get_string(variant, nullptr), "none"); - g_value_set_variant(value, g_variant_new_boolean(is_locked)); + g_value_set_variant(value, variant); return TRUE; } @@ -79,18 +77,8 @@ private: const GVariantType * /*expected_type*/, gpointer /*unused*/) { - // Toggling to 'on' *should* lock to the screen's current orientation. - // We don't have any way of knowing Screen.orientation in this service, - // so just pick one at random to satisfy the binding's needs. - // - // In practice this doesn't matter since the indicator isn't visible - // when the lock mode is 'none' so the end user won't ever be able - // to toggle the menuitem from None to anything else. - - auto state_is_true = g_variant_get_boolean(g_value_get_variant(value)); - return g_variant_new_string(state_is_true ? "PrimaryOrientation" : "none"); + return g_variant_new_boolean(g_value_get_boolean(value)); } -#endif GSimpleActionGroup* create_action_group() { @@ -101,9 +89,14 @@ private: action = g_simple_action_new_stateful("rotation-lock", nullptr, g_variant_new_boolean(false)); - g_settings_bind(m_settings, "rotation-lock", - action, "state", - G_SETTINGS_BIND_DEFAULT); + g_settings_bind_with_mapping(m_settings, "rotation-lock", + action, "state", + G_SETTINGS_BIND_DEFAULT, + settings_to_action_state, + action_state_to_settings, + nullptr, + nullptr); + g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action)); g_object_unref(G_OBJECT(action)); g_signal_connect_swapped(m_settings, "changed::rotation-lock", @@ -141,7 +134,7 @@ private: Header h; h.title = _("Rotation lock"); h.a11y = h.title; - h.is_visible = g_settings_get_enum(m_settings, "rotation-lock") != 0; + h.is_visible = g_settings_get_boolean(m_settings, "rotation-lock"); h.icon = m_icon; m_phone->header().set(h); } -- cgit v1.2.3 From 997f89bae00ec896c87a8a3877d2d16fc0175f99 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 6 Oct 2014 15:26:40 -0500 Subject: make a debugging message go through g_debug() instead of g_message() --- src/exporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exporter.cpp b/src/exporter.cpp index f45d9d6..8b2a72a 100644 --- a/src/exporter.cpp +++ b/src/exporter.cpp @@ -141,7 +141,7 @@ private: profile->header().changed().connect([action_group,action_name](const Header& header){ auto state = create_header_state(header); auto tmp = g_variant_print(state, true); - g_message("header changed; updating action state to '%s'", tmp); + g_debug("header changed; updating action state to '%s'", tmp); g_action_group_change_action_state(G_ACTION_GROUP(action_group), action_name.c_str(), create_header_state(header)); -- cgit v1.2.3 From 94ba0a4147052dec53e2ba818ec3d03141e8f26b Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 6 Oct 2014 15:57:13 -0500 Subject: don't use 'auto tmp = ...' when tmp is going to be passed to g_free() --- src/exporter.cpp | 2 +- tests/glib-fixture.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exporter.cpp b/src/exporter.cpp index 8b2a72a..21e8af7 100644 --- a/src/exporter.cpp +++ b/src/exporter.cpp @@ -140,7 +140,7 @@ private: g_action_map_add_action(G_ACTION_MAP(action_group), G_ACTION(a)); profile->header().changed().connect([action_group,action_name](const Header& header){ auto state = create_header_state(header); - auto tmp = g_variant_print(state, true); + char* tmp = g_variant_print(state, true); g_debug("header changed; updating action state to '%s'", tmp); g_action_group_change_action_state(G_ACTION_GROUP(action_group), action_name.c_str(), diff --git a/tests/glib-fixture.h b/tests/glib-fixture.h index a5da2f5..65d2921 100644 --- a/tests/glib-fixture.h +++ b/tests/glib-fixture.h @@ -67,7 +67,7 @@ class GlibFixture : public ::testing::Test const gchar * message, gpointer self) { - auto tmp = g_strdup_printf ("%s:%d \"%s\"", log_domain, (int)log_level, message); + char* tmp = g_strdup_printf ("%s:%d \"%s\"", log_domain, (int)log_level, message); static_cast(self)->log[log_level].push_back(tmp); g_free(tmp); } -- cgit v1.2.3