[polari] lib: Add some DND helper methods



commit 1721ad3e9c19a413b4b13e6ba1fb921723e9b409
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jul 30 03:07:41 2013 +0200

    lib: Add some DND helper methods
    
    GdkAtom is not introspectable, so add some small wrapper methods
    as workaround.

 src/Makefile-lib.am          |    2 +
 src/lib/polari-drag-helper.c |   53 ++++++++++++++++++++++++++++++++++++++++++
 src/lib/polari-drag-helper.h |   38 ++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile-lib.am b/src/Makefile-lib.am
index e474112..9832fa3 100644
--- a/src/Makefile-lib.am
+++ b/src/Makefile-lib.am
@@ -1,11 +1,13 @@
 pkglib_LTLIBRARIES = libpolari-1.0.la
 
 libpolari_headers = \
+       lib/polari-drag-helper.h \
        lib/polari-fixed-size-frame.h \
        lib/polari-room.h \
        $(NULL)
 
 libpolari_sources = \
+       lib/polari-drag-helper.c \
        lib/polari-fixed-size-frame.c \
        lib/polari-room.c \
        $(NULL)
diff --git a/src/lib/polari-drag-helper.c b/src/lib/polari-drag-helper.c
new file mode 100644
index 0000000..8d25b70
--- /dev/null
+++ b/src/lib/polari-drag-helper.c
@@ -0,0 +1,53 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This program 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 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 program.  If not, see <http://www.gnu.org/licenses/>.";
+ */
+
+#include "polari-drag-helper.h"
+
+void
+polari_drag_dest_request_data (GtkWidget      *widget,
+                               GdkDragContext *context,
+                               guint32         time_)
+{
+  GdkAtom target;
+
+  target = gtk_drag_dest_find_target (widget, context, NULL);
+  if (target == GDK_NONE)
+    return;
+
+  gtk_drag_get_data (widget, context, target, time_);
+}
+
+gboolean
+polari_drag_dest_supports_target (GtkWidget      *widget,
+                                  GdkDragContext *context)
+{
+  return gtk_drag_dest_find_target (widget, context, NULL) != GDK_NONE;
+}
+
+guint
+polari_drag_dest_find_target (GtkWidget      *widget,
+                              GdkDragContext *context)
+{
+  GdkAtom target;
+  guint info;
+
+  target = gtk_drag_dest_find_target (widget, context, NULL);
+  gtk_target_list_find (gtk_drag_dest_get_target_list (widget), target, &info);
+
+  return info;
+}
diff --git a/src/lib/polari-drag-helper.h b/src/lib/polari-drag-helper.h
new file mode 100644
index 0000000..3e94d6d
--- /dev/null
+++ b/src/lib/polari-drag-helper.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This program 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 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 program.  If not, see <http://www.gnu.org/licenses/>.";
+ */
+
+#ifndef __POLARI_UTILS_H__
+#define __POLARI_UTILS_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+void     polari_drag_dest_request_data (GtkWidget      *widget,
+                                        GdkDragContext *context,
+                                        guint32         time_);
+
+gboolean polari_drag_dest_supports_target (GtkWidget      *widget,
+                                           GdkDragContext *context);
+
+guint    polari_drag_dest_find_target (GtkWidget      *widget,
+                                       GdkDragContext *context);
+
+G_END_DECLS
+
+#endif /* __POLARI_UTILS_H__ */


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