]> Pileus Git - grits/blobdiff - src/objects/grits-object.h
Add grits_object_destroy functions and fix memory leaks
[grits] / src / objects / grits-object.h
index 9969278b5114891034bb9817cbd692b698d2c29c..2c11cd3ba1751d9d64a35ef42ad0e4eaa4d18e7d 100644 (file)
 #define GRITS_SKIP_CENTER  (1<<2)
 #define GRITS_SKIP_STATE   (1<<3)
 
+/* Mouse move threshold for clicking */
+#define GRITS_CLICK_THRESHOLD 8
+
 /* Picking states */
 typedef struct {
        guint picked   : 1;
        guint selected : 1;
-       guint clicking : 1;
+       guint clicking : 6;
 } GritsState;
 
 typedef struct _GritsObject      GritsObject;
@@ -98,6 +101,30 @@ void grits_object_queue_draw(GritsObject *object);
  */
 void grits_object_set_cursor(GritsObject *object, GdkCursorType cursor);
 
+/**
+ * grits_object_destroy:
+ * @object: The #GritsObject to destroy
+ *
+ * Removes the widget from it's current viewer (if it has one) and decrements
+ * it's reference count.
+ */
+void grits_object_destroy(GritsObject *object);
+
+/**
+ * grits_object_destroy_pointer:
+ * @object: The pointer to the #GritsObject to destroy
+ *
+ * This functions the same as grits_object_destroy, except that the location of
+ * the object is set to null before proceeding.
+ */
+#define grits_object_destroy_pointer(object) ({           \
+       if (*object) {                                    \
+               GritsObject *tmp = GRITS_OBJECT(*object); \
+               *object = NULL;                           \
+               grits_object_destroy(tmp);                \
+       }                                                 \
+})
+
 /**
  * grits_object_center:
  * @object: The #GritsObject to get the center of