1 /*
2 * xfdesktop - xfce4's desktop manager
3 *
4 * Copyright (c) 2006 Brian Tarricone, <bjt23@cornell.edu>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24
25 #include <glib-object.h>
26
27 #include "xfdesktop-icon-view-manager.h"
28 #include "xfdesktop-icon-view.h"
29
30 GType
xfdesktop_icon_view_manager_get_type(void)31 xfdesktop_icon_view_manager_get_type(void)
32 {
33 static GType manager_type = 0;
34
35 if(!manager_type) {
36 static const GTypeInfo manager_info = {
37 sizeof(XfdesktopIconViewManagerIface),
38 NULL,
39 NULL,
40 NULL,
41 NULL,
42 NULL,
43 0,
44 0,
45 NULL,
46 };
47
48 manager_type = g_type_register_static(G_TYPE_INTERFACE,
49 "XfdesktopIconViewManager",
50 &manager_info, 0);
51 g_type_interface_add_prerequisite(manager_type, G_TYPE_OBJECT);
52 }
53
54 return manager_type;
55 }
56
57 gboolean
xfdesktop_icon_view_manager_init(XfdesktopIconViewManager * manager,XfdesktopIconView * icon_view)58 xfdesktop_icon_view_manager_init(XfdesktopIconViewManager *manager,
59 XfdesktopIconView *icon_view)
60 {
61 XfdesktopIconViewManagerIface *iface;
62
63 g_return_val_if_fail(XFDESKTOP_IS_ICON_VIEW_MANAGER(manager)
64 && XFDESKTOP_IS_ICON_VIEW(icon_view), FALSE);
65
66 iface = XFDESKTOP_ICON_VIEW_MANAGER_GET_IFACE(manager);
67 g_return_val_if_fail(iface->manager_init, FALSE);
68
69 return iface->manager_init(manager, icon_view);
70 }
71
72 void
xfdesktop_icon_view_manager_fini(XfdesktopIconViewManager * manager)73 xfdesktop_icon_view_manager_fini(XfdesktopIconViewManager *manager)
74 {
75 XfdesktopIconViewManagerIface *iface;
76
77 g_return_if_fail(XFDESKTOP_IS_ICON_VIEW_MANAGER(manager));
78
79 iface = XFDESKTOP_ICON_VIEW_MANAGER_GET_IFACE(manager);
80 g_return_if_fail(iface->manager_fini);
81
82 iface->manager_fini(manager);
83 }
84
85 gboolean
xfdesktop_icon_view_manager_drag_drop(XfdesktopIconViewManager * manager,XfdesktopIcon * drop_icon,GdkDragContext * context,gint16 row,gint16 col,guint time_)86 xfdesktop_icon_view_manager_drag_drop(XfdesktopIconViewManager *manager,
87 XfdesktopIcon *drop_icon,
88 GdkDragContext *context,
89 gint16 row,
90 gint16 col,
91 guint time_)
92 {
93 XfdesktopIconViewManagerIface *iface;
94
95 g_return_val_if_fail(XFDESKTOP_IS_ICON_VIEW_MANAGER(manager), FALSE);
96
97 iface = XFDESKTOP_ICON_VIEW_MANAGER_GET_IFACE(manager);
98 g_return_val_if_fail(iface->drag_drop, FALSE);
99
100 return iface->drag_drop(manager, drop_icon, context, row, col, time_);
101 }
102
103 void
xfdesktop_icon_view_manager_drag_data_received(XfdesktopIconViewManager * manager,XfdesktopIcon * drop_icon,GdkDragContext * context,gint16 row,gint16 col,GtkSelectionData * data,guint info,guint time_)104 xfdesktop_icon_view_manager_drag_data_received(XfdesktopIconViewManager *manager,
105 XfdesktopIcon *drop_icon,
106 GdkDragContext *context,
107 gint16 row,
108 gint16 col,
109 GtkSelectionData *data,
110 guint info,
111 guint time_)
112 {
113 XfdesktopIconViewManagerIface *iface;
114
115 g_return_if_fail(XFDESKTOP_IS_ICON_VIEW_MANAGER(manager));
116
117 iface = XFDESKTOP_ICON_VIEW_MANAGER_GET_IFACE(manager);
118 g_return_if_fail(iface->drag_data_received);
119
120 iface->drag_data_received(manager, drop_icon, context, row, col, data, info,
121 time_);
122 }
123
124 void
xfdesktop_icon_view_manager_drag_data_get(XfdesktopIconViewManager * manager,GList * drag_icons,GdkDragContext * context,GtkSelectionData * data,guint info,guint time_)125 xfdesktop_icon_view_manager_drag_data_get(XfdesktopIconViewManager *manager,
126 GList *drag_icons,
127 GdkDragContext *context,
128 GtkSelectionData *data,
129 guint info,
130 guint time_)
131 {
132 XfdesktopIconViewManagerIface *iface;
133
134 g_return_if_fail(XFDESKTOP_IS_ICON_VIEW_MANAGER(manager));
135
136 iface = XFDESKTOP_ICON_VIEW_MANAGER_GET_IFACE(manager);
137 g_return_if_fail(iface->drag_data_get);
138
139 iface->drag_data_get(manager, drag_icons, context, data, info, time_);
140 }
141
142 GdkDragAction
xfdesktop_icon_view_manager_propose_drop_action(XfdesktopIconViewManager * manager,XfdesktopIcon * drop_icon,GdkDragAction action,GdkDragContext * context,GtkSelectionData * data,guint info)143 xfdesktop_icon_view_manager_propose_drop_action(XfdesktopIconViewManager *manager,
144 XfdesktopIcon *drop_icon,
145 GdkDragAction action,
146 GdkDragContext *context,
147 GtkSelectionData *data,
148 guint info)
149 {
150 XfdesktopIconViewManagerIface *iface;
151
152 g_return_val_if_fail(XFDESKTOP_IS_ICON_VIEW_MANAGER(manager), action);
153
154 iface = XFDESKTOP_ICON_VIEW_MANAGER_GET_IFACE(manager);
155 g_return_val_if_fail(iface->propose_drop_action, action);
156
157 return iface->propose_drop_action(manager, drop_icon, action, context, data,
158 info);
159 }
160