Ignore:
Timestamp:
Nov 29, 2006, 9:17:22 PM (19 years ago)
Author:
cinc
Message:

Added methods and code to NOMWindow and NOMFolderWindow classes. WPFolder uses a NOMFolderWindow for holding the icons.

File:
1 edited

Legend:

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

    r122 r127  
    6363#include "desktoptypes.h"
    6464
     65/* Gui stuff */
     66#include "nomguitk.h"
     67#include "nomfolderwindow.h"
     68
    6569/* Enum for the folder store */
    6670enum
     
    8589  return store;
    8690}
    87 
    88 static void
    89 itemActivated (GtkIconView *icon_view,
    90                 GtkTreePath *tree_path,
    91                 gpointer     user_data)
    92 {
    93   DosBeep(1500, 100);
    94 }
    95 
    96 /*
    97   Check if the right button click was within a certain time. That means
    98   the user released the button again within a short time period. On OS/2
    99   a context menu will display after the user released the button not when
    100   the user pressed it.
    101  */
    102 #define CTXT_MENU_BUTTON_DELAY 250
    103 static gboolean
    104 fldr_checkContextButton(GdkEventButton *event)
    105 {
    106   static guint guiTime=0;
    107 
    108   /* Right mouse button */
    109   if (event->button != 3)
    110     return FALSE;
    111 
    112   /* Ignore double-clicks and triple-clicks */
    113   if(event->type == GDK_BUTTON_PRESS)
    114     guiTime=event->time;
    115 
    116   if(event->type == GDK_BUTTON_RELEASE)
    117     {
    118       if(event->time-guiTime<CTXT_MENU_BUTTON_DELAY)
    119         return TRUE;
    120     }
    121 
    122   return FALSE;
    123 }
    124 
    125 static gboolean
    126 fldr_handleButtonEvent (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
    127 {
    128   if(fldr_checkContextButton(event))
    129     {
    130       DosBeep(5000, 100);
    131       /* This is the folder object not the object on which a click occured */
    132       WPObject *wpObject=(WPObject*)user_data;
    133       if(nomIsObj(wpObject)){
    134         nomPrintf("%s: %x->%s\n", __FUNCTION__, wpObject, wpObject->mtab->nomClassName);       
    135       }
    136 #if 0     
    137       if(!somIsObj(wpObject))
    138         return TRUE;
    139 
    140       /* ptlPopupPt is NULLHANDLE because GTK automatically pick a useful position for the popup
    141          menu. */
    142       _wpDisplayMenu(wpObject, NULLHANDLE, (HWND) widget, NULLHANDLE, 0, (ULONG) 0);
    143       return TRUE;
    144 #endif
    145     }
    146 
    147   return FALSE;
    148 }
    149 
    15091
    15192static BOOL
     
    230171
    231172/* pszPath contains the fully qualified path (checked with WPS) */
    232 NOM_Scope CORBA_boolean NOMLINK impl_WPFolder_wpPopulate(WPFolder* nomSelf, const CORBA_unsigned_long ulReserved, const CORBA_char * pszPath, const CORBA_boolean fFoldersOnly, CORBA_Environment *ev)
     173NOM_Scope CORBA_boolean NOMLINK impl_WPFolder_wpPopulate(WPFolder* nomSelf, const CORBA_unsigned_long ulReserved,
     174                                                         const CORBA_char * pszPath, const CORBA_boolean fFoldersOnly,
     175                                                         CORBA_Environment *ev)
    233176{
    234177 WPFolderData* nomThis=WPFolderGetData(nomSelf);
     
    369312
    370313/*
    371   This method creates the folder window it doesn't queries any files or creates
     314  This method creates the folder window it doesn't query any files or creates
    372315  models and stuff.
    373316*/
    374317NOM_Scope gpointer NOMLINK impl_WPFolder_wpCreateFolderWindow(WPFolder* nomSelf, CORBA_Environment *ev)
    375318{
    376 /* WPFolderData* nomThis=WPFolderGetData(nomSelf); */
    377   GtkWidget* window;
    378   GtkWidget *vbox;
    379   GtkWidget *sw;
    380   GtkWidget *icon_view;
    381   GtkWidget *tool_bar;
    382   GtkToolItem *up_button;
     319  NOMFolderWindow * nomFldrWindow;
    383320  PPRIVFOLDERDATA priv;
    384 
    385321  WPFolderData *nomThis = WPFolderGetData(nomSelf);
    386322
    387   /* Folder toplevel window. */
    388   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    389   /* Set title */
    390   //  gtk_window_set_title (GTK_WINDOW (window), gcPath);
    391   gtk_window_set_title (GTK_WINDOW (window), "");
    392   /* FIXME: Set default size of folder frame. Will later use a stored value */
    393   gtk_window_set_default_size (GTK_WINDOW (window), 650, 400);
    394 
    395   vbox = gtk_vbox_new (FALSE, 0);
    396   gtk_container_add (GTK_CONTAINER (window), vbox);
    397 
    398   /* Create and pack the toolbar */
    399   tool_bar = gtk_toolbar_new ();
    400   gtk_box_pack_start (GTK_BOX (vbox), tool_bar, FALSE, FALSE, 0); /* Don't expand the toolbar vertically if sized */
    401  
    402   /* Parent button */
    403   up_button = gtk_tool_button_new_from_stock (GTK_STOCK_GO_UP);
    404   gtk_tool_item_set_is_important (up_button, TRUE);
    405   /* Disable button */
    406   gtk_widget_set_sensitive (GTK_WIDGET (up_button), FALSE);
    407   /* Put it into the toolbar */
    408   gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), up_button, -1);
    409  
    410   sw = gtk_scrolled_window_new (NULL, NULL);
    411   /* Drawing style */
    412   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
    413                                        GTK_SHADOW_ETCHED_IN);
    414   /* Show scrollbars only if necessary */
    415   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
    416                                   GTK_POLICY_AUTOMATIC,
    417                                   GTK_POLICY_AUTOMATIC);
    418   /* Pack it into the vbox with size adjusting to the vbox */
    419   gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
    420   /* Create an icon view without model */
    421   icon_view = gtk_icon_view_new ();
    422   /* Allow multiple selection in icon view */
    423   gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_view),
    424                                     GTK_SELECTION_MULTIPLE);
    425   /* Connect to the "item_activated" signal */
    426   g_signal_connect (icon_view, "item-activated",
    427                     G_CALLBACK (itemActivated), nomSelf);
    428   /* This is for kb binding only */
    429 #if 0
    430   g_signal_connect (GTK_WIDGET(icon_view), "popup-menu",
    431                     G_CALLBACK (fldr_cbPopupMenu), nomSelf);
    432 #endif
    433   /* Handle mouse buttons */
    434   g_signal_connect (GTK_WIDGET(icon_view), "button-press-event",
    435                     G_CALLBACK (fldr_handleButtonEvent), nomSelf);
    436   g_signal_connect (GTK_WIDGET(icon_view), "button-release-event",
    437                     G_CALLBACK (fldr_handleButtonEvent), nomSelf);
    438 
    439 #if 0
    440   /* Connect to the "clicked" signal of the "Up" tool button */
    441   g_signal_connect (up_button, "clicked",
    442                     G_CALLBACK (up_clicked), store);
    443 #endif
    444   /* Add icon view as child to the scroll window created earlier */
    445   gtk_container_add (GTK_CONTAINER (sw), icon_view);
    446323  priv=(PPRIVFOLDERDATA)_privFolderData;
    447   priv->gtkIconView=icon_view;
    448 
    449   gtk_widget_grab_focus (icon_view);
    450 
    451   gtk_widget_show_all (window);
    452  
    453   return window;
    454 }
    455 
    456 
    457 
    458 
    459 
     324
     325  nomFldrWindow=NOMFolderWindowNew();
     326
     327#warning !!!!! This is only for testing !!!!!
     328  priv->gtkIconView=NOMFolderWindow_getContainerHandle(nomFldrWindow, ev);
     329
     330  NOMFolderWindow_show(nomFldrWindow, ev);
     331
     332  return NOMFolderWindow_getWindowHandle(nomFldrWindow, ev);;
     333}
     334
     335
     336
     337
     338
Note: See TracChangeset for help on using the changeset viewer.