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