Changeset 127 for trunk/gui/class_c/nomfolderwindow.c
- Timestamp:
- Nov 29, 2006, 9:17:22 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/class_c/nomfolderwindow.c
r126 r127 56 56 CORBA_Environment *ev) 57 57 { 58 /* NOMFolderWindowData* nomThis=NOMFolderWindowGetData(nomSelf); */ 59 60 } 61 58 NOMFolderWindowData* nomThis=NOMFolderWindowGetData(nomSelf); 59 60 _pgContainerHandle=pgWidget; 61 } 62 63 64 static void 65 itemActivated (GtkIconView *icon_view, 66 GtkTreePath *tree_path, 67 gpointer user_data) 68 { 69 DosBeep(1500, 100); 70 } 71 72 /* 73 Check if the right button click was within a certain time. That means 74 the user released the button again within a short time period. On OS/2 75 a context menu will display after the user released the button not when 76 the user pressed it. 77 */ 78 #define CTXT_MENU_BUTTON_DELAY 250 79 static gboolean 80 fldr_checkContextButton(GdkEventButton *event) 81 { 82 static guint guiTime=0; 83 84 /* Right mouse button */ 85 if (event->button != 3) 86 return FALSE; 87 88 /* Ignore double-clicks and triple-clicks */ 89 if(event->type == GDK_BUTTON_PRESS) 90 guiTime=event->time; 91 92 if(event->type == GDK_BUTTON_RELEASE) 93 { 94 if(event->time-guiTime<CTXT_MENU_BUTTON_DELAY) 95 return TRUE; 96 } 97 98 return FALSE; 99 } 100 101 static gboolean 102 fldr_handleButtonEvent (GtkWidget *widget, GdkEventButton *event, gpointer user_data) 103 { 104 if(fldr_checkContextButton(event)) 105 { 106 DosBeep(5000, 100); 107 #if 0 108 /* This is the folder object not the object on which a click occured */ 109 WPObject *wpObject=(WPObject*)user_data; 110 if(nomIsObj(wpObject)){ 111 nomPrintf("%s: %x->%s\n", __FUNCTION__, wpObject, wpObject->mtab->nomClassName); 112 } 113 114 if(!somIsObj(wpObject)) 115 return TRUE; 116 117 /* ptlPopupPt is NULLHANDLE because GTK automatically pick a useful position for the popup 118 menu. */ 119 _wpDisplayMenu(wpObject, NULLHANDLE, (HWND) widget, NULLHANDLE, 0, (ULONG) 0); 120 return TRUE; 121 #endif 122 } 123 124 return FALSE; 125 } 126 127 NOM_Scope void NOMLINK impl_NOMFolderWindow_nomInit(NOMFolderWindow* nomSelf, CORBA_Environment *ev) 128 { 129 GtkWidget* window; 130 GtkWidget *vbox; 131 GtkWidget *sw; 132 GtkWidget *icon_view; 133 GtkWidget *tool_bar; 134 GtkToolItem *up_button; 135 136 NOMFolderWindowData* nomThis=NOMFolderWindowGetData(nomSelf); 137 138 /* Let parents initialize */ 139 NOMFolderWindow_nomInit_parent((NOMObject*) nomSelf, ev); 140 141 /* Create a default (hidden) folder window */ 142 143 /* Folder toplevel window. */ 144 window = gtk_window_new (GTK_WINDOW_TOPLEVEL); 145 /* Set title */ 146 // gtk_window_set_title (GTK_WINDOW (window), ""); 147 148 /* FIXME: Set default size of folder frame. Will later use a stored value */ 149 gtk_window_set_default_size (GTK_WINDOW (window), 650, 400); 150 151 vbox = gtk_vbox_new (FALSE, 0); 152 gtk_container_add (GTK_CONTAINER (window), vbox); 153 154 /* Create and pack the toolbar */ 155 tool_bar = gtk_toolbar_new (); 156 gtk_box_pack_start (GTK_BOX (vbox), tool_bar, FALSE, FALSE, 0); /* Don't expand the toolbar vertically if sized */ 157 158 /* Parent button */ 159 up_button = gtk_tool_button_new_from_stock (GTK_STOCK_GO_UP); 160 gtk_tool_item_set_is_important (up_button, TRUE); 161 /* Disable button */ 162 gtk_widget_set_sensitive (GTK_WIDGET (up_button), FALSE); 163 /* Put it into the toolbar */ 164 gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), up_button, -1); 165 166 sw = gtk_scrolled_window_new (NULL, NULL); 167 /* Drawing style */ 168 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), 169 GTK_SHADOW_ETCHED_IN); 170 /* Show scrollbars only if necessary */ 171 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), 172 GTK_POLICY_AUTOMATIC, 173 GTK_POLICY_AUTOMATIC); 174 /* Pack it into the vbox with size adjusting to the vbox */ 175 gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0); 176 /* Create an icon view without model */ 177 icon_view = gtk_icon_view_new (); 178 _pgContainerHandle=icon_view; 179 180 /* Allow multiple selection in icon view */ 181 gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_view), 182 GTK_SELECTION_MULTIPLE); 183 /* Connect to the "item_activated" signal */ 184 g_signal_connect (icon_view, "item-activated", 185 G_CALLBACK (itemActivated), nomSelf); 186 /* This is for kb binding only */ 187 #if 0 188 g_signal_connect (GTK_WIDGET(icon_view), "popup-menu", 189 G_CALLBACK (fldr_cbPopupMenu), nomSelf); 190 #endif 191 /* Handle mouse buttons */ 192 g_signal_connect (GTK_WIDGET(icon_view), "button-press-event", 193 G_CALLBACK (fldr_handleButtonEvent), nomSelf); 194 g_signal_connect (GTK_WIDGET(icon_view), "button-release-event", 195 G_CALLBACK (fldr_handleButtonEvent), nomSelf); 196 197 #if 0 198 /* Connect to the "clicked" signal of the "Up" tool button */ 199 g_signal_connect (up_button, "clicked", 200 G_CALLBACK (up_clicked), store); 201 #endif 202 /* Add icon view as child to the scroll window created earlier */ 203 gtk_container_add (GTK_CONTAINER (sw), icon_view); 204 205 gtk_widget_grab_focus (icon_view); 206 NOMFolderWindow_setWindowHandle(nomSelf, window, NULLHANDLE); 207 /* Window is hidden here and must be shown by the caller */ 208 } 209
Note:
See TracChangeset
for help on using the changeset viewer.