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 = GtkAppChooserWidget.html 27 * outPack = gtk 28 * outFile = AppChooserWidget 29 * strct = GtkAppChooserWidget 30 * realStrct= 31 * ctorStrct= 32 * clss = AppChooserWidget 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_widget_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gio.AppInfo 49 * - gtk.Menu 50 * - gtk.AppChooserIF 51 * - gtk.AppChooserT 52 * structWrap: 53 * - GAppInfo* -> AppInfo 54 * - GtkMenu* -> Menu 55 * module aliases: 56 * local aliases: 57 * overrides: 58 */ 59 60 module gtk.AppChooserWidget; 61 62 public import gtkc.gtktypes; 63 64 private import gtkc.gtk; 65 private import glib.ConstructionException; 66 private import gobject.ObjectG; 67 68 private import gobject.Signals; 69 public import gtkc.gdktypes; 70 71 private import glib.Str; 72 private import gio.AppInfo; 73 private import gtk.Menu; 74 private import gtk.AppChooserIF; 75 private import gtk.AppChooserT; 76 77 78 79 private import gtk.Box; 80 81 /** 82 * GtkAppChooserWidget is a widget for selecting applications. 83 * It is the main building block for GtkAppChooserDialog. Most 84 * applications only need to use the latter; but you can use 85 * this widget as part of a larger widget if you have special needs. 86 * 87 * GtkAppChooserWidget offers detailed control over what applications 88 * are shown, using the 89 * "show-default", 90 * "show-recommended", 91 * "show-fallback", 92 * "show-other" and 93 * "show-all" 94 * properties. See the GtkAppChooser documentation for more information 95 * about these groups of applications. 96 * 97 * To keep track of the selected application, use the 98 * "application-selected" and "application-activated" signals. 99 */ 100 public class AppChooserWidget : Box, AppChooserIF 101 { 102 103 /** the main Gtk struct */ 104 protected GtkAppChooserWidget* gtkAppChooserWidget; 105 106 107 public GtkAppChooserWidget* getAppChooserWidgetStruct() 108 { 109 return gtkAppChooserWidget; 110 } 111 112 113 /** the main Gtk struct as a void* */ 114 protected override void* getStruct() 115 { 116 return cast(void*)gtkAppChooserWidget; 117 } 118 119 /** 120 * Sets our main struct and passes it to the parent class 121 */ 122 public this (GtkAppChooserWidget* gtkAppChooserWidget) 123 { 124 super(cast(GtkBox*)gtkAppChooserWidget); 125 this.gtkAppChooserWidget = gtkAppChooserWidget; 126 } 127 128 protected override void setStruct(GObject* obj) 129 { 130 super.setStruct(obj); 131 gtkAppChooserWidget = cast(GtkAppChooserWidget*)obj; 132 } 133 134 // add the AppChooser capabilities 135 mixin AppChooserT!(GtkAppChooserWidget); 136 137 /** 138 */ 139 int[string] connectedSignals; 140 141 void delegate(AppInfo, AppChooserWidget)[] onApplicationActivatedListeners; 142 /** 143 * Emitted when an application item is activated from the widget's list. 144 * This usually happens when the user double clicks an item, or an item 145 * is selected and the user presses one of the keys Space, Shift+Space, 146 * Return or Enter. 147 */ 148 void addOnApplicationActivated(void delegate(AppInfo, AppChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 149 { 150 if ( !("application-activated" in connectedSignals) ) 151 { 152 Signals.connectData( 153 getStruct(), 154 "application-activated", 155 cast(GCallback)&callBackApplicationActivated, 156 cast(void*)this, 157 null, 158 connectFlags); 159 connectedSignals["application-activated"] = 1; 160 } 161 onApplicationActivatedListeners ~= dlg; 162 } 163 extern(C) static void callBackApplicationActivated(GtkAppChooserWidget* selfStruct, GAppInfo* application, AppChooserWidget _appChooserWidget) 164 { 165 foreach ( void delegate(AppInfo, AppChooserWidget) dlg ; _appChooserWidget.onApplicationActivatedListeners ) 166 { 167 dlg(ObjectG.getDObject!(AppInfo)(application), _appChooserWidget); 168 } 169 } 170 171 void delegate(AppInfo, AppChooserWidget)[] onApplicationSelectedListeners; 172 /** 173 * Emitted when an application item is selected from the widget's list. 174 */ 175 void addOnApplicationSelected(void delegate(AppInfo, AppChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 176 { 177 if ( !("application-selected" in connectedSignals) ) 178 { 179 Signals.connectData( 180 getStruct(), 181 "application-selected", 182 cast(GCallback)&callBackApplicationSelected, 183 cast(void*)this, 184 null, 185 connectFlags); 186 connectedSignals["application-selected"] = 1; 187 } 188 onApplicationSelectedListeners ~= dlg; 189 } 190 extern(C) static void callBackApplicationSelected(GtkAppChooserWidget* selfStruct, GAppInfo* application, AppChooserWidget _appChooserWidget) 191 { 192 foreach ( void delegate(AppInfo, AppChooserWidget) dlg ; _appChooserWidget.onApplicationSelectedListeners ) 193 { 194 dlg(ObjectG.getDObject!(AppInfo)(application), _appChooserWidget); 195 } 196 } 197 198 void delegate(Menu, AppInfo, AppChooserWidget)[] onPopulatePopupListeners; 199 /** 200 * Emitted when a context menu is about to popup over an application item. 201 * Clients can insert menu items into the provided GtkMenu object in the 202 * callback of this signal; the context menu will be shown over the item 203 * if at least one item has been added to the menu. 204 */ 205 void addOnPopulatePopup(void delegate(Menu, AppInfo, AppChooserWidget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 206 { 207 if ( !("populate-popup" in connectedSignals) ) 208 { 209 Signals.connectData( 210 getStruct(), 211 "populate-popup", 212 cast(GCallback)&callBackPopulatePopup, 213 cast(void*)this, 214 null, 215 connectFlags); 216 connectedSignals["populate-popup"] = 1; 217 } 218 onPopulatePopupListeners ~= dlg; 219 } 220 extern(C) static void callBackPopulatePopup(GtkAppChooserWidget* selfStruct, GtkMenu* menu, GAppInfo* application, AppChooserWidget _appChooserWidget) 221 { 222 foreach ( void delegate(Menu, AppInfo, AppChooserWidget) dlg ; _appChooserWidget.onPopulatePopupListeners ) 223 { 224 dlg(ObjectG.getDObject!(Menu)(menu), ObjectG.getDObject!(AppInfo)(application), _appChooserWidget); 225 } 226 } 227 228 229 /** 230 * Creates a new GtkAppChooserWidget for applications 231 * that can handle content of the given type. 232 * Params: 233 * contentType = the content type to show applications for 234 * Throws: ConstructionException GTK+ fails to create the object. 235 */ 236 public this (string contentType) 237 { 238 // GtkWidget * gtk_app_chooser_widget_new (const gchar *content_type); 239 auto p = gtk_app_chooser_widget_new(Str.toStringz(contentType)); 240 if(p is null) 241 { 242 throw new ConstructionException("null returned by gtk_app_chooser_widget_new(Str.toStringz(contentType))"); 243 } 244 this(cast(GtkAppChooserWidget*) p); 245 } 246 247 /** 248 * Sets whether the app chooser should show the default handler 249 * for the content type in a separate section. 250 * Params: 251 * setting = the new value for "show-default" 252 * Since 3.0 253 */ 254 public void setShowDefault(int setting) 255 { 256 // void gtk_app_chooser_widget_set_show_default (GtkAppChooserWidget *self, gboolean setting); 257 gtk_app_chooser_widget_set_show_default(gtkAppChooserWidget, setting); 258 } 259 260 /** 261 * Returns the current value of the "show-default" 262 * property. 263 * Returns: the value of "show-default" Since 3.0 264 */ 265 public int getShowDefault() 266 { 267 // gboolean gtk_app_chooser_widget_get_show_default (GtkAppChooserWidget *self); 268 return gtk_app_chooser_widget_get_show_default(gtkAppChooserWidget); 269 } 270 271 /** 272 * Sets whether the app chooser should show recommended applications 273 * for the content type in a separate section. 274 * Params: 275 * setting = the new value for "show-recommended" 276 * Since 3.0 277 */ 278 public void setShowRecommended(int setting) 279 { 280 // void gtk_app_chooser_widget_set_show_recommended (GtkAppChooserWidget *self, gboolean setting); 281 gtk_app_chooser_widget_set_show_recommended(gtkAppChooserWidget, setting); 282 } 283 284 /** 285 * Returns the current value of the "show-recommended" 286 * property. 287 * Returns: the value of "show-recommended" Since 3.0 288 */ 289 public int getShowRecommended() 290 { 291 // gboolean gtk_app_chooser_widget_get_show_recommended (GtkAppChooserWidget *self); 292 return gtk_app_chooser_widget_get_show_recommended(gtkAppChooserWidget); 293 } 294 295 /** 296 * Sets whether the app chooser should show related applications 297 * for the content type in a separate section. 298 * Params: 299 * setting = the new value for "show-fallback" 300 * Since 3.0 301 */ 302 public void setShowFallback(int setting) 303 { 304 // void gtk_app_chooser_widget_set_show_fallback (GtkAppChooserWidget *self, gboolean setting); 305 gtk_app_chooser_widget_set_show_fallback(gtkAppChooserWidget, setting); 306 } 307 308 /** 309 * Returns the current value of the "show-fallback" 310 * property. 311 * Returns: the value of "show-fallback" Since 3.0 312 */ 313 public int getShowFallback() 314 { 315 // gboolean gtk_app_chooser_widget_get_show_fallback (GtkAppChooserWidget *self); 316 return gtk_app_chooser_widget_get_show_fallback(gtkAppChooserWidget); 317 } 318 319 /** 320 * Sets whether the app chooser should show applications 321 * which are unrelated to the content type. 322 * Params: 323 * setting = the new value for "show-other" 324 * Since 3.0 325 */ 326 public void setShowOther(int setting) 327 { 328 // void gtk_app_chooser_widget_set_show_other (GtkAppChooserWidget *self, gboolean setting); 329 gtk_app_chooser_widget_set_show_other(gtkAppChooserWidget, setting); 330 } 331 332 /** 333 * Returns the current value of the "show-other" 334 * property. 335 * Returns: the value of "show-other" Since 3.0 336 */ 337 public int getShowOther() 338 { 339 // gboolean gtk_app_chooser_widget_get_show_other (GtkAppChooserWidget *self); 340 return gtk_app_chooser_widget_get_show_other(gtkAppChooserWidget); 341 } 342 343 /** 344 * Sets whether the app chooser should show all applications 345 * in a flat list. 346 * Params: 347 * setting = the new value for "show-all" 348 * Since 3.0 349 */ 350 public void setShowAll(int setting) 351 { 352 // void gtk_app_chooser_widget_set_show_all (GtkAppChooserWidget *self, gboolean setting); 353 gtk_app_chooser_widget_set_show_all(gtkAppChooserWidget, setting); 354 } 355 356 /** 357 * Returns the current value of the "show-all" 358 * property. 359 * Returns: the value of "show-all" Since 3.0 360 */ 361 public int getShowAll() 362 { 363 // gboolean gtk_app_chooser_widget_get_show_all (GtkAppChooserWidget *self); 364 return gtk_app_chooser_widget_get_show_all(gtkAppChooserWidget); 365 } 366 367 /** 368 * Sets the text that is shown if there are not applications 369 * that can handle the content type. 370 * Params: 371 * text = the new value for "default-text" 372 */ 373 public void setDefaultText(string text) 374 { 375 // void gtk_app_chooser_widget_set_default_text (GtkAppChooserWidget *self, const gchar *text); 376 gtk_app_chooser_widget_set_default_text(gtkAppChooserWidget, Str.toStringz(text)); 377 } 378 379 /** 380 * Returns the text that is shown if there are not applications 381 * that can handle the content type. 382 * Returns: the value of "default-text" Since 3.0 383 */ 384 public string getDefaultText() 385 { 386 // const gchar * gtk_app_chooser_widget_get_default_text (GtkAppChooserWidget *self); 387 return Str.toString(gtk_app_chooser_widget_get_default_text(gtkAppChooserWidget)); 388 } 389 }