1 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
2 | * Version: CDDL 1.0/LGPL 2.1
|
---|
3 | *
|
---|
4 | * The contents of this file are subject to the COMMON DEVELOPMENT AND
|
---|
5 | * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
|
---|
6 | * this file except in compliance with the License. You may obtain a copy of
|
---|
7 | * the License at http://www.sun.com/cddl/
|
---|
8 | *
|
---|
9 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
11 | * for the specific language governing rights and limitations under the
|
---|
12 | * License.
|
---|
13 | *
|
---|
14 | * The Original Code is "NOM" Netlabs Object Model
|
---|
15 | *
|
---|
16 | * The Initial Developer of the Original Code is
|
---|
17 | * netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
|
---|
18 | * Portions created by the Initial Developer are Copyright (C) 2005-2007
|
---|
19 | * the Initial Developer. All Rights Reserved.
|
---|
20 | *
|
---|
21 | * Contributor(s):
|
---|
22 | *
|
---|
23 | * Alternatively, the contents of this file may be used under the terms of
|
---|
24 | * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
|
---|
25 | * case the provisions of the LGPL are applicable instead of those above. If
|
---|
26 | * you wish to allow use of your version of this file only under the terms of
|
---|
27 | * the LGPL, and not to allow others to use your version of this file under
|
---|
28 | * the terms of the CDDL, indicate your decision by deleting the provisions
|
---|
29 | * above and replace them with the notice and other provisions required by the
|
---|
30 | * LGPL. If you do not delete the provisions above, a recipient may use your
|
---|
31 | * version of this file under the terms of any one of the CDDL or the LGPL.
|
---|
32 | *
|
---|
33 | * ***** END LICENSE BLOCK ***** */
|
---|
34 | /*
|
---|
35 | * This file was generated by orbit-idl-2 for Voyager
|
---|
36 | *
|
---|
37 | */
|
---|
38 | #ifndef NOM_WPFolderWindow_IMPLEMENTATION_FILE
|
---|
39 | #define NOM_WPFolderWindow_IMPLEMENTATION_FILE
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #define INCL_DOS
|
---|
43 |
|
---|
44 | #define METHOD_DEBUG
|
---|
45 |
|
---|
46 | #include <os2.h>
|
---|
47 |
|
---|
48 | #include <nom.h>
|
---|
49 | #include <nomtk.h>
|
---|
50 |
|
---|
51 | #include <string.h>
|
---|
52 | #include <gtk/gtk.h>
|
---|
53 | #include "nomguitk.h"
|
---|
54 | #include "nomwindow.h"
|
---|
55 | #include "desktoptypes.h"
|
---|
56 |
|
---|
57 | #include "wpnotebook.h"
|
---|
58 | #include "wpfolderwindow.h"
|
---|
59 | #include "wpfolder.h"
|
---|
60 | #include "m_wpfolder.h"
|
---|
61 | #include "wpfolderwindow.ih"
|
---|
62 | #include "wpobject.h"
|
---|
63 | #include "exception.h"
|
---|
64 |
|
---|
65 | #include "nomdragwindow.h"
|
---|
66 | #include "nomdraginfo.h"
|
---|
67 |
|
---|
68 | NOM_Scope PGtkWidget NOMLINK impl_WPFolderWindow_wpQueryContainerHandle(WPFolderWindow* nomSelf, CORBA_Environment *ev)
|
---|
69 | {
|
---|
70 | WPFolderWindowData* nomThis=WPFolderWindowGetData(nomSelf);
|
---|
71 |
|
---|
72 | return (PGtkWidget) g_atomic_pointer_get(&_pgContainerHandle);
|
---|
73 | }
|
---|
74 |
|
---|
75 | NOM_Scope void NOMLINK impl_WPFolderWindow_wpSetContainerHandle(WPFolderWindow* nomSelf, const PGtkWidget pgWidget,
|
---|
76 | CORBA_Environment *ev)
|
---|
77 | {
|
---|
78 | WPFolderWindowData* nomThis=WPFolderWindowGetData(nomSelf);
|
---|
79 |
|
---|
80 | _pgContainerHandle=pgWidget;
|
---|
81 | }
|
---|
82 |
|
---|
83 | /*
|
---|
84 | Check if the right button click was within a certain time. That means
|
---|
85 | the user released the button again within a short time period. On OS/2
|
---|
86 | a context menu will display after the user released the button not when
|
---|
87 | the user pressed it.
|
---|
88 | */
|
---|
89 | #define CTXT_MENU_BUTTON_DELAY 250
|
---|
90 | static gboolean
|
---|
91 | fldr_checkContextButton(GdkEventButton *event)
|
---|
92 | {
|
---|
93 | static guint guiTime=0;
|
---|
94 |
|
---|
95 | /* Right mouse button */
|
---|
96 | if (event->button != 3)
|
---|
97 | return FALSE;
|
---|
98 |
|
---|
99 | /* Ignore double-clicks and triple-clicks */
|
---|
100 | if(event->type == GDK_BUTTON_PRESS)
|
---|
101 | guiTime=event->time;
|
---|
102 |
|
---|
103 | if(event->type == GDK_BUTTON_RELEASE)
|
---|
104 | {
|
---|
105 | if(event->time-guiTime<CTXT_MENU_BUTTON_DELAY)
|
---|
106 | return TRUE;
|
---|
107 | }
|
---|
108 |
|
---|
109 | return FALSE;
|
---|
110 | }
|
---|
111 |
|
---|
112 |
|
---|
113 | static gboolean
|
---|
114 | fldr_handleButtonEvent (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
|
---|
115 | {
|
---|
116 |
|
---|
117 |
|
---|
118 | TRY(FLDR_BUTTONEVENT) {
|
---|
119 | if(fldr_checkContextButton(event))
|
---|
120 | {
|
---|
121 | PWPFolderWindow pWindow;
|
---|
122 | GtkTreePath* treePath;
|
---|
123 |
|
---|
124 | pWindow=(WPFolderWindow*)user_data;
|
---|
125 | //TST_OBJECT(pWindow);
|
---|
126 | treePath=gtk_icon_view_get_path_at_pos(GTK_ICON_VIEW(widget), event->x, event->y );
|
---|
127 | if(NULL==treePath)
|
---|
128 | {
|
---|
129 | /* Click on white space */
|
---|
130 | WPFolder* wpFolder;
|
---|
131 | wpFolder=(WPFolder*)WPFolderWindow_wpQueryObject(pWindow, NULLHANDLE);
|
---|
132 | TST_OBJECT(wpFolder);
|
---|
133 | //(TRUE ? WPFolder_wpSetFldrFlags(wpFolder, 0, 0, NULLHANDLE) : FALSE) ;
|
---|
134 | //WPFolderWindow_show(pWindow, NULLHANDLE) ;
|
---|
135 | //WPFolder_wpQueryFldrFlags(pWindow, NULLHANDLE) ;
|
---|
136 | //g_message("Result: %d ", (TRUE ? WPFolder_wpSetFldrFlags(NULL/*wpFolder*/, 0, 0, NULLHANDLE) : FALSE)) ;
|
---|
137 | if(nomIsObj(wpFolder))
|
---|
138 | WPObject_wpDisplayMenu((WPObject*)wpFolder, pWindow, NULL, MENU_OPENVIEWPOPUP, 0, NULL);
|
---|
139 | else
|
---|
140 | g_message("%d %s: WPFolder object not valid!", __LINE__, __FUNCTION__);
|
---|
141 | }
|
---|
142 | else
|
---|
143 | {
|
---|
144 | GtkTreeIter iter;
|
---|
145 | GtkTreeModel* model;
|
---|
146 | WPObject *wpObject;
|
---|
147 | /* Click on an icon */
|
---|
148 |
|
---|
149 | //g_message("%s: %s", __FUNCTION__, gtk_tree_path_to_string(treePath));
|
---|
150 |
|
---|
151 | model=gtk_icon_view_get_model(GTK_ICON_VIEW(widget));
|
---|
152 | //g_message("%s: model: %x", __FUNCTION__, (UINT)model);
|
---|
153 |
|
---|
154 | gtk_tree_model_get_iter(model , &iter, treePath);
|
---|
155 | //g_message("%s: iter.stamp: %x %x %x %x", __FUNCTION__, (UINT)iter.stamp, (UINT) iter.user_data
|
---|
156 | // , (UINT)iter.user_data2, (UINT)iter.user_data3);
|
---|
157 | gtk_tree_model_get(model, &iter, 0, &wpObject, -1);
|
---|
158 |
|
---|
159 | TST_OBJECT(wpObject);
|
---|
160 |
|
---|
161 | if(nomIsObj(wpObject)){
|
---|
162 | g_message("%s: %s calling wpDisplayMenu()", __FUNCTION__, wpObject->mtab->nomClassName);
|
---|
163 | WPObject_wpDisplayMenu((WPObject*)wpObject, pWindow, NULL, MENU_OBJECTPOPUP, 0, NULL);
|
---|
164 | }
|
---|
165 | else
|
---|
166 | g_message("%d %s: WPDataFile object not valid!", __LINE__, __FUNCTION__);
|
---|
167 |
|
---|
168 | }
|
---|
169 | }/* if() */
|
---|
170 | }CATCH{
|
---|
171 | //LOUD;
|
---|
172 | g_message("Line %d: Trap in %s", __LINE__, __FUNCTION__);
|
---|
173 | } END_CATCH(FLDR_BUTTONEVENT);
|
---|
174 |
|
---|
175 | return FALSE;
|
---|
176 | }
|
---|
177 |
|
---|
178 | /* FIXME: move to an include file */
|
---|
179 | enum{
|
---|
180 | WPOBJECT_TARGET_OBJECT,
|
---|
181 | WPOBJECT_TARGET_CPATH,
|
---|
182 | WPOBJECT_TARGET_PATH,
|
---|
183 | WPOBJECT_TARGET_STRING
|
---|
184 | };
|
---|
185 |
|
---|
186 | static GtkTargetEntry targetEntries[]=
|
---|
187 | {
|
---|
188 | {"WPObject", 0, WPOBJECT_TARGET_OBJECT},
|
---|
189 | {"WPObject-C-path", 0, WPOBJECT_TARGET_CPATH},
|
---|
190 | {"WPObject-path", 0, WPOBJECT_TARGET_PATH},
|
---|
191 | {"STRING", 0, WPOBJECT_TARGET_STRING},
|
---|
192 | };
|
---|
193 |
|
---|
194 | static NOMDragWindow *nomDragWindow=NULL;
|
---|
195 | static NOMDragInfo *nomDragInfo=NULL;
|
---|
196 |
|
---|
197 | /*
|
---|
198 | This callback handles the drop of an item on an object.
|
---|
199 | */
|
---|
200 | static gboolean fldrWindowHandleDragDrop(GtkWidget * wgtThis, GdkDragContext* dragContext,
|
---|
201 | gint x, gint y,
|
---|
202 | guint t, gpointer ptrUserData)
|
---|
203 | {
|
---|
204 | GtkTreePath* treePath;
|
---|
205 | PWPFolderWindow pWindow;
|
---|
206 | gulong rc=0;
|
---|
207 | WPObject *wpObject;
|
---|
208 |
|
---|
209 | //g_message(" %s", __FUNCTION__);
|
---|
210 | //g_message(" action: %d", dragContext->action );
|
---|
211 |
|
---|
212 | /* Find the object beneath the pointer */
|
---|
213 | treePath=gtk_icon_view_get_path_at_pos(GTK_ICON_VIEW(wgtThis), x, y );
|
---|
214 | if(NULL==treePath)
|
---|
215 | {
|
---|
216 |
|
---|
217 | /* White space, so ask the folder */
|
---|
218 |
|
---|
219 | pWindow=(WPFolderWindow*)ptrUserData;
|
---|
220 | if(!nomIsObj(pWindow))
|
---|
221 | return FALSE;
|
---|
222 |
|
---|
223 | wpObject=WPFolderWindow_wpQueryObject(pWindow, NULLHANDLE);
|
---|
224 |
|
---|
225 | if(!nomIsObj(wpObject))
|
---|
226 | return FALSE;
|
---|
227 | }
|
---|
228 | else
|
---|
229 | {
|
---|
230 | GtkTreeIter iter;
|
---|
231 | GtkTreeModel* model;
|
---|
232 |
|
---|
233 | /* Over an icon */
|
---|
234 |
|
---|
235 | model=gtk_icon_view_get_model(GTK_ICON_VIEW(wgtThis));
|
---|
236 | gtk_tree_model_get_iter(model , &iter, treePath);
|
---|
237 | gtk_tree_model_get(model, &iter, 0, &wpObject, -1);
|
---|
238 |
|
---|
239 | //TST_OBJECT(wpObject);
|
---|
240 |
|
---|
241 | if(!nomIsObj(wpObject))
|
---|
242 | return FALSE;
|
---|
243 | }
|
---|
244 | rc=WPObject_wpDragOver(wpObject, wgtThis, nomDragInfo, NULL);
|
---|
245 |
|
---|
246 | if(dragContext->targets)
|
---|
247 | {
|
---|
248 | GdkAtom targetType;
|
---|
249 | targetType=GDK_POINTER_TO_ATOM(g_list_nth_data(dragContext->targets, WPOBJECT_TARGET_OBJECT));
|
---|
250 | // g_message(" calling gtk_drag_get_data()..." );
|
---|
251 | gtk_drag_get_data(wgtThis, dragContext, targetType, t);
|
---|
252 |
|
---|
253 | /* FIXME:
|
---|
254 | We don't use the returned data for now but use our own draginfo stuff. This is
|
---|
255 | broken.
|
---|
256 | The following may be moved to dragDataReceived later. */
|
---|
257 | if(rc) {
|
---|
258 | // g_message("Now call wpDrop() actions: %d action: %d sugg %d", dragContext->action,
|
---|
259 | // dragContext->action, dragContext->suggested_action);
|
---|
260 |
|
---|
261 | WPObject_wpDrop( wpObject, wgtThis, nomDragInfo, NULLHANDLE);
|
---|
262 |
|
---|
263 | gtk_drag_finish(dragContext, TRUE, FALSE, t);
|
---|
264 | return TRUE;
|
---|
265 | }
|
---|
266 |
|
---|
267 | }
|
---|
268 | return FALSE;
|
---|
269 | }
|
---|
270 |
|
---|
271 | #if 0
|
---|
272 | static void fldrDragLeave(GtkWidget * widget, GdkDragContext* dragContext,
|
---|
273 | guint t, gpointer ptrUserData)
|
---|
274 | {
|
---|
275 | GdkPixmap *pixMapDrag;
|
---|
276 | gdk_pixbuf_render_pixmap_and_mask(pixBufStop, &pixMapDrag, NULL, 128);
|
---|
277 | gdk_window_set_back_pixmap(wgtDrag->window, pixMapDrag, FALSE);
|
---|
278 | g_object_unref(pixMapDrag);
|
---|
279 | gtk_widget_queue_draw(wgtDrag);
|
---|
280 | g_message("%s", __FUNCTION__);
|
---|
281 | return;
|
---|
282 | }
|
---|
283 | #endif
|
---|
284 |
|
---|
285 | /**
|
---|
286 | Callback for the drag-begin signal.
|
---|
287 | */
|
---|
288 | static void fldrWindowHandleDragBegin(GtkWidget * widget, GdkDragContext* dragContext,
|
---|
289 | gpointer ptrUserData)
|
---|
290 | {
|
---|
291 | GtkTreePath* treePath;
|
---|
292 | gint x, y;
|
---|
293 |
|
---|
294 | /* Create the drag window displayed to the user */
|
---|
295 | if(NULLHANDLE==nomDragWindow)
|
---|
296 | {
|
---|
297 | nomDragWindow=NOMDragWindowNew();
|
---|
298 | }
|
---|
299 |
|
---|
300 | if(NULLHANDLE==nomDragInfo)
|
---|
301 | {
|
---|
302 | nomDragInfo=NOMDragInfoNew();
|
---|
303 | }
|
---|
304 |
|
---|
305 | if(!dragContext)
|
---|
306 | return;
|
---|
307 |
|
---|
308 | /* Make sure we have no leftovers... */
|
---|
309 | NOMDragInfo_deleteAllDragItems(nomDragInfo, NULLHANDLE);
|
---|
310 | NOMDragInfo_setGdkDragContextPointer(nomDragInfo, dragContext, NULLHANDLE);
|
---|
311 |
|
---|
312 | /* Get the object beneath the pointer if any */
|
---|
313 | gtk_widget_get_pointer(widget, &x, &y);
|
---|
314 | treePath=gtk_icon_view_get_path_at_pos(GTK_ICON_VIEW(widget), x, y );
|
---|
315 |
|
---|
316 | if(NULL==treePath)
|
---|
317 | {
|
---|
318 | /* Click on white space */
|
---|
319 | // NOMDragWindow_hide(nomDragWindow, NULLHANDLE);
|
---|
320 | g_message("%d %s: White space!", __LINE__, __FUNCTION__);
|
---|
321 | }
|
---|
322 | else
|
---|
323 | {
|
---|
324 | GtkTreeIter iter;
|
---|
325 | GtkTreeModel* model;
|
---|
326 | WPObject *wpObject;
|
---|
327 | WPFolderWindow *wpFolderWindow=(WPFolderWindow*)ptrUserData;
|
---|
328 |
|
---|
329 | /* Click on an icon occurred */
|
---|
330 |
|
---|
331 | if(!nomIsObj(wpFolderWindow))
|
---|
332 | return; //Oops...
|
---|
333 |
|
---|
334 | g_message("%s: %s", __FUNCTION__, gtk_tree_path_to_string(treePath));
|
---|
335 |
|
---|
336 | /* Get the object belonging to the tree path */
|
---|
337 | model=gtk_icon_view_get_model(GTK_ICON_VIEW(widget));
|
---|
338 | gtk_tree_model_get_iter(model , &iter, treePath);
|
---|
339 | gtk_tree_model_get(model, &iter, 0, &wpObject, -1);
|
---|
340 |
|
---|
341 | // TST_OBJECT(wpObject);
|
---|
342 |
|
---|
343 | if(nomIsObj(wpObject)){
|
---|
344 | g_message("%s: %s begin DnD", __FUNCTION__, wpObject->mtab->nomClassName);
|
---|
345 |
|
---|
346 | /* Add the object to the list of items for this drag */
|
---|
347 | NOMDragInfo_addWPObjectToItemList(nomDragInfo, wpObject,
|
---|
348 | (PWPFolder)WPFolderWindow_wpQueryObject(wpFolderWindow, NULLHANDLE),
|
---|
349 | widget, NULLHANDLE);
|
---|
350 | }
|
---|
351 | else
|
---|
352 | g_message("%d %s: WPDataFile object not valid!", __LINE__, __FUNCTION__);
|
---|
353 |
|
---|
354 | NOMDragWindow_show(nomDragWindow, NULLHANDLE);
|
---|
355 | }
|
---|
356 |
|
---|
357 |
|
---|
358 | /* Tell GTK to use our drag window as an 'icon' while dragging. */
|
---|
359 | gtk_drag_set_icon_widget(dragContext,
|
---|
360 | NOMDragWindow_queryWindowHandle(nomDragWindow, NULLHANDLE), 0, 0);
|
---|
361 |
|
---|
362 | // gdk_drag_status(dragContext, GDK_ACTION_MOVE, t);
|
---|
363 | //NOMDragWindow_hide(nomDragWindow, NULLHANDLE);
|
---|
364 | return;
|
---|
365 | }
|
---|
366 |
|
---|
367 | static gboolean fldrWindowHandleDragMotion(GtkWidget * wgtThis, GdkDragContext* dragContext, int x, int y, guint t,
|
---|
368 | gpointer ptrUserData)
|
---|
369 | {
|
---|
370 | GtkWidget *wgtSource;
|
---|
371 | GtkTreePath* treePath;
|
---|
372 | PWPFolderWindow pWindow;
|
---|
373 | WPObject *wpObject;
|
---|
374 | gulong rc=0;
|
---|
375 | static gulong oldRc=0xff;/* Make sure we at last one time have an rc!=oldRc so the icon is
|
---|
376 | set properly below */
|
---|
377 |
|
---|
378 | if(dragContext==NULL)
|
---|
379 | return FALSE;
|
---|
380 |
|
---|
381 | if((wgtSource=gtk_drag_get_source_widget(dragContext))==NULLHANDLE)
|
---|
382 | return FALSE;
|
---|
383 |
|
---|
384 | /* This does not work for some reason */
|
---|
385 | // gtk_drag_highlight(wgtThis);
|
---|
386 | //gtk_widget_queue_draw(wgtThis);
|
---|
387 |
|
---|
388 |
|
---|
389 | if(dragContext)
|
---|
390 | {
|
---|
391 | // g_message(" Actions: %x %x" , dragContext->actions, dragContext->suggested_action);
|
---|
392 | }
|
---|
393 |
|
---|
394 | #if 0
|
---|
395 | if(wgtSource==wgtThis){
|
---|
396 | gdk_drag_status(dragContext, GDK_ACTION_MOVE, t);
|
---|
397 | // gdk_drag_status(dragContext, 0, t);
|
---|
398 | gtk_drag_highlight(wgtThis);
|
---|
399 | }
|
---|
400 | else{
|
---|
401 | gdk_drag_status(dragContext, GDK_ACTION_COPY, t);
|
---|
402 | gtk_drag_unhighlight(wgtSource);
|
---|
403 | }
|
---|
404 | #endif
|
---|
405 |
|
---|
406 | /* Find the object beneath the pointer */
|
---|
407 | treePath=gtk_icon_view_get_path_at_pos(GTK_ICON_VIEW(wgtThis), x, y );
|
---|
408 | if(NULL==treePath)
|
---|
409 | {
|
---|
410 | /* White space, so ask the folder */
|
---|
411 |
|
---|
412 | pWindow=(WPFolderWindow*)ptrUserData;
|
---|
413 | if(!nomIsObj(pWindow))
|
---|
414 | return FALSE;
|
---|
415 |
|
---|
416 | wpObject=WPFolderWindow_wpQueryObject(pWindow, NULLHANDLE);
|
---|
417 |
|
---|
418 | if(!nomIsObj(wpObject))
|
---|
419 | return FALSE;
|
---|
420 | }
|
---|
421 | else
|
---|
422 | {
|
---|
423 | GtkTreeIter iter;
|
---|
424 | GtkTreeModel* model;
|
---|
425 |
|
---|
426 | /* Over an icon */
|
---|
427 |
|
---|
428 | model=gtk_icon_view_get_model(GTK_ICON_VIEW(wgtThis));
|
---|
429 |
|
---|
430 | gtk_tree_model_get_iter(model , &iter, treePath);
|
---|
431 | gtk_tree_model_get(model, &iter, 0, &wpObject, -1);
|
---|
432 |
|
---|
433 | //TST_OBJECT(wpObject);
|
---|
434 |
|
---|
435 | if(!nomIsObj(wpObject))
|
---|
436 | return FALSE;
|
---|
437 | //g_message("Over an icon");
|
---|
438 | }
|
---|
439 | rc=WPObject_wpDragOver(wpObject, wgtThis, nomDragInfo, NULL);
|
---|
440 | //g_message("rc: %d oldRc %d", rc, oldRc);
|
---|
441 |
|
---|
442 | /* Change the drag icon if necesary. Note that this will not change the
|
---|
443 | cursor. */
|
---|
444 | if(oldRc!=rc)
|
---|
445 | {
|
---|
446 | /* drag icon */
|
---|
447 | switch(rc)
|
---|
448 | {
|
---|
449 | case DOR_NODROP:
|
---|
450 | {
|
---|
451 | /* Don't drop */
|
---|
452 | NOMDragWindow_displayStopImage(nomDragWindow, NULLHANDLE);
|
---|
453 | // gdk_drag_status(dragContext, 0, t);
|
---|
454 | break;
|
---|
455 | }
|
---|
456 | default:
|
---|
457 | {
|
---|
458 | NOMDragWindow_displayDragImage(nomDragWindow, NULLHANDLE);
|
---|
459 | // gdk_drag_status(dragContext, GDK_ACTION_MOVE, t);
|
---|
460 | break;
|
---|
461 | }
|
---|
462 | }
|
---|
463 | /* Tell GTK to redraw the drag window */
|
---|
464 | gtk_widget_queue_draw(NOMDragWindow_queryWindowHandle(nomDragWindow, NULLHANDLE));
|
---|
465 | }
|
---|
466 | oldRc=rc;
|
---|
467 |
|
---|
468 | switch(dragContext->actions)
|
---|
469 | {
|
---|
470 | case GDK_ACTION_COPY:
|
---|
471 | {
|
---|
472 | gdk_drag_status(dragContext, GDK_ACTION_COPY, t);
|
---|
473 | break;
|
---|
474 | }
|
---|
475 | case GDK_ACTION_MOVE:
|
---|
476 | {
|
---|
477 | gdk_drag_status(dragContext, GDK_ACTION_MOVE, t);
|
---|
478 | break;
|
---|
479 | }
|
---|
480 | case GDK_ACTION_LINK:
|
---|
481 | {
|
---|
482 | gdk_drag_status(dragContext, GDK_ACTION_LINK, t);
|
---|
483 | break;
|
---|
484 | }
|
---|
485 | default:
|
---|
486 | {
|
---|
487 | if(dragContext->actions & GDK_ACTION_MOVE) //FIXME
|
---|
488 | gdk_drag_status(dragContext, GDK_ACTION_MOVE, t);
|
---|
489 | break;
|
---|
490 | }
|
---|
491 | }
|
---|
492 | #if 0
|
---|
493 | /* Now change the cursor */
|
---|
494 | switch(rc & DOR_ALLFLAGS)
|
---|
495 | {
|
---|
496 | case DOR_NODROP:
|
---|
497 | {
|
---|
498 | /* Don't drop */
|
---|
499 | gdk_drag_status(dragContext, 0, t);
|
---|
500 | break;
|
---|
501 | }
|
---|
502 | default:
|
---|
503 | {
|
---|
504 | switch(rc & DO_ALLFLAGS)
|
---|
505 | {
|
---|
506 | case DO_MOVE:
|
---|
507 | {
|
---|
508 | gdk_drag_status(dragContext, GDK_ACTION_MOVE, t);
|
---|
509 | break;
|
---|
510 | }
|
---|
511 | case DO_COPY:
|
---|
512 | {
|
---|
513 | gdk_drag_status(dragContext, GDK_ACTION_COPY, t);
|
---|
514 | break;
|
---|
515 | }
|
---|
516 | case DO_LINK:
|
---|
517 | {
|
---|
518 | gdk_drag_status(dragContext, GDK_ACTION_LINK, t);
|
---|
519 | break;
|
---|
520 | }
|
---|
521 |
|
---|
522 | default:
|
---|
523 | if(dragContext->actions & GDK_ACTION_MOVE) //FIXME
|
---|
524 | gdk_drag_status(dragContext, GDK_ACTION_MOVE, t);
|
---|
525 | break;
|
---|
526 | }
|
---|
527 | break;
|
---|
528 | }
|
---|
529 | }/* switch() */
|
---|
530 | #endif
|
---|
531 |
|
---|
532 | return FALSE;
|
---|
533 | }
|
---|
534 |
|
---|
535 |
|
---|
536 | static void fldrWindowHandleDragDataReceived(GtkWidget * widget, GdkDragContext* dragContext, int x, int y, GtkSelectionData *selData,
|
---|
537 | guint info, guint uiTime, gpointer ptrUserData)
|
---|
538 | {
|
---|
539 | g_message("%s", __FUNCTION__);
|
---|
540 | // gdk_drag_status(dragContext, GDK_ACTION_COPY, uiTime);
|
---|
541 | return;
|
---|
542 | }
|
---|
543 |
|
---|
544 |
|
---|
545 | /*
|
---|
546 |
|
---|
547 | \param uiInfo the entry in the GtkTargetList used in gtk_drag_source_set().
|
---|
548 |
|
---|
549 | */
|
---|
550 | static void fldrWindowHandleDragDataGet(GtkWidget * widget, GdkDragContext* dragContext, GtkSelectionData *selData,
|
---|
551 | guint uiTargetInfo, guint t, gpointer ptrUserData)
|
---|
552 | {
|
---|
553 |
|
---|
554 | g_message("%s", __FUNCTION__);
|
---|
555 | // g_message(" info: %d, userData: %x", uiTargetInfo, ptrUserData);
|
---|
556 |
|
---|
557 | switch(uiTargetInfo)
|
---|
558 | {
|
---|
559 | case WPOBJECT_TARGET_OBJECT:
|
---|
560 | {
|
---|
561 | gpointer wpObject=1234;
|
---|
562 |
|
---|
563 | g_message("WPOBJECT_TARGET_OBJECT requested");
|
---|
564 | gtk_selection_data_set(selData, selData->target, 8, (guchar*) &wpObject, sizeof(wpObject));
|
---|
565 | break;
|
---|
566 | }
|
---|
567 | default:
|
---|
568 |
|
---|
569 | break;
|
---|
570 | };
|
---|
571 |
|
---|
572 | return;
|
---|
573 | }
|
---|
574 |
|
---|
575 | NOM_Scope void NOMLINK impl_WPFolderWindow_nomInit(WPFolderWindow* nomSelf, CORBA_Environment *ev)
|
---|
576 | {
|
---|
577 | GtkWidget* window;
|
---|
578 | GtkWidget *vbox;
|
---|
579 | GtkWidget *sw;
|
---|
580 | GtkWidget *icon_view;
|
---|
581 | GtkWidget *tool_bar;
|
---|
582 | GtkToolItem *up_button;
|
---|
583 | // GtkWidget *menuBar, *file;
|
---|
584 | // WPFolderWindowData* nomThis=WPFolderWindowGetData(nomSelf);
|
---|
585 |
|
---|
586 | /* Let parents initialize */
|
---|
587 | WPFolderWindow_nomInit_parent((NOMObject*)nomSelf, NULLHANDLE);
|
---|
588 |
|
---|
589 | /* Create a default (hidden) folder window */
|
---|
590 |
|
---|
591 | /* Folder toplevel window. */
|
---|
592 | window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
---|
593 |
|
---|
594 | /* FIXME: Set default size of folder frame. Will later use a stored value */
|
---|
595 | gtk_window_set_default_size (GTK_WINDOW (window), 650, 400);
|
---|
596 |
|
---|
597 | /* Make sure we have a reference to the class so the garbage collector
|
---|
598 | doesn't unload us */
|
---|
599 | g_object_set_data(G_OBJECT(window), NOMOBJECT_KEY_STRING, nomSelf);
|
---|
600 |
|
---|
601 | #if 0
|
---|
602 | menuBar=gtk_menu_bar_new();
|
---|
603 | file=gtk_menu_item_new_with_label("File");
|
---|
604 | //gtk_signal_connect(GTK_OBJECT(file), "destroy", GTK_SIGNAL_FUNC(tst), NULL);
|
---|
605 |
|
---|
606 | gtk_container_add(GTK_CONTAINER(menuBar), file);
|
---|
607 | gtk_widget_show(menuBar);
|
---|
608 | gtk_widget_show(file);
|
---|
609 | #endif
|
---|
610 |
|
---|
611 | vbox = gtk_vbox_new (FALSE, 0);
|
---|
612 |
|
---|
613 | gtk_container_add (GTK_CONTAINER (window), vbox);
|
---|
614 |
|
---|
615 | /* Create and pack the toolbar */
|
---|
616 | tool_bar = gtk_toolbar_new ();
|
---|
617 |
|
---|
618 | // gtk_box_pack_start (GTK_BOX (vbox), menuBar, FALSE, FALSE, 0); /* Don't expand the toolbar vertically if sized */
|
---|
619 | gtk_box_pack_start (GTK_BOX (vbox), tool_bar, FALSE, FALSE, 0); /* Don't expand the toolbar vertically if sized */
|
---|
620 |
|
---|
621 | /* Parent button */
|
---|
622 | up_button = gtk_tool_button_new_from_stock (GTK_STOCK_GO_UP);
|
---|
623 | gtk_tool_item_set_is_important (up_button, TRUE);
|
---|
624 | /* Disable button */
|
---|
625 | gtk_widget_set_sensitive (GTK_WIDGET (up_button), FALSE);
|
---|
626 | /* Put it into the toolbar */
|
---|
627 | gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), up_button, -1);
|
---|
628 |
|
---|
629 | sw = gtk_scrolled_window_new (NULL, NULL);
|
---|
630 | /* Drawing style */
|
---|
631 | gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
---|
632 | GTK_SHADOW_ETCHED_IN);
|
---|
633 | /* Show scrollbars only if necessary */
|
---|
634 | gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
---|
635 | GTK_POLICY_AUTOMATIC,
|
---|
636 | GTK_POLICY_AUTOMATIC);
|
---|
637 | /* Pack it into the vbox with size adjusting to the vbox */
|
---|
638 | gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
|
---|
639 | /* Create an icon view without model */
|
---|
640 | icon_view = gtk_icon_view_new ();
|
---|
641 |
|
---|
642 | /* Allow multiple selection in icon view */
|
---|
643 | gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_view),
|
---|
644 | GTK_SELECTION_MULTIPLE);
|
---|
645 | #if 0
|
---|
646 | /* Connect to the "item_activated" signal */
|
---|
647 | g_signal_connect (icon_view, "item-activated",
|
---|
648 | G_CALLBACK (itemActivated), nomSelf);
|
---|
649 | #endif
|
---|
650 | //#endif
|
---|
651 |
|
---|
652 | /* This is for kb binding only */
|
---|
653 | #if 0
|
---|
654 | g_signal_connect (GTK_WIDGET(icon_view), "popup-menu",
|
---|
655 | G_CALLBACK (fldr_cbPopupMenu), nomSelf);
|
---|
656 | #endif
|
---|
657 |
|
---|
658 | #if 0
|
---|
659 | /* Connect to the "clicked" signal of the "Up" tool button */
|
---|
660 | g_signal_connect (up_button, "clicked",
|
---|
661 | G_CALLBACK (up_clicked), store);
|
---|
662 | #endif
|
---|
663 |
|
---|
664 | /* Prepare drag and drop */
|
---|
665 | _wpConnectDefaultSignalHandlers(nomSelf, icon_view, NULLHANDLE);
|
---|
666 | WPFolderWindow_wpSetContainerHandle(nomSelf, icon_view, NULLHANDLE);
|
---|
667 |
|
---|
668 | /* Add icon view as child to the scroll window created earlier */
|
---|
669 | gtk_container_add (GTK_CONTAINER (sw), icon_view);
|
---|
670 |
|
---|
671 | gtk_widget_grab_focus (icon_view);
|
---|
672 |
|
---|
673 | // g_signal_connect (GTK_WIDGET(window), "size-request",
|
---|
674 | // G_CALLBACK (handleEvent), nomSelf);
|
---|
675 |
|
---|
676 | WPFolderWindow_setWindowHandle(nomSelf, window, NULLHANDLE);
|
---|
677 | /* Window is hidden here and must be shown by the caller */
|
---|
678 | }
|
---|
679 |
|
---|
680 | NOM_Scope void NOMLINK impl_WPFolderWindow_wpConnectDefaultSignalHandlers(WPFolderWindow* nomSelf,
|
---|
681 | const PGtkWidget pgWidget,
|
---|
682 | CORBA_Environment *ev)
|
---|
683 | {
|
---|
684 | /* WPFolderWindowData* nomThis=WPFolderWindowGetData(nomSelf); */
|
---|
685 |
|
---|
686 | /* Handle mouse buttons */
|
---|
687 | g_signal_connect (GTK_WIDGET(pgWidget), "button-press-event",
|
---|
688 | G_CALLBACK (fldr_handleButtonEvent), nomSelf);
|
---|
689 | g_signal_connect (GTK_WIDGET(pgWidget), "button-release-event",
|
---|
690 | G_CALLBACK (fldr_handleButtonEvent), nomSelf);
|
---|
691 |
|
---|
692 | /* Handle folder DnD */
|
---|
693 | g_signal_connect(GTK_WIDGET(pgWidget), "drag-begin",
|
---|
694 | G_CALLBACK(fldrWindowHandleDragBegin), nomSelf);
|
---|
695 | g_signal_connect(GTK_WIDGET(pgWidget), "drag-motion",
|
---|
696 | G_CALLBACK(fldrWindowHandleDragMotion), nomSelf);
|
---|
697 | g_signal_connect(GTK_WIDGET(pgWidget), "drag-drop",
|
---|
698 | G_CALLBACK(fldrWindowHandleDragDrop), nomSelf);
|
---|
699 | g_signal_connect(GTK_WIDGET(pgWidget), "drag_data_received",
|
---|
700 | G_CALLBACK(fldrWindowHandleDragDataReceived), nomSelf);
|
---|
701 | g_signal_connect(GTK_WIDGET(pgWidget), "drag_data_get",
|
---|
702 | G_CALLBACK(fldrWindowHandleDragDataGet), nomSelf);
|
---|
703 |
|
---|
704 | /* Prepare drag and drop */
|
---|
705 | gtk_drag_source_set(GTK_WIDGET(pgWidget), GDK_BUTTON3_MASK, targetEntries,
|
---|
706 | G_N_ELEMENTS(targetEntries),
|
---|
707 | GDK_ACTION_DEFAULT|GDK_ACTION_LINK|GDK_ACTION_COPY|GDK_ACTION_MOVE);
|
---|
708 | gtk_drag_dest_set(GTK_WIDGET(pgWidget), GTK_DEST_DEFAULT_ALL, targetEntries, 1,
|
---|
709 | GDK_ACTION_DEFAULT|GDK_ACTION_LINK|GDK_ACTION_COPY|GDK_ACTION_MOVE);
|
---|
710 |
|
---|
711 | }
|
---|
712 |
|
---|