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