diff --git a/data/cx.ring.RingGnome.gschema.xml b/data/cx.ring.RingGnome.gschema.xml index 80852aaa95e3f3c48fc14ba9aa6593c6a0cb733b..0f36a23e5ba32ee2d57f7e0931a54cb3cbc71ec1 100644 --- a/data/cx.ring.RingGnome.gschema.xml +++ b/data/cx.ring.RingGnome.gschema.xml @@ -21,5 +21,10 @@ <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> </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> </schemalist> diff --git a/src/currentcallview.cpp b/src/currentcallview.cpp index 9aafe4b2804d609446bb665af271435511e97358..24016b0855afbf76d5d5a911d37aa710b3cc3250 100644 --- a/src/currentcallview.cpp +++ b/src/currentcallview.cpp @@ -48,6 +48,7 @@ #include "ringnotify.h" #include <audio/codecmodel.h> #include <account.h> +#include "utils/files.h" struct _CurrentCallView { @@ -69,6 +70,7 @@ struct _CurrentCallViewPrivate GtkWidget *label_duration; GtkWidget *frame_video; GtkWidget *video_widget; + GtkWidget *paned_chat; GtkWidget *vbox_chat; GtkWidget *togglebutton_chat; GtkWidget *textview_chat; @@ -88,6 +90,8 @@ struct _CurrentCallViewPrivate QMetaObject::Connection media_added_connection; QMetaObject::Connection new_message_connection; QMetaObject::Connection incoming_msg_connection; + + GSettings *settings; }; G_DEFINE_TYPE_WITH_PRIVATE(CurrentCallView, current_call_view, GTK_TYPE_BOX); @@ -116,6 +120,8 @@ current_call_view_dispose(GObject *object) priv->fullscreen_window = NULL; } + g_clear_object(&priv->settings); + 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) 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 current_call_view_init(CurrentCallView *view) { @@ -176,6 +198,15 @@ current_call_view_init(CurrentCallView *view) * the chat treeview */ GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(priv->scrolledwindow_chat)); 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 @@ -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_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, 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, togglebutton_chat); gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, textview_chat); diff --git a/src/generalsettingsview.cpp b/src/generalsettingsview.cpp index 3bf2e86b6754be1a2941021ed51d1d061db2f806..9bf1e067131d4ec821c2a1430e66896fc8780d53 100644 --- a/src/generalsettingsview.cpp +++ b/src/generalsettingsview.cpp @@ -55,6 +55,8 @@ struct _GeneralSettingsViewPrivate GtkWidget *checkbutton_autostart; GtkWidget *checkbutton_hideonclose; GtkWidget *checkbutton_bringtofront; + GtkWidget *radiobutton_chatright; + GtkWidget *radiobutton_chatbottom; /* history settings */ GtkWidget *adjustment_history_duration; @@ -142,6 +144,12 @@ general_settings_view_init(GeneralSettingsView *self) g_settings_bind(priv->settings, "bring-window-to-front", priv->checkbutton_bringtofront, "active", 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 */ gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_history_duration), @@ -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_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, 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, button_clear_history); } diff --git a/ui/currentcallview.ui b/ui/currentcallview.ui index 074e03dd274b9023cb7c66841d27c7ef42d7c117..b263bc5583ad33e7983c77b0341c4a845ca40dc2 100644 --- a/ui/currentcallview.ui +++ b/ui/currentcallview.ui @@ -9,7 +9,6 @@ <object class="GtkPaned" id="paned_chat"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="orientation">vertical</property> <!-- box which shows all the call info, name, the video, status, etc --> diff --git a/ui/generalsettingsview.ui b/ui/generalsettingsview.ui index e7e00450b65813552cd7fd4b1453744aff8afa88..99fb7818e1af8675a3ca2b0291723a912a3f75da 100644 --- a/ui/generalsettingsview.ui +++ b/ui/generalsettingsview.ui @@ -68,6 +68,29 @@ <property name="draw_indicator">True</property> </object> </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> </child> <!-- end box ring settings -->