summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSorokin Alexei <[email protected]>2016-03-07 00:45:46 +0300
committerSorokin Alexei <[email protected]>2016-03-07 00:45:46 +0300
commitc0efce1fb03875877ddc9e7d3a7aca77b10fd434 (patch)
treed66b646edca1db8e717b5ef9a3771f8dd8eff186
parent087b25e1c35659f28e85e464e99a6970eba97dff (diff)
downloadmate-terminal-c0efce1fb03875877ddc9e7d3a7aca77b10fd434.tar.bz2
mate-terminal-c0efce1fb03875877ddc9e7d3a7aca77b10fd434.tar.xz
GTK+3.20: fix window sizes
caused by https://git.gnome.org/browse/gtk+/commit/?id=08974a1, fixes #111
-rw-r--r--src/terminal-window.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/terminal-window.c b/src/terminal-window.c
index d7819c5..9bcd397 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -3044,8 +3044,14 @@ terminal_window_update_geometry (TerminalWindow *window)
TerminalWindowPrivate *priv = window->priv;
GtkWidget *widget;
GdkGeometry hints;
- int char_width;
- int char_height;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkBorder padding;
+#else
+ GtkBorder *inner_border = NULL;
+#endif
+ GtkRequisition toplevel_request, widget_request;
+ int base_width, base_height;
+ int char_width, char_height;
if (priv->active_screen == NULL)
return;
@@ -3067,24 +3073,32 @@ terminal_window_update_geometry (TerminalWindow *window)
* padding we need to change the hints when the theme changes.
*/
-#if VTE_CHECK_VERSION (0, 38, 0)
- GtkBorder padding;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (GTK_WIDGET (window), NULL, &toplevel_request);
+ gtk_widget_get_preferred_size (widget, NULL, &widget_request);
+#else
+ gtk_widget_size_request (GTK_WIDGET (window), &toplevel_request);
+ gtk_widget_size_request (widget, &widget_request);
+#endif
- gtk_style_context_get_padding(gtk_widget_get_style_context(widget),
- gtk_widget_get_state_flags(widget),
- &padding);
+ base_width = toplevel_request.width - widget_request.width;
+ base_height = toplevel_request.height - widget_request.height;
- hints.base_width = padding.left + padding.right;
- hints.base_height = padding.top + padding.bottom;
-#else
- GtkBorder *inner_border = NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_style_context_get_padding (gtk_widget_get_style_context (widget),
+ gtk_widget_get_state_flags (widget),
+ &padding);
+ hints.base_width = base_width + padding.left + padding.right;
+ hints.base_height = base_height + padding.top + padding.bottom;
+#else
gtk_widget_style_get (widget, "inner-border", &inner_border, NULL);
- hints.base_width = (inner_border ? (inner_border->left + inner_border->right) : 0);
- hints.base_height = (inner_border ? (inner_border->top + inner_border->bottom) : 0);
+ hints.base_width = base_width + (inner_border ? (inner_border->left + inner_border->right) : 0);
+ hints.base_height = base_height + (inner_border ? (inner_border->top + inner_border->bottom) : 0);
gtk_border_free (inner_border);
+ inner_border = NULL;
#endif
#define MIN_WIDTH_CHARS 4
@@ -3093,12 +3107,12 @@ terminal_window_update_geometry (TerminalWindow *window)
hints.width_inc = char_width;
hints.height_inc = char_height;
- /* min size is min size of just the geometry widget, remember. */
+ /* min size is min size of the whole window, remember. */
hints.min_width = hints.base_width + hints.width_inc * MIN_WIDTH_CHARS;
hints.min_height = hints.base_height + hints.height_inc * MIN_HEIGHT_CHARS;
gtk_window_set_geometry_hints (GTK_WINDOW (window),
- widget,
+ NULL,
&hints,
GDK_HINT_RESIZE_INC |
GDK_HINT_MIN_SIZE |