1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-04 20:07:36 +00:00
Anton Lazarev 2023-12-13 17:34:57 -08:00
parent ca059116b9
commit 47e30c12a7

View file

@ -70,7 +70,7 @@ struct _CallsSipAccountWidget {
GtkEntry *port;
char *last_port;
AdwComboRow *protocol;
GListStore *protocols_store; /* bound model for protocol AdwComboRow */
GtkStringList *protocols_store; /* bound model for protocol AdwComboRow */
AdwComboRow *media_encryption;
GListStore *media_encryption_store;
GtkSwitch *tel_switch;
@ -114,13 +114,11 @@ is_form_filled (CallsSipAccountWidget *self)
static const char *
get_selected_protocol (CallsSipAccountWidget *self)
{
g_autoptr (AdwValueObject) obj = NULL;
const char *protocol = NULL;
gint i;
if ((i = adw_combo_row_get_selected_index (self->protocol)) != -1) {
obj = g_list_model_get_item (G_LIST_MODEL (self->protocols_store), i);
protocol = adw_value_object_get_string (obj);
if ((i = adw_combo_row_get_selected(self->protocol)) != GTK_INVALID_LIST_POSITION) {
protocol = gtk_string_list_get_string (self->protocols_store, i);
}
return protocol;
}
@ -129,11 +127,11 @@ get_selected_protocol (CallsSipAccountWidget *self)
static SipMediaEncryption
get_selected_media_encryption (CallsSipAccountWidget *self)
{
g_autoptr (AdwValueObject) obj = NULL;
GObject *obj = NULL;
SipMediaEncryption media_encryption = SIP_MEDIA_ENCRYPTION_NONE;
gint i;
if ((i = adw_combo_row_get_selected_index (self->media_encryption)) != -1) {
if ((i = adw_combo_row_get_selected(self->media_encryption)) != GTK_INVALID_LIST_POSITION) {
obj = g_list_model_get_item (G_LIST_MODEL (self->media_encryption_store), i);
media_encryption = (SipMediaEncryption) GPOINTER_TO_INT (g_object_get_data (G_OBJECT (obj), "value"));
}
@ -158,7 +156,7 @@ update_media_encryption (CallsSipAccountWidget *self)
transport_is_tls | sdes_always_allowed);
if (!transport_is_tls && !sdes_always_allowed)
adw_combo_row_set_selected_index (self->media_encryption, 0);
adw_combo_row_set_selected (self->media_encryption, 0);
}
@ -335,9 +333,7 @@ find_protocol (CallsSipAccountWidget *self,
len = g_list_model_get_n_items (G_LIST_MODEL (self->protocols_store));
for (guint i = 0; i < len; i++) {
g_autoptr (AdwValueObject) obj =
g_list_model_get_item (G_LIST_MODEL (self->protocols_store), i);
const char *prot = adw_value_object_get_string (obj);
const char *prot = gtk_string_list_get_string (self->protocols_store, i);
if (g_strcmp0 (protocol, prot) == 0) {
if (index)
@ -363,7 +359,7 @@ find_media_encryption (CallsSipAccountWidget *self,
len = g_list_model_get_n_items (G_LIST_MODEL (self->media_encryption_store));
for (guint i = 0; i < len; i++) {
g_autoptr (AdwValueObject) obj =
GString* obj =
g_list_model_get_item (G_LIST_MODEL (self->media_encryption_store), i);
SipMediaEncryption obj_enc =
(SipMediaEncryption) GPOINTER_TO_INT (g_object_get_data (G_OBJECT (obj), "value"));
@ -390,9 +386,9 @@ clear_form (CallsSipAccountWidget *self)
gtk_editable_set_text (GTK_EDITABLE (self->user), "");
gtk_editable_set_text (GTK_EDITABLE (self->password), "");
gtk_editable_set_text (GTK_EDITABLE (self->port), "0");
adw_combo_row_set_selected_index (self->protocol, 0);
adw_combo_row_set_selected (self->protocol, 0);
gtk_widget_set_sensitive (GTK_WIDGET (self->media_encryption), FALSE);
adw_combo_row_set_selected_index (self->media_encryption, 0);
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);
@ -464,8 +460,8 @@ edit_form (CallsSipAccountWidget *self,
gtk_editable_set_text (GTK_EDITABLE (self->password), password);
set_password_visibility (self, FALSE);
gtk_editable_set_text (GTK_EDITABLE (self->port), port_str);
adw_combo_row_set_selected_index (self->protocol, protocol_index);
adw_combo_row_set_selected_index (self->media_encryption, encryption_index);
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);
@ -652,7 +648,7 @@ calls_sip_account_widget_class_init (CallsSipAccountWidgetClass *klass)
static void
calls_sip_account_widget_init (CallsSipAccountWidget *self)
{
AdwValueObject *obj;
GtkStringObject *obj;
self->settings = calls_settings_get_default ();
@ -663,44 +659,30 @@ calls_sip_account_widget_init (CallsSipAccountWidget *self)
gtk_widget_init_template (GTK_WIDGET (self));
self->media_encryption_store = g_list_store_new (ADW_TYPE_VALUE_OBJECT);
self->media_encryption_store = g_list_store_new (GTK_TYPE_STRING_OBJECT);
obj = adw_value_object_new_string (_("No encryption"));
obj = gtk_string_object_new (_("No encryption"));
g_object_set_data (G_OBJECT (obj),
"value", GINT_TO_POINTER (SIP_MEDIA_ENCRYPTION_NONE));
g_list_store_insert (self->media_encryption_store, 0, obj);
g_clear_object (&obj);
/* TODO Optional encryption */
obj = adw_value_object_new_string (_("Force encryption"));
obj = gtk_string_object_new (_("Force encryption"));
g_object_set_data (G_OBJECT (obj),
"value", GINT_TO_POINTER (SIP_MEDIA_ENCRYPTION_FORCED));
g_list_store_insert (self->media_encryption_store, 1, obj);
g_clear_object (&obj);
adw_combo_row_bind_name_model (self->media_encryption,
G_LIST_MODEL (self->media_encryption_store),
(AdwComboRowGetNameFunc) adw_value_object_dup_string,
NULL, NULL);
adw_combo_row_set_model(self->media_encryption, G_LIST_MODEL (self->media_encryption_store));
self->protocols_store = g_list_store_new (ADW_TYPE_VALUE_OBJECT);
self->protocols_store = gtk_string_list_new (NULL);
obj = adw_value_object_new_string ("UDP");
g_list_store_insert (self->protocols_store, 0, obj);
g_clear_object (&obj);
gtk_string_list_append (self->protocols_store, "UDP");
gtk_string_list_append (self->protocols_store, "TCP");
gtk_string_list_append (self->protocols_store, "TLS");
obj = adw_value_object_new_string ("TCP");
g_list_store_insert (self->protocols_store, 1, obj);
g_clear_object (&obj);
obj = adw_value_object_new_string ("TLS");
g_list_store_insert (self->protocols_store, 2, obj);
g_clear_object (&obj);
adw_combo_row_bind_name_model (self->protocol,
G_LIST_MODEL (self->protocols_store),
(AdwComboRowGetNameFunc) adw_value_object_dup_string,
NULL, NULL);
adw_combo_row_set_model(self->protocol, G_LIST_MODEL (self->protocols_store));
}