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 gsv.SourceMarkAttributes; 26 27 private import gdk.RGBA; 28 private import gdkpixbuf.Pixbuf; 29 private import gio.IconIF; 30 private import glib.ConstructionException; 31 private import glib.MemorySlice; 32 private import glib.Str; 33 private import gobject.ObjectG; 34 private import gobject.Signals; 35 private import gsv.SourceMark; 36 private import gsv.c.functions; 37 public import gsv.c.types; 38 public import gsvc.gsvtypes; 39 private import gtk.Widget; 40 private import std.algorithm; 41 42 43 /** */ 44 public class SourceMarkAttributes : ObjectG 45 { 46 /** the main Gtk struct */ 47 protected GtkSourceMarkAttributes* gtkSourceMarkAttributes; 48 49 /** Get the main Gtk struct */ 50 public GtkSourceMarkAttributes* getSourceMarkAttributesStruct(bool transferOwnership = false) 51 { 52 if (transferOwnership) 53 ownedRef = false; 54 return gtkSourceMarkAttributes; 55 } 56 57 /** the main Gtk struct as a void* */ 58 protected override void* getStruct() 59 { 60 return cast(void*)gtkSourceMarkAttributes; 61 } 62 63 /** 64 * Sets our main struct and passes it to the parent class. 65 */ 66 public this (GtkSourceMarkAttributes* gtkSourceMarkAttributes, bool ownedRef = false) 67 { 68 this.gtkSourceMarkAttributes = gtkSourceMarkAttributes; 69 super(cast(GObject*)gtkSourceMarkAttributes, ownedRef); 70 } 71 72 /** */ 73 public void setStockId(StockID stockId) 74 { 75 setStockId(cast(string)stockId); 76 } 77 78 /** 79 */ 80 81 /** */ 82 public static GType getType() 83 { 84 return gtk_source_mark_attributes_get_type(); 85 } 86 87 /** 88 * Creates a new source mark attributes. 89 * 90 * Returns: a new source mark attributes. 91 * 92 * Throws: ConstructionException GTK+ fails to create the object. 93 */ 94 public this() 95 { 96 auto p = gtk_source_mark_attributes_new(); 97 98 if(p is null) 99 { 100 throw new ConstructionException("null returned by new"); 101 } 102 103 this(cast(GtkSourceMarkAttributes*) p, true); 104 } 105 106 /** 107 * Stores background color in @background. 108 * 109 * Params: 110 * background = a #GdkRGBA. 111 * 112 * Returns: whether background color for @attributes was set. 113 */ 114 public bool getBackground(out RGBA background) 115 { 116 GdkRGBA* outbackground = sliceNew!GdkRGBA(); 117 118 auto p = gtk_source_mark_attributes_get_background(gtkSourceMarkAttributes, outbackground) != 0; 119 120 background = ObjectG.getDObject!(RGBA)(outbackground, true); 121 122 return p; 123 } 124 125 /** 126 * Gets a #GIcon to be used as a base for rendered icon. Note that the icon can 127 * be %NULL if it wasn't set earlier. 128 * 129 * Returns: An icon. The icon belongs to @attributes and should 130 * not be unreffed. 131 */ 132 public IconIF getGicon() 133 { 134 auto p = gtk_source_mark_attributes_get_gicon(gtkSourceMarkAttributes); 135 136 if(p is null) 137 { 138 return null; 139 } 140 141 return ObjectG.getDObject!(IconIF)(cast(GIcon*) p); 142 } 143 144 /** 145 * Gets a name of an icon to be used as a base for rendered icon. Note that the 146 * icon name can be %NULL if it wasn't set earlier. 147 * 148 * Returns: An icon name. The string belongs to @attributes and 149 * should not be freed. 150 */ 151 public string getIconName() 152 { 153 return Str.toString(gtk_source_mark_attributes_get_icon_name(gtkSourceMarkAttributes)); 154 } 155 156 /** 157 * Gets a #GdkPixbuf to be used as a base for rendered icon. Note that the 158 * pixbuf can be %NULL if it wasn't set earlier. 159 * 160 * Returns: A pixbuf. The pixbuf belongs to @attributes and 161 * should not be unreffed. 162 */ 163 public Pixbuf getPixbuf() 164 { 165 auto p = gtk_source_mark_attributes_get_pixbuf(gtkSourceMarkAttributes); 166 167 if(p is null) 168 { 169 return null; 170 } 171 172 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 173 } 174 175 /** 176 * Gets a stock id of an icon used by this attributes. Note that the stock id can 177 * be %NULL if it wasn't set earlier. 178 * 179 * Deprecated: Don't use this function. 180 * 181 * Returns: Stock id. Returned string is owned by @attributes and 182 * shouldn't be freed. 183 */ 184 public string getStockId() 185 { 186 return Str.toString(gtk_source_mark_attributes_get_stock_id(gtkSourceMarkAttributes)); 187 } 188 189 /** 190 * Queries for a tooltip by emitting 191 * a #GtkSourceMarkAttributes::query-tooltip-markup signal. The tooltip may contain 192 * a markup. 193 * 194 * Params: 195 * mark = a #GtkSourceMark. 196 * 197 * Returns: A tooltip. The returned string should be freed by 198 * using g_free() when done with it. 199 */ 200 public string getTooltipMarkup(SourceMark mark) 201 { 202 auto retStr = gtk_source_mark_attributes_get_tooltip_markup(gtkSourceMarkAttributes, (mark is null) ? null : mark.getSourceMarkStruct()); 203 204 scope(exit) Str.freeString(retStr); 205 return Str.toString(retStr); 206 } 207 208 /** 209 * Queries for a tooltip by emitting 210 * a #GtkSourceMarkAttributes::query-tooltip-text signal. The tooltip is a plain 211 * text. 212 * 213 * Params: 214 * mark = a #GtkSourceMark. 215 * 216 * Returns: A tooltip. The returned string should be freed by 217 * using g_free() when done with it. 218 */ 219 public string getTooltipText(SourceMark mark) 220 { 221 auto retStr = gtk_source_mark_attributes_get_tooltip_text(gtkSourceMarkAttributes, (mark is null) ? null : mark.getSourceMarkStruct()); 222 223 scope(exit) Str.freeString(retStr); 224 return Str.toString(retStr); 225 } 226 227 /** 228 * Renders an icon of given size. The base of the icon is set by the last call 229 * to one of: gtk_source_mark_attributes_set_pixbuf(), 230 * gtk_source_mark_attributes_set_gicon(), 231 * gtk_source_mark_attributes_set_icon_name() or 232 * gtk_source_mark_attributes_set_stock_id(). @size cannot be lower than 1. 233 * 234 * Params: 235 * widget = widget of which style settings may be used. 236 * size = size of the rendered icon. 237 * 238 * Returns: A rendered pixbuf. The pixbuf belongs to @attributes 239 * and should not be unreffed. 240 */ 241 public Pixbuf renderIcon(Widget widget, int size) 242 { 243 auto p = gtk_source_mark_attributes_render_icon(gtkSourceMarkAttributes, (widget is null) ? null : widget.getWidgetStruct(), size); 244 245 if(p is null) 246 { 247 return null; 248 } 249 250 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 251 } 252 253 /** 254 * Sets background color to the one given in @background. 255 * 256 * Params: 257 * background = a #GdkRGBA. 258 */ 259 public void setBackground(RGBA background) 260 { 261 gtk_source_mark_attributes_set_background(gtkSourceMarkAttributes, (background is null) ? null : background.getRGBAStruct()); 262 } 263 264 /** 265 * Sets an icon to be used as a base for rendered icon. 266 * 267 * Params: 268 * gicon = a #GIcon to be used. 269 */ 270 public void setGicon(IconIF gicon) 271 { 272 gtk_source_mark_attributes_set_gicon(gtkSourceMarkAttributes, (gicon is null) ? null : gicon.getIconStruct()); 273 } 274 275 /** 276 * Sets a name of an icon to be used as a base for rendered icon. 277 * 278 * Params: 279 * iconName = name of an icon to be used. 280 */ 281 public void setIconName(string iconName) 282 { 283 gtk_source_mark_attributes_set_icon_name(gtkSourceMarkAttributes, Str.toStringz(iconName)); 284 } 285 286 /** 287 * Sets a pixbuf to be used as a base for rendered icon. 288 * 289 * Params: 290 * pixbuf = a #GdkPixbuf to be used. 291 */ 292 public void setPixbuf(Pixbuf pixbuf) 293 { 294 gtk_source_mark_attributes_set_pixbuf(gtkSourceMarkAttributes, (pixbuf is null) ? null : pixbuf.getPixbufStruct()); 295 } 296 297 /** 298 * Sets stock id to be used as a base for rendered icon. 299 * 300 * Deprecated: Don't use this function. 301 * 302 * Params: 303 * stockId = a stock id. 304 */ 305 public void setStockId(string stockId) 306 { 307 gtk_source_mark_attributes_set_stock_id(gtkSourceMarkAttributes, Str.toStringz(stockId)); 308 } 309 310 /** 311 * The code should connect to this signal to provide a tooltip for given 312 * @mark. The tooltip can contain a markup. 313 * 314 * Params: 315 * mark = The #GtkSourceMark. 316 * 317 * Returns: A tooltip. The string should be freed with 318 * g_free() when done with it. 319 */ 320 gulong addOnQueryTooltipMarkup(string delegate(SourceMark, SourceMarkAttributes) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 321 { 322 return Signals.connect(this, "query-tooltip-markup", dlg, connectFlags ^ ConnectFlags.SWAPPED); 323 } 324 325 /** 326 * The code should connect to this signal to provide a tooltip for given 327 * @mark. The tooltip should be just a plain text. 328 * 329 * Params: 330 * mark = The #GtkSourceMark. 331 * 332 * Returns: A tooltip. The string should be freed with 333 * g_free() when done with it. 334 */ 335 gulong addOnQueryTooltipText(string delegate(SourceMark, SourceMarkAttributes) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 336 { 337 return Signals.connect(this, "query-tooltip-text", dlg, connectFlags ^ ConnectFlags.SWAPPED); 338 } 339 }