Commit a5e8e368 authored by Stepan Salenikovich's avatar Stepan Salenikovich

chat: add option for chat to be the right (default)

The chat can now be bellow the video or to the right.
An option for this is added to the gsettings schema and
to the UI. The default is for it to be to the right
like the other Ring clients.

Change-Id: I6db382ac77ce0ed192bb717ee7825471ae8f34ee
Tuleap: #110
parent a5129f6e
...@@ -21,5 +21,10 @@ ...@@ -21,5 +21,10 @@
<summary>Saves whether or not the main window is currently hidden or not.</summary> <summary>Saves whether or not the main window is currently hidden or not.</summary>
<description>This is used when launching the application with the '--restore-last-window-state' option, which will launch the application with the main window in the same state as when it was last quit.</description> <description>This is used when launching the application with the '--restore-last-window-state' option, which will launch the application with the main window in the same state as when it was last quit.</description>
</key> </key>
<key name="chat-pane-horizontal" type="b">
<default>true</default>
<summary>Display the chat to the rigth (default) or at the bottom.</summary>
<description>If the chat pane is horizontal then the chat is displayed to the right of the video; otherwise it will be displayed bellow it.</description>
</key>
</schema> </schema>
</schemalist> </schemalist>
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "ringnotify.h" #include "ringnotify.h"
#include <audio/codecmodel.h> #include <audio/codecmodel.h>
#include <account.h> #include <account.h>
#include "utils/files.h"
struct _CurrentCallView struct _CurrentCallView
{ {
...@@ -69,6 +70,7 @@ struct _CurrentCallViewPrivate ...@@ -69,6 +70,7 @@ struct _CurrentCallViewPrivate
GtkWidget *label_duration; GtkWidget *label_duration;
GtkWidget *frame_video; GtkWidget *frame_video;
GtkWidget *video_widget; GtkWidget *video_widget;
GtkWidget *paned_chat;
GtkWidget *vbox_chat; GtkWidget *vbox_chat;
GtkWidget *togglebutton_chat; GtkWidget *togglebutton_chat;
GtkWidget *textview_chat; GtkWidget *textview_chat;
...@@ -88,6 +90,8 @@ struct _CurrentCallViewPrivate ...@@ -88,6 +90,8 @@ struct _CurrentCallViewPrivate
QMetaObject::Connection media_added_connection; QMetaObject::Connection media_added_connection;
QMetaObject::Connection new_message_connection; QMetaObject::Connection new_message_connection;
QMetaObject::Connection incoming_msg_connection; QMetaObject::Connection incoming_msg_connection;
GSettings *settings;
}; };
G_DEFINE_TYPE_WITH_PRIVATE(CurrentCallView, current_call_view, GTK_TYPE_BOX); G_DEFINE_TYPE_WITH_PRIVATE(CurrentCallView, current_call_view, GTK_TYPE_BOX);
...@@ -116,6 +120,8 @@ current_call_view_dispose(GObject *object) ...@@ -116,6 +120,8 @@ current_call_view_dispose(GObject *object)
priv->fullscreen_window = NULL; priv->fullscreen_window = NULL;
} }
g_clear_object(&priv->settings);
G_OBJECT_CLASS(current_call_view_parent_class)->dispose(object); G_OBJECT_CLASS(current_call_view_parent_class)->dispose(object);
} }
...@@ -160,6 +166,22 @@ scroll_to_bottom(GtkAdjustment *adjustment, G_GNUC_UNUSED gpointer user_data) ...@@ -160,6 +166,22 @@ scroll_to_bottom(GtkAdjustment *adjustment, G_GNUC_UNUSED gpointer user_data)
gtk_adjustment_get_upper(adjustment) - gtk_adjustment_get_page_size(adjustment)); gtk_adjustment_get_upper(adjustment) - gtk_adjustment_get_page_size(adjustment));
} }
gboolean
map_boolean_to_orientation(GValue *value, GVariant *variant, G_GNUC_UNUSED gpointer user_data)
{
if (g_variant_is_of_type(variant, G_VARIANT_TYPE_BOOLEAN)) {
if (g_variant_get_boolean(variant)) {
// true, chat should be horizontal (to the right)
g_value_set_enum(value, GTK_ORIENTATION_HORIZONTAL);
} else {
// false, chat should be vertical (at the bottom)
g_value_set_enum(value, GTK_ORIENTATION_VERTICAL);
}
return TRUE;
}
return FALSE;
}
static void static void
current_call_view_init(CurrentCallView *view) current_call_view_init(CurrentCallView *view)
{ {
...@@ -176,6 +198,15 @@ current_call_view_init(CurrentCallView *view) ...@@ -176,6 +198,15 @@ current_call_view_init(CurrentCallView *view)
* the chat treeview */ * the chat treeview */
GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(priv->scrolledwindow_chat)); GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(priv->scrolledwindow_chat));
g_signal_connect(adjustment, "changed", G_CALLBACK(scroll_to_bottom), NULL); g_signal_connect(adjustment, "changed", G_CALLBACK(scroll_to_bottom), NULL);
// bind the chat location to the gsetting
priv->settings = g_settings_new_full(get_ring_schema(), NULL, NULL);
g_settings_bind_with_mapping(priv->settings, "chat-pane-horizontal",
priv->paned_chat, "orientation",
G_SETTINGS_BIND_GET,
map_boolean_to_orientation,
nullptr, nullptr, nullptr);
} }
static void static void
...@@ -191,6 +222,7 @@ current_call_view_class_init(CurrentCallViewClass *klass) ...@@ -191,6 +222,7 @@ current_call_view_class_init(CurrentCallViewClass *klass)
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_status); gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_status);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_duration); gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_duration);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, frame_video); gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, frame_video);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, paned_chat);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, vbox_chat); gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, vbox_chat);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_chat); gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, togglebutton_chat);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, textview_chat); gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, textview_chat);
......
...@@ -55,6 +55,8 @@ struct _GeneralSettingsViewPrivate ...@@ -55,6 +55,8 @@ struct _GeneralSettingsViewPrivate
GtkWidget *checkbutton_autostart; GtkWidget *checkbutton_autostart;
GtkWidget *checkbutton_hideonclose; GtkWidget *checkbutton_hideonclose;
GtkWidget *checkbutton_bringtofront; GtkWidget *checkbutton_bringtofront;
GtkWidget *radiobutton_chatright;
GtkWidget *radiobutton_chatbottom;
/* history settings */ /* history settings */
GtkWidget *adjustment_history_duration; GtkWidget *adjustment_history_duration;
...@@ -142,6 +144,12 @@ general_settings_view_init(GeneralSettingsView *self) ...@@ -142,6 +144,12 @@ general_settings_view_init(GeneralSettingsView *self)
g_settings_bind(priv->settings, "bring-window-to-front", g_settings_bind(priv->settings, "bring-window-to-front",
priv->checkbutton_bringtofront, "active", priv->checkbutton_bringtofront, "active",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
g_settings_bind(priv->settings, "chat-pane-horizontal",
priv->radiobutton_chatright, "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind(priv->settings, "chat-pane-horizontal",
priv->radiobutton_chatbottom, "active",
(GSettingsBindFlags) (G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN));
/* history limit */ /* history limit */
gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_history_duration), gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_history_duration),
...@@ -164,6 +172,8 @@ general_settings_view_class_init(GeneralSettingsViewClass *klass) ...@@ -164,6 +172,8 @@ general_settings_view_class_init(GeneralSettingsViewClass *klass)
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_autostart); gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_autostart);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_hideonclose); gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_hideonclose);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_bringtofront); gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_bringtofront);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, radiobutton_chatright);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, radiobutton_chatbottom);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, adjustment_history_duration); gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, adjustment_history_duration);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, button_clear_history); gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, button_clear_history);
} }
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<object class="GtkPaned" id="paned_chat"> <object class="GtkPaned" id="paned_chat">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="orientation">vertical</property>
<!-- box which shows all the call info, <!-- box which shows all the call info,
name, the video, status, etc --> name, the video, status, etc -->
......
...@@ -68,6 +68,29 @@ ...@@ -68,6 +68,29 @@
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</object> </object>
</child> </child>
<child>
<object class="GtkButtonBox" id="buttonbox_chatposition">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="orientation">horizontal</property>
<property name="layout-style">start</property>
<child>
<object class="GtkRadioButton" id="radiobutton_chatright">
<property name="label" translatable="yes">Show chat on the right.</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
</child>
<child>
<object class="GtkRadioButton" id="radiobutton_chatbottom">
<property name="label" translatable="yes">Show chat on the bottom.</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="group">radiobutton_chatright</property>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
<!-- end box ring settings --> <!-- end box ring settings -->
......
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