[gtk/wip/oholy/gtkmountoperation-newline-gtk-3-24] gtkmountoperation: Drop the new line character when splitting a message
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/oholy/gtkmountoperation-newline-gtk-3-24] gtkmountoperation: Drop the new line character when splitting a message
- Date: Fri, 7 Aug 2020 12:58:06 +0000 (UTC)
commit ec1e2fac9573c70a063499ec9bbfea132fa55080
Author: Ondrej Holy <oholy redhat com>
Date: Fri Aug 7 09:38:37 2020 +0200
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.
gtk/gtkmountoperation.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c
index 43b039e40e..2cf7e75d58 100644
--- a/gtk/gtkmountoperation.c
+++ b/gtk/gtkmountoperation.c
@@ -558,7 +558,7 @@ gtk_mount_operation_ask_password_do_gtk (GtkMountOperation *operation,
gboolean can_anonymous;
guint rows;
gchar *primary;
- const gchar *secondary;
+ const gchar *secondary = NULL;
PangoAttrList *attrs;
gboolean use_header;
@@ -618,17 +618,14 @@ G_GNUC_END_IGNORE_DEPRECATIONS
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0);
- secondary = strstr (message, "\n");
- if (secondary != NULL)
- {
- primary = g_strndup (message, secondary - message + 1);
- }
- else
+ primary = strstr (message, "\n");
+ if (primary)
{
- primary = g_strdup (message);
+ secondary = primary + 1;
+ primary = g_strndup (message, primary - 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_valign (label, GTK_ALIGN_CENTER);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]