Changeset 237 for trunk/desktop


Ignore:
Timestamp:
Feb 11, 2007, 4:52:34 PM (19 years ago)
Author:
cinc
Message:

Started drag and drop implementation. Some dox additions.

Location:
trunk/desktop
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/desktop/class_c/wpfolder.c

    r224 r237  
    1616* The Initial Developer of the Original Code is
    1717* netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
    18 * Portions created by the Initial Developer are Copyright (C) 2005-2006
     18* Portions created by the Initial Developer are Copyright (C) 2005-2007
    1919* the Initial Developer. All Rights Reserved.
    2020*
     
    341341           
    342342            wpFldrWindow=WPFolder_wpCreateFolderWindow(nomSelf, NULLHANDLE);
    343             WPFolderWindow_wpSetWPObject(wpFldrWindow, (WPObject*)nomSelf, NULLHANDLE);
    344343           
    345344            /* Insert it into inuse list */
     
    470469}
    471470
    472 /*
     471enum{
     472  WPOBJECT_TARGET_PATH,
     473  WPOBJECT_TARGET_OBJECT,
     474  WPOBJECT_TARGET_STRING
     475};
     476
     477static GtkTargetEntry targetEntries[]=
     478{
     479  {"WPObject-path", 0, WPOBJECT_TARGET_PATH},
     480  {"WPObject", 0, WPOBJECT_TARGET_OBJECT},
     481  {"STRING", 0, WPOBJECT_TARGET_STRING},
     482};
     483
     484static void fldrDragDataReceived(GtkWidget * widget, GdkDragContext* dragContext, int x, int y, GtkSelectionData *seldata,
     485                          guint info, guint uiTime, gpointer ptrUserData)
     486{
     487  DosBeep(5000, 100);
     488  g_message("%s", __FUNCTION__);
     489  return;
     490}
     491
     492
     493
     494
     495static void fldrDragDataGet(GtkWidget * widget, GdkDragContext* dragContext, GtkSelectionData *seldata,
     496                    guint uiInfo, guint t, gpointer ptrUserData)
     497{
     498  DosBeep(100, 100);
     499  g_message("%s", __FUNCTION__);
     500  //  gtk_selection_data_set();
     501  return;
     502}
     503
     504
     505#if 0
     506/**
     507   Get the WPFolder object from a container widget (icon view). If the object can't be queried
     508   NULL is returned.
     509   Note that this function checks if the pointer points to a NOMObject so a call to
     510   nomIsObj() is not necessary.
     511 */
     512static PWPFolder fldrQueryWPFolderFromContainer(GtkWidget * wgtThis)
     513{
     514  GtkWidget* wgtToplevel;
     515  PWPFolder wpFolder;
     516
     517  if((wgtToplevel=gtk_widget_get_toplevel(wgtThis))==NULLHANDLE)
     518    return NULLHANDLE;
     519
     520  if(!GTK_WIDGET_TOPLEVEL(wgtToplevel))
     521    return NULLHANDLE;
     522
     523  wpFolder=(PWPFolder) g_object_get_data(G_OBJECT(wgtToplevel), NOMOBJECT_KEY_STRING);
     524  if(nomIsObj(wpFolder))
     525    return wpFolder;
     526
     527  return NULLHANDLE;
     528}
     529#endif
     530
     531
     532/**
    473533  This method creates the folder window it doesn't query any files or creates
    474534  models and stuff.
     
    479539  PPRIVFOLDERDATA priv;
    480540  WPFolderData *nomThis = WPFolderGetData(nomSelf);
    481 
     541 
    482542  priv=(PPRIVFOLDERDATA)_privFolderData;
    483543
    484544  wpFldrWindow=WPFolderWindowNew();
     545
     546  /* Save a pointer to the desktop folder object */
     547  WPFolderWindow_wpSetWPObject(wpFldrWindow, (WPObject*)nomSelf, NULLHANDLE);
    485548
    486549  /* Connect to the "item_activated" signal */
     
    489552
    490553  WPFolderWindow_wpSetWindowTitle(wpFldrWindow, WPFolder_wpQueryTitle(nomSelf, NULLHANDLE), NULLHANDLE);
     554
     555  /* Prepare drag and drop */
     556  gtk_drag_source_set(WPFolderWindow_wpQueryContainerHandle(wpFldrWindow, NULLHANDLE), GDK_BUTTON3_MASK, targetEntries,
     557                      G_N_ELEMENTS(targetEntries) ,
     558                      GDK_ACTION_LINK|GDK_ACTION_COPY|GDK_ACTION_MOVE);
     559  gtk_drag_dest_set(WPFolderWindow_wpQueryContainerHandle(wpFldrWindow, NULLHANDLE), GTK_DEST_DEFAULT_ALL, targetEntries, 1 ,
     560                      GDK_ACTION_LINK|GDK_ACTION_COPY|GDK_ACTION_MOVE);
     561  g_signal_connect(WPFolderWindow_wpQueryContainerHandle(wpFldrWindow, NULLHANDLE),"drag_data_received",
     562                   G_CALLBACK(fldrDragDataReceived), NULL);
     563  g_signal_connect(WPFolderWindow_wpQueryContainerHandle(wpFldrWindow, NULLHANDLE),"drag_data_get",
     564                   G_CALLBACK(fldrDragDataGet), NULL);
    491565
    492566  /* Show the new window */
     
    572646
    573647
    574 
    575 
     648/* orbit-idl-c-stubs.c, cs_output_stub line 347 */
     649NOM_Scope gulong NOMLINK impl_WPFolder_wpDragOver(WPFolder* nomSelf, const gpointer containerHandle,
     650                                                  const gpointer pDragInfo, CORBA_Environment *ev)
     651{
     652/* WPFolderData* nomThis=WPFolderGetData(nomSelf); */
     653
     654  return GDK_ACTION_COPY;
     655 
     656#if 0
     657  /* orbit-idl-c-stubs.c, VoyagerWriteProtoForParentCall line 119 */
     658  WPFolder_wpDragOver_parent(nomSelf,  ev);
     659#endif
     660}
     661
     662
  • trunk/desktop/class_c/wpfolderwindow.c

    r224 r237  
    166166}
    167167
     168static gboolean fldrWindowHandleDragDrop(GtkWidget * widget, GdkDragContext* dragContext, gint x, gint y,
     169                         guint t, gpointer ptrUserData)
     170{
     171  DosBeep(2500, 10);
     172  DosBeep(500, 10);
     173  DosBeep(2500, 10);
     174  g_message("%s", __FUNCTION__);
     175  return FALSE;
     176}
     177
     178#if 0
     179static void fldrDragLeave(GtkWidget * widget, GdkDragContext* dragContext,
     180                          guint t, gpointer ptrUserData)
     181{
     182  GdkPixmap *pixMapDrag;
     183 
     184  gdk_pixbuf_render_pixmap_and_mask(pixBufStop, &pixMapDrag, NULL, 128);
     185  gdk_window_set_back_pixmap(wgtDrag->window, pixMapDrag, FALSE);
     186  g_object_unref(pixMapDrag);
     187  gtk_widget_queue_draw(wgtDrag);
     188
     189  g_message("%s", __FUNCTION__);
     190
     191  return;
     192}
     193#endif
     194
     195static GtkWidget *wgtDrag=NULL;
     196
     197static GdkPixmap *pixMapDrag=NULL;
     198static GdkPixmap *pixMapStop=NULL;
     199
     200/*
     201  Callback which loads a pixmap into the drag widget as soon as it#s realized.
     202 */
     203static void fldrWidgetRealize(GtkWidget * wgtDrag, gpointer ptrUserData)
     204{
     205  gdk_window_set_back_pixmap(wgtDrag->window, pixMapDrag, FALSE);
     206
     207  g_message("%s", __FUNCTION__);
     208  return;
     209}
     210
     211static void fldrWindowHandleDragBegin(GtkWidget * widget, GdkDragContext* dragContext,
     212                    gpointer ptrUserData)
     213{
     214  if(NULLHANDLE==wgtDrag)
     215    {
     216      GdkPixbuf *pixBufDrag;
     217      GdkPixbuf *pixBufStop;
     218
     219      wgtDrag=gtk_window_new(GTK_WINDOW_POPUP);
     220
     221      /*
     222        FIXME:
     223        In GTK 2.8 use *_HINT_DND instead.
     224       */
     225#warning move this somewhere else. Maybe into WPClassMgr
     226      gtk_window_set_type_hint(GTK_WINDOW(wgtDrag), GDK_WINDOW_TYPE_HINT_MENU);
     227      gtk_widget_set_app_paintable(GTK_WIDGET(wgtDrag), TRUE);
     228
     229      pixBufDrag=gtk_widget_render_icon(wgtDrag, GTK_STOCK_DND, GTK_ICON_SIZE_DND, NULL);
     230      gdk_pixbuf_render_pixmap_and_mask(pixBufDrag, &pixMapDrag, NULL, 128);
     231
     232      gtk_widget_set_size_request(wgtDrag, gdk_pixbuf_get_width(pixBufDrag), gdk_pixbuf_get_height(pixBufDrag));
     233
     234      g_object_unref(pixBufDrag);
     235
     236      pixBufStop=gtk_widget_render_icon(wgtDrag, GTK_STOCK_STOP, GTK_ICON_SIZE_DND, NULL);
     237      gdk_pixbuf_render_pixmap_and_mask(pixBufStop, &pixMapStop, NULL, 128);
     238      g_object_unref(pixBufStop);
     239
     240      if(!pixMapDrag)
     241        g_warning("Cannot load pixbuf");
     242      if(!pixMapStop)
     243        g_warning("Cannot load stop pixbuf");
     244
     245      //      gdk_pixbuf_render_pixmap_and_mask(pixBufDrag, &pixMapDrag, NULL, 128);
     246      //    gdk_window_set_back_pixmap(wgtDrag->window, pixMapDrag, FALSE);
     247      //      g_object_unref(pixMapDrag);
     248      g_signal_connect_after(GTK_WIDGET(wgtDrag), "realize", G_CALLBACK(fldrWidgetRealize), NULL);
     249    }
     250  DosBeep(1000, 10);
     251  g_message("%s", __FUNCTION__);
     252  //  if(wgtDrag->window)
     253  //gdk_window_set_back_pixmap(wgtDrag->window, pixMapDrag, FALSE);
     254
     255  gtk_drag_set_icon_widget(dragContext, wgtDrag, 0, 0);
     256
     257  return;
     258}
     259
     260static gboolean fldrWindowHandleDragMotion(GtkWidget * wgtThis, GdkDragContext* dragContext, int x, int y, guint t,
     261                    gpointer ptrUserData)
     262{
     263  GtkWidget *wgtSource;
     264  GtkTreePath* treePath;
     265  PWPFolderWindow pWindow;
     266  gulong rc=0;
     267  static gulong oldRc=0;
     268
     269  if(dragContext==NULL)
     270    return FALSE;
     271
     272  if((wgtSource=gtk_drag_get_source_widget(dragContext))==NULLHANDLE)
     273    return FALSE;
     274
     275#if 0
     276  if(wgtSource==wgtThis){
     277    gdk_drag_status(dragContext, GDK_ACTION_MOVE, t);
     278    //    gdk_drag_status(dragContext, 0, t);
     279    gtk_drag_highlight(wgtThis);
     280  }
     281  else{
     282    gdk_drag_status(dragContext, GDK_ACTION_COPY, t);
     283    gtk_drag_unhighlight(wgtSource);
     284  }
     285#endif
     286
     287  treePath=gtk_icon_view_get_path_at_pos(GTK_ICON_VIEW(wgtThis), x, y );
     288
     289  if(NULL==treePath)
     290    {     
     291      PWPFolder wpFolder;
     292      /* White space */
     293
     294      pWindow=(WPFolderWindow*)ptrUserData;
     295      if(!nomIsObj(pWindow))
     296        return FALSE;
     297
     298      wpFolder=(WPFolder*)WPFolderWindow_wpQueryWPObject(pWindow, NULLHANDLE);     
     299
     300      if(!nomIsObj(wpFolder))
     301        return FALSE;
     302
     303      rc=WPObject_wpDragOver((WPObject*)wpFolder, wgtThis, dragContext, NULL);
     304    }
     305  else
     306    {
     307      GtkTreeIter iter;
     308      GtkTreeModel* model;
     309      WPObject *wpObject;
     310      /* Over an icon */
     311     
     312      //   g_message("%s: %s", __FUNCTION__, gtk_tree_path_to_string(treePath));
     313      //    gtk_icon_view_item_activated(GTK_ICON_VIEW(wgtThis), treePath);
     314
     315      model=gtk_icon_view_get_model(GTK_ICON_VIEW(wgtThis));
     316           
     317      gtk_tree_model_get_iter(model , &iter, treePath);           
     318      gtk_tree_model_get(model, &iter, 0, &wpObject, -1);
     319
     320      //TST_OBJECT(wpObject);
     321
     322      //if(nomIsObj(wpObject))
     323      rc=WPObject_wpDragOver((WPObject*)wpObject, wgtThis, dragContext, NULL);
     324    }
     325
     326  if(oldRc!=rc)
     327    {
     328      /* drag icon */
     329      switch(rc)
     330        {
     331        case 0:
     332          {
     333            /* Don't drop */   
     334            gdk_window_set_back_pixmap(wgtDrag->window, pixMapStop, FALSE);
     335            break;
     336          }
     337        default:
     338          {
     339            gdk_window_set_back_pixmap(wgtDrag->window, pixMapDrag, FALSE);
     340            break;
     341          }
     342        }
     343      gtk_widget_queue_draw(wgtDrag);
     344    }
     345  oldRc=rc;
     346
     347  return FALSE;
     348}
     349
     350
    168351NOM_Scope void NOMLINK impl_WPFolderWindow_nomInit(WPFolderWindow* nomSelf, CORBA_Environment *ev)
    169352{
     
    255438                    G_CALLBACK (fldr_handleButtonEvent), nomSelf);
    256439
     440  /* Handle folder DnD */
     441  g_signal_connect(GTK_WIDGET(icon_view),"drag-begin",
     442                   G_CALLBACK(fldrWindowHandleDragBegin), nomSelf);
     443  g_signal_connect(GTK_WIDGET(icon_view),"drag-motion",
     444                   G_CALLBACK(fldrWindowHandleDragMotion), nomSelf);
     445  g_signal_connect(GTK_WIDGET(icon_view),"drag-drop",
     446                   G_CALLBACK(fldrWindowHandleDragDrop), nomSelf);
     447
     448
    257449#if 0
    258450  /* Connect to the "clicked" signal of the "Up" tool button */
  • trunk/desktop/class_c/wpobject.c

    r224 r237  
    1616* The Initial Developer of the Original Code is
    1717* netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
    18 * Portions created by the Initial Developer are Copyright (C) 2005-2006
     18* Portions created by the Initial Developer are Copyright (C) 2005-2007
    1919* the Initial Developer. All Rights Reserved.
    2020*
     
    798798
    799799
    800 
    801 
     800NOM_Scope gulong NOMLINK impl_WPObject_wpDragOver(WPObject* nomSelf, const gpointer containerHandle,
     801                                                  const gpointer pDragInfo, CORBA_Environment *ev)
     802{
     803/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
     804
     805  return 0; /* Don't allow drop */
     806}
     807
     808NOM_Scope gulong NOMLINK impl_WPObject_wpDrop(WPObject* nomSelf, const gpointer containerHandle,
     809                                              const gpointer pDragInfo, CORBA_Environment *ev)
     810{
     811/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
     812
     813  DosBeep(500, 100);
     814  return 0;
     815}
     816
     817
  • trunk/desktop/class_c/wpwindow.c

    r206 r237  
    1616* The Initial Developer of the Original Code is
    1717* netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
    18 * Portions created by the Initial Developer are Copyright (C) 2005-2006
     18* Portions created by the Initial Developer are Copyright (C) 2005-2007
    1919* the Initial Developer. All Rights Reserved.
    2020*
     
    5353#include "wpwindow.ih"
    5454
     55/**
     56   This function implements the wpSetWPObject() method of WPWindow. See method description for more
     57   info.
     58
     59   \sa wpQueryWPObject(), wpSetWPObject()
     60 */
    5561NOM_Scope void NOMLINK impl_WPWindow_wpSetWPObject(WPWindow* nomSelf, const PWPObject wpObject, CORBA_Environment *ev)
    5662{
     
    5965}
    6066
     67/**
     68   This function implements the wpQueryWPObject() method of WPWindow. See method description for more
     69   info.
     70
     71   \sa wpQueryWPObject(), wpSetWPObject()
     72 */
    6173NOM_Scope PWPObject NOMLINK impl_WPWindow_wpQueryWPObject(WPWindow* nomSelf, CORBA_Environment *ev)
    6274{
     
    6678}
    6779
     80/**
     81   This function implements the wpSetWindowTitle() method of WPWindow. See method description for more
     82   info.
     83
     84   \sa wpSetWindowTitle()
     85 */
    6886NOM_Scope void NOMLINK impl_WPWindow_wpSetWindowTitle(WPWindow* nomSelf, const PNOMString newTitle,
    6987                                                      CORBA_Environment *ev)
     
    7593}
    7694
     95
  • trunk/desktop/idl/wpfolder.idl

    r203 r237  
    1616* The Initial Developer of the Original Code is
    1717* netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
    18 * Portions created by the Initial Developer are Copyright (C) 2005-2006
     18* Portions created by the Initial Developer are Copyright (C) 2005-2007
    1919* the Initial Developer. All Rights Reserved.
    2020*
     
    7171  NOMOVERRIDE(wpQueryIcon);
    7272  NOMOVERRIDE(wpQueryDefaultView);
     73  NOMOVERRIDE(wpDragOver);
    7374
    7475  NOMINSTANCEVAR(PPRIVFOLDERDATA privFolderData); /* This will go away... */
  • trunk/desktop/idl/wpobject.idl

    r224 r237  
    1616* The Initial Developer of the Original Code is
    1717* netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
    18 * Portions created by the Initial Developer are Copyright (C) 2005-2006
     18* Portions created by the Initial Developer are Copyright (C) 2005-2007
    1919* the Initial Developer. All Rights Reserved.
    2020*
     
    7373     is tracked in the objects inuse list.
    7474
    75      \par How to override
     75     \par How to override:
    7676     This method is usually not overriden.
    7777
     
    8989     will be collected later.
    9090
    91      \par How to override
     91     \par How to override:
    9292     This method is usually not overriden.
    9393
     
    104104     \remark Desktop classes should override this method instead of nomInit().
    105105
    106      \par How to override
     106     \par How to override:
    107107     This method should be overriden by classes which need initialization. The parent
    108108     must be called first.
     
    129129     taken into account. wpViewObject() should be called most of the time.
    130130
    131      \par How to override
     131     \par How to override:
    132132     Desktop objects override this method when they have a private view.
    133133
     
    149149     that the method call itself is not.
    150150
    151      \par How to override
     151     \par How to override:
    152152     This method is usually not overriden.
    153153
     
    163163     that the method call itself is not.
    164164
    165      \par How to override
     165     \par How to override:
    166166     This method is usually not overriden.
    167167
     
    176176     in a multithreaded environment other threads may alter the use counter at any time.
    177177
    178      \par How to override
     178     \par How to override:
    179179     This method is usually not overriden.
    180180
     
    187187
    188188  /**
    189 
     189     Request the object semaphor which protects the objects data structures. For example
     190     before changing the in use list of the object the semaphor is aquired to prevent
     191     access from several places at the same time.
     192
     193     \par How to override
     194     This method is usually not overriden.
     195
     196     \return 0 if no error occured. Any other value describes an error.
     197
     198     \sa wpReleaseObjectMutexSem()
    190199   */
    191200  unsigned long  wpRequestObjectMutexSem(in unsigned long ulReserved);
    192   unsigned long  wpReleaseObjectMutexSem();
     201
     202  /**
     203     Release the object semaphor which protects the objects data structures. For example
     204     before changing the in use list of the object the semaphor is aquired to prevent
     205     access from several places at the same time.
     206
     207     \par How to override:
     208     This method is usually not overriden.
     209
     210     \return 0 if no error occured. Any other value describes an error.
     211
     212     \sa wpRequestObjectMutexSem()
     213   */
     214  unsigned long wpReleaseObjectMutexSem();
    193215
    194216  void wpSetTitle(in PNOMString pnomStrNewTitle);
     
    218240     \remark This method should be use in preference to the wpOpen() method.
    219241
    220      \par How to override
     242     \par How to override:
    221243     This method is usually not overriden.
    222244
     
    235257     Search the objects inuse list for the given view and if found bring it to the front.
    236258
    237      \par How to override
     259     \par How to override:
    238260     This method is usually not overriden.
    239261
     
    253275     memory used by the object, open views and some more.
    254276
    255      \How to override
    256      This method is usually not overriden.
    257 
    258      \param
     277     \par How to override:
     278     This method is usually not overriden.
     279
     280
    259281     \return TRUE if success.
    260282
     
    267289     memory used by the object, open views and some more.
    268290
    269      \remark The use item will not be freed by this method.
    270 
    271      \par How to override
     291     \remark The use item will not be freed by this method. This must be done by the caller.
     292
     293     \par How to override:
    272294     This method is usually not overriden.
    273295
     
    288310  boolean wpSaveImmediate();
    289311
     312  /**
     313     Set the information about the folder this object is living in. This method is called for
     314     example if the object is moved to another location.
     315
     316     \par How to override:
     317     This method is usually not overriden.
     318
     319     \param wpParentFolder The folder this object is living in.
     320     \return Folder object. Note that this is not a folder view (window).
     321
     322     \sa wpQueryFolder()
     323   */
    290324  void wpSetFolder(in PWPFolder wpParentFolder);
    291325
     
    293327     Get the folder this object is living in.
    294328
    295      \return Folder object. Note that this is not a folder view (window)
     329     \par How to override:
     330     This method is usually not overriden.
     331
     332     \return Folder object. Note that this is not a folder view (window).
    296333
    297334     \sa wpSetFolder()
     
    307344  gulong wpQueryConcurrentView();
    308345
     346  gulong wpDragOver(in gpointer containerHandle, in gpointer pDragInfo);
     347
     348  gulong wpDrop(in gpointer containerHandle, in gpointer pDragInfo);
    309349  /* Methods overriden by this class */
    310350
  • trunk/desktop/idl/wpwindow.idl

    r191 r237  
    6161  NOMCLASSVERSION(1, 0);
    6262
     63  /**
     64     Instances of the WPWindow class (or subclasses of WPWindow) are usually created
     65     by desktop classes. For example WPFolderWindow instances (folder views) or
     66     WPNoteBook instances (settings notebooks). This method is used so the desktop class
     67     can save a pointer to itself for use from within the WPWindow class code.
     68 
     69     \remark Note that this method is \b not a wrapper around
     70     \code
     71     g_object_set_data(G_OBJECT(window), NOMOBJECT_KEY_STRING, nomSelf);
     72     \endcode
     73     That call is used internally by the WPWindow class to connect a WPWindow instance
     74     (nomSelf in this call) with a GTK window.
     75
     76     \par How to override:
     77     This method is usually not overriden.
     78
     79     \param wpObject The desktop object this window belongs to.
     80
     81     \par Example:
     82     The follwing code is a method implementation of class WPFolder. It creates a new
     83     folder window (of class WPFolderWindow) and uses wpSetWPObject() to connect the folder
     84     object (nomSelf) with the folder window.
     85     \include wpsetwpobject.c
     86
     87     \sa wpQueryWPObject()
     88   */
    6389  void wpSetWPObject(in PWPObject wpObject);
     90
     91  /**
     92     Query the desktop object this window belongs to.
     93
     94     \remark Note that this method is \b not a wrapper around
     95     \code
     96     g_object_get_data(G_OBJECT(window), NOMOBJECT_KEY_STRING);
     97     \endcode
     98     Using that call one queries the window object (\b not the desktop object) from
     99     a GTK toplevel window.
     100
     101     \par How to override:
     102     This method is usually not overriden.
     103
     104     \sa wpSetWPObject()
     105  */
    64106  PWPObject wpQueryWPObject();
    65107  void wpSetWindowTitle(in PNOMString newTitle);
Note: See TracChangeset for help on using the changeset viewer.