1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-04 20:07:36 +00:00

sip-account-widget: Use adwaita rows for server settings

Part-of: <https://gitlab.gnome.org/GNOME/calls/-/merge_requests/738>
This commit is contained in:
Anton Lazarev 2024-06-23 16:49:15 -07:00
parent 17325b3104
commit e35c15ad7d
2 changed files with 35 additions and 72 deletions

View file

@ -65,18 +65,18 @@ struct _CallsSipAccountWidget {
GtkWidget *delete_btn;
/* widgets for editing account credentials */
GtkEntry *host;
GtkEntry *display_name;
GtkEntry *user;
GtkEntry *password;
GtkEntry *port;
AdwEntryRow *host;
AdwEntryRow *display_name;
AdwEntryRow *user;
AdwEntryRow *password;
AdwEntryRow *port;
char *last_port;
AdwComboRow *protocol;
GtkStringList *protocols_store; /* bound model for protocol AdwComboRow */
AdwComboRow *media_encryption;
GListStore *media_encryption_store;
GtkSwitch *tel_switch;
GtkSwitch *auto_connect_switch;
AdwSwitchRow *tel_switch;
AdwSwitchRow *auto_connect_switch;
/* properties */
@ -188,13 +188,13 @@ on_port_entry_insert_text (CallsSipAccountWidget *self,
char *new_text,
int new_text_length,
gpointer position,
GtkEntry *entry)
AdwEntryRow *entry)
{
size_t digit_end, len;
int *pos;
g_assert (CALLS_IS_SIP_ACCOUNT_WIDGET (self));
g_assert (GTK_IS_ENTRY (entry));
g_assert (ADW_IS_ENTRY_ROW (entry));
if (!new_text || !*new_text || self->port_self_change)
return;
@ -223,7 +223,7 @@ on_port_entry_insert_text (CallsSipAccountWidget *self,
static gboolean
update_port_cursor_position (GtkEntry *entry)
update_port_cursor_position (AdwEntryRow *entry)
{
int pos;
@ -252,7 +252,7 @@ on_port_entry_after_insert_text (CallsSipAccountWidget *self,
char *new_text,
int new_text_length,
gpointer position,
GtkEntry *entry)
AdwEntryRow *entry)
{
int port = get_port (self);
@ -357,8 +357,8 @@ clear_form (CallsSipAccountWidget *self)
adw_combo_row_set_selected (self->protocol, 0);
gtk_widget_set_sensitive (GTK_WIDGET (self->media_encryption), FALSE);
adw_combo_row_set_selected (self->media_encryption, 0);
gtk_switch_set_state (self->tel_switch, FALSE);
gtk_switch_set_state (self->auto_connect_switch, TRUE);
adw_switch_row_set_active (self->tel_switch, FALSE);
adw_switch_row_set_active (self->auto_connect_switch, TRUE);
self->origin = NULL;
@ -429,8 +429,8 @@ edit_form (CallsSipAccountWidget *self,
gtk_editable_set_text (GTK_EDITABLE (self->port), port_str);
adw_combo_row_set_selected (self->protocol, protocol_index);
adw_combo_row_set_selected (self->media_encryption, encryption_index);
gtk_switch_set_state (self->tel_switch, can_tel);
gtk_switch_set_state (self->auto_connect_switch, auto_connect);
adw_switch_row_set_active (self->tel_switch, can_tel);
adw_switch_row_set_active (self->auto_connect_switch, auto_connect);
gtk_widget_set_sensitive (self->apply_btn, FALSE);
@ -492,8 +492,8 @@ on_apply_clicked (CallsSipAccountWidget *self)
get_selected_protocol (self),
get_port (self),
get_selected_media_encryption (self),
gtk_switch_get_state (self->tel_switch),
gtk_switch_get_state (self->auto_connect_switch));
adw_switch_row_get_active (self->tel_switch),
adw_switch_row_get_active (self->auto_connect_switch));
update_header (self);
calls_sip_provider_save_accounts_to_disk (self->provider);

View file

@ -52,14 +52,9 @@
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwActionRow">
<object class="AdwEntryRow" id="host">
<property name="title" translatable="yes">Server</property>
<child>
<object class="GtkEntry" id="host">
<property name="valign">center</property>
<signal name="changed" handler="on_user_changed" swapped="yes"/>
</object>
</child>
<signal name="changed" handler="on_user_changed" swapped="yes"/>
</object>
</child>
</object>
@ -67,15 +62,9 @@
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Display Name</property>
<property name="subtitle" translatable="yes">Optional</property>
<child>
<object class="GtkEntry" id="display_name">
<property name="valign">center</property>
<signal name="changed" handler="on_user_changed" swapped="yes"/>
</object>
</child>
<object class="AdwEntryRow" id="display_name">
<property name="title" translatable="yes">Display Name (Optional)</property>
<signal name="changed" handler="on_user_changed" swapped="yes"/>
</object>
</child>
</object>
@ -83,26 +72,15 @@
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwActionRow">
<object class="AdwEntryRow" id="user">
<property name="title" translatable="yes">User ID</property>
<child>
<object class="GtkEntry" id="user">
<property name="valign">center</property>
<signal name="changed" handler="on_user_changed" swapped="yes"/>
</object>
</child>
<signal name="changed" handler="on_user_changed" swapped="yes"/>
</object>
</child>
<child>
<object class="AdwActionRow">
<object class="AdwPasswordEntryRow" id="password">
<property name="title" translatable="yes">Password</property>
<child>
<object class="GtkPasswordEntry" id="password">
<property name="valign">center</property>
<property name="show-peek-icon">True</property>
<signal name="changed" handler="on_user_changed" swapped="yes"/>
</object>
</child>
<signal name="changed" handler="on_user_changed" swapped="yes"/>
</object>
</child>
</object>
@ -110,17 +88,12 @@
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwActionRow">
<object class="AdwEntryRow" id="port">
<property name="title" translatable="yes">Port</property>
<child>
<object class="GtkEntry" id="port">
<property name="valign">center</property>
<property name="input-purpose">digits</property>
<signal name="changed" handler="on_user_changed" swapped="yes"/>
<signal name="insert-text" handler="on_port_entry_insert_text" swapped="yes"/>
<signal name="insert-text" handler="on_port_entry_after_insert_text" swapped="yes" after="yes"/>
</object>
</child>
<property name="input-purpose">digits</property>
<signal name="changed" handler="on_user_changed" swapped="yes"/>
<signal name="insert-text" handler="on_port_entry_insert_text" swapped="yes"/>
<signal name="insert-text" handler="on_port_entry_after_insert_text" swapped="yes" after="yes"/>
</object>
</child>
<child>
@ -140,25 +113,15 @@
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwActionRow">
<object class="AdwSwitchRow" id="tel_switch">
<property name="title" translatable="yes">Use for Phone Calls</property>
<child>
<object class="GtkSwitch" id="tel_switch">
<property name="valign">center</property>
<signal name="notify::active" handler="on_user_changed" swapped="yes"/>
</object>
</child>
<signal name="notify::active" handler="on_user_changed" swapped="yes"/>
</object>
</child>
<child>
<object class="AdwActionRow">
<object class="AdwSwitchRow" id="auto_connect_switch">
<property name="title" translatable="yes">Automatically Connect</property>
<child>
<object class="GtkSwitch" id="auto_connect_switch">
<property name="valign">center</property>
<signal name="notify::active" handler="on_user_changed" swapped="yes"/>
</object>
</child>
<signal name="notify::active" handler="on_user_changed" swapped="yes"/>
</object>
</child>
</object>