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 * Conversion parameters: 26 * inFile = GtkAppChooserButton.html 27 * outPack = gtk 28 * outFile = AppChooserButton 29 * strct = GtkAppChooserButton 30 * realStrct= 31 * ctorStrct= 32 * clss = AppChooserButton 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * - AppChooserIF 40 * prefixes: 41 * - gtk_app_chooser_button_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gio.IconIF 49 * - gtk.AppChooserIF 50 * - gtk.AppChooserT 51 * structWrap: 52 * - GIcon* -> IconIF 53 * module aliases: 54 * local aliases: 55 * overrides: 56 */ 57 58 module gtk.AppChooserButton; 59 60 public import gtkc.gtktypes; 61 62 private import gtkc.gtk; 63 private import glib.ConstructionException; 64 private import gobject.ObjectG; 65 66 private import gobject.Signals; 67 public import gtkc.gdktypes; 68 private import glib.Str; 69 private import gio.IconIF; 70 private import gtk.AppChooserIF; 71 private import gtk.AppChooserT; 72 73 74 private import gtk.ComboBox; 75 76 /** 77 * The GtkAppChooserButton is a widget that lets the user select 78 * an application. It implements the GtkAppChooser interface. 79 * 80 * Initially, a GtkAppChooserButton selects the first application 81 * in its list, which will either be the most-recently used application 82 * or, if "show-default-item" is TRUE, the 83 * default application. 84 * 85 * The list of applications shown in a GtkAppChooserButton includes 86 * the recommended applications for the given content type. When 87 * "show-default-item" is set, the default application 88 * is also included. To let the user chooser other applications, 89 * you can set the "show-dialog-item" property, 90 * which allows to open a full GtkAppChooserDialog. 91 * 92 * It is possible to add custom items to the list, using 93 * gtk_app_chooser_button_append_custom_item(). These items cause 94 * the "custom-item-activated" signal to be 95 * emitted when they are selected. 96 * 97 * To track changes in the selected application, use the 98 * "changed" signal. 99 */ 100 public class AppChooserButton : ComboBox, AppChooserIF 101 { 102 103 /** the main Gtk struct */ 104 protected GtkAppChooserButton* gtkAppChooserButton; 105 106 107 /** Get the main Gtk struct */ 108 public GtkAppChooserButton* getAppChooserButtonStruct() 109 { 110 return gtkAppChooserButton; 111 } 112 113 114 /** the main Gtk struct as a void* */ 115 protected override void* getStruct() 116 { 117 return cast(void*)gtkAppChooserButton; 118 } 119 120 /** 121 * Sets our main struct and passes it to the parent class 122 */ 123 public this (GtkAppChooserButton* gtkAppChooserButton) 124 { 125 super(cast(GtkComboBox*)gtkAppChooserButton); 126 this.gtkAppChooserButton = gtkAppChooserButton; 127 } 128 129 protected override void setStruct(GObject* obj) 130 { 131 super.setStruct(obj); 132 gtkAppChooserButton = cast(GtkAppChooserButton*)obj; 133 } 134 135 // add the AppChooser capabilities 136 mixin AppChooserT!(GtkAppChooserButton); 137 138 /** 139 */ 140 int[string] connectedSignals; 141 142 void delegate(string, AppChooserButton)[] onCustomItemActivatedListeners; 143 /** 144 * Emitted when a custom item, previously added with 145 * gtk_app_chooser_button_append_custom_item(), is activated from the 146 * dropdown menu. 147 */ 148 void addOnCustomItemActivated(void delegate(string, AppChooserButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 149 { 150 if ( !("custom-item-activated" in connectedSignals) ) 151 { 152 Signals.connectData( 153 getStruct(), 154 "custom-item-activated", 155 cast(GCallback)&callBackCustomItemActivated, 156 cast(void*)this, 157 null, 158 connectFlags); 159 connectedSignals["custom-item-activated"] = 1; 160 } 161 onCustomItemActivatedListeners ~= dlg; 162 } 163 extern(C) static void callBackCustomItemActivated(GtkAppChooserButton* selfStruct, gchar* itemName, AppChooserButton _appChooserButton) 164 { 165 foreach ( void delegate(string, AppChooserButton) dlg ; _appChooserButton.onCustomItemActivatedListeners ) 166 { 167 dlg(Str.toString(itemName), _appChooserButton); 168 } 169 } 170 171 172 /** 173 * Creates a new GtkAppChooserButton for applications 174 * that can handle content of the given type. 175 * Params: 176 * contentType = the content type to show applications for 177 * Throws: ConstructionException GTK+ fails to create the object. 178 */ 179 public this (string contentType) 180 { 181 // GtkWidget * gtk_app_chooser_button_new (const gchar *content_type); 182 auto p = gtk_app_chooser_button_new(Str.toStringz(contentType)); 183 if(p is null) 184 { 185 throw new ConstructionException("null returned by gtk_app_chooser_button_new(Str.toStringz(contentType))"); 186 } 187 this(cast(GtkAppChooserButton*) p); 188 } 189 190 /** 191 * Appends a custom item to the list of applications that is shown 192 * in the popup; the item name must be unique per-widget. 193 * Clients can use the provided name as a detail for the 194 * "custom-item-activated" signal, to add a 195 * callback for the activation of a particular custom item in the list. 196 * See also gtk_app_chooser_button_append_separator(). 197 * Params: 198 * name = the name of the custom item 199 * label = the label for the custom item 200 * icon = the icon for the custom item 201 * Since 3.0 202 */ 203 public void appendCustomItem(string name, string label, IconIF icon) 204 { 205 // void gtk_app_chooser_button_append_custom_item (GtkAppChooserButton *self, const gchar *name, const gchar *label, GIcon *icon); 206 gtk_app_chooser_button_append_custom_item(gtkAppChooserButton, Str.toStringz(name), Str.toStringz(label), (icon is null) ? null : icon.getIconTStruct()); 207 } 208 209 /** 210 * Appends a separator to the list of applications that is shown 211 * in the popup. 212 */ 213 public void appendSeparator() 214 { 215 // void gtk_app_chooser_button_append_separator (GtkAppChooserButton *self); 216 gtk_app_chooser_button_append_separator(gtkAppChooserButton); 217 } 218 219 /** 220 * Selects a custom item previously added with 221 * gtk_app_chooser_button_append_custom_item(). 222 * Use gtk_app_chooser_refresh() to bring the selection 223 * to its initial state. 224 * Params: 225 * name = the name of the custom item 226 * Since 3.0 227 */ 228 public void setActiveCustomItem(string name) 229 { 230 // void gtk_app_chooser_button_set_active_custom_item (GtkAppChooserButton *self, const gchar *name); 231 gtk_app_chooser_button_set_active_custom_item(gtkAppChooserButton, Str.toStringz(name)); 232 } 233 234 /** 235 * Returns the current value of the "show-default-item" 236 * property. 237 * Returns: the value of "show-default-item" Since 3.2 238 */ 239 public int getShowDefaultItem() 240 { 241 // gboolean gtk_app_chooser_button_get_show_default_item (GtkAppChooserButton *self); 242 return gtk_app_chooser_button_get_show_default_item(gtkAppChooserButton); 243 } 244 245 /** 246 * Sets whether the dropdown menu of this button should show the 247 * default application for the given content type at top. 248 * Params: 249 * setting = the new value for "show-default-item" 250 * Since 3.2 251 */ 252 public void setShowDefaultItem(int setting) 253 { 254 // void gtk_app_chooser_button_set_show_default_item (GtkAppChooserButton *self, gboolean setting); 255 gtk_app_chooser_button_set_show_default_item(gtkAppChooserButton, setting); 256 } 257 258 /** 259 * Returns the current value of the "show-dialog-item" 260 * property. 261 * Returns: the value of "show-dialog-item" Since 3.0 262 */ 263 public int getShowDialogItem() 264 { 265 // gboolean gtk_app_chooser_button_get_show_dialog_item (GtkAppChooserButton *self); 266 return gtk_app_chooser_button_get_show_dialog_item(gtkAppChooserButton); 267 } 268 269 /** 270 * Sets whether the dropdown menu of this button should show an 271 * entry to trigger a GtkAppChooserDialog. 272 * Params: 273 * setting = the new value for "show-dialog-item" 274 * Since 3.0 275 */ 276 public void setShowDialogItem(int setting) 277 { 278 // void gtk_app_chooser_button_set_show_dialog_item (GtkAppChooserButton *self, gboolean setting); 279 gtk_app_chooser_button_set_show_dialog_item(gtkAppChooserButton, setting); 280 } 281 282 /** 283 * Returns the text to display at the top of the dialog. 284 * Returns: the text to display at the top of the dialog, or NULL, in which case a default text is displayed 285 */ 286 public string getHeading() 287 { 288 // const gchar * gtk_app_chooser_button_get_heading (GtkAppChooserButton *self); 289 return Str.toString(gtk_app_chooser_button_get_heading(gtkAppChooserButton)); 290 } 291 292 /** 293 * Sets the text to display at the top of the dialog. 294 * If the heading is not set, the dialog displays a default text. 295 * Params: 296 * heading = a string containing Pango markup 297 */ 298 public void setHeading(string heading) 299 { 300 // void gtk_app_chooser_button_set_heading (GtkAppChooserButton *self, const gchar *heading); 301 gtk_app_chooser_button_set_heading(gtkAppChooserButton, Str.toStringz(heading)); 302 } 303 }