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 /** */ 74 public static GType getType() 75 { 76 return gtk_source_mark_attributes_get_type(); 77 } 78 79 /** 80 * Creates a new source mark attributes. 81 * 82 * Returns: a new source mark attributes. 83 * 84 * Throws: ConstructionException GTK+ fails to create the object. 85 */ 86 public this() 87 { 88 auto p = gtk_source_mark_attributes_new(); 89 90 if(p is null) 91 { 92 throw new ConstructionException("null returned by new"); 93 } 94 95 this(cast(GtkSourceMarkAttributes*) p, true); 96 } 97 98 /** 99 * Stores background color in @background. 100 * 101 * Params: 102 * background = a #GdkRGBA. 103 * 104 * Returns: whether background color for @attributes was set. 105 */ 106 public bool getBackground(out RGBA background) 107 { 108 GdkRGBA* outbackground = sliceNew!GdkRGBA(); 109 110 auto p = gtk_source_mark_attributes_get_background(gtkSourceMarkAttributes, outbackground) != 0; 111 112 background = ObjectG.getDObject!(RGBA)(outbackground, true); 113 114 return p; 115 } 116 117 /** 118 * Gets a #GIcon to be used as a base for rendered icon. Note that the icon can 119 * be %NULL if it wasn't set earlier. 120 * 121 * Returns: An icon. The icon belongs to @attributes and should 122 * not be unreffed. 123 */ 124 public IconIF getGicon() 125 { 126 auto p = gtk_source_mark_attributes_get_gicon(gtkSourceMarkAttributes); 127 128 if(p is null) 129 { 130 return null; 131 } 132 133 return ObjectG.getDObject!(IconIF)(cast(GIcon*) p); 134 } 135 136 /** 137 * Gets a name of an icon to be used as a base for rendered icon. Note that the 138 * icon name can be %NULL if it wasn't set earlier. 139 * 140 * Returns: An icon name. The string belongs to @attributes and 141 * should not be freed. 142 */ 143 public string getIconName() 144 { 145 return Str.toString(gtk_source_mark_attributes_get_icon_name(gtkSourceMarkAttributes)); 146 } 147 148 /** 149 * Gets a #GdkPixbuf to be used as a base for rendered icon. Note that the 150 * pixbuf can be %NULL if it wasn't set earlier. 151 * 152 * Returns: A pixbuf. The pixbuf belongs to @attributes and 153 * should not be unreffed. 154 */ 155 public Pixbuf getPixbuf() 156 { 157 auto p = gtk_source_mark_attributes_get_pixbuf(gtkSourceMarkAttributes); 158 159 if(p is null) 160 { 161 return null; 162 } 163 164 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 165 } 166 167 /** 168 * Queries for a tooltip by emitting 169 * a #GtkSourceMarkAttributes::query-tooltip-markup signal. The tooltip may contain 170 * a markup. 171 * 172 * Params: 173 * mark = a #GtkSourceMark. 174 * 175 * Returns: A tooltip. The returned string should be freed by 176 * using g_free() when done with it. 177 */ 178 public string getTooltipMarkup(SourceMark mark) 179 { 180 auto retStr = gtk_source_mark_attributes_get_tooltip_markup(gtkSourceMarkAttributes, (mark is null) ? null : mark.getSourceMarkStruct()); 181 182 scope(exit) Str.freeString(retStr); 183 return Str.toString(retStr); 184 } 185 186 /** 187 * Queries for a tooltip by emitting 188 * a #GtkSourceMarkAttributes::query-tooltip-text signal. The tooltip is a plain 189 * text. 190 * 191 * Params: 192 * mark = a #GtkSourceMark. 193 * 194 * Returns: A tooltip. The returned string should be freed by 195 * using g_free() when done with it. 196 */ 197 public string getTooltipText(SourceMark mark) 198 { 199 auto retStr = gtk_source_mark_attributes_get_tooltip_text(gtkSourceMarkAttributes, (mark is null) ? null : mark.getSourceMarkStruct()); 200 201 scope(exit) Str.freeString(retStr); 202 return Str.toString(retStr); 203 } 204 205 /** 206 * Renders an icon of given size. The base of the icon is set by the last call 207 * to one of: gtk_source_mark_attributes_set_pixbuf(), 208 * gtk_source_mark_attributes_set_gicon() or 209 * gtk_source_mark_attributes_set_icon_name(). @size cannot be lower than 1. 210 * 211 * Params: 212 * widget = widget of which style settings may be used. 213 * size = size of the rendered icon. 214 * 215 * Returns: A rendered pixbuf. The pixbuf belongs to @attributes 216 * and should not be unreffed. 217 */ 218 public Pixbuf renderIcon(Widget widget, int size) 219 { 220 auto p = gtk_source_mark_attributes_render_icon(gtkSourceMarkAttributes, (widget is null) ? null : widget.getWidgetStruct(), size); 221 222 if(p is null) 223 { 224 return null; 225 } 226 227 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 228 } 229 230 /** 231 * Sets background color to the one given in @background. 232 * 233 * Params: 234 * background = a #GdkRGBA. 235 */ 236 public void setBackground(RGBA background) 237 { 238 gtk_source_mark_attributes_set_background(gtkSourceMarkAttributes, (background is null) ? null : background.getRGBAStruct()); 239 } 240 241 /** 242 * Sets an icon to be used as a base for rendered icon. 243 * 244 * Params: 245 * gicon = a #GIcon to be used. 246 */ 247 public void setGicon(IconIF gicon) 248 { 249 gtk_source_mark_attributes_set_gicon(gtkSourceMarkAttributes, (gicon is null) ? null : gicon.getIconStruct()); 250 } 251 252 /** 253 * Sets a name of an icon to be used as a base for rendered icon. 254 * 255 * Params: 256 * iconName = name of an icon to be used. 257 */ 258 public void setIconName(string iconName) 259 { 260 gtk_source_mark_attributes_set_icon_name(gtkSourceMarkAttributes, Str.toStringz(iconName)); 261 } 262 263 /** 264 * Sets a pixbuf to be used as a base for rendered icon. 265 * 266 * Params: 267 * pixbuf = a #GdkPixbuf to be used. 268 */ 269 public void setPixbuf(Pixbuf pixbuf) 270 { 271 gtk_source_mark_attributes_set_pixbuf(gtkSourceMarkAttributes, (pixbuf is null) ? null : pixbuf.getPixbufStruct()); 272 } 273 274 /** 275 * The code should connect to this signal to provide a tooltip for given 276 * @mark. The tooltip can contain a markup. 277 * 278 * Params: 279 * mark = The #GtkSourceMark. 280 * 281 * Returns: A tooltip. The string should be freed with 282 * g_free() when done with it. 283 */ 284 gulong addOnQueryTooltipMarkup(string delegate(SourceMark, SourceMarkAttributes) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 285 { 286 return Signals.connect(this, "query-tooltip-markup", dlg, connectFlags ^ ConnectFlags.SWAPPED); 287 } 288 289 /** 290 * The code should connect to this signal to provide a tooltip for given 291 * @mark. The tooltip should be just a plain text. 292 * 293 * Params: 294 * mark = The #GtkSourceMark. 295 * 296 * Returns: A tooltip. The string should be freed with 297 * g_free() when done with it. 298 */ 299 gulong addOnQueryTooltipText(string delegate(SourceMark, SourceMarkAttributes) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 300 { 301 return Signals.connect(this, "query-tooltip-text", dlg, connectFlags ^ ConnectFlags.SWAPPED); 302 } 303 }