[gtk/prop-list: 55/70] columnviewcolumn: Add a resizable property



commit e76554e3e93844309fc6d68c99c6de7b9c8e69a1
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Dec 20 14:07:14 2019 -0500

    columnviewcolumn: Add a resizable property
    
    This will be used for interactive column resizing
    in the future.

 gtk/gtkcolumnviewcolumn.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++-
 gtk/gtkcolumnviewcolumn.h |  6 +++++
 2 files changed, 67 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkcolumnviewcolumn.c b/gtk/gtkcolumnviewcolumn.c
index d113b5c9dd..6c80736066 100644
--- a/gtk/gtkcolumnviewcolumn.c
+++ b/gtk/gtkcolumnviewcolumn.c
@@ -63,7 +63,8 @@ struct _GtkColumnViewColumn
 
   int fixed_width;
 
-  gboolean visible;
+  guint visible   : 1;
+  guint resizable : 1;
 
   /* This list isn't sorted - this is just caching for performance */
   GtkColumnViewCell *first_cell; /* no reference, just caching */
@@ -82,6 +83,7 @@ enum
   PROP_TITLE,
   PROP_SORTER,
   PROP_VISIBLE,
+  PROP_RESIZABLE,
   PROP_FIXED_WIDTH,
 
   N_PROPS
@@ -136,6 +138,10 @@ gtk_column_view_column_get_property (GObject    *object,
       g_value_set_boolean (value, self->visible);
       break;
 
+    case PROP_RESIZABLE:
+      g_value_set_boolean (value, self->resizable);
+      break;
+
     case PROP_FIXED_WIDTH:
       g_value_set_int (value, self->fixed_width);
       break;
@@ -172,6 +178,10 @@ gtk_column_view_column_set_property (GObject      *object,
       gtk_column_view_column_set_visible (self, g_value_get_boolean (value));
       break;
 
+    case PROP_RESIZABLE:
+      gtk_column_view_column_set_resizable (self, g_value_get_boolean (value));
+      break;
+
     case PROP_FIXED_WIDTH:
       gtk_column_view_column_set_fixed_width (self, g_value_get_int (value));
       break;
@@ -246,6 +256,18 @@ gtk_column_view_column_class_init (GtkColumnViewColumnClass *klass)
                           TRUE,
                           G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
 
+  /**
+   * GtkColumnViewColumn:resizable:
+   *
+   * Whether this column is resizable
+   */
+  properties[PROP_RESIZABLE] =
+    g_param_spec_boolean ("resizable",
+                          P_("Resizable"),
+                          P_("Whether this column is resizable"),
+                          TRUE,
+                          G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+
   properties[PROP_FIXED_WIDTH] =
     g_param_spec_int ("fixed-width",
                       P_("Fixed width"),
@@ -262,6 +284,7 @@ gtk_column_view_column_init (GtkColumnViewColumn *self)
   self->minimum_size_request = -1;
   self->natural_size_request = -1;
   self->visible = TRUE;
+  self->resizable = TRUE;
   self->fixed_width = -1;
 }
 
@@ -748,6 +771,43 @@ gtk_column_view_column_get_visible (GtkColumnViewColumn *self)
   return self->visible;
 }
 
+/**
+ * gtk_column_view_column_set_resizable:
+ * @self: a #GtkColumnViewColumn
+ * @resizable: whether this column should be resizable 
+ *
+ * Sets whether this column should be resizable by dragging.
+ */
+void
+gtk_column_view_column_set_resizable (GtkColumnViewColumn *self,
+                                      gboolean             resizable)
+{
+  g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
+
+  if (self->resizable == resizable)
+    return;
+
+  self->resizable = resizable;
+
+  g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_RESIZABLE]);
+}
+
+/**
+ * gtk_column_view_get_resizable:
+ * @self: a #GtkColumnView
+ *
+ * Returns whether this column is resizable.
+ *
+ * Returns: %TRUE if this column is resizable
+ */
+gboolean
+gtk_column_view_column_get_resizable (GtkColumnViewColumn *self)
+{
+  g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), TRUE);
+
+  return self->resizable;
+}
+
 void
 gtk_column_view_column_set_fixed_width (GtkColumnViewColumn *self,
                                         int                  fixed_width)
diff --git a/gtk/gtkcolumnviewcolumn.h b/gtk/gtkcolumnviewcolumn.h
index 32392612b2..3be8a1cb7d 100644
--- a/gtk/gtkcolumnviewcolumn.h
+++ b/gtk/gtkcolumnviewcolumn.h
@@ -84,6 +84,12 @@ void                    gtk_column_view_column_set_fixed_width          (GtkColu
 GDK_AVAILABLE_IN_ALL
 int                     gtk_column_view_column_get_fixed_width          (GtkColumnViewColumn    *self);
 
+GDK_AVAILABLE_IN_ALL
+void                    gtk_column_view_column_set_resizable            (GtkColumnViewColumn    *self,
+                                                                         gboolean                resizable);
+GDK_AVAILABLE_IN_ALL
+gboolean                gtk_column_view_column_get_resizable            (GtkColumnViewColumn    *self);
+
 G_END_DECLS
 
 #endif  /* __GTK_COLUMN_VIEW_COLUMN_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]