Commit 97b44af2 authored by Landry Breuil's avatar Landry Breuil Committed by Landry Breuil
Browse files

move the logic setting GtkSpin port value to setup_for_type()

should fix #11.

setup_for_type() was forcefully setting the port value with the method default
port, potentially overwriting a value coming from a bookmark previously set by
init_values()

Instead, let's move the code setting the value to setup_for_type(), defaulting
to 0, then to the method port if we've detected a known scheme, and if we're
editing a bookmark, take the value from the bookmark.

tested in the following cases:
- creating a new connection -> the port value is set to the scheme default
- editing an existing bookmark -> the value comes from the bookmark
- changing the scheme type on an existing bookmark -> the port value is reset
  to the scheme default
parent 749f361b
Pipeline #6888 passed with stages
in 1 minute and 1 second
......@@ -391,9 +391,7 @@ static void init_values(GigoloBookmarkEditDialog *dialog)
GigoloBookmarkEditDialogPrivate *priv = gigolo_bookmark_edit_dialog_get_instance_private(dialog);
gchar *uri, *user;
const gchar *tmp;
guint port;
guint idx;
/* Name */
tmp = gigolo_bookmark_get_name(priv->bookmark_init);
if (tmp != NULL)
......@@ -454,8 +452,6 @@ static void init_values(GigoloBookmarkEditDialog *dialog)
tmp = gigolo_bookmark_get_path(priv->bookmark_init);
if (tmp != NULL)
gtk_entry_set_text(GTK_ENTRY(priv->path_entry), tmp);
/* Port */
port = gigolo_bookmark_get_port(priv->bookmark_init);
idx = scheme_to_index(gigolo_bookmark_get_scheme(priv->bookmark_init));
......@@ -463,10 +459,6 @@ static void init_values(GigoloBookmarkEditDialog *dialog)
GTK_SWITCH(priv->autoconnect_switch),
gigolo_bookmark_get_autoconnect(priv->bookmark_init));
if (port == 0)
port = methods[idx].port;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->port_spin), port);
combo_set_active(priv->type_combo, idx);
}
......@@ -475,6 +467,7 @@ static void setup_for_type(GigoloBookmarkEditDialog *dialog)
{
struct MethodInfo *meth;
guint idx;
guint port = 0;
GtkTreeIter iter;
GigoloBookmarkEditDialogPrivate *priv = gigolo_bookmark_edit_dialog_get_instance_private(dialog);
......@@ -485,7 +478,6 @@ static void setup_for_type(GigoloBookmarkEditDialog *dialog)
&iter, COLUMN_INDEX, &idx, -1);
g_return_if_fail(idx < methods_len);
meth = &(methods[idx]);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->port_spin), meth->port);
gtk_widget_hide (priv->uri_label);
gtk_widget_hide (priv->uri_entry);
......@@ -523,6 +515,11 @@ static void setup_for_type(GigoloBookmarkEditDialog *dialog)
}
else
{
port = meth->port;
if (priv->bookmark_init && idx == scheme_to_index(gigolo_bookmark_get_scheme(priv->bookmark_init)))
port = gigolo_bookmark_get_port(priv->bookmark_init);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->port_spin), port);
if (meth->flags & SHOW_DEVICE)
gtk_label_set_text_with_mnemonic(GTK_LABEL(priv->host_label), _("_Device:"));
else
......
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