[gtk/present-toplevel-2: 67/70] Add a GdkDragIcon interface
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/present-toplevel-2: 67/70] Add a GdkDragIcon interface
- Date: Wed, 4 Mar 2020 00:11:06 +0000 (UTC)
commit e4d4ff8a2a26344ebd2752d7386cf6e6053206d1
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Mar 3 15:55:45 2020 -0800
Add a GdkDragIcon interface
This will provide functionality specific to drag icons.
gdk/gdk.h | 1 +
gdk/gdkdragicon.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++
gdk/gdkdragicon.h | 43 +++++++++++++++++++++++++++
gdk/gdkdragiconprivate.h | 20 +++++++++++++
gdk/meson.build | 2 ++
5 files changed, 141 insertions(+)
---
diff --git a/gdk/gdk.h b/gdk/gdk.h
index 5f6b03f3eb..281b07cb35 100644
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -71,6 +71,7 @@
#include <gdk/gdkpopup.h>
#include <gdk/gdktoplevellayout.h>
#include <gdk/gdktoplevel.h>
+#include <gdk/gdkdragicon.h>
#include <gdk/gdk-autocleanup.h>
diff --git a/gdk/gdkdragicon.c b/gdk/gdkdragicon.c
new file mode 100644
index 0000000000..74801de5df
--- /dev/null
+++ b/gdk/gdkdragicon.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright © 2020 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Matthias Clasen <mclasen redhat com>
+ */
+
+#include "config.h"
+
+#include "gdkintl.h"
+#include "gdkdragiconprivate.h"
+#include "gdk-private.h"
+
+/**
+ * SECTION:gdkdragicon
+ * @Short_description: Interface for drag icon surfaces
+ * @Title: Drag icons
+ *
+ * A #GdkDragIcon is a surface that is used during a
+ * DND operation.
+ */
+
+
+/* FIXME: this can't have GdkSurface as a prerequisite
+ * as long as GdkSurface implements this interface itself
+ */
+G_DEFINE_INTERFACE (GdkDragIcon, gdk_drag_icon, G_TYPE_OBJECT)
+
+static gboolean
+gdk_drag_icon_default_present (GdkDragIcon *drag_icon,
+ int width,
+ int height)
+{
+ return FALSE;
+}
+
+static void
+gdk_drag_icon_default_init (GdkDragIconInterface *iface)
+{
+ iface->present = gdk_drag_icon_default_present;
+}
+
+/**
+ * gdk_drag_icon_present:
+ * @drag_icon: the #GdkDragIcon to show
+ * @width: the unconstrained drag_icon width to layout
+ * @height: the unconstrained drag_icon height to layout
+ *
+ * Present @drag_icon.
+ *
+ * Returns: %FALSE if it failed to be presented, otherwise %TRUE.
+ */
+gboolean
+gdk_drag_icon_present (GdkDragIcon *drag_icon,
+ int width,
+ int height)
+{
+ g_return_val_if_fail (GDK_IS_DRAG_ICON (drag_icon), FALSE);
+ g_return_val_if_fail (width > 0, FALSE);
+ g_return_val_if_fail (height > 0, FALSE);
+
+ return GDK_DRAG_ICON_GET_IFACE (drag_icon)->present (drag_icon, width, height);
+}
diff --git a/gdk/gdkdragicon.h b/gdk/gdkdragicon.h
new file mode 100644
index 0000000000..b6d98f7989
--- /dev/null
+++ b/gdk/gdkdragicon.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2020 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Matthias Clasen <mclasen redhat com>
+ */
+
+#ifndef __GDK_DRAG_ICON_H__
+#define __GDK_DRAG_ICON_H__
+
+#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gdk/gdk.h> can be included directly."
+#endif
+
+#include <gdk/gdksurface.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_DRAG_ICON (gdk_drag_icon_get_type ())
+
+GDK_AVAILABLE_IN_ALL
+G_DECLARE_INTERFACE (GdkDragIcon, gdk_drag_icon, GDK, DRAG_ICON, GObject)
+
+GDK_AVAILABLE_IN_ALL
+gboolean gdk_drag_icon_present (GdkDragIcon *drag_icon,
+ int width,
+ int height);
+
+G_END_DECLS
+
+#endif /* __GDK_DRAG_ICON_H__ */
diff --git a/gdk/gdkdragiconprivate.h b/gdk/gdkdragiconprivate.h
new file mode 100644
index 0000000000..b909d82d6d
--- /dev/null
+++ b/gdk/gdkdragiconprivate.h
@@ -0,0 +1,20 @@
+#ifndef __GDK_DRAG_ICON_PRIVATE_H__
+#define __GDK_DRAG_ICON_PRIVATE_H__
+
+#include "gdkdragicon.h"
+
+G_BEGIN_DECLS
+
+
+struct _GdkDragIconInterface
+{
+ GTypeInterface g_iface;
+
+ gboolean (* present) (GdkDragIcon *drag_icon,
+ int width,
+ int height);
+};
+
+G_END_DECLS
+
+#endif /* __GDK_DRAG_ICON_PRIVATE_H__ */
diff --git a/gdk/meson.build b/gdk/meson.build
index 0c1a277549..3c242255ce 100644
--- a/gdk/meson.build
+++ b/gdk/meson.build
@@ -48,6 +48,7 @@ gdk_public_sources = files([
'gdkpopup.c',
'gdktoplevellayout.c',
'gdktoplevel.c',
+ 'gdkdragicon.c',
])
gdk_public_headers = files([
@@ -95,6 +96,7 @@ gdk_public_headers = files([
'gdkpopup.h',
'gdktoplevellayout.h',
'gdktoplevel.h',
+ 'gdkdragicon.h',
])
install_headers(gdk_public_headers, subdir: 'gtk-4.0/gdk/')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]