Changeset 241 for trunk/desktop/class_c/wpfolderwindow.c
- Timestamp:
- Mar 6, 2007, 8:47:20 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/desktop/class_c/wpfolderwindow.c
r240 r241 62 62 #include "exception.h" 63 63 64 #include "nomdragwindow.h" 65 #include "nomdraginfo.h" 66 64 67 NOM_Scope PGtkWidget NOMLINK impl_WPFolderWindow_wpQueryContainerHandle(WPFolderWindow* nomSelf, CORBA_Environment *ev) 65 68 { … … 70 73 71 74 NOM_Scope void NOMLINK impl_WPFolderWindow_wpSetContainerHandle(WPFolderWindow* nomSelf, const PGtkWidget pgWidget, 72 CORBA_Environment *ev)75 CORBA_Environment *ev) 73 76 { 74 77 WPFolderWindowData* nomThis=WPFolderWindowGetData(nomSelf); … … 116 119 PWPFolderWindow pWindow; 117 120 GtkTreePath* treePath; 118 //DosBeep(5000, 100); 121 119 122 pWindow=(WPFolderWindow*)user_data; 120 123 //TST_OBJECT(pWindow); … … 182 185 }; 183 186 187 static NOMDragWindow *nomDragWindow=NULL; 188 static NOMDragInfo *nomDragInfo=NULL; 184 189 185 190 /* 186 191 This callback handles the drop of an item on an object. 187 192 */ 188 static gboolean fldrWindowHandleDragDrop(GtkWidget * wgtThis, GdkDragContext* dragContext, gint x, gint y, 193 static gboolean fldrWindowHandleDragDrop(GtkWidget * wgtThis, GdkDragContext* dragContext, 194 gint x, gint y, 189 195 guint t, gpointer ptrUserData) 190 196 { 191 DosBeep(500, 10); 192 g_message("%s", __FUNCTION__); 193 g_message(" action: %d", dragContext->action ); 194 197 GtkTreePath* treePath; 198 PWPFolderWindow pWindow; 199 gulong rc=0; 200 WPObject *wpObject; 201 202 //g_message(" %s", __FUNCTION__); 203 //g_message(" action: %d", dragContext->action ); 204 205 /* Find the object beneath the pointer */ 206 treePath=gtk_icon_view_get_path_at_pos(GTK_ICON_VIEW(wgtThis), x, y ); 207 if(NULL==treePath) 208 { 209 210 /* White space, so ask the folder */ 211 212 pWindow=(WPFolderWindow*)ptrUserData; 213 if(!nomIsObj(pWindow)) 214 return FALSE; 215 216 wpObject=WPFolderWindow_wpQueryWPObject(pWindow, NULLHANDLE); 217 218 if(!nomIsObj(wpObject)) 219 return FALSE; 220 } 221 else 222 { 223 GtkTreeIter iter; 224 GtkTreeModel* model; 225 226 /* Over an icon */ 227 228 model=gtk_icon_view_get_model(GTK_ICON_VIEW(wgtThis)); 229 gtk_tree_model_get_iter(model , &iter, treePath); 230 gtk_tree_model_get(model, &iter, 0, &wpObject, -1); 231 232 //TST_OBJECT(wpObject); 233 234 if(!nomIsObj(wpObject)) 235 return FALSE; 236 } 237 rc=WPObject_wpDragOver(wpObject, wgtThis, nomDragInfo, NULL); 238 g_message("rc: %d", rc); 195 239 if(dragContext->targets) 196 240 { 197 241 GdkAtom targetType; 198 242 targetType=GDK_POINTER_TO_ATOM(g_list_nth_data(dragContext->targets, WPOBJECT_TARGET_OBJECT)); 199 g_message(" calling gtk_drag_get_data()..." );243 // g_message(" calling gtk_drag_get_data()..." ); 200 244 gtk_drag_get_data(wgtThis, dragContext, targetType, t); 245 246 /* FIXME: 247 We don't use the returned data for now but use our own draginfo stuff. This is 248 broken. 249 The following may be moved to dragDataReceived later. */ 250 if(rc) { 251 // g_message("Now call wpDrop() actions: %d action: %d sugg %d", dragContext->action, 252 // dragContext->action, dragContext->suggested_action); 253 254 WPObject_wpDrop( wpObject, wgtThis, nomDragInfo, NULLHANDLE); 255 256 gtk_drag_finish(dragContext, TRUE, FALSE, t); 257 return TRUE; 258 } 259 201 260 } 202 261 return FALSE; … … 208 267 { 209 268 GdkPixmap *pixMapDrag; 210 211 269 gdk_pixbuf_render_pixmap_and_mask(pixBufStop, &pixMapDrag, NULL, 128); 212 270 gdk_window_set_back_pixmap(wgtDrag->window, pixMapDrag, FALSE); 213 271 g_object_unref(pixMapDrag); 214 272 gtk_widget_queue_draw(wgtDrag); 215 216 g_message("%s", __FUNCTION__);217 218 return;219 }220 #endif221 222 static GtkWidget *wgtDrag=NULL;223 224 static GdkPixmap *pixMapDrag=NULL;225 static GdkPixmap *pixMapStop=NULL;226 227 /*228 Callback which loads a pixmap into the drag widget as soon as it's realized.229 */230 static void fldrWidgetRealize(GtkWidget * wgtDrag, gpointer ptrUserData)231 {232 gdk_window_set_back_pixmap(wgtDrag->window, pixMapDrag, FALSE);233 234 273 g_message("%s", __FUNCTION__); 235 274 return; 236 275 } 276 #endif 277 237 278 /** 238 279 Callback for the drag-begin signal. 239 280 */ 240 281 static void fldrWindowHandleDragBegin(GtkWidget * widget, GdkDragContext* dragContext, 241 gpointer ptrUserData) 242 { 243 if(NULLHANDLE==wgtDrag) 244 { 245 GdkPixbuf *pixBufDrag; 246 GdkPixbuf *pixBufStop; 247 248 wgtDrag=gtk_window_new(GTK_WINDOW_POPUP); 249 250 /* 251 FIXME: 252 In GTK 2.8 use *_HINT_DND instead. 253 */ 254 #warning move this somewhere else. Maybe into WPClassMgr 255 gtk_window_set_type_hint(GTK_WINDOW(wgtDrag), GDK_WINDOW_TYPE_HINT_MENU); 256 gtk_widget_set_app_paintable(GTK_WIDGET(wgtDrag), TRUE); 257 258 pixBufDrag=gtk_widget_render_icon(wgtDrag, GTK_STOCK_DND, GTK_ICON_SIZE_DND, NULL); 259 gdk_pixbuf_render_pixmap_and_mask(pixBufDrag, &pixMapDrag, NULL, 128); 260 261 gtk_widget_set_size_request(wgtDrag, gdk_pixbuf_get_width(pixBufDrag), gdk_pixbuf_get_height(pixBufDrag)); 262 263 g_object_unref(pixBufDrag); 264 265 pixBufStop=gtk_widget_render_icon(wgtDrag, GTK_STOCK_STOP, GTK_ICON_SIZE_DND, NULL); 266 gdk_pixbuf_render_pixmap_and_mask(pixBufStop, &pixMapStop, NULL, 128); 267 g_object_unref(pixBufStop); 268 269 if(!pixMapDrag) 270 g_warning("Cannot load pixbuf"); 271 if(!pixMapStop) 272 g_warning("Cannot load stop pixbuf"); 273 274 // gdk_pixbuf_render_pixmap_and_mask(pixBufDrag, &pixMapDrag, NULL, 128); 275 // gdk_window_set_back_pixmap(wgtDrag->window, pixMapDrag, FALSE); 276 // g_object_unref(pixMapDrag); 277 g_signal_connect_after(GTK_WIDGET(wgtDrag), "realize", G_CALLBACK(fldrWidgetRealize), NULL); 278 } 279 DosBeep(1000, 10); 280 g_message("%s", __FUNCTION__); 281 // if(wgtDrag->window) 282 //gdk_window_set_back_pixmap(wgtDrag->window, pixMapDrag, FALSE); 283 284 gtk_drag_set_icon_widget(dragContext, wgtDrag, 0, 0); 285 282 gpointer ptrUserData) 283 { 284 GtkTreePath* treePath; 285 gint x, y; 286 287 /* Create the drag window displayed to the user */ 288 if(NULLHANDLE==nomDragWindow) 289 { 290 nomDragWindow=NOMDragWindowNew(); 291 } 292 293 if(NULLHANDLE==nomDragInfo) 294 { 295 nomDragInfo=NOMDragInfoNew(); 296 } 297 298 if(!dragContext) 299 return; 300 301 /* Make sure we have no leftovers... */ 302 NOMDragInfo_deleteAllDragItems(nomDragInfo, NULLHANDLE); 303 NOMDragInfo_setGdkDragContextPointer(nomDragInfo, dragContext, NULLHANDLE); 304 305 /* Get the object beneath the pointer if any */ 306 gtk_widget_get_pointer(widget, &x, &y); 307 treePath=gtk_icon_view_get_path_at_pos(GTK_ICON_VIEW(widget), x, y ); 308 309 if(NULL==treePath) 310 { 311 /* Click on white space */ 312 // NOMDragWindow_hide(nomDragWindow, NULLHANDLE); 313 g_message("%d %s: White space!", __LINE__, __FUNCTION__); 314 } 315 else 316 { 317 GtkTreeIter iter; 318 GtkTreeModel* model; 319 WPObject *wpObject; 320 WPFolderWindow *wpFolderWindow=(WPFolderWindow*)ptrUserData; 321 322 /* Click on an icon occurred */ 323 324 if(!nomIsObj(wpFolderWindow)) 325 return; //Oops... 326 327 g_message("%s: %s", __FUNCTION__, gtk_tree_path_to_string(treePath)); 328 329 /* Get the object belonging to the tree path */ 330 model=gtk_icon_view_get_model(GTK_ICON_VIEW(widget)); 331 gtk_tree_model_get_iter(model , &iter, treePath); 332 gtk_tree_model_get(model, &iter, 0, &wpObject, -1); 333 334 // TST_OBJECT(wpObject); 335 336 if(nomIsObj(wpObject)){ 337 g_message("%s: %s begin DnD", __FUNCTION__, wpObject->mtab->nomClassName); 338 339 /* Add the object to the list of items for this drag */ 340 NOMDragInfo_addWPObjectToItemList(nomDragInfo, wpObject, 341 (PWPFolder)WPFolderWindow_wpQueryWPObject(wpFolderWindow, NULLHANDLE), 342 widget, NULLHANDLE); 343 } 344 else 345 g_message("%d %s: WPDataFile object not valid!", __LINE__, __FUNCTION__); 346 347 NOMDragWindow_show(nomDragWindow, NULLHANDLE); 348 } 349 350 351 /* Tell GTK to use our drag window as an 'icon' while dragging. */ 352 gtk_drag_set_icon_widget(dragContext, 353 NOMDragWindow_queryWindowHandle(nomDragWindow, NULLHANDLE), 0, 0); 354 355 // gdk_drag_status(dragContext, GDK_ACTION_MOVE, t); 356 //NOMDragWindow_hide(nomDragWindow, NULLHANDLE); 286 357 return; 287 358 } … … 293 364 GtkTreePath* treePath; 294 365 PWPFolderWindow pWindow; 366 WPObject *wpObject; 295 367 gulong rc=0; 296 static gulong oldRc=0; 368 static gulong oldRc=0xff;/* Make sure we at last one time have an rc!=oldRc so the icon is 369 set properly below */ 297 370 298 371 if(dragContext==NULL) … … 303 376 304 377 /* This does not work for some reason */ 305 gtk_drag_highlight(wgtThis); 306 gtk_widget_queue_draw(wgtThis); 378 // gtk_drag_highlight(wgtThis); 379 //gtk_widget_queue_draw(wgtThis); 380 307 381 308 382 if(dragContext) 309 383 { 310 g_message(" Actions: %x %x" , dragContext->actions, dragContext->suggested_action);384 // g_message(" Actions: %x %x" , dragContext->actions, dragContext->suggested_action); 311 385 } 312 386 … … 323 397 #endif 324 398 399 /* Find the object beneath the pointer */ 325 400 treePath=gtk_icon_view_get_path_at_pos(GTK_ICON_VIEW(wgtThis), x, y ); 326 327 401 if(NULL==treePath) 328 402 { 329 PWPFolder wpFolder; 330 /* White space */ 403 /* White space, so ask the folder */ 331 404 332 405 pWindow=(WPFolderWindow*)ptrUserData; … … 334 407 return FALSE; 335 408 336 wp Folder=(WPFolder*)WPFolderWindow_wpQueryWPObject(pWindow, NULLHANDLE);337 338 if(!nomIsObj(wp Folder))409 wpObject=WPFolderWindow_wpQueryWPObject(pWindow, NULLHANDLE); 410 411 if(!nomIsObj(wpObject)) 339 412 return FALSE; 340 341 rc=WPObject_wpDragOver((WPObject*)wpFolder, wgtThis, dragContext, NULL);342 413 } 343 414 else … … 345 416 GtkTreeIter iter; 346 417 GtkTreeModel* model; 347 WPObject *wpObject; 418 348 419 /* Over an icon */ 349 420 350 // g_message("%s: %s", __FUNCTION__, gtk_tree_path_to_string(treePath));351 // gtk_icon_view_item_activated(GTK_ICON_VIEW(wgtThis), treePath);352 353 421 model=gtk_icon_view_get_model(GTK_ICON_VIEW(wgtThis)); 354 422 … … 358 426 //TST_OBJECT(wpObject); 359 427 360 //if(nomIsObj(wpObject)) 361 rc=WPObject_wpDragOver((WPObject*)wpObject, wgtThis, dragContext, NULL); 362 } 363 428 if(!nomIsObj(wpObject)) 429 return FALSE; 430 //g_message("Over an icon"); 431 } 432 rc=WPObject_wpDragOver(wpObject, wgtThis, nomDragInfo, NULL); 433 //g_message("rc: %d oldRc %d", rc, oldRc); 434 435 /* Change the drag icon if necesary. Note that this will not change the 436 cursor. */ 364 437 if(oldRc!=rc) 365 438 { … … 367 440 switch(rc) 368 441 { 369 case 0:442 case DOR_NODROP: 370 443 { 371 444 /* Don't drop */ 372 gdk_window_set_back_pixmap(wgtDrag->window, pixMapStop, FALSE); 445 NOMDragWindow_displayStopImage(nomDragWindow, NULLHANDLE); 446 // gdk_drag_status(dragContext, 0, t); 373 447 break; 374 448 } 375 449 default: 376 450 { 377 gdk_window_set_back_pixmap(wgtDrag->window, pixMapDrag, FALSE); 451 NOMDragWindow_displayDragImage(nomDragWindow, NULLHANDLE); 452 // gdk_drag_status(dragContext, GDK_ACTION_MOVE, t); 453 break; 454 } 455 } 456 /* Tell GTK to redraw the drag window */ 457 gtk_widget_queue_draw(NOMDragWindow_queryWindowHandle(nomDragWindow, NULLHANDLE)); 458 } 459 oldRc=rc; 460 461 switch(dragContext->actions) 462 { 463 case GDK_ACTION_COPY: 464 { 465 gdk_drag_status(dragContext, GDK_ACTION_COPY, t); 466 break; 467 } 468 case GDK_ACTION_MOVE: 469 { 470 gdk_drag_status(dragContext, GDK_ACTION_MOVE, t); 471 break; 472 } 473 case GDK_ACTION_LINK: 474 { 475 gdk_drag_status(dragContext, GDK_ACTION_LINK, t); 476 break; 477 } 478 default: 479 { 480 if(dragContext->actions & GDK_ACTION_MOVE) //FIXME 481 gdk_drag_status(dragContext, GDK_ACTION_MOVE, t); 482 break; 483 } 484 } 485 #if 0 486 /* Now change the cursor */ 487 switch(rc & DOR_ALLFLAGS) 488 { 489 case DOR_NODROP: 490 { 491 /* Don't drop */ 492 gdk_drag_status(dragContext, 0, t); 493 break; 494 } 495 default: 496 { 497 switch(rc & DO_ALLFLAGS) 498 { 499 case DO_MOVE: 500 { 501 gdk_drag_status(dragContext, GDK_ACTION_MOVE, t); 502 break; 503 } 504 case DO_COPY: 505 { 506 gdk_drag_status(dragContext, GDK_ACTION_COPY, t); 507 break; 508 } 509 case DO_LINK: 510 { 511 gdk_drag_status(dragContext, GDK_ACTION_LINK, t); 512 break; 513 } 514 515 default: 516 if(dragContext->actions & GDK_ACTION_MOVE) //FIXME 517 gdk_drag_status(dragContext, GDK_ACTION_MOVE, t); 378 518 break; 379 519 } 380 }381 gtk_widget_queue_draw(wgtDrag);382 } 383 oldRc=rc; 384 520 break; 521 } 522 }/* switch() */ 523 #endif 524 385 525 return FALSE; 386 526 } … … 390 530 guint info, guint uiTime, gpointer ptrUserData) 391 531 { 392 DosBeep(5000, 100);393 532 g_message("%s", __FUNCTION__); 394 533 // gdk_drag_status(dragContext, GDK_ACTION_COPY, uiTime); … … 397 536 398 537 399 400 538 /* 401 539 … … 424 562 break; 425 563 }; 426 // 564 427 565 return; 428 566 } … … 525 663 G_CALLBACK(fldrWindowHandleDragDrop), nomSelf); 526 664 g_signal_connect(GTK_WIDGET(icon_view), "drag_data_received", 527 G_CALLBACK(fldrWindowHandleDragDataReceived), NULL);665 G_CALLBACK(fldrWindowHandleDragDataReceived), nomSelf); 528 666 g_signal_connect(GTK_WIDGET(icon_view), "drag_data_get", 529 G_CALLBACK(fldrWindowHandleDragDataGet), NULL);667 G_CALLBACK(fldrWindowHandleDragDataGet), nomSelf); 530 668 531 669 /* Prepare drag and drop */ 532 670 gtk_drag_source_set(GTK_WIDGET(icon_view), GDK_BUTTON3_MASK, targetEntries, 533 G_N_ELEMENTS(targetEntries) 534 GDK_ACTION_ LINK|GDK_ACTION_COPY|GDK_ACTION_MOVE);535 gtk_drag_dest_set(GTK_WIDGET(icon_view), GTK_DEST_DEFAULT_ALL, targetEntries, 1 536 GDK_ACTION_ LINK|GDK_ACTION_COPY|GDK_ACTION_MOVE);671 G_N_ELEMENTS(targetEntries), 672 GDK_ACTION_DEFAULT|GDK_ACTION_LINK|GDK_ACTION_COPY|GDK_ACTION_MOVE); 673 gtk_drag_dest_set(GTK_WIDGET(icon_view), GTK_DEST_DEFAULT_ALL, targetEntries, 1, 674 GDK_ACTION_DEFAULT|GDK_ACTION_LINK|GDK_ACTION_COPY|GDK_ACTION_MOVE); 537 675 538 676 #if 0
Note:
See TracChangeset
for help on using the changeset viewer.