gtkmountoperation: Drop the new line character when splitting a message

When asking for a password, the message string is split on primary
and secondary if it contains a newline character. However, the newline
character is currently part of both strings, which creates weird
spacing between the GtkLabels. I suppose this is bug, which was not
visible as in most cases (if not all) the message string hasn't
contained the new line characters so far. But we are going to change
that now, see GNOME/gvfs!82. Let's drop the new line character similarly
as it is done when asking for a question, or showing processes in order
to fix the weird spacing.
This commit is contained in:
Ondrej Holy
2020-08-07 09:38:37 +02:00
parent d5b42f78aa
commit ec1e2fac95

View File

@ -558,7 +558,7 @@ gtk_mount_operation_ask_password_do_gtk (GtkMountOperation *operation,
gboolean can_anonymous; gboolean can_anonymous;
guint rows; guint rows;
gchar *primary; gchar *primary;
const gchar *secondary; const gchar *secondary = NULL;
PangoAttrList *attrs; PangoAttrList *attrs;
gboolean use_header; gboolean use_header;
@ -618,17 +618,14 @@ G_GNUC_END_IGNORE_DEPRECATIONS
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18); main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0);
secondary = strstr (message, "\n"); primary = strstr (message, "\n");
if (secondary != NULL) if (primary)
{ {
primary = g_strndup (message, secondary - message + 1); secondary = primary + 1;
} primary = g_strndup (message, primary - message);
else
{
primary = g_strdup (message);
} }
label = gtk_label_new (primary); label = gtk_label_new (primary != NULL ? primary : message);
gtk_widget_set_halign (label, GTK_ALIGN_START); gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);