[epiphany] Constrain pages popover to current window
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Constrain pages popover to current window
- Date: Sat, 11 May 2019 15:02:22 +0000 (UTC)
commit ee9728ebb7cec15d86e672b2fbee74de4fe8cae6
Author: Jan-Michael Brummer <jan brummer tabos org>
Date: Thu May 2 15:50:01 2019 +0200
Constrain pages popover to current window
Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/656
src/ephy-pages-popover.c | 35 +++++++++++++++++++++++++++++++++++
src/meson.build | 1 +
2 files changed, 36 insertions(+)
---
diff --git a/src/ephy-pages-popover.c b/src/ephy-pages-popover.c
index a1ba5311e..b490d1a4b 100644
--- a/src/ephy-pages-popover.c
+++ b/src/ephy-pages-popover.c
@@ -23,6 +23,10 @@
#include "ephy-pages-popover.h"
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
#define HANDY_USE_UNSTABLE_API
#include <handy.h>
#include "ephy-notebook.h"
@@ -160,6 +164,30 @@ ephy_pages_popover_dispose (GObject *object)
G_OBJECT_CLASS (ephy_pages_popover_parent_class)->dispose (object);
}
+#ifdef GDK_WINDOWING_X11
+static void
+ephy_pages_popover_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ EphyPagesPopover *self = EPHY_PAGES_POPOVER (widget);
+ int height;
+
+ GTK_WIDGET_CLASS (ephy_pages_popover_parent_class)->get_preferred_height (widget,
+ minimum_height,
+ natural_height);
+ /* Ensure that popover won't leave current window */
+ height = gtk_widget_get_allocated_height (GTK_WIDGET (self->notebook));
+ gtk_scrolled_window_set_max_content_height (self->scrolled_window, height);
+}
+
+static GtkSizeRequestMode
+ephy_pages_popover_get_request_mode (GtkWidget *widget)
+{
+ return GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT;
+}
+#endif
+
static void
ephy_pages_popover_class_init (EphyPagesPopoverClass *klass)
{
@@ -169,6 +197,13 @@ ephy_pages_popover_class_init (EphyPagesPopoverClass *klass)
object_class->dispose = ephy_pages_popover_dispose;
object_class->finalize = ephy_pages_popover_finalize;
+#ifdef GDK_WINDOWING_X11
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+ widget_class->get_request_mode = ephy_pages_popover_get_request_mode;
+ widget_class->get_preferred_height = ephy_pages_popover_get_preferred_height;
+ }
+#endif
+
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/epiphany/gtk/pages-popover.ui");
gtk_widget_class_bind_template_child (widget_class, EphyPagesPopover, list_box);
gtk_widget_class_bind_template_child (widget_class, EphyPagesPopover, scrolled_window);
diff --git a/src/meson.build b/src/meson.build
index e463a5008..66597f5d4 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -61,6 +61,7 @@ libephymain_deps = [
ephymisc_dep,
ephysync_dep,
ephywidgets_dep,
+ gdk_dep,
libhandy_dep,
libnotify_dep
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]