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 = GtkFontChooser.html 27 * outPack = gtk 28 * outFile = FontChooserT 29 * strct = GtkFontChooser 30 * realStrct= 31 * ctorStrct= 32 * clss = FontChooserT 33 * interf = FontChooserIF 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * - TStruct 38 * extend = 39 * implements: 40 * prefixes: 41 * - gtk_font_chooser_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - pango.PgFontDescription 49 * - pango.PgFontFace 50 * - pango.PgFontFamily 51 * structWrap: 52 * - PangoFontDescription* -> PgFontDescription 53 * - PangoFontFace* -> PgFontFace 54 * - PangoFontFamily* -> PgFontFamily 55 * module aliases: 56 * local aliases: 57 * overrides: 58 */ 59 60 module gtk.FontChooserT; 61 62 public import gtkc.gtktypes; 63 64 public import gtkc.gtk; 65 public import glib.ConstructionException; 66 public import gobject.ObjectG; 67 68 public import gobject.Signals; 69 public import gtkc.gdktypes; 70 public import glib.Str; 71 public import pango.PgFontDescription; 72 public import pango.PgFontFace; 73 public import pango.PgFontFamily; 74 75 76 77 /** 78 * GtkFontChooser is an interface that can be implemented by widgets 79 * displaying the list of fonts. In GTK+, the main objects 80 * that implement this interface are GtkFontChooserWidget, 81 * GtkFontChooserDialog and GtkFontButton. 82 */ 83 public template FontChooserT(TStruct) 84 { 85 86 /** the main Gtk struct */ 87 protected GtkFontChooser* gtkFontChooser; 88 89 90 /** Get the main Gtk struct */ 91 public GtkFontChooser* getFontChooserTStruct() 92 { 93 return cast(GtkFontChooser*)getStruct(); 94 } 95 96 97 /** 98 */ 99 int[string] connectedSignals; 100 101 void delegate(string, FontChooserIF)[] _onFontActivatedListeners; 102 @property void delegate(string, FontChooserIF)[] onFontActivatedListeners() 103 { 104 return _onFontActivatedListeners; 105 } 106 /** 107 * Emitted when a font is activated. 108 * This usually happens when the user double clicks an item, 109 * or an item is selected and the user presses one of the keys 110 * Space, Shift+Space, Return or Enter. 111 * See Also 112 * GtkFontChooserDialog, GtkFontChooserWidget, GtkFontButton 113 */ 114 void addOnFontActivated(void delegate(string, FontChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 115 { 116 if ( !("font-activated" in connectedSignals) ) 117 { 118 Signals.connectData( 119 getStruct(), 120 "font-activated", 121 cast(GCallback)&callBackFontActivated, 122 cast(void*)cast(FontChooserIF)this, 123 null, 124 connectFlags); 125 connectedSignals["font-activated"] = 1; 126 } 127 _onFontActivatedListeners ~= dlg; 128 } 129 extern(C) static void callBackFontActivated(GtkFontChooser* selfStruct, gchar* fontname, FontChooserIF _fontChooserIF) 130 { 131 foreach ( void delegate(string, FontChooserIF) dlg ; _fontChooserIF.onFontActivatedListeners ) 132 { 133 dlg(Str.toString(fontname), _fontChooserIF); 134 } 135 } 136 137 138 /** 139 * Gets the PangoFontFamily representing the selected font family. 140 * Font families are a collection of font faces. 141 * If the selected font is not installed, returns NULL. 142 * Returns: A PangoFontFamily representing the selected font family, or NULL. The returned object is owned by fontchooser and must not be modified or freed. [transfer none] Since 3.2 143 */ 144 public PgFontFamily getFontFamily() 145 { 146 // PangoFontFamily * gtk_font_chooser_get_font_family (GtkFontChooser *fontchooser); 147 auto p = gtk_font_chooser_get_font_family(getFontChooserTStruct()); 148 149 if(p is null) 150 { 151 return null; 152 } 153 154 return ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) p); 155 } 156 157 /** 158 * Gets the PangoFontFace representing the selected font group 159 * details (i.e. family, slant, weight, width, etc). 160 * If the selected font is not installed, returns NULL. 161 * Returns: A PangoFontFace representing the selected font group details, or NULL. The returned object is owned by fontchooser and must not be modified or freed. [transfer none] Since 3.2 162 */ 163 public PgFontFace getFontFace() 164 { 165 // PangoFontFace * gtk_font_chooser_get_font_face (GtkFontChooser *fontchooser); 166 auto p = gtk_font_chooser_get_font_face(getFontChooserTStruct()); 167 168 if(p is null) 169 { 170 return null; 171 } 172 173 return ObjectG.getDObject!(PgFontFace)(cast(PangoFontFace*) p); 174 } 175 176 /** 177 * The selected font size. 178 * Returns: A n integer representing the selected font size, or -1 if no font size is selected. Since 3.2 179 */ 180 public int getFontSize() 181 { 182 // gint gtk_font_chooser_get_font_size (GtkFontChooser *fontchooser); 183 return gtk_font_chooser_get_font_size(getFontChooserTStruct()); 184 } 185 186 /** 187 * Gets the currently-selected font name. 188 * Note that this can be a different string than what you set with 189 * gtk_font_chooser_set_font(), as the font chooser widget may 190 * normalize font names and thus return a string with a different 191 * structure. For example, "Helvetica Italic Bold 12" could be 192 * normalized to "Helvetica Bold Italic 12". 193 * Use pango_font_description_equal() if you want to compare two 194 * font descriptions. 195 * Returns: A string with the name of the current font, or NULL if no font is selected. You must free this string with g_free(). [transfer full][allow-none] Since 3.2 196 */ 197 public string getFont() 198 { 199 // gchar * gtk_font_chooser_get_font (GtkFontChooser *fontchooser); 200 return Str.toString(gtk_font_chooser_get_font(getFontChooserTStruct())); 201 } 202 203 /** 204 * Sets the currently-selected font. 205 * Params: 206 * fontname = a font name like "Helvetica 12" or "Times Bold 18" 207 * Since 3.2 208 */ 209 public void setFont(string fontname) 210 { 211 // void gtk_font_chooser_set_font (GtkFontChooser *fontchooser, const gchar *fontname); 212 gtk_font_chooser_set_font(getFontChooserTStruct(), Str.toStringz(fontname)); 213 } 214 215 /** 216 * Gets the currently-selected font. 217 * Note that this can be a different string than what you set with 218 * gtk_font_chooser_set_font(), as the font chooser widget may 219 * normalize font names and thus return a string with a different 220 * structure. For example, "Helvetica Italic Bold 12" could be 221 * normalized to "Helvetica Bold Italic 12". 222 * Use pango_font_description_equal() if you want to compare two 223 * font descriptions. 224 * Returns: A PangoFontDescription for the current font, or NULL if no font is selected. [transfer full][allow-none] Since 3.2 225 */ 226 public PgFontDescription getFontDesc() 227 { 228 // PangoFontDescription * gtk_font_chooser_get_font_desc (GtkFontChooser *fontchooser); 229 auto p = gtk_font_chooser_get_font_desc(getFontChooserTStruct()); 230 231 if(p is null) 232 { 233 return null; 234 } 235 236 return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p); 237 } 238 239 /** 240 * Sets the currently-selected font from font_desc. 241 * Params: 242 * fontDesc = a PangoFontDescription 243 * Since 3.2 244 */ 245 public void setFontDesc(PgFontDescription fontDesc) 246 { 247 // void gtk_font_chooser_set_font_desc (GtkFontChooser *fontchooser, const PangoFontDescription *font_desc); 248 gtk_font_chooser_set_font_desc(getFontChooserTStruct(), (fontDesc is null) ? null : fontDesc.getPgFontDescriptionStruct()); 249 } 250 251 /** 252 * Gets the text displayed in the preview area. 253 * Returns: the text displayed in the preview area. [transfer full] Since 3.2 254 */ 255 public string getPreviewText() 256 { 257 // gchar * gtk_font_chooser_get_preview_text (GtkFontChooser *fontchooser); 258 return Str.toString(gtk_font_chooser_get_preview_text(getFontChooserTStruct())); 259 } 260 261 /** 262 * Sets the text displayed in the preview area. 263 * The text is used to show how the selected font looks. 264 * Params: 265 * text = the text to display in the preview area. [transfer none] 266 * Since 3.2 267 */ 268 public void setPreviewText(string text) 269 { 270 // void gtk_font_chooser_set_preview_text (GtkFontChooser *fontchooser, const gchar *text); 271 gtk_font_chooser_set_preview_text(getFontChooserTStruct(), Str.toStringz(text)); 272 } 273 274 /** 275 * Returns whether the preview entry is shown or not. 276 * Returns: TRUE if the preview entry is shown or FALSE if it is hidden. Since 3.2 277 */ 278 public int getShowPreviewEntry() 279 { 280 // gboolean gtk_font_chooser_get_show_preview_entry (GtkFontChooser *fontchooser); 281 return gtk_font_chooser_get_show_preview_entry(getFontChooserTStruct()); 282 } 283 284 /** 285 * Shows or hides the editable preview entry. 286 * Params: 287 * showPreviewEntry = whether to show the editable preview entry or not 288 * Since 3.2 289 */ 290 public void setShowPreviewEntry(int showPreviewEntry) 291 { 292 // void gtk_font_chooser_set_show_preview_entry (GtkFontChooser *fontchooser, gboolean show_preview_entry); 293 gtk_font_chooser_set_show_preview_entry(getFontChooserTStruct(), showPreviewEntry); 294 } 295 296 /** 297 * Adds a filter function that decides which fonts to display 298 * in the font chooser. 299 * Params: 300 * filter = a GtkFontFilterFunc, or NULL. [allow-none] 301 * userData = data to pass to filter 302 * destroy = function to call to free data when it is no longer needed 303 * Since 3.2 304 */ 305 public void setFilterFunc(GtkFontFilterFunc filter, void* userData, GDestroyNotify destroy) 306 { 307 // void gtk_font_chooser_set_filter_func (GtkFontChooser *fontchooser, GtkFontFilterFunc filter, gpointer user_data, GDestroyNotify destroy); 308 gtk_font_chooser_set_filter_func(getFontChooserTStruct(), filter, userData, destroy); 309 } 310 }