[gnome-builder] egg: bring back EggScrolledWindow
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] egg: bring back EggScrolledWindow
- Date: Sat, 2 Jul 2016 09:24:16 +0000 (UTC)
commit 16a233883ac67f08e213590d29ed934a36e0144c
Author: Christian Hergert <chergert redhat com>
Date: Sat Jul 2 02:23:48 2016 -0700
egg: bring back EggScrolledWindow
GtkScrolledWindow still does not handle height-for-width properly, so we
still need our helper class.
contrib/egg/Makefile.am | 2 +
contrib/egg/egg-scrolled-window.c | 74 +++++++++++++++++++++++++++++++++++++
contrib/egg/egg-scrolled-window.h | 32 ++++++++++++++++
3 files changed, 108 insertions(+), 0 deletions(-)
---
diff --git a/contrib/egg/Makefile.am b/contrib/egg/Makefile.am
index 61cbb67..1d0e8b3 100644
--- a/contrib/egg/Makefile.am
+++ b/contrib/egg/Makefile.am
@@ -26,6 +26,7 @@ headers_DATA = \
egg-priority-box.h \
egg-private.h \
egg-radio-box.h \
+ egg-scrolled-window.h \
egg-search-bar.h \
egg-settings-flag-action.h \
egg-settings-sandwich.h \
@@ -59,6 +60,7 @@ libegg_private_la_SOURCES = \
egg-pill-box.c \
egg-priority-box.c \
egg-radio-box.c \
+ egg-scrolled-window.c \
egg-search-bar.c \
egg-settings-flag-action.c \
egg-settings-sandwich.c \
diff --git a/contrib/egg/egg-scrolled-window.c b/contrib/egg/egg-scrolled-window.c
new file mode 100644
index 0000000..5e1e83b
--- /dev/null
+++ b/contrib/egg/egg-scrolled-window.c
@@ -0,0 +1,74 @@
+/* egg-scrolled-window.c
+ *
+ * Copyright (C) 2016 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define G_LOG_DOMAIN "egg-scrolled-window"
+
+#include "egg-scrolled-window.h"
+
+struct _EggScrolledWindow
+{
+ GtkScrolledWindow parent_instance;
+};
+
+G_DEFINE_TYPE (EggScrolledWindow, egg_scrolled_window, GTK_TYPE_SCROLLED_WINDOW)
+
+static void
+egg_scrolled_window_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *min_height,
+ gint *nat_height)
+{
+ EggScrolledWindow *self = (EggScrolledWindow *)widget;
+ GtkWidget *child;
+
+ g_assert (EGG_IS_SCROLLED_WINDOW (self));
+ g_assert (min_height != NULL);
+ g_assert (nat_height != NULL);
+
+ GTK_WIDGET_CLASS (egg_scrolled_window_parent_class)->get_preferred_height_for_width (widget, width,
min_height, nat_height);
+
+ if (NULL != (child = gtk_bin_get_child (GTK_BIN (self))))
+ {
+ gint child_min_height;
+ gint child_nat_height;
+ gint max_content_height;
+
+ max_content_height = gtk_scrolled_window_get_max_content_height (GTK_SCROLLED_WINDOW (self));
+
+ gtk_widget_get_preferred_height_for_width (child,
+ width,
+ &child_min_height,
+ &child_nat_height);
+
+ if (child_nat_height > *nat_height)
+ *nat_height = MIN (max_content_height, child_nat_height);
+ }
+}
+
+static void
+egg_scrolled_window_class_init (EggScrolledWindowClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ widget_class->get_preferred_height_for_width = egg_scrolled_window_get_preferred_height_for_width;
+}
+
+static void
+egg_scrolled_window_init (EggScrolledWindow *self)
+{
+}
diff --git a/contrib/egg/egg-scrolled-window.h b/contrib/egg/egg-scrolled-window.h
new file mode 100644
index 0000000..f831cb1
--- /dev/null
+++ b/contrib/egg/egg-scrolled-window.h
@@ -0,0 +1,32 @@
+/* egg-scrolled-window.h
+ *
+ * Copyright (C) 2016 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef EGG_SCROLLED_WINDOW_H
+#define EGG_SCROLLED_WINDOW_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define EGG_TYPE_SCROLLED_WINDOW (egg_scrolled_window_get_type())
+
+G_DECLARE_FINAL_TYPE (EggScrolledWindow, egg_scrolled_window, EGG, SCROLLED_WINDOW, GtkScrolledWindow)
+
+G_END_DECLS
+
+#endif /* EGG_SCROLLED_WINDOW_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]