Commit c42a44ef authored by Guido Gunther's avatar Guido Gunther

settings: Add orientation lock to rotate quick setting

Long press switches between potrait/landscape and rotation lock.
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 2ae87ad3
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "feedback-manager.h" #include "feedback-manager.h"
#include "notifications/notify-manager.h" #include "notifications/notify-manager.h"
#include "notifications/notification-frame.h" #include "notifications/notification-frame.h"
#include "rotateinfo.h"
#include <pulse/pulseaudio.h> #include <pulse/pulseaudio.h>
#include "gvc-mixer-control.h" #include "gvc-mixer-control.h"
...@@ -82,16 +83,60 @@ static void ...@@ -82,16 +83,60 @@ static void
rotation_setting_clicked_cb (PhoshSettings *self) rotation_setting_clicked_cb (PhoshSettings *self)
{ {
PhoshShell *shell = phosh_shell_get_default (); PhoshShell *shell = phosh_shell_get_default ();
PhoshRotationManager *rotation_manager;
PhoshRotationManagerMode mode;
PhoshMonitorTransform transform; PhoshMonitorTransform transform;
gboolean locked;
g_return_if_fail (PHOSH_IS_SETTINGS (self)); g_return_if_fail (PHOSH_IS_SETTINGS (self));
transform = phosh_shell_get_transform (shell);
phosh_shell_set_transform (shell, transform == PHOSH_MONITOR_TRANSFORM_NORMAL rotation_manager = phosh_shell_get_rotation_manager (shell);
? PHOSH_MONITOR_TRANSFORM_270 g_return_if_fail (rotation_manager);
: PHOSH_MONITOR_TRANSFORM_NORMAL); mode = phosh_rotation_manager_get_mode (PHOSH_ROTATION_MANAGER (rotation_manager));
switch (mode) {
case PHOSH_ROTATION_MANAGER_MODE_OFF:
transform = phosh_shell_get_transform (shell);
phosh_shell_set_transform (shell, transform == PHOSH_MONITOR_TRANSFORM_NORMAL
? PHOSH_MONITOR_TRANSFORM_270
: PHOSH_MONITOR_TRANSFORM_NORMAL);
break;
case PHOSH_ROTATION_MANAGER_MODE_SENSOR:
locked = phosh_rotation_manager_get_orientation_locked (rotation_manager);
phosh_rotation_manager_set_orientation_locked (rotation_manager, !locked);
break;
default:
g_assert_not_reached ();
}
g_signal_emit (self, signals[SETTING_DONE], 0); g_signal_emit (self, signals[SETTING_DONE], 0);
} }
static void
rotation_setting_long_pressed_cb (PhoshSettings *self)
{
PhoshShell *shell = phosh_shell_get_default ();
PhoshRotateInfoMode mode;
PhoshRotationManager *rotation_manager;
rotation_manager = phosh_shell_get_rotation_manager (shell);
g_return_if_fail (rotation_manager);
mode = phosh_rotation_manager_get_mode (rotation_manager);
switch (mode) {
case PHOSH_ROTATION_MANAGER_MODE_OFF:
mode = PHOSH_ROTATION_MANAGER_MODE_SENSOR;
break;
case PHOSH_ROTATION_MANAGER_MODE_SENSOR:
mode = PHOSH_ROTATION_MANAGER_MODE_OFF;
break;
default:
g_assert_not_reached ();
}
g_debug ("Rotation manager mode: %d", mode);
phosh_rotation_manager_set_mode (rotation_manager, mode);
}
static void static void
feedback_setting_clicked_cb (PhoshSettings *self) feedback_setting_clicked_cb (PhoshSettings *self)
{ {
...@@ -469,6 +514,7 @@ phosh_settings_class_init (PhoshSettingsClass *klass) ...@@ -469,6 +514,7 @@ phosh_settings_class_init (PhoshSettingsClass *klass)
gtk_widget_class_bind_template_callback (widget_class, feedback_setting_long_pressed_cb); gtk_widget_class_bind_template_callback (widget_class, feedback_setting_long_pressed_cb);
gtk_widget_class_bind_template_callback (widget_class, on_media_player_raised); gtk_widget_class_bind_template_callback (widget_class, on_media_player_raised);
gtk_widget_class_bind_template_callback (widget_class, rotation_setting_clicked_cb); gtk_widget_class_bind_template_callback (widget_class, rotation_setting_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, rotation_setting_long_pressed_cb);
gtk_widget_class_bind_template_callback (widget_class, torch_setting_clicked_cb); gtk_widget_class_bind_template_callback (widget_class, torch_setting_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, wifi_setting_clicked_cb); gtk_widget_class_bind_template_callback (widget_class, wifi_setting_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, wwan_setting_clicked_cb); gtk_widget_class_bind_template_callback (widget_class, wwan_setting_clicked_cb);
......
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<signal name="clicked" handler="rotation_setting_clicked_cb" object="PhoshSettings" swapped="yes"/> <signal name="clicked" handler="rotation_setting_clicked_cb" object="PhoshSettings" swapped="yes"/>
<signal name="long-pressed" handler="rotation_setting_long_pressed_cb" object="PhoshSettings" swapped="yes"/>
<child> <child>
<object class="PhoshRotateInfo" id="rotateinfo"> <object class="PhoshRotateInfo" id="rotateinfo">
<property name="visible">True</property> <property name="visible">True</property>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment