[libpanel] resizer: add DRAG_POSITION property



commit 11fac976bcd60823e5db745254b79184ed6b34af
Author: Christian Hergert <chergert redhat com>
Date:   Fri Sep 16 19:23:08 2022 -0700

    resizer: add DRAG_POSITION property
    
    This is helpful to be able to monitor/debug things from inspector.

 src/panel-resizer.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/src/panel-resizer.c b/src/panel-resizer.c
index 3fe31ac..06a2694 100644
--- a/src/panel-resizer.c
+++ b/src/panel-resizer.c
@@ -46,6 +46,7 @@ G_DEFINE_TYPE (PanelResizer, panel_resizer, GTK_TYPE_WIDGET)
 enum {
   PROP_0,
   PROP_CHILD,
+  PROP_DRAG_POSITION,
   N_PROPS
 };
 
@@ -148,6 +149,8 @@ panel_resizer_drag_update_cb (PanelResizer   *self,
   else if (self->area == PANEL_AREA_BOTTOM)
     self->drag_position = gtk_widget_get_height (GTK_WIDGET (self)) - offset_y;
 
+  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DRAG_POSITION]);
+
   gtk_widget_queue_resize (GTK_WIDGET (self));
 }
 
@@ -381,6 +384,10 @@ panel_resizer_get_property (GObject    *object,
       g_value_set_object (value, panel_resizer_get_child (self));
       break;
 
+    case PROP_DRAG_POSITION:
+      g_value_set_int (value, self->drag_position);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -427,6 +434,10 @@ panel_resizer_class_init (PanelResizerClass *klass)
                          GTK_TYPE_WIDGET,
                          (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
 
+  properties [PROP_DRAG_POSITION] =
+    g_param_spec_int ("drag-position", NULL, NULL, G_MININT, G_MAXINT, 0,
+                      (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
   g_object_class_install_properties (object_class, N_PROPS, properties);
 
   gtk_widget_class_set_css_name (widget_class, "panelresizer");
@@ -543,5 +554,7 @@ panel_resizer_set_drag_position (PanelResizer *self,
   self->drag_position_set = drag_position >= 0;
   self->drag_position = MAX (drag_position, 0);
 
+  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DRAG_POSITION]);
+
   gtk_widget_queue_resize (GTK_WIDGET (self));
 }


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