[gtk/wip/otte/listview: 73/101] gridview: Implement GtkOrientable
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/listview: 73/101] gridview: Implement GtkOrientable
- Date: Sat, 19 Oct 2019 19:51:32 +0000 (UTC)
commit a25af20dbbaa4c93cc78254af66f727eb3d324a8
Author: Benjamin Otte <otte redhat com>
Date: Thu Oct 10 05:24:29 2019 +0200
gridview: Implement GtkOrientable
Again, this is just the skeleton, because the Gridview does nothing yet.
gtk/gtkgridview.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c
index 19fb96704c..d23f366e93 100644
--- a/gtk/gtkgridview.c
+++ b/gtk/gtkgridview.c
@@ -25,8 +25,10 @@
#include "gtkintl.h"
#include "gtklistitemfactory.h"
#include "gtklistitemmanagerprivate.h"
+#include "gtkorientableprivate.h"
#include "gtkprivate.h"
#include "gtkscrollable.h"
+#include "gtktypebuiltins.h"
#define DEFAULT_MAX_COLUMNS (7)
@@ -50,6 +52,7 @@ struct _GtkGridView
GtkListItemManager *item_manager;
GtkAdjustment *adjustment[2];
GtkScrollablePolicy scroll_policy[2];
+ GtkOrientation orientation;
guint min_columns;
guint max_columns;
};
@@ -79,6 +82,7 @@ enum
PROP_MAX_COLUMNS,
PROP_MIN_COLUMNS,
PROP_MODEL,
+ PROP_ORIENTATION,
PROP_VADJUSTMENT,
PROP_VSCROLL_POLICY,
@@ -86,6 +90,7 @@ enum
};
G_DEFINE_TYPE_WITH_CODE (GtkGridView, gtk_grid_view, GTK_TYPE_WIDGET,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)
G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
static GParamSpec *properties[N_PROPS] = { NULL, };
@@ -235,6 +240,10 @@ gtk_grid_view_get_property (GObject *object,
g_value_set_object (value, self->model);
break;
+ case PROP_ORIENTATION:
+ g_value_set_enum (value, self->orientation);
+ break;
+
case PROP_VADJUSTMENT:
g_value_set_object (value, self->adjustment[GTK_ORIENTATION_VERTICAL]);
break;
@@ -318,6 +327,19 @@ gtk_grid_view_set_property (GObject *object,
case PROP_MIN_COLUMNS:
gtk_grid_view_set_min_columns (self, g_value_get_uint (value));
break;
+
+ case PROP_ORIENTATION:
+ {
+ GtkOrientation orientation = g_value_get_enum (value);
+ if (self->orientation != orientation)
+ {
+ self->orientation = orientation;
+ _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
+ gtk_widget_queue_resize (GTK_WIDGET (self));
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ORIENTATION]);
+ }
+ }
+ break;
case PROP_MODEL:
gtk_grid_view_set_model (self, g_value_get_object (value));
@@ -418,9 +440,24 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+ /**
+ * GtkGridView:orientation:
+ *
+ * The orientation of the gridview. See GtkOrientable:orientation
+ * for details.
+ */
+ properties[PROP_ORIENTATION] =
+ g_param_spec_enum ("orientation",
+ P_("Orientation"),
+ P_("The orientation of the orientable"),
+ GTK_TYPE_ORIENTATION,
+ GTK_ORIENTATION_VERTICAL,
+ GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (gobject_class, N_PROPS, properties);
- gtk_widget_class_set_css_name (widget_class, I_("grid"));
+ gtk_widget_class_set_css_name (widget_class, I_("flowbox"));
+
}
static void
@@ -461,6 +498,7 @@ gtk_grid_view_init (GtkGridView *self)
self->min_columns = 1;
self->max_columns = DEFAULT_MAX_COLUMNS;
+ self->orientation = GTK_ORIENTATION_VERTICAL;
self->adjustment[GTK_ORIENTATION_HORIZONTAL] = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
self->adjustment[GTK_ORIENTATION_VERTICAL] = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]