Commit b83cd4c8 authored by Jason Crain's avatar Jason Crain

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.
parent 6adc0705
......@@ -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_scrolled_window_set_propagate_natural_width (GTK_SCROLLED_WINDOW (scrolled),
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);
......@@ -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,
"hexpand", TRUE,
"max-width-chars", 100,
"wrap-mode", PANGO_WRAP_WORD_CHAR,
"wrap", TRUE,
"lines", 5,
} 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);
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