aboutsummaryrefslogtreecommitdiff
path: root/src/rotation-lock.cpp
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-10-09 13:44:12 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-10-09 13:44:12 +0000
commitc8edcbeb3add928e37705ec51c8739d953f0d540 (patch)
treefd2bff9b14767a059828dc8460f14b94a98c58cd /src/rotation-lock.cpp
parent7eaeb6486f681391b5d5b9a3d15ceeedc4313244 (diff)
parent94ba0a4147052dec53e2ba818ec3d03141e8f26b (diff)
downloadayatana-indicator-display-c8edcbeb3add928e37705ec51c8739d953f0d540.tar.gz
ayatana-indicator-display-c8edcbeb3add928e37705ec51c8739d953f0d540.tar.bz2
ayatana-indicator-display-c8edcbeb3add928e37705ec51c8739d953f0d540.zip
Use com.ubuntu.touch.system's "rotation-lock" boolean for the rotation lock indicator. Fixes: 1378078
Approved by: Ted Gould, PS Jenkins bot
Diffstat (limited to 'src/rotation-lock.cpp')
-rw-r--r--src/rotation-lock.cpp29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/rotation-lock.cpp b/src/rotation-lock.cpp
index e305b38..31e9d12 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);
@@ -69,8 +69,7 @@ private:
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;
}
@@ -78,16 +77,7 @@ 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));
}
GSimpleActionGroup* create_action_group()
@@ -99,17 +89,18 @@ private:
action = g_simple_action_new_stateful("rotation-lock",
nullptr,
g_variant_new_boolean(false));
- g_settings_bind_with_mapping(m_settings, "orientation-lock",
+ 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::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 +109,7 @@ private:
**** Phone profile
***/
- static void on_orientation_lock_setting_changed (gpointer gself)
+ static void on_rotation_lock_setting_changed (gpointer gself)
{
static_cast<Impl*>(gself)->update_phone_header();
}
@@ -143,7 +134,7 @@ private:
Header h;
h.title = _("Rotation");
h.a11y = h.title;
- h.is_visible = g_settings_get_enum(m_settings, "orientation-lock") != 0;
+ h.is_visible = g_settings_get_boolean(m_settings, "rotation-lock");
h.icon = m_icon;
m_phone->header().set(h);
}
@@ -153,7 +144,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<SimpleProfile> m_phone;