[gtk+/wip/attachment: 1/3] gdkwindow: add attachment data structures
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/attachment: 1/3] gdkwindow: add attachment data structures
- Date: Mon, 14 Sep 2015 05:45:52 +0000 (UTC)
commit f03ce00b2312fd93a79ef1b23079ed9c955d1b9b
Author: William Hua <william hua canonical com>
Date: Sat Sep 12 00:38:16 2015 -0400
gdkwindow: add attachment data structures
gdk/gdkwindow.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
gdk/gdkwindow.h | 61 +++++++++++++++++++++++++++++++++++++
2 files changed, 151 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 44c30d1..e8cc0f1 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -11461,3 +11461,93 @@ gdk_window_show_window_menu (GdkWindow *window,
else
return FALSE;
}
+
+static GdkAttachmentConstraint *
+gdk_attachment_constraint_new (GdkAttachmentVariable variable,
+ gint value)
+{
+ GdkAttachmentConstraint *constraint = g_new (GdkAttachmentConstraint, 1);
+
+ constraint->variable = variable;
+ constraint->value = value;
+
+ return constraint;
+}
+
+static gpointer
+gdk_attachment_constraint_copy (gconstpointer pointer,
+ gpointer unused)
+{
+ const GdkAttachmentConstraint *constraint = pointer;
+
+ g_return_val_if_fail (constraint != NULL, NULL);
+
+ return gdk_attachment_constraint_new (constraint->variable, constraint->value);
+}
+
+static void
+gdk_attachment_constraint_free (gpointer pointer)
+{
+ g_free (pointer);
+}
+
+GdkAttachmentParameters *
+gdk_attachment_parameters_new (void)
+{
+ return g_new0 (GdkAttachmentParameters, 1);
+}
+
+gpointer
+gdk_attachment_parameters_copy (gconstpointer pointer,
+ gpointer unused)
+{
+ const GdkAttachmentParameters *parameters = pointer;
+ GdkAttachmentParameters *copy;
+
+ g_return_val_if_fail (parameters != NULL, NULL);
+
+ copy = gdk_attachment_parameters_new ();
+
+ copy->primary_constraints = g_list_copy_deep (parameters->primary_constraints,
gdk_attachment_constraint_copy, NULL);
+ copy->secondary_constraints = g_list_copy_deep (parameters->secondary_constraints,
gdk_attachment_constraint_copy, NULL);
+ copy->window_padding = parameters->window_padding;
+ copy->offset_callback = parameters->offset_callback;
+
+ return copy;
+}
+
+void
+gdk_attachment_parameters_free (gpointer pointer)
+{
+ GdkAttachmentParameters *parameters = pointer;
+
+ if (!parameters)
+ return;
+
+ g_list_free_full (parameters->secondary_constraints, gdk_attachment_constraint_free);
+ g_list_free_full (parameters->primary_constraints, gdk_attachment_constraint_free);
+
+ g_free (parameters);
+}
+
+void
+gdk_attachment_parameters_add_primary_constraint (GdkAttachmentParameters *parameters,
+ GdkAttachmentVariable variable,
+ gint value)
+{
+ g_return_if_fail (parameters != NULL);
+
+ parameters->primary_constraints = g_list_append (parameters->primary_constraints,
+ gdk_attachment_constraint_new (variable, value));
+}
+
+void
+gdk_attachment_parameters_add_secondary_constraint (GdkAttachmentParameters *parameters,
+ GdkAttachmentVariable variable,
+ gint value)
+{
+ g_return_if_fail (parameters != NULL);
+
+ parameters->secondary_constraints = g_list_append (parameters->secondary_constraints,
+ gdk_attachment_constraint_new (variable, value));
+}
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index 7eee684..088a0d8 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -463,6 +463,47 @@ struct _GdkGeometry
GdkGravity win_gravity;
};
+typedef enum _GdkAttachmentVariable GdkAttachmentVariable;
+typedef struct _GdkAttachmentConstraint GdkAttachmentConstraint;
+typedef struct _GdkAttachmentPadding GdkAttachmentPadding;
+typedef struct _GdkAttachmentParameters GdkAttachmentParameters;
+typedef void (*GdkAttachmentOffsetCallback) (GdkWindow *window,
+ gint delta_x,
+ gint delta_y);
+
+enum _GdkAttachmentVariable
+{
+ GDK_X_MIN,
+ GDK_X_MID,
+ GDK_X_MAX,
+ GDK_Y_MIN,
+ GDK_Y_MID,
+ GDK_Y_MAX
+};
+
+struct _GdkAttachmentConstraint
+{
+ GdkAttachmentVariable variable;
+ gint value;
+};
+
+struct _GdkAttachmentPadding
+{
+ gint top;
+ gint left;
+ gint right;
+ gint bottom;
+};
+
+struct _GdkAttachmentParameters
+{
+ GdkPoint parent_origin;
+ GList *primary_constraints;
+ GList *secondary_constraints;
+ GdkAttachmentPadding window_padding;
+ GdkAttachmentOffsetCallback offset_callback;
+};
+
typedef struct _GdkWindowClass GdkWindowClass;
#define GDK_TYPE_WINDOW (gdk_window_get_type ())
@@ -1124,6 +1165,26 @@ GDK_AVAILABLE_IN_3_16
GdkGLContext * gdk_window_create_gl_context (GdkWindow *window,
GError **error);
+GDK_AVAILABLE_IN_3_18
+GdkAttachmentParameters * gdk_attachment_parameters_new (void);
+
+GDK_AVAILABLE_IN_3_18
+gpointer gdk_attachment_parameters_copy (gconstpointer
parameters,
+ gpointer
unused);
+
+GDK_AVAILABLE_IN_3_18
+void gdk_attachment_parameters_free (gpointer
parameters);
+
+GDK_AVAILABLE_IN_3_18
+void gdk_attachment_parameters_add_primary_constraint (GdkAttachmentParameters
*parameters,
+ GdkAttachmentVariable
variable,
+ gint
value);
+
+GDK_AVAILABLE_IN_3_18
+void gdk_attachment_parameters_add_secondary_constraint (GdkAttachmentParameters
*parameters,
+ GdkAttachmentVariable
variable,
+ gint
value);
+
G_END_DECLS
#endif /* __GDK_WINDOW_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]