[evince] properties: Fix dialog extending past edge of screen
- From: Jason Crain <jcrain src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] properties: Fix dialog extending past edge of screen
- Date: Wed, 27 Dec 2017 19:41:08 +0000 (UTC)
commit b83cd4c8ed3df0d3a768a059fa3b438cefc557bb
Author: Jason Crain <jcrain src gnome org>
Date: Mon Dec 25 19:12:24 2017 -0600
properties: Fix dialog extending past edge of screen
A property with a lot of newlines can extend Nautilus's file properties
dialog past the edge of the screen. Replace these newlines with spaces
to limit the vertical size and let the label's ellipsizing work
correctly. Have labels wrap for up to five lines in case someone is
relying on the properties dialog showing large properties. Place
properties page in a GtkScrolledWindow in case it is still too tall.
https://bugzilla.gnome.org/show_bug.cgi?id=733618
properties/ev-properties-main.c | 13 ++++++++++++-
properties/ev-properties-view.c | 37 ++++++++++++++++++++++++++++++++++++-
2 files changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/properties/ev-properties-main.c b/properties/ev-properties-main.c
index 0832c59..261268f 100644
--- a/properties/ev-properties-main.c
+++ b/properties/ev-properties-main.c
@@ -92,6 +92,7 @@ ev_properties_get_pages (NautilusPropertyPageProvider *provider,
gchar *uri = NULL;
gchar *mime_type = NULL;
GtkWidget *page, *label;
+ GtkWidget *scrolled;
NautilusPropertyPage *property_page;
/* only add properties page if a single file is selected */
@@ -118,8 +119,18 @@ ev_properties_get_pages (NautilusPropertyPageProvider *provider,
ev_properties_view_set_info (EV_PROPERTIES_VIEW (page),
ev_document_get_info (document));
gtk_widget_show (page);
+
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+ GTK_POLICY_NEVER,
+ GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_propagate_natural_width (GTK_SCROLLED_WINDOW (scrolled),
+ TRUE);
+ gtk_container_add (GTK_CONTAINER (scrolled), page);
+ gtk_widget_show (scrolled);
+
property_page = nautilus_property_page_new ("document-properties",
- label, page);
+ label, scrolled);
pages = g_list_prepend (pages, property_page);
diff --git a/properties/ev-properties-view.c b/properties/ev-properties-view.c
index 90e9d3f..707e172 100644
--- a/properties/ev-properties-view.c
+++ b/properties/ev-properties-view.c
@@ -151,6 +151,36 @@ make_valid_utf8 (const gchar *name)
return g_string_free (string, FALSE);
}
+static gchar *
+cleanup_text (const char *str)
+{
+ char *valid;
+ GString *gstr;
+ gboolean prev_isspace = TRUE;
+
+ g_assert_nonnull (str);
+ valid = make_valid_utf8 (str);
+ gstr = g_string_new (NULL);
+
+ for (str = valid; *str != '\0'; str = g_utf8_next_char (str)) {
+ gunichar c = g_utf8_get_char (str);
+
+ if (g_unichar_isspace (c)) {
+ /* replace a run of any whitespace characters with a
+ * space single character */
+ if (!prev_isspace)
+ g_string_append_c (gstr, ' ');
+ prev_isspace = TRUE;
+ } else {
+ g_string_append_unichar (gstr, c);
+ prev_isspace = FALSE;
+ }
+ }
+
+ g_free (valid);
+ return g_string_free (gstr, FALSE);
+}
+
static void
set_property (EvPropertiesView *properties,
GtkGrid *grid,
@@ -182,6 +212,11 @@ set_property (EvPropertiesView *properties,
"width_chars", 25,
"selectable", TRUE,
"ellipsize", PANGO_ELLIPSIZE_END,
+ "hexpand", TRUE,
+ "max-width-chars", 100,
+ "wrap-mode", PANGO_WRAP_WORD_CHAR,
+ "wrap", TRUE,
+ "lines", 5,
NULL);
} else {
value_label = properties->labels[property];
@@ -197,7 +232,7 @@ set_property (EvPropertiesView *properties,
gtk_label_set_markup (GTK_LABEL (value_label), markup);
g_free (markup);
} else {
- valid_text = make_valid_utf8 (text ? text : "");
+ valid_text = cleanup_text (text);
gtk_label_set_text (GTK_LABEL (value_label), valid_text);
g_free (valid_text);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]