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.FileChooserButton; 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.Dialog; 33 private import gtk.FileChooserIF; 34 private import gtk.FileChooserT; 35 private import gtk.Widget; 36 private import gtk.c.functions; 37 public import gtk.c.types; 38 public import gtkc.gtktypes; 39 private import std.algorithm; 40 41 42 /** 43 * The #GtkFileChooserButton is a widget that lets the user select a 44 * file. It implements the #GtkFileChooser interface. Visually, it is a 45 * file name with a button to bring up a #GtkFileChooserDialog. 46 * The user can then use that dialog to change the file associated with 47 * that button. This widget does not support setting the 48 * #GtkFileChooser:select-multiple property to %TRUE. 49 * 50 * ## Create a button to let the user select a file in /etc 51 * 52 * |[<!-- language="C" --> 53 * { 54 * GtkWidget *button; 55 * 56 * button = gtk_file_chooser_button_new (_("Select a file"), 57 * GTK_FILE_CHOOSER_ACTION_OPEN); 58 * gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button), 59 * "/etc"); 60 * } 61 * ]| 62 * 63 * The #GtkFileChooserButton supports the #GtkFileChooserActions 64 * %GTK_FILE_CHOOSER_ACTION_OPEN and %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER. 65 * 66 * > The #GtkFileChooserButton will ellipsize the label, and will thus 67 * > request little horizontal space. To give the button more space, 68 * > you should call gtk_widget_get_preferred_size(), 69 * > gtk_file_chooser_button_set_width_chars(), or pack the button in 70 * > such a way that other interface elements give space to the 71 * > widget. 72 */ 73 public class FileChooserButton : Box, FileChooserIF 74 { 75 /** the main Gtk struct */ 76 protected GtkFileChooserButton* gtkFileChooserButton; 77 78 /** Get the main Gtk struct */ 79 public GtkFileChooserButton* getFileChooserButtonStruct(bool transferOwnership = false) 80 { 81 if (transferOwnership) 82 ownedRef = false; 83 return gtkFileChooserButton; 84 } 85 86 /** the main Gtk struct as a void* */ 87 protected override void* getStruct() 88 { 89 return cast(void*)gtkFileChooserButton; 90 } 91 92 /** 93 * Sets our main struct and passes it to the parent class. 94 */ 95 public this (GtkFileChooserButton* gtkFileChooserButton, bool ownedRef = false) 96 { 97 this.gtkFileChooserButton = gtkFileChooserButton; 98 super(cast(GtkBox*)gtkFileChooserButton, ownedRef); 99 } 100 101 // add the FileChooser capabilities 102 mixin FileChooserT!(GtkFileChooserButton); 103 104 105 /** */ 106 public static GType getType() 107 { 108 return gtk_file_chooser_button_get_type(); 109 } 110 111 /** 112 * Creates a new file-selecting button widget. 113 * 114 * Params: 115 * title = the title of the browse dialog. 116 * action = the open mode for the widget. 117 * 118 * Returns: a new button widget. 119 * 120 * Since: 2.6 121 * 122 * Throws: ConstructionException GTK+ fails to create the object. 123 */ 124 public this(string title, GtkFileChooserAction action) 125 { 126 auto p = gtk_file_chooser_button_new(Str.toStringz(title), action); 127 128 if(p is null) 129 { 130 throw new ConstructionException("null returned by new"); 131 } 132 133 this(cast(GtkFileChooserButton*) p); 134 } 135 136 /** 137 * Creates a #GtkFileChooserButton widget which uses @dialog as its 138 * file-picking window. 139 * 140 * Note that @dialog must be a #GtkDialog (or subclass) which 141 * implements the #GtkFileChooser interface and must not have 142 * %GTK_DIALOG_DESTROY_WITH_PARENT set. 143 * 144 * Also note that the dialog needs to have its confirmative button 145 * added with response %GTK_RESPONSE_ACCEPT or %GTK_RESPONSE_OK in 146 * order for the button to take over the file selected in the dialog. 147 * 148 * Params: 149 * dialog = the widget to use as dialog 150 * 151 * Returns: a new button widget. 152 * 153 * Since: 2.6 154 * 155 * Throws: ConstructionException GTK+ fails to create the object. 156 */ 157 public this(Dialog dialog) 158 { 159 auto p = gtk_file_chooser_button_new_with_dialog((dialog is null) ? null : cast(GtkWidget*)dialog.getDialogStruct()); 160 161 if(p is null) 162 { 163 throw new ConstructionException("null returned by new_with_dialog"); 164 } 165 166 this(cast(GtkFileChooserButton*) p); 167 } 168 169 /** 170 * Returns whether the button grabs focus when it is clicked with the mouse. 171 * See gtk_file_chooser_button_set_focus_on_click(). 172 * 173 * Deprecated: Use gtk_widget_get_focus_on_click() instead 174 * 175 * Returns: %TRUE if the button grabs focus when it is clicked with 176 * the mouse. 177 * 178 * Since: 2.10 179 */ 180 public override bool getFocusOnClick() 181 { 182 return gtk_file_chooser_button_get_focus_on_click(gtkFileChooserButton) != 0; 183 } 184 185 /** 186 * Retrieves the title of the browse dialog used by @button. The returned value 187 * should not be modified or freed. 188 * 189 * Returns: a pointer to the browse dialog’s title. 190 * 191 * Since: 2.6 192 */ 193 public string getTitle() 194 { 195 return Str.toString(gtk_file_chooser_button_get_title(gtkFileChooserButton)); 196 } 197 198 /** 199 * Retrieves the width in characters of the @button widget’s entry and/or label. 200 * 201 * Returns: an integer width (in characters) that the button will use to size itself. 202 * 203 * Since: 2.6 204 */ 205 public int getWidthChars() 206 { 207 return gtk_file_chooser_button_get_width_chars(gtkFileChooserButton); 208 } 209 210 /** 211 * Sets whether the button will grab focus when it is clicked with the mouse. 212 * Making mouse clicks not grab focus is useful in places like toolbars where 213 * you don’t want the keyboard focus removed from the main area of the 214 * application. 215 * 216 * Deprecated: Use gtk_widget_set_focus_on_click() instead 217 * 218 * Params: 219 * focusOnClick = whether the button grabs focus when clicked with the mouse 220 * 221 * Since: 2.10 222 */ 223 public override void setFocusOnClick(bool focusOnClick) 224 { 225 gtk_file_chooser_button_set_focus_on_click(gtkFileChooserButton, focusOnClick); 226 } 227 228 /** 229 * Modifies the @title of the browse dialog used by @button. 230 * 231 * Params: 232 * title = the new browse dialog title. 233 * 234 * Since: 2.6 235 */ 236 public void setTitle(string title) 237 { 238 gtk_file_chooser_button_set_title(gtkFileChooserButton, Str.toStringz(title)); 239 } 240 241 /** 242 * Sets the width (in characters) that @button will use to @n_chars. 243 * 244 * Params: 245 * nChars = the new width, in characters. 246 * 247 * Since: 2.6 248 */ 249 public void setWidthChars(int nChars) 250 { 251 gtk_file_chooser_button_set_width_chars(gtkFileChooserButton, nChars); 252 } 253 254 /** 255 * The ::file-set signal is emitted when the user selects a file. 256 * 257 * Note that this signal is only emitted when the user 258 * changes the file. 259 * 260 * Since: 2.12 261 */ 262 gulong addOnFileSet(void delegate(FileChooserButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 263 { 264 return Signals.connect(this, "file-set", dlg, connectFlags ^ ConnectFlags.SWAPPED); 265 } 266 }