1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.FileChooserWidget; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gtk.Box; 32 private import gtk.FileChooserIF; 33 private import gtk.FileChooserT; 34 private import gtk.Widget; 35 public import gtkc.gdktypes; 36 private import gtkc.gtk; 37 public import gtkc.gtktypes; 38 39 40 /** 41 * #GtkFileChooserWidget is a widget for choosing files. 42 * It exposes the #GtkFileChooser interface, and you should 43 * use the methods of this interface to interact with the 44 * widget. 45 */ 46 public class FileChooserWidget : Box, FileChooserIF 47 { 48 /** the main Gtk struct */ 49 protected GtkFileChooserWidget* gtkFileChooserWidget; 50 51 /** Get the main Gtk struct */ 52 public GtkFileChooserWidget* getFileChooserWidgetStruct() 53 { 54 return gtkFileChooserWidget; 55 } 56 57 /** the main Gtk struct as a void* */ 58 protected override void* getStruct() 59 { 60 return cast(void*)gtkFileChooserWidget; 61 } 62 63 protected override void setStruct(GObject* obj) 64 { 65 gtkFileChooserWidget = cast(GtkFileChooserWidget*)obj; 66 super.setStruct(obj); 67 } 68 69 /** 70 * Sets our main struct and passes it to the parent class. 71 */ 72 public this (GtkFileChooserWidget* gtkFileChooserWidget, bool ownedRef = false) 73 { 74 this.gtkFileChooserWidget = gtkFileChooserWidget; 75 super(cast(GtkBox*)gtkFileChooserWidget, ownedRef); 76 } 77 78 // add the FileChooser capabilities 79 mixin FileChooserT!(GtkFileChooserWidget); 80 81 82 /** */ 83 public static GType getType() 84 { 85 return gtk_file_chooser_widget_get_type(); 86 } 87 88 /** 89 * Creates a new #GtkFileChooserWidget. This is a file chooser widget that can 90 * be embedded in custom windows, and it is the same widget that is used by 91 * #GtkFileChooserDialog. 92 * 93 * Params: 94 * action = Open or save mode for the widget 95 * 96 * Return: a new #GtkFileChooserWidget 97 * 98 * Since: 2.4 99 * 100 * Throws: ConstructionException GTK+ fails to create the object. 101 */ 102 public this(GtkFileChooserAction action) 103 { 104 auto p = gtk_file_chooser_widget_new(action); 105 106 if(p is null) 107 { 108 throw new ConstructionException("null returned by new"); 109 } 110 111 this(cast(GtkFileChooserWidget*) p); 112 } 113 114 int[string] connectedSignals; 115 116 void delegate(FileChooserWidget)[] onDesktopFolderListeners; 117 /** 118 * The ::desktop-folder signal is a [keybinding signal][GtkBindingSignal] 119 * which gets emitted when the user asks for it. 120 * 121 * This is used to make the file chooser show the user's Desktop 122 * folder in the file list. 123 * 124 * The default binding for this signal is `Alt + D`. 125 */ 126 void addOnDesktopFolder(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 127 { 128 if ( "desktop-folder" !in connectedSignals ) 129 { 130 Signals.connectData( 131 this, 132 "desktop-folder", 133 cast(GCallback)&callBackDesktopFolder, 134 cast(void*)this, 135 null, 136 connectFlags); 137 connectedSignals["desktop-folder"] = 1; 138 } 139 onDesktopFolderListeners ~= dlg; 140 } 141 extern(C) static void callBackDesktopFolder(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 142 { 143 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onDesktopFolderListeners ) 144 { 145 dlg(_filechooserwidget); 146 } 147 } 148 149 void delegate(FileChooserWidget)[] onDownFolderListeners; 150 /** 151 * The ::down-folder signal is a [keybinding signal][GtkBindingSignal] 152 * which gets emitted when the user asks for it. 153 * 154 * This is used to make the file chooser go to a child of the current folder 155 * in the file hierarchy. The subfolder that will be used is displayed in the 156 * path bar widget of the file chooser. For example, if the path bar is showing 157 * "/foo/bar/baz", with bar currently displayed, then this will cause the file 158 * chooser to switch to the "baz" subfolder. 159 * 160 * The default binding for this signal is `Alt + Down`. 161 */ 162 void addOnDownFolder(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 163 { 164 if ( "down-folder" !in connectedSignals ) 165 { 166 Signals.connectData( 167 this, 168 "down-folder", 169 cast(GCallback)&callBackDownFolder, 170 cast(void*)this, 171 null, 172 connectFlags); 173 connectedSignals["down-folder"] = 1; 174 } 175 onDownFolderListeners ~= dlg; 176 } 177 extern(C) static void callBackDownFolder(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 178 { 179 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onDownFolderListeners ) 180 { 181 dlg(_filechooserwidget); 182 } 183 } 184 185 void delegate(FileChooserWidget)[] onHomeFolderListeners; 186 /** 187 * The ::home-folder signal is a [keybinding signal][GtkBindingSignal] 188 * which gets emitted when the user asks for it. 189 * 190 * This is used to make the file chooser show the user's home 191 * folder in the file list. 192 * 193 * The default binding for this signal is `Alt + Home`. 194 */ 195 void addOnHomeFolder(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 196 { 197 if ( "home-folder" !in connectedSignals ) 198 { 199 Signals.connectData( 200 this, 201 "home-folder", 202 cast(GCallback)&callBackHomeFolder, 203 cast(void*)this, 204 null, 205 connectFlags); 206 connectedSignals["home-folder"] = 1; 207 } 208 onHomeFolderListeners ~= dlg; 209 } 210 extern(C) static void callBackHomeFolder(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 211 { 212 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onHomeFolderListeners ) 213 { 214 dlg(_filechooserwidget); 215 } 216 } 217 218 void delegate(string, FileChooserWidget)[] onLocationPopupListeners; 219 /** 220 * The ::location-popup signal is a [keybinding signal][GtkBindingSignal] 221 * which gets emitted when the user asks for it. 222 * 223 * This is used to make the file chooser show a "Location" prompt which 224 * the user can use to manually type the name of the file he wishes to select. 225 * 226 * The default bindings for this signal are `Control + L` with a @path string 227 * of "" (the empty string). It is also bound to `/` with a @path string of 228 * "`/`" (a slash): this lets you type `/` and immediately type a path name. 229 * On Unix systems, this is bound to `~` (tilde) with a @path string of "~" 230 * itself for access to home directories. 231 * 232 * Params: 233 * path = a string that gets put in the text entry for the file name 234 */ 235 void addOnLocationPopup(void delegate(string, FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 236 { 237 if ( "location-popup" !in connectedSignals ) 238 { 239 Signals.connectData( 240 this, 241 "location-popup", 242 cast(GCallback)&callBackLocationPopup, 243 cast(void*)this, 244 null, 245 connectFlags); 246 connectedSignals["location-popup"] = 1; 247 } 248 onLocationPopupListeners ~= dlg; 249 } 250 extern(C) static void callBackLocationPopup(GtkFileChooserWidget* filechooserwidgetStruct, char* path, FileChooserWidget _filechooserwidget) 251 { 252 foreach ( void delegate(string, FileChooserWidget) dlg; _filechooserwidget.onLocationPopupListeners ) 253 { 254 dlg(Str.toString(path), _filechooserwidget); 255 } 256 } 257 258 void delegate(FileChooserWidget)[] onLocationPopupOnPasteListeners; 259 /** 260 * The ::location-popup-on-paste signal is a [keybinding signal][GtkBindingSignal] 261 * which gets emitted when the user asks for it. 262 * 263 * This is used to make the file chooser show a "Location" prompt when the user 264 * pastes into a #GtkFileChooserWidget. 265 * 266 * The default binding for this signal is `Control + V`. 267 */ 268 void addOnLocationPopupOnPaste(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 269 { 270 if ( "location-popup-on-paste" !in connectedSignals ) 271 { 272 Signals.connectData( 273 this, 274 "location-popup-on-paste", 275 cast(GCallback)&callBackLocationPopupOnPaste, 276 cast(void*)this, 277 null, 278 connectFlags); 279 connectedSignals["location-popup-on-paste"] = 1; 280 } 281 onLocationPopupOnPasteListeners ~= dlg; 282 } 283 extern(C) static void callBackLocationPopupOnPaste(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 284 { 285 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onLocationPopupOnPasteListeners ) 286 { 287 dlg(_filechooserwidget); 288 } 289 } 290 291 void delegate(FileChooserWidget)[] onLocationTogglePopupListeners; 292 /** 293 * The ::location-toggle-popup signal is a [keybinding signal][GtkBindingSignal] 294 * which gets emitted when the user asks for it. 295 * 296 * This is used to toggle the visibility of a "Location" prompt which the user 297 * can use to manually type the name of the file he wishes to select. 298 * 299 * The default binding for this signal is `Control + L`. 300 */ 301 void addOnLocationTogglePopup(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 302 { 303 if ( "location-toggle-popup" !in connectedSignals ) 304 { 305 Signals.connectData( 306 this, 307 "location-toggle-popup", 308 cast(GCallback)&callBackLocationTogglePopup, 309 cast(void*)this, 310 null, 311 connectFlags); 312 connectedSignals["location-toggle-popup"] = 1; 313 } 314 onLocationTogglePopupListeners ~= dlg; 315 } 316 extern(C) static void callBackLocationTogglePopup(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 317 { 318 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onLocationTogglePopupListeners ) 319 { 320 dlg(_filechooserwidget); 321 } 322 } 323 324 void delegate(FileChooserWidget)[] onPlacesShortcutListeners; 325 /** 326 * The ::places-shortcut signal is a [keybinding signal][GtkBindingSignal] 327 * which gets emitted when the user asks for it. 328 * 329 * This is used to move the focus to the places sidebar. 330 * 331 * The default binding for this signal is `Alt + P`. 332 */ 333 void addOnPlacesShortcut(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 334 { 335 if ( "places-shortcut" !in connectedSignals ) 336 { 337 Signals.connectData( 338 this, 339 "places-shortcut", 340 cast(GCallback)&callBackPlacesShortcut, 341 cast(void*)this, 342 null, 343 connectFlags); 344 connectedSignals["places-shortcut"] = 1; 345 } 346 onPlacesShortcutListeners ~= dlg; 347 } 348 extern(C) static void callBackPlacesShortcut(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 349 { 350 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onPlacesShortcutListeners ) 351 { 352 dlg(_filechooserwidget); 353 } 354 } 355 356 void delegate(int, FileChooserWidget)[] onQuickBookmarkListeners; 357 /** 358 * The ::quick-bookmark signal is a [keybinding signal][GtkBindingSignal] 359 * which gets emitted when the user asks for it. 360 * 361 * This is used to make the file chooser switch to the bookmark specified 362 * in the @bookmark_index parameter. For example, if you have three bookmarks, 363 * you can pass 0, 1, 2 to this signal to switch to each of them, respectively. 364 * 365 * The default binding for this signal is `Alt + 1`, `Alt + 2`, 366 * etc. until `Alt + 0`. Note that in the default binding, that 367 * `Alt + 1` is actually defined to switch to the bookmark at index 368 * 0, and so on successively; `Alt + 0` is defined to switch to the 369 * bookmark at index 10. 370 * 371 * Params: 372 * bookmarkIndex = the number of the bookmark to switch to 373 */ 374 void addOnQuickBookmark(void delegate(int, FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 375 { 376 if ( "quick-bookmark" !in connectedSignals ) 377 { 378 Signals.connectData( 379 this, 380 "quick-bookmark", 381 cast(GCallback)&callBackQuickBookmark, 382 cast(void*)this, 383 null, 384 connectFlags); 385 connectedSignals["quick-bookmark"] = 1; 386 } 387 onQuickBookmarkListeners ~= dlg; 388 } 389 extern(C) static void callBackQuickBookmark(GtkFileChooserWidget* filechooserwidgetStruct, int bookmarkIndex, FileChooserWidget _filechooserwidget) 390 { 391 foreach ( void delegate(int, FileChooserWidget) dlg; _filechooserwidget.onQuickBookmarkListeners ) 392 { 393 dlg(bookmarkIndex, _filechooserwidget); 394 } 395 } 396 397 void delegate(FileChooserWidget)[] onRecentShortcutListeners; 398 /** 399 * The ::recent-shortcut signal is a [keybinding signal][GtkBindingSignal] 400 * which gets emitted when the user asks for it. 401 * 402 * This is used to make the file chooser show the Recent location. 403 * 404 * The default binding for this signal is `Alt + R`. 405 */ 406 void addOnRecentShortcut(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 407 { 408 if ( "recent-shortcut" !in connectedSignals ) 409 { 410 Signals.connectData( 411 this, 412 "recent-shortcut", 413 cast(GCallback)&callBackRecentShortcut, 414 cast(void*)this, 415 null, 416 connectFlags); 417 connectedSignals["recent-shortcut"] = 1; 418 } 419 onRecentShortcutListeners ~= dlg; 420 } 421 extern(C) static void callBackRecentShortcut(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 422 { 423 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onRecentShortcutListeners ) 424 { 425 dlg(_filechooserwidget); 426 } 427 } 428 429 void delegate(FileChooserWidget)[] onSearchShortcutListeners; 430 /** 431 * The ::search-shortcut signal is a [keybinding signal][GtkBindingSignal] 432 * which gets emitted when the user asks for it. 433 * 434 * This is used to make the file chooser show the search entry. 435 * 436 * The default binding for this signal is `Alt + S`. 437 */ 438 void addOnSearchShortcut(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 439 { 440 if ( "search-shortcut" !in connectedSignals ) 441 { 442 Signals.connectData( 443 this, 444 "search-shortcut", 445 cast(GCallback)&callBackSearchShortcut, 446 cast(void*)this, 447 null, 448 connectFlags); 449 connectedSignals["search-shortcut"] = 1; 450 } 451 onSearchShortcutListeners ~= dlg; 452 } 453 extern(C) static void callBackSearchShortcut(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 454 { 455 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onSearchShortcutListeners ) 456 { 457 dlg(_filechooserwidget); 458 } 459 } 460 461 void delegate(FileChooserWidget)[] onShowHiddenListeners; 462 /** 463 * The ::show-hidden signal is a [keybinding signal][GtkBindingSignal] 464 * which gets emitted when the user asks for it. 465 * 466 * This is used to make the file chooser display hidden files. 467 * 468 * The default binding for this signal is `Control + H`. 469 */ 470 void addOnShowHidden(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 471 { 472 if ( "show-hidden" !in connectedSignals ) 473 { 474 Signals.connectData( 475 this, 476 "show-hidden", 477 cast(GCallback)&callBackShowHidden, 478 cast(void*)this, 479 null, 480 connectFlags); 481 connectedSignals["show-hidden"] = 1; 482 } 483 onShowHiddenListeners ~= dlg; 484 } 485 extern(C) static void callBackShowHidden(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 486 { 487 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onShowHiddenListeners ) 488 { 489 dlg(_filechooserwidget); 490 } 491 } 492 493 void delegate(FileChooserWidget)[] onUpFolderListeners; 494 /** 495 * The ::up-folder signal is a [keybinding signal][GtkBindingSignal] 496 * which gets emitted when the user asks for it. 497 * 498 * This is used to make the file chooser go to the parent of the current folder 499 * in the file hierarchy. 500 * 501 * The default binding for this signal is `Alt + Up`. 502 */ 503 void addOnUpFolder(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 504 { 505 if ( "up-folder" !in connectedSignals ) 506 { 507 Signals.connectData( 508 this, 509 "up-folder", 510 cast(GCallback)&callBackUpFolder, 511 cast(void*)this, 512 null, 513 connectFlags); 514 connectedSignals["up-folder"] = 1; 515 } 516 onUpFolderListeners ~= dlg; 517 } 518 extern(C) static void callBackUpFolder(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 519 { 520 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onUpFolderListeners ) 521 { 522 dlg(_filechooserwidget); 523 } 524 } 525 }