[tepl/wip/misc] Better fix problem of GtkWindow height that grows when adding infobars
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl/wip/misc] Better fix problem of GtkWindow height that grows when adding infobars
- Date: Fri, 23 Jun 2017 12:46:26 +0000 (UTC)
commit ca060e784f440df96c780eab01fc998f88641ce2
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Jun 23 14:44:49 2017 +0200
Better fix problem of GtkWindow height that grows when adding infobars
tepl/tepl-info-bar.c | 20 +++++++++++++++++++-
tepl/tepl-tab.c | 7 -------
2 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/tepl/tepl-info-bar.c b/tepl/tepl-info-bar.c
index 32484a1..9bfdc08 100644
--- a/tepl/tepl-info-bar.c
+++ b/tepl/tepl-info-bar.c
@@ -1,7 +1,7 @@
/*
* This file is part of Tepl, a text editor library.
*
- * Copyright 2016 - Sébastien Wilmet <swilmet gnome org>
+ * Copyright 2016, 2017 - Sébastien Wilmet <swilmet gnome org>
*
* Tepl is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
@@ -383,5 +383,23 @@ tepl_info_bar_create_label (void)
gtk_label_set_line_wrap_mode (label, PANGO_WRAP_WORD_CHAR);
gtk_label_set_selectable (label, TRUE);
+ /* Since the wrapping is enabled, we need to set a minimum width.
+ *
+ * If a minimum width is not set, adding an info bar to a container
+ * (e.g. a TeplTab) can make the GtkWindow height to grow. Because
+ * without a minimum width (and without ellipsization), when the user
+ * resizes the window (e.g. reducing the width) the widgets inside the
+ * window must be able to be drawn. When the info bar must be drawn with
+ * a width of e.g. 20 pixels, it takes a huge height because of the text
+ * wrapping. So by setting a minimum width to the label, the maximum
+ * height that the info bar can take is limited, so in most cases the
+ * GtkWindow current height is sufficient to draw the info bar with its
+ * maximum height.
+ *
+ * See also:
+ * https://wiki.gnome.org/HowDoI/Labels
+ */
+ gtk_label_set_width_chars (label, 50);
+
return label;
}
diff --git a/tepl/tepl-tab.c b/tepl/tepl-tab.c
index 0c787f6..3768e39 100644
--- a/tepl/tepl-tab.c
+++ b/tepl/tepl-tab.c
@@ -69,13 +69,6 @@ create_scrolled_window (void)
"expand", TRUE,
NULL);
- /* If a size request is not set to the scrolled window, adding info bars
- * makes the GtkWindow height to grow, probably because there is a
- * gtk_widget_queue_resize() which takes the natural size of the
- * scrolled window. Setting a size request fixes the problem.
- */
- gtk_widget_set_size_request (scrolled_window, 100, 40);
-
return GTK_SCROLLED_WINDOW (scrolled_window);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]