Commit 1e191dc8 authored by Sébastien Blin's avatar Sébastien Blin

accounttab: move auto-answer and UPnP option to advanced tab

Change-Id: Ifa96aaed02fcfa230c03109c5dc21559bf78b9f4
Reviewed-by: Philippe Gorley's avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent f21ffca6
......@@ -45,6 +45,7 @@ struct _AccountAdvancedTabPrivate
{
Account *account;
GtkWidget *vbox_main;
GtkWidget *grid_parameters;
GtkWidget *frame_registration;
GtkWidget *box_registration;
GtkWidget *box_registration_expire;
......@@ -116,6 +117,7 @@ account_advanced_tab_class_init(AccountAdvancedTabClass *klass)
"/cx/ring/RingGnome/accountadvancedtab.ui");
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, vbox_main);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, grid_parameters);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, frame_registration);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, box_registration);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountAdvancedTab, box_registration_expire);
......@@ -424,6 +426,30 @@ bootstrap_server_edited(GtkCellRendererText *renderer, gchar *path, gchar *new_t
);
}
}
static void
entry_name_service_url_changed(GtkEditable *entry, AccountAdvancedTab *view)
{
g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(view));
AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(view);
priv->account->setNameServiceURL(QString(gtk_editable_get_chars(entry, 0, -1)));
}
static void
auto_answer(GtkToggleButton *checkbutton, AccountAdvancedTab *view)
{
g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(view));
AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(view);
priv->account->setAutoAnswer(gtk_toggle_button_get_active(checkbutton));
}
static void
upnp_enabled(GtkToggleButton *checkbutton, AccountAdvancedTab *view)
{
g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(view));
AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(view);
priv->account->setUpnpEnabled(gtk_toggle_button_get_active(checkbutton));
}
static void
build_tab_view(AccountAdvancedTab *self)
......@@ -431,6 +457,46 @@ build_tab_view(AccountAdvancedTab *self)
g_return_if_fail(IS_ACCOUNT_ADVANCED_TAB(self));
AccountAdvancedTabPrivate *priv = ACCOUNT_ADVANCED_TAB_GET_PRIVATE(self);
// separate pointers for each so that we reference them in the account changed callback
GtkWidget *checkbutton_autoanswer = NULL;
GtkWidget *checkbutton_upnp = NULL;
// build parameters grid
int grid_row = 0;
GtkWidget *label = NULL;
if (priv->account->protocol() == Account::Protocol::RING) {
// RING account
// Name service
label = gtk_label_new(_("Name service URL"));
gtk_widget_set_halign(label, GTK_ALIGN_START);
gtk_grid_attach(GTK_GRID(priv->grid_parameters), label, 0, grid_row, 1, 1);
GtkWidget* entry_name_service_url = gtk_entry_new();
gtk_widget_set_halign(entry_name_service_url, GTK_ALIGN_START);
gtk_entry_set_text(GTK_ENTRY(entry_name_service_url), priv->account->nameServiceURL().toLocal8Bit().constData());
gtk_grid_attach(GTK_GRID(priv->grid_parameters), entry_name_service_url, 1, grid_row, 1, 1);
g_signal_connect(entry_name_service_url, "changed", G_CALLBACK(entry_name_service_url_changed), self);
++grid_row;
}
// auto answer
checkbutton_autoanswer = gtk_check_button_new_with_label(_("Auto-answer calls"));
gtk_widget_set_halign(checkbutton_autoanswer, GTK_ALIGN_START);
gtk_grid_attach(GTK_GRID(priv->grid_parameters), checkbutton_autoanswer, 0, grid_row, 1, 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_autoanswer), priv->account->isAutoAnswer());
g_signal_connect(checkbutton_autoanswer, "toggled", G_CALLBACK(auto_answer), self);
++grid_row;
// upnp
checkbutton_upnp = gtk_check_button_new_with_label(_("UPnP enabled"));
gtk_widget_set_halign(checkbutton_upnp, GTK_ALIGN_START);
gtk_grid_attach(GTK_GRID(priv->grid_parameters), checkbutton_upnp, 0, grid_row, 1, 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_upnp), priv->account->isUpnpEnabled());
g_signal_connect(checkbutton_upnp, "toggled", G_CALLBACK(upnp_enabled), self);
++grid_row;
gtk_widget_show_all(priv->grid_parameters);
/* only show registration timeout for SIP account */
if (priv->account->protocol() != Account::Protocol::SIP) {
gtk_container_remove(GTK_CONTAINER(priv->box_registration), priv->box_registration_expire);
......@@ -646,6 +712,10 @@ build_tab_view(AccountAdvancedTab *self)
priv->account,
&Account::changed,
[=] () {
// upnp and auto answer
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_autoanswer), priv->account->isAutoAnswer());
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_upnp), priv->account->isUpnpEnabled());
/* only show registration timeout for SIP account */
if ( priv->box_registration_expire ) {
gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_registration_timeout),
......
......@@ -42,6 +42,7 @@ struct _AccountGeneralTabPrivate
{
Account *account;
GtkWidget *grid_account;
GtkWidget* frame_parameters;
GtkWidget *grid_parameters;
GtkWidget* entry_current_password;
......@@ -86,6 +87,7 @@ account_general_tab_class_init(AccountGeneralTabClass *klass)
"/cx/ring/RingGnome/accountgeneraltab.ui");
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountGeneralTab, grid_account);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountGeneralTab, frame_parameters);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountGeneralTab, grid_parameters);
/* change password view */
......@@ -111,14 +113,6 @@ account_alias_changed(GtkEditable *entry, AccountGeneralTab *view)
priv->account->setDisplayName(gtk_entry_get_text(GTK_ENTRY(entry)));
}
static void
entry_name_service_url_changed(GtkEditable *entry, AccountGeneralTab *view)
{
g_return_if_fail(IS_ACCOUNT_GENERAL_TAB(view));
AccountGeneralTabPrivate *priv = ACCOUNT_GENERAL_TAB_GET_PRIVATE(view);
priv->account->setNameServiceURL(QString(gtk_editable_get_chars(entry, 0, -1)));
}
static void
account_hostname_changed(GtkEditable *entry, AccountGeneralTab *view)
{
......@@ -165,22 +159,6 @@ account_mailbox_changed(GtkEditable *entry, AccountGeneralTab *view)
priv->account->setMailbox(QString(gtk_editable_get_chars(entry, 0, -1)));
}
static void
auto_answer(GtkToggleButton *checkbutton, AccountGeneralTab *view)
{
g_return_if_fail(IS_ACCOUNT_GENERAL_TAB(view));
AccountGeneralTabPrivate *priv = ACCOUNT_GENERAL_TAB_GET_PRIVATE(view);
priv->account->setAutoAnswer(gtk_toggle_button_get_active(checkbutton));
}
static void
upnp_enabled(GtkToggleButton *checkbutton, AccountGeneralTab *view)
{
g_return_if_fail(IS_ACCOUNT_GENERAL_TAB(view));
AccountGeneralTabPrivate *priv = ACCOUNT_GENERAL_TAB_GET_PRIVATE(view);
priv->account->setUpnpEnabled(gtk_toggle_button_get_active(checkbutton));
}
static void
reset_change_password(AccountGeneralTab *view)
{
......@@ -275,8 +253,6 @@ build_tab_view(AccountGeneralTab *view)
GtkWidget *entry_password = NULL;
GtkWidget *entry_proxy = NULL;
GtkWidget *entry_voicemail = NULL;
GtkWidget *checkbutton_autoanswer = NULL;
GtkWidget *checkbutton_upnp = NULL;
/* build account grid */
......@@ -404,37 +380,11 @@ build_tab_view(AccountGeneralTab *view)
g_signal_connect(entry_voicemail, "changed", G_CALLBACK(account_mailbox_changed), view);
gtk_grid_attach(GTK_GRID(priv->grid_parameters), entry_voicemail, 1, grid_row, 1, 1);
++grid_row;
} else {
/* RING account */
/* Name service */
label = gtk_label_new(_("Name service URL"));
gtk_widget_set_halign(label, GTK_ALIGN_START);
gtk_grid_attach(GTK_GRID(priv->grid_parameters), label, 0, grid_row, 1, 1);
GtkWidget* entry_name_service_url = gtk_entry_new();
gtk_widget_set_halign(entry_name_service_url, GTK_ALIGN_START);
gtk_entry_set_text(GTK_ENTRY(entry_name_service_url), priv->account->nameServiceURL().toLocal8Bit().constData());
gtk_grid_attach(GTK_GRID(priv->grid_parameters), entry_name_service_url, 1, grid_row, 1, 1);
g_signal_connect(entry_name_service_url, "changed", G_CALLBACK(entry_name_service_url_changed), view);
++grid_row;
} else {
gtk_widget_hide(priv->frame_parameters);
}
/* auto answer */
checkbutton_autoanswer = gtk_check_button_new_with_label(_("Auto-answer calls"));
gtk_widget_set_halign(checkbutton_autoanswer, GTK_ALIGN_START);
gtk_grid_attach(GTK_GRID(priv->grid_parameters), checkbutton_autoanswer, 0, grid_row, 1, 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_autoanswer), priv->account->isAutoAnswer());
g_signal_connect(checkbutton_autoanswer, "toggled", G_CALLBACK(auto_answer), view);
++grid_row;
/* upnp */
checkbutton_upnp = gtk_check_button_new_with_label(_("UPnP enabled"));
gtk_widget_set_halign(checkbutton_upnp, GTK_ALIGN_START);
gtk_grid_attach(GTK_GRID(priv->grid_parameters), checkbutton_upnp, 0, grid_row, 1, 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_upnp), priv->account->isUpnpEnabled());
g_signal_connect(checkbutton_upnp, "toggled", G_CALLBACK(upnp_enabled), view);
++grid_row;
gtk_widget_show_all(priv->grid_parameters);
/* update account parameters if model is updated */
priv->account_updated = QObject::connect(
......@@ -450,9 +400,6 @@ build_tab_view(AccountGeneralTab *view)
gtk_entry_set_text(GTK_ENTRY(entry_proxy), priv->account->proxy().toLocal8Bit().constData());
gtk_entry_set_text(GTK_ENTRY(entry_voicemail), priv->account->mailbox().toLocal8Bit().constData());
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_autoanswer), priv->account->isAutoAnswer());
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_upnp), priv->account->isUpnpEnabled());
}
);
......@@ -463,8 +410,6 @@ build_tab_view(AccountGeneralTab *view)
g_signal_connect_swapped(priv->button_choose_file, "clicked", G_CALLBACK(choose_export_file), view);
gtk_widget_set_visible(priv->entry_current_password, priv->account->archiveHasPassword());
gtk_widget_show_all(priv->grid_parameters);
}
GtkWidget *
......
......@@ -55,6 +55,54 @@
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<property name="border_width">10</property>
<child>
<object class="GtkFrame" id="frame_settings">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment_parameters">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">10</property>
<property name="left_padding">10</property>
<child>
<object class="GtkGrid" id="grid_parameters">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">10</property>
<property name="column_spacing">10</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label_parameters">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Auto-answer and UPnP</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame_registration">
<property name="visible">True</property>
......
......@@ -123,12 +123,6 @@
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
......
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