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 84 public static GType getType() 85 { 86 return gtk_file_chooser_widget_get_type(); 87 } 88 89 /** 90 * Creates a new #GtkFileChooserWidget. This is a file chooser widget that can 91 * be embedded in custom windows, and it is the same widget that is used by 92 * #GtkFileChooserDialog. 93 * 94 * Params: 95 * action = Open or save mode for the widget 96 * 97 * Return: a new #GtkFileChooserWidget 98 * 99 * Since: 2.4 100 * 101 * Throws: ConstructionException GTK+ fails to create the object. 102 */ 103 public this(GtkFileChooserAction action) 104 { 105 auto p = gtk_file_chooser_widget_new(action); 106 107 if(p is null) 108 { 109 throw new ConstructionException("null returned by new"); 110 } 111 112 this(cast(GtkFileChooserWidget*) p); 113 } 114 115 int[string] connectedSignals; 116 117 void delegate(FileChooserWidget)[] onDesktopFolderListeners; 118 /** 119 * The ::desktop-folder signal is a [keybinding signal][GtkBindingSignal] 120 * which gets emitted when the user asks for it. 121 * 122 * This is used to make the file chooser show the user's Desktop 123 * folder in the file list. 124 * 125 * The default binding for this signal is `Alt + D`. 126 */ 127 void addOnDesktopFolder(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 128 { 129 if ( "desktop-folder" !in connectedSignals ) 130 { 131 Signals.connectData( 132 this, 133 "desktop-folder", 134 cast(GCallback)&callBackDesktopFolder, 135 cast(void*)this, 136 null, 137 connectFlags); 138 connectedSignals["desktop-folder"] = 1; 139 } 140 onDesktopFolderListeners ~= dlg; 141 } 142 extern(C) static void callBackDesktopFolder(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 143 { 144 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onDesktopFolderListeners ) 145 { 146 dlg(_filechooserwidget); 147 } 148 } 149 150 void delegate(FileChooserWidget)[] onDownFolderListeners; 151 /** 152 * The ::down-folder signal is a [keybinding signal][GtkBindingSignal] 153 * which gets emitted when the user asks for it. 154 * 155 * This is used to make the file chooser go to a child of the current folder 156 * in the file hierarchy. The subfolder that will be used is displayed in the 157 * path bar widget of the file chooser. For example, if the path bar is showing 158 * "/foo/bar/baz", with bar currently displayed, then this will cause the file 159 * chooser to switch to the "baz" subfolder. 160 * 161 * The default binding for this signal is `Alt + Down`. 162 */ 163 void addOnDownFolder(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 164 { 165 if ( "down-folder" !in connectedSignals ) 166 { 167 Signals.connectData( 168 this, 169 "down-folder", 170 cast(GCallback)&callBackDownFolder, 171 cast(void*)this, 172 null, 173 connectFlags); 174 connectedSignals["down-folder"] = 1; 175 } 176 onDownFolderListeners ~= dlg; 177 } 178 extern(C) static void callBackDownFolder(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 179 { 180 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onDownFolderListeners ) 181 { 182 dlg(_filechooserwidget); 183 } 184 } 185 186 void delegate(FileChooserWidget)[] onHomeFolderListeners; 187 /** 188 * The ::home-folder signal is a [keybinding signal][GtkBindingSignal] 189 * which gets emitted when the user asks for it. 190 * 191 * This is used to make the file chooser show the user's home 192 * folder in the file list. 193 * 194 * The default binding for this signal is `Alt + Home`. 195 */ 196 void addOnHomeFolder(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 197 { 198 if ( "home-folder" !in connectedSignals ) 199 { 200 Signals.connectData( 201 this, 202 "home-folder", 203 cast(GCallback)&callBackHomeFolder, 204 cast(void*)this, 205 null, 206 connectFlags); 207 connectedSignals["home-folder"] = 1; 208 } 209 onHomeFolderListeners ~= dlg; 210 } 211 extern(C) static void callBackHomeFolder(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 212 { 213 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onHomeFolderListeners ) 214 { 215 dlg(_filechooserwidget); 216 } 217 } 218 219 void delegate(string, FileChooserWidget)[] onLocationPopupListeners; 220 /** 221 * The ::location-popup signal is a [keybinding signal][GtkBindingSignal] 222 * which gets emitted when the user asks for it. 223 * 224 * This is used to make the file chooser show a "Location" prompt which 225 * the user can use to manually type the name of the file he wishes to select. 226 * 227 * The default bindings for this signal are `Control + L` with a @path string 228 * of "" (the empty string). It is also bound to `/` with a @path string of 229 * "`/`" (a slash): this lets you type `/` and immediately type a path name. 230 * On Unix systems, this is bound to `~` (tilde) with a @path string of "~" 231 * itself for access to home directories. 232 * 233 * Params: 234 * path = a string that gets put in the text entry for the file name 235 */ 236 void addOnLocationPopup(void delegate(string, FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 237 { 238 if ( "location-popup" !in connectedSignals ) 239 { 240 Signals.connectData( 241 this, 242 "location-popup", 243 cast(GCallback)&callBackLocationPopup, 244 cast(void*)this, 245 null, 246 connectFlags); 247 connectedSignals["location-popup"] = 1; 248 } 249 onLocationPopupListeners ~= dlg; 250 } 251 extern(C) static void callBackLocationPopup(GtkFileChooserWidget* filechooserwidgetStruct, char* path, FileChooserWidget _filechooserwidget) 252 { 253 foreach ( void delegate(string, FileChooserWidget) dlg; _filechooserwidget.onLocationPopupListeners ) 254 { 255 dlg(Str.toString(path), _filechooserwidget); 256 } 257 } 258 259 void delegate(FileChooserWidget)[] onLocationPopupOnPasteListeners; 260 /** 261 * The ::location-popup-on-paste signal is a [keybinding signal][GtkBindingSignal] 262 * which gets emitted when the user asks for it. 263 * 264 * This is used to make the file chooser show a "Location" prompt when the user 265 * pastes into a #GtkFileChooserWidget. 266 * 267 * The default binding for this signal is `Control + V`. 268 */ 269 void addOnLocationPopupOnPaste(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 270 { 271 if ( "location-popup-on-paste" !in connectedSignals ) 272 { 273 Signals.connectData( 274 this, 275 "location-popup-on-paste", 276 cast(GCallback)&callBackLocationPopupOnPaste, 277 cast(void*)this, 278 null, 279 connectFlags); 280 connectedSignals["location-popup-on-paste"] = 1; 281 } 282 onLocationPopupOnPasteListeners ~= dlg; 283 } 284 extern(C) static void callBackLocationPopupOnPaste(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 285 { 286 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onLocationPopupOnPasteListeners ) 287 { 288 dlg(_filechooserwidget); 289 } 290 } 291 292 void delegate(FileChooserWidget)[] onLocationTogglePopupListeners; 293 /** 294 * The ::location-toggle-popup signal is a [keybinding signal][GtkBindingSignal] 295 * which gets emitted when the user asks for it. 296 * 297 * This is used to toggle the visibility of a "Location" prompt which the user 298 * can use to manually type the name of the file he wishes to select. 299 * 300 * The default binding for this signal is `Control + L`. 301 */ 302 void addOnLocationTogglePopup(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 303 { 304 if ( "location-toggle-popup" !in connectedSignals ) 305 { 306 Signals.connectData( 307 this, 308 "location-toggle-popup", 309 cast(GCallback)&callBackLocationTogglePopup, 310 cast(void*)this, 311 null, 312 connectFlags); 313 connectedSignals["location-toggle-popup"] = 1; 314 } 315 onLocationTogglePopupListeners ~= dlg; 316 } 317 extern(C) static void callBackLocationTogglePopup(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 318 { 319 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onLocationTogglePopupListeners ) 320 { 321 dlg(_filechooserwidget); 322 } 323 } 324 325 void delegate(FileChooserWidget)[] onPlacesShortcutListeners; 326 /** 327 * The ::places-shortcut signal is a [keybinding signal][GtkBindingSignal] 328 * which gets emitted when the user asks for it. 329 * 330 * This is used to move the focus to the places sidebar. 331 * 332 * The default binding for this signal is `Alt + P`. 333 */ 334 void addOnPlacesShortcut(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 335 { 336 if ( "places-shortcut" !in connectedSignals ) 337 { 338 Signals.connectData( 339 this, 340 "places-shortcut", 341 cast(GCallback)&callBackPlacesShortcut, 342 cast(void*)this, 343 null, 344 connectFlags); 345 connectedSignals["places-shortcut"] = 1; 346 } 347 onPlacesShortcutListeners ~= dlg; 348 } 349 extern(C) static void callBackPlacesShortcut(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 350 { 351 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onPlacesShortcutListeners ) 352 { 353 dlg(_filechooserwidget); 354 } 355 } 356 357 void delegate(int, FileChooserWidget)[] onQuickBookmarkListeners; 358 /** 359 * The ::quick-bookmark signal is a [keybinding signal][GtkBindingSignal] 360 * which gets emitted when the user asks for it. 361 * 362 * This is used to make the file chooser switch to the bookmark specified 363 * in the @bookmark_index parameter. For example, if you have three bookmarks, 364 * you can pass 0, 1, 2 to this signal to switch to each of them, respectively. 365 * 366 * The default binding for this signal is `Alt + 1`, `Alt + 2`, 367 * etc. until `Alt + 0`. Note that in the default binding, that 368 * `Alt + 1` is actually defined to switch to the bookmark at index 369 * 0, and so on successively; `Alt + 0` is defined to switch to the 370 * bookmark at index 10. 371 * 372 * Params: 373 * bookmarkIndex = the number of the bookmark to switch to 374 */ 375 void addOnQuickBookmark(void delegate(int, FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 376 { 377 if ( "quick-bookmark" !in connectedSignals ) 378 { 379 Signals.connectData( 380 this, 381 "quick-bookmark", 382 cast(GCallback)&callBackQuickBookmark, 383 cast(void*)this, 384 null, 385 connectFlags); 386 connectedSignals["quick-bookmark"] = 1; 387 } 388 onQuickBookmarkListeners ~= dlg; 389 } 390 extern(C) static void callBackQuickBookmark(GtkFileChooserWidget* filechooserwidgetStruct, int bookmarkIndex, FileChooserWidget _filechooserwidget) 391 { 392 foreach ( void delegate(int, FileChooserWidget) dlg; _filechooserwidget.onQuickBookmarkListeners ) 393 { 394 dlg(bookmarkIndex, _filechooserwidget); 395 } 396 } 397 398 void delegate(FileChooserWidget)[] onRecentShortcutListeners; 399 /** 400 * The ::recent-shortcut signal is a [keybinding signal][GtkBindingSignal] 401 * which gets emitted when the user asks for it. 402 * 403 * This is used to make the file chooser show the Recent location. 404 * 405 * The default binding for this signal is `Alt + R`. 406 */ 407 void addOnRecentShortcut(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 408 { 409 if ( "recent-shortcut" !in connectedSignals ) 410 { 411 Signals.connectData( 412 this, 413 "recent-shortcut", 414 cast(GCallback)&callBackRecentShortcut, 415 cast(void*)this, 416 null, 417 connectFlags); 418 connectedSignals["recent-shortcut"] = 1; 419 } 420 onRecentShortcutListeners ~= dlg; 421 } 422 extern(C) static void callBackRecentShortcut(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 423 { 424 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onRecentShortcutListeners ) 425 { 426 dlg(_filechooserwidget); 427 } 428 } 429 430 void delegate(FileChooserWidget)[] onSearchShortcutListeners; 431 /** 432 * The ::search-shortcut signal is a [keybinding signal][GtkBindingSignal] 433 * which gets emitted when the user asks for it. 434 * 435 * This is used to make the file chooser show the search entry. 436 * 437 * The default binding for this signal is `Alt + S`. 438 */ 439 void addOnSearchShortcut(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 440 { 441 if ( "search-shortcut" !in connectedSignals ) 442 { 443 Signals.connectData( 444 this, 445 "search-shortcut", 446 cast(GCallback)&callBackSearchShortcut, 447 cast(void*)this, 448 null, 449 connectFlags); 450 connectedSignals["search-shortcut"] = 1; 451 } 452 onSearchShortcutListeners ~= dlg; 453 } 454 extern(C) static void callBackSearchShortcut(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 455 { 456 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onSearchShortcutListeners ) 457 { 458 dlg(_filechooserwidget); 459 } 460 } 461 462 void delegate(FileChooserWidget)[] onShowHiddenListeners; 463 /** 464 * The ::show-hidden signal is a [keybinding signal][GtkBindingSignal] 465 * which gets emitted when the user asks for it. 466 * 467 * This is used to make the file chooser display hidden files. 468 * 469 * The default binding for this signal is `Control + H`. 470 */ 471 void addOnShowHidden(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 472 { 473 if ( "show-hidden" !in connectedSignals ) 474 { 475 Signals.connectData( 476 this, 477 "show-hidden", 478 cast(GCallback)&callBackShowHidden, 479 cast(void*)this, 480 null, 481 connectFlags); 482 connectedSignals["show-hidden"] = 1; 483 } 484 onShowHiddenListeners ~= dlg; 485 } 486 extern(C) static void callBackShowHidden(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 487 { 488 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onShowHiddenListeners ) 489 { 490 dlg(_filechooserwidget); 491 } 492 } 493 494 void delegate(FileChooserWidget)[] onUpFolderListeners; 495 /** 496 * The ::up-folder signal is a [keybinding signal][GtkBindingSignal] 497 * which gets emitted when the user asks for it. 498 * 499 * This is used to make the file chooser go to the parent of the current folder 500 * in the file hierarchy. 501 * 502 * The default binding for this signal is `Alt + Up`. 503 */ 504 void addOnUpFolder(void delegate(FileChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 505 { 506 if ( "up-folder" !in connectedSignals ) 507 { 508 Signals.connectData( 509 this, 510 "up-folder", 511 cast(GCallback)&callBackUpFolder, 512 cast(void*)this, 513 null, 514 connectFlags); 515 connectedSignals["up-folder"] = 1; 516 } 517 onUpFolderListeners ~= dlg; 518 } 519 extern(C) static void callBackUpFolder(GtkFileChooserWidget* filechooserwidgetStruct, FileChooserWidget _filechooserwidget) 520 { 521 foreach ( void delegate(FileChooserWidget) dlg; _filechooserwidget.onUpFolderListeners ) 522 { 523 dlg(_filechooserwidget); 524 } 525 } 526 }