add CSS example
This commit is contained in:
parent
ad0859a2b7
commit
7cf16e3de7
15 changed files with 186 additions and 106821 deletions
77
README.adoc
77
README.adoc
|
|
@ -565,5 +565,82 @@ main()
|
|||
In this example we have to define our new widget type first, then we have to
|
||||
declare a variable of that type and pass that variable to the init() proc.
|
||||
|
||||
== CSS styles, GErrors and Exceptions
|
||||
|
||||
image::NimGTK3Label.png[]
|
||||
|
||||
Often GTK beginners ask how one can apply custom styles to GTK widgets, for example custom colors.
|
||||
While in most cases the use of custom colors gives just ugly results, as the custom colors generally do
|
||||
not match well with the default color scheme, it is good to know how we can do it. For GTK3 styles are
|
||||
applied to widgets by using _Cascading Style Sheets_ (_CSS_). You may find C example code similar to this:
|
||||
|
||||
[[label.c]]
|
||||
[source,c]
|
||||
.label.c
|
||||
----
|
||||
// https://stackoverflow.com/questions/30791670/how-to-style-a-gtklabel-with-css
|
||||
// gcc `pkg-config gtk+-3.0 --cflags` test.c -o test `pkg-config --libs gtk+-3.0`
|
||||
#include <gtk/gtk.h>
|
||||
int main(int argc, char *argv[]) {
|
||||
gtk_init(&argc, &argv);
|
||||
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
GtkWidget *label = gtk_label_new("Label");
|
||||
GtkCssProvider *cssProvider = gtk_css_provider_new();
|
||||
char *data = "label {color: green;}";
|
||||
gtk_css_provider_load_from_data(cssProvider, data, -1, NULL);
|
||||
gtk_style_context_add_provider(gtk_widget_get_style_context(window),
|
||||
GTK_STYLE_PROVIDER(cssProvider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
|
||||
gtk_container_add(GTK_CONTAINER(window), label);
|
||||
gtk_widget_show_all(window);
|
||||
gtk_main();
|
||||
}
|
||||
----
|
||||
|
||||
Converting that to Nim is again straight forward:
|
||||
|
||||
[[label.nim]]
|
||||
[source,nim]
|
||||
.label.nim
|
||||
----
|
||||
# nim c label.nim
|
||||
import gintro/[gtk, glib]
|
||||
import gintro/gio except Application, newApplication
|
||||
|
||||
proc activate(app: Application) =
|
||||
let window = newApplicationWindow(app)
|
||||
let label = newLabel("Yellow text on green background")
|
||||
let cssProvider = newCssProvider()
|
||||
let data = "label {color: yellow; background: green;}"
|
||||
#discard cssProvider.loadFromPath("doesnotexist")
|
||||
discard cssProvider.loadFromData(data)
|
||||
let styleContext = label.getStyleContext
|
||||
assert styleContext != nil
|
||||
addProvider(styleContext, cssProvider, STYLE_PROVIDER_PRIORITY_USER)
|
||||
window.add(label)
|
||||
showAll(window)
|
||||
|
||||
proc main =
|
||||
let app = newApplication("org.gtk.example")
|
||||
connect(app, "activate", activate)
|
||||
discard run(app)
|
||||
|
||||
main()
|
||||
----
|
||||
|
||||
For this example we create a plain label widget with some text. To colorize it, we generate a
|
||||
CssProvider and load it with a textual description of of our desired colors. Then we extract the
|
||||
style context from the label and add our CssProvider to it.
|
||||
|
||||
The last parameter of the _C_ function gtk_css_provider_load_from_data() is of type GError and can
|
||||
be used in _C_ code to detect runtime errors. The _C_ code above just passes NULL to ignore this error.
|
||||
For Nim we map that GError argument to _exceptions_. To test what happens in Nim when an GError would
|
||||
report an error condition, you may uncomment function loadFromPath() in the code above. As the specified path
|
||||
does not exist, we should get an exeption with a message telling us the problem. Of course in your real
|
||||
code you may catch such exceptions with Nim's `try:` blocks. (You may also modify the data variable above to
|
||||
an illegal CSS statement -- if the statement is seriously wrong, then you should get an exception from
|
||||
loadFromData().
|
||||
|
||||
NOTE: Related work: https://github.com/jdmansour/nim-smartgi
|
||||
|
||||
|
|
|
|||
23
examples/label.nim
Normal file
23
examples/label.nim
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# nim c label.nim
|
||||
import gintro/[gtk, glib]
|
||||
import gintro/gio except Application, newApplication
|
||||
|
||||
proc activate(app: Application) =
|
||||
let window = newApplicationWindow(app)
|
||||
let label = newLabel("Yellow text on green background")
|
||||
let cssProvider = newCssProvider()
|
||||
let data = "label {color: yellow; background: green;}"
|
||||
#discard cssProvider.loadFromPath("doesnotexist")
|
||||
discard cssProvider.loadFromData(data)
|
||||
let styleContext = label.getStyleContext
|
||||
assert styleContext != nil
|
||||
addProvider(styleContext, cssProvider, STYLE_PROVIDER_PRIORITY_USER)
|
||||
window.add(label)
|
||||
showAll(window)
|
||||
|
||||
proc main =
|
||||
let app = newApplication("org.gtk.example")
|
||||
connect(app, "activate", activate)
|
||||
discard run(app)
|
||||
|
||||
main()
|
||||
3706
gintro/atk.nim
3706
gintro/atk.nim
File diff suppressed because it is too large
Load diff
|
|
@ -1,80 +0,0 @@
|
|||
# dependencies:
|
||||
# immediate dependencies:
|
||||
# libraries:
|
||||
# libcairo-gobject.so.2
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
const Lib* = "libcairo-gobject.so.2"
|
||||
{.pragma: libprag, cdecl, dynlib: Lib.}
|
||||
|
||||
type
|
||||
Context00* {.pure.} = object
|
||||
Context* = ref object
|
||||
impl*: ptr Context00
|
||||
|
||||
type
|
||||
Surface00* {.pure.} = object
|
||||
Surface* = ref object
|
||||
impl*: ptr Surface00
|
||||
|
||||
type
|
||||
Matrix00* {.pure.} = object
|
||||
Matrix* = ref object
|
||||
impl*: ptr Matrix00
|
||||
|
||||
type
|
||||
Pattern00* {.pure.} = object
|
||||
Pattern* = ref object
|
||||
impl*: ptr Pattern00
|
||||
|
||||
type
|
||||
Region00* {.pure.} = object
|
||||
Region* = ref object
|
||||
impl*: ptr Region00
|
||||
|
||||
type
|
||||
Content* {.size: sizeof(cint), pure.} = enum
|
||||
COLOR = 4096
|
||||
ALPHA = 8192
|
||||
COLOR_ALPHA = 12288
|
||||
|
||||
type
|
||||
FontOptions00* {.pure.} = object
|
||||
FontOptions* = ref object
|
||||
impl*: ptr FontOptions00
|
||||
|
||||
type
|
||||
FontType00* {.pure.} = object
|
||||
FontType* = ref object
|
||||
impl*: ptr FontType00
|
||||
|
||||
type
|
||||
FontFace00* {.pure.} = object
|
||||
FontFace* = ref object
|
||||
impl*: ptr FontFace00
|
||||
|
||||
type
|
||||
ScaledFont00* {.pure.} = object
|
||||
ScaledFont* = ref object
|
||||
impl*: ptr ScaledFont00
|
||||
|
||||
type
|
||||
Path00* {.pure.} = object
|
||||
Path* = ref object
|
||||
impl*: ptr Path00
|
||||
|
||||
type
|
||||
RectangleInt00* {.pure.} = object
|
||||
x*: int32
|
||||
y*: int32
|
||||
width*: int32
|
||||
height*: int32
|
||||
RectangleInt* = ref object
|
||||
impl*: ptr RectangleInt00
|
||||
|
||||
proc cairo_image_surface_create*() {.
|
||||
importc: "cairo_image_surface_create", libprag.}
|
||||
|
||||
proc imageSurfaceCreate*() {.
|
||||
importc: "cairo_image_surface_create", libprag.}
|
||||
# === remaining symbols:
|
||||
12452
gintro/gdk.nim
12452
gintro/gdk.nim
File diff suppressed because it is too large
Load diff
1565
gintro/gdkpixbuf.nim
1565
gintro/gdkpixbuf.nim
File diff suppressed because it is too large
Load diff
21398
gintro/gio.nim
21398
gintro/gio.nim
File diff suppressed because it is too large
Load diff
10450
gintro/glib.nim
10450
gintro/glib.nim
File diff suppressed because it is too large
Load diff
|
|
@ -1,75 +0,0 @@
|
|||
# dependencies:
|
||||
# GLib-2.0
|
||||
# immediate dependencies:
|
||||
# GLib-2.0
|
||||
# libraries:
|
||||
# libgmodule-2.0.so.0
|
||||
{.deadCodeElim: on.}
|
||||
import glib
|
||||
const Lib* = "libgmodule-2.0.so.0"
|
||||
{.pragma: libprag, cdecl, dynlib: Lib.}
|
||||
let Quark = g_quark_from_static_string("NimGIQuark")
|
||||
|
||||
type
|
||||
Module00* {.pure.} = object
|
||||
Module* = ref object
|
||||
impl*: ptr Module00
|
||||
|
||||
proc g_module_close*(self: ptr Module00): gboolean {.
|
||||
importc: "g_module_close", libprag.}
|
||||
|
||||
proc close*(self: Module): bool =
|
||||
toBool(g_module_close(cast[ptr Module00](self.impl)))
|
||||
|
||||
proc g_module_make_resident*(self: ptr Module00) {.
|
||||
importc: "g_module_make_resident", libprag.}
|
||||
|
||||
proc makeResident*(self: Module) =
|
||||
g_module_make_resident(cast[ptr Module00](self.impl))
|
||||
|
||||
proc g_module_name*(self: ptr Module00): cstring {.
|
||||
importc: "g_module_name", libprag.}
|
||||
|
||||
proc name*(self: Module): string =
|
||||
let resul0 = g_module_name(cast[ptr Module00](self.impl))
|
||||
result = $resul0
|
||||
|
||||
proc g_module_symbol*(self: ptr Module00; symbolName: cstring; symbol: var pointer): gboolean {.
|
||||
importc: "g_module_symbol", libprag.}
|
||||
|
||||
proc symbol*(self: Module; symbolName: string; symbol: var pointer): bool =
|
||||
toBool(g_module_symbol(cast[ptr Module00](self.impl), cstring(symbolName), symbol))
|
||||
|
||||
proc g_module_build_path*(directory: cstring; moduleName: cstring): cstring {.
|
||||
importc: "g_module_build_path", libprag.}
|
||||
|
||||
proc buildPath*(directory: string; moduleName: string): string =
|
||||
let resul0 = g_module_build_path(cstring(directory), cstring(moduleName))
|
||||
result = $resul0
|
||||
cogfree(resul0)
|
||||
|
||||
proc g_module_error*(): cstring {.
|
||||
importc: "g_module_error", libprag.}
|
||||
|
||||
proc error*(): string =
|
||||
let resul0 = g_module_error()
|
||||
result = $resul0
|
||||
|
||||
proc g_module_supported*(): gboolean {.
|
||||
importc: "g_module_supported", libprag.}
|
||||
|
||||
proc supported*(): gboolean {.
|
||||
importc: "g_module_supported", libprag.}
|
||||
|
||||
type
|
||||
ModuleCheckInit* = proc (module: ptr Module00): cstring {.cdecl.}
|
||||
|
||||
type
|
||||
ModuleFlags* {.size: sizeof(cint), pure.} = enum
|
||||
lazy = 1
|
||||
local = 2
|
||||
mask = 3
|
||||
|
||||
type
|
||||
ModuleUnload* = proc (module: ptr Module00) {.cdecl.}
|
||||
# === remaining symbols:
|
||||
2162
gintro/gobject.nim
2162
gintro/gobject.nim
File diff suppressed because it is too large
Load diff
50546
gintro/gtk.nim
50546
gintro/gtk.nim
File diff suppressed because it is too large
Load diff
3884
gintro/pango.nim
3884
gintro/pango.nim
File diff suppressed because it is too large
Load diff
428
gintro/rsvg.nim
428
gintro/rsvg.nim
|
|
@ -1,428 +0,0 @@
|
|||
# dependencies:
|
||||
# cairo-1.0
|
||||
# GLib-2.0
|
||||
# Gio-2.0
|
||||
# GObject-2.0
|
||||
# GModule-2.0
|
||||
# GdkPixbuf-2.0
|
||||
# immediate dependencies:
|
||||
# cairo-1.0
|
||||
# Gio-2.0
|
||||
# GdkPixbuf-2.0
|
||||
# GObject-2.0
|
||||
# GLib-2.0
|
||||
# libraries:
|
||||
# librsvg-2.so.2
|
||||
{.deadCodeElim: on.}
|
||||
import cairo, glib, gio, gobject, gmodule, gdkpixbuf
|
||||
const Lib* = "librsvg-2.so.2"
|
||||
{.pragma: libprag, cdecl, dynlib: Lib.}
|
||||
let Quark = g_quark_from_static_string("NimGIQuark")
|
||||
|
||||
type
|
||||
DimensionData00* {.pure.} = object
|
||||
width*: int32
|
||||
height*: int32
|
||||
em*: cdouble
|
||||
ex*: cdouble
|
||||
DimensionData* = ref object
|
||||
impl*: ptr DimensionData00
|
||||
|
||||
type
|
||||
Error* {.size: sizeof(cint), pure.} = enum
|
||||
errorFailed = 0
|
||||
|
||||
type
|
||||
HandlePrivate00* {.pure.} = object
|
||||
HandlePrivate* = ref object
|
||||
impl*: ptr HandlePrivate00
|
||||
|
||||
type
|
||||
Handle* = ref object of gobject.Object
|
||||
Handle00* = object of gobject.Object00
|
||||
priv1: ptr HandlePrivate00
|
||||
abiPadding*: array[15, pointer]
|
||||
|
||||
proc rsvg_handle_new*(): ptr Handle00 {.
|
||||
importc: "rsvg_handle_new", libprag.}
|
||||
|
||||
proc newHandle*(): Handle =
|
||||
new(result, finalizeGObject)
|
||||
result.impl = rsvg_handle_new()
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc initHandle*[T](result: var T) =
|
||||
assert(result is Handle)
|
||||
new(result, finalizeGObject)
|
||||
result.impl = rsvg_handle_new()
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc rsvg_handle_new_from_data*(data: uint8Array; dataLen: uint64): ptr Handle00 {.
|
||||
importc: "rsvg_handle_new_from_data", libprag.}
|
||||
|
||||
proc newHandleFromData*(data: uint8Array; dataLen: uint64): Handle =
|
||||
new(result, finalizeGObject)
|
||||
result.impl = rsvg_handle_new_from_data(data, dataLen)
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc initHandleFromData*[T](result: var T; data: uint8Array; dataLen: uint64) =
|
||||
assert(result is Handle)
|
||||
new(result, finalizeGObject)
|
||||
result.impl = rsvg_handle_new_from_data(data, dataLen)
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc rsvg_handle_new_from_file*(fileName: cstring): ptr Handle00 {.
|
||||
importc: "rsvg_handle_new_from_file", libprag.}
|
||||
|
||||
proc newHandleFromFile*(fileName: string): Handle =
|
||||
new(result, finalizeGObject)
|
||||
result.impl = rsvg_handle_new_from_file(cstring(fileName))
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc initHandleFromFile*[T](result: var T; fileName: string) =
|
||||
assert(result is Handle)
|
||||
new(result, finalizeGObject)
|
||||
result.impl = rsvg_handle_new_from_file(cstring(fileName))
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc rsvg_handle_close*(self: ptr Handle00): gboolean {.
|
||||
importc: "rsvg_handle_close", libprag.}
|
||||
|
||||
proc close*(self: Handle): bool =
|
||||
toBool(rsvg_handle_close(cast[ptr Handle00](self.impl)))
|
||||
|
||||
proc rsvg_handle_get_base_uri*(self: ptr Handle00): cstring {.
|
||||
importc: "rsvg_handle_get_base_uri", libprag.}
|
||||
|
||||
proc getBaseUri*(self: Handle): string =
|
||||
let resul0 = rsvg_handle_get_base_uri(cast[ptr Handle00](self.impl))
|
||||
result = $resul0
|
||||
|
||||
proc baseUri*(self: Handle): string =
|
||||
let resul0 = rsvg_handle_get_base_uri(cast[ptr Handle00](self.impl))
|
||||
result = $resul0
|
||||
|
||||
proc rsvg_handle_get_dimensions*(self: ptr Handle00; dimensionData: var DimensionData00) {.
|
||||
importc: "rsvg_handle_get_dimensions", libprag.}
|
||||
|
||||
proc getDimensions*(self: ptr Handle00; dimensionData: var DimensionData00) {.
|
||||
importc: "rsvg_handle_get_dimensions", libprag.}
|
||||
|
||||
proc dimensions*(self: ptr Handle00; dimensionData: var DimensionData00) {.
|
||||
importc: "rsvg_handle_get_dimensions", libprag.}
|
||||
|
||||
proc rsvg_handle_get_dimensions_sub*(self: ptr Handle00; dimensionData: var DimensionData00;
|
||||
id: cstring): gboolean {.
|
||||
importc: "rsvg_handle_get_dimensions_sub", libprag.}
|
||||
|
||||
proc getDimensionsSub*(self: ptr Handle00; dimensionData: var DimensionData00;
|
||||
id: cstring): gboolean {.
|
||||
importc: "rsvg_handle_get_dimensions_sub", libprag.}
|
||||
|
||||
proc dimensionsSub*(self: ptr Handle00; dimensionData: var DimensionData00;
|
||||
id: cstring): gboolean {.
|
||||
importc: "rsvg_handle_get_dimensions_sub", libprag.}
|
||||
|
||||
proc rsvg_handle_get_pixbuf*(self: ptr Handle00): ptr gdkpixbuf.Pixbuf00 {.
|
||||
importc: "rsvg_handle_get_pixbuf", libprag.}
|
||||
|
||||
proc getPixbuf*(self: Handle): gdkpixbuf.Pixbuf =
|
||||
let gobj = rsvg_handle_get_pixbuf(cast[ptr Handle00](self.impl))
|
||||
if g_object_get_qdata(gobj, Quark) != nil:
|
||||
result = cast[gdkpixbuf.Pixbuf](g_object_get_qdata(gobj, Quark))
|
||||
assert(result.impl == gobj)
|
||||
else:
|
||||
new(result, finalizeGObject)
|
||||
result.impl = gobj
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc pixbuf*(self: Handle): gdkpixbuf.Pixbuf =
|
||||
let gobj = rsvg_handle_get_pixbuf(cast[ptr Handle00](self.impl))
|
||||
if g_object_get_qdata(gobj, Quark) != nil:
|
||||
result = cast[gdkpixbuf.Pixbuf](g_object_get_qdata(gobj, Quark))
|
||||
assert(result.impl == gobj)
|
||||
else:
|
||||
new(result, finalizeGObject)
|
||||
result.impl = gobj
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc rsvg_handle_get_pixbuf_sub*(self: ptr Handle00; id: cstring): ptr gdkpixbuf.Pixbuf00 {.
|
||||
importc: "rsvg_handle_get_pixbuf_sub", libprag.}
|
||||
|
||||
proc getPixbufSub*(self: Handle; id: string): gdkpixbuf.Pixbuf =
|
||||
let gobj = rsvg_handle_get_pixbuf_sub(cast[ptr Handle00](self.impl), cstring(id))
|
||||
if g_object_get_qdata(gobj, Quark) != nil:
|
||||
result = cast[gdkpixbuf.Pixbuf](g_object_get_qdata(gobj, Quark))
|
||||
assert(result.impl == gobj)
|
||||
else:
|
||||
new(result, finalizeGObject)
|
||||
result.impl = gobj
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc pixbufSub*(self: Handle; id: string): gdkpixbuf.Pixbuf =
|
||||
let gobj = rsvg_handle_get_pixbuf_sub(cast[ptr Handle00](self.impl), cstring(id))
|
||||
if g_object_get_qdata(gobj, Quark) != nil:
|
||||
result = cast[gdkpixbuf.Pixbuf](g_object_get_qdata(gobj, Quark))
|
||||
assert(result.impl == gobj)
|
||||
else:
|
||||
new(result, finalizeGObject)
|
||||
result.impl = gobj
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc rsvg_handle_has_sub*(self: ptr Handle00; id: cstring): gboolean {.
|
||||
importc: "rsvg_handle_has_sub", libprag.}
|
||||
|
||||
proc hasSub*(self: Handle; id: string): bool =
|
||||
toBool(rsvg_handle_has_sub(cast[ptr Handle00](self.impl), cstring(id)))
|
||||
|
||||
proc rsvg_handle_read_stream_sync*(self: ptr Handle00; stream: ptr gio.InputStream00;
|
||||
cancellable: ptr gio.Cancellable00): gboolean {.
|
||||
importc: "rsvg_handle_read_stream_sync", libprag.}
|
||||
|
||||
proc readStreamSync*(self: Handle; stream: gio.InputStream; cancellable: gio.Cancellable): bool =
|
||||
toBool(rsvg_handle_read_stream_sync(cast[ptr Handle00](self.impl), cast[ptr gio.InputStream00](stream.impl), cast[ptr gio.Cancellable00](cancellable.impl)))
|
||||
|
||||
proc rsvg_handle_render_cairo*(self: ptr Handle00; cr: ptr cairo.Context00): gboolean {.
|
||||
importc: "rsvg_handle_render_cairo", libprag.}
|
||||
|
||||
proc renderCairo*(self: Handle; cr: cairo.Context): bool =
|
||||
toBool(rsvg_handle_render_cairo(cast[ptr Handle00](self.impl), cast[ptr cairo.Context00](cr.impl)))
|
||||
|
||||
proc rsvg_handle_render_cairo_sub*(self: ptr Handle00; cr: ptr cairo.Context00; id: cstring): gboolean {.
|
||||
importc: "rsvg_handle_render_cairo_sub", libprag.}
|
||||
|
||||
proc renderCairoSub*(self: Handle; cr: cairo.Context; id: string): bool =
|
||||
toBool(rsvg_handle_render_cairo_sub(cast[ptr Handle00](self.impl), cast[ptr cairo.Context00](cr.impl), cstring(id)))
|
||||
|
||||
proc rsvg_handle_set_base_gfile*(self: ptr Handle00; baseFile: ptr gio.File00) {.
|
||||
importc: "rsvg_handle_set_base_gfile", libprag.}
|
||||
|
||||
proc setBaseGfile*(self: Handle; baseFile: gio.File) =
|
||||
rsvg_handle_set_base_gfile(cast[ptr Handle00](self.impl), cast[ptr gio.File00](baseFile.impl))
|
||||
|
||||
proc `baseGfile=`*(self: Handle; baseFile: gio.File) =
|
||||
rsvg_handle_set_base_gfile(cast[ptr Handle00](self.impl), cast[ptr gio.File00](baseFile.impl))
|
||||
|
||||
proc rsvg_handle_set_base_uri*(self: ptr Handle00; baseUri: cstring) {.
|
||||
importc: "rsvg_handle_set_base_uri", libprag.}
|
||||
|
||||
proc setBaseUri*(self: Handle; baseUri: string) =
|
||||
rsvg_handle_set_base_uri(cast[ptr Handle00](self.impl), cstring(baseUri))
|
||||
|
||||
proc `baseUri=`*(self: Handle; baseUri: string) =
|
||||
rsvg_handle_set_base_uri(cast[ptr Handle00](self.impl), cstring(baseUri))
|
||||
|
||||
proc rsvg_handle_set_dpi*(self: ptr Handle00; dpi: cdouble) {.
|
||||
importc: "rsvg_handle_set_dpi", libprag.}
|
||||
|
||||
proc setDpi*(self: Handle; dpi: cdouble) =
|
||||
rsvg_handle_set_dpi(cast[ptr Handle00](self.impl), dpi)
|
||||
|
||||
proc `dpi=`*(self: Handle; dpi: cdouble) =
|
||||
rsvg_handle_set_dpi(cast[ptr Handle00](self.impl), dpi)
|
||||
|
||||
proc rsvg_handle_set_dpi_x_y*(self: ptr Handle00; dpiX: cdouble; dpiY: cdouble) {.
|
||||
importc: "rsvg_handle_set_dpi_x_y", libprag.}
|
||||
|
||||
proc setDpiXY*(self: Handle; dpiX: cdouble; dpiY: cdouble) =
|
||||
rsvg_handle_set_dpi_x_y(cast[ptr Handle00](self.impl), dpiX, dpiY)
|
||||
|
||||
proc rsvg_handle_write*(self: ptr Handle00; buf: uint8Array; count: uint64): gboolean {.
|
||||
importc: "rsvg_handle_write", libprag.}
|
||||
|
||||
proc write*(self: Handle; buf: uint8Array; count: uint64): bool =
|
||||
toBool(rsvg_handle_write(cast[ptr Handle00](self.impl), buf, count))
|
||||
|
||||
type
|
||||
HandleFlag* {.size: sizeof(cint), pure.} = enum
|
||||
flagUnlimited = 1
|
||||
flagKeepImageData = 2
|
||||
|
||||
HandleFlags* {.size: sizeof(cint).} = set[HandleFlag]
|
||||
|
||||
proc rsvg_handle_new_from_gfile_sync*(file: ptr gio.File00; flags: HandleFlags; cancellable: ptr gio.Cancellable00): ptr Handle00 {.
|
||||
importc: "rsvg_handle_new_from_gfile_sync", libprag.}
|
||||
|
||||
proc newHandleFromGfileSync*(file: gio.File; flags: HandleFlags; cancellable: gio.Cancellable): Handle =
|
||||
new(result, finalizeGObject)
|
||||
result.impl = rsvg_handle_new_from_gfile_sync(cast[ptr gio.File00](file.impl), flags, cast[ptr gio.Cancellable00](cancellable.impl))
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc initHandleFromGfileSync*[T](result: var T; file: gio.File; flags: HandleFlags; cancellable: gio.Cancellable) =
|
||||
assert(result is Handle)
|
||||
new(result, finalizeGObject)
|
||||
result.impl = rsvg_handle_new_from_gfile_sync(cast[ptr gio.File00](file.impl), flags, cast[ptr gio.Cancellable00](cancellable.impl))
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc rsvg_handle_new_from_stream_sync*(inputStream: ptr gio.InputStream00; baseFile: ptr gio.File00;
|
||||
flags: HandleFlags; cancellable: ptr gio.Cancellable00): ptr Handle00 {.
|
||||
importc: "rsvg_handle_new_from_stream_sync", libprag.}
|
||||
|
||||
proc newHandleFromStreamSync*(inputStream: gio.InputStream; baseFile: gio.File;
|
||||
flags: HandleFlags; cancellable: gio.Cancellable): Handle =
|
||||
new(result, finalizeGObject)
|
||||
result.impl = rsvg_handle_new_from_stream_sync(cast[ptr gio.InputStream00](inputStream.impl), cast[ptr gio.File00](baseFile.impl), flags, cast[ptr gio.Cancellable00](cancellable.impl))
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc initHandleFromStreamSync*[T](result: var T; inputStream: gio.InputStream; baseFile: gio.File;
|
||||
flags: HandleFlags; cancellable: gio.Cancellable) =
|
||||
assert(result is Handle)
|
||||
new(result, finalizeGObject)
|
||||
result.impl = rsvg_handle_new_from_stream_sync(cast[ptr gio.InputStream00](inputStream.impl), cast[ptr gio.File00](baseFile.impl), flags, cast[ptr gio.Cancellable00](cancellable.impl))
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc rsvg_handle_new_with_flags*(flags: HandleFlags): ptr Handle00 {.
|
||||
importc: "rsvg_handle_new_with_flags", libprag.}
|
||||
|
||||
proc newHandleWithFlags*(flags: HandleFlags): Handle =
|
||||
new(result, finalizeGObject)
|
||||
result.impl = rsvg_handle_new_with_flags(flags)
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
proc initHandleWithFlags*[T](result: var T; flags: HandleFlags) =
|
||||
assert(result is Handle)
|
||||
new(result, finalizeGObject)
|
||||
result.impl = rsvg_handle_new_with_flags(flags)
|
||||
GC_ref(result)
|
||||
discard g_object_ref_sink(result.impl)
|
||||
g_object_add_toggle_ref(result.impl, toggleNotify, addr(result[]))
|
||||
g_object_unref(result.impl)
|
||||
assert(g_object_get_qdata(result.impl, Quark) == nil)
|
||||
g_object_set_qdata(result.impl, Quark, addr(result[]))
|
||||
|
||||
type
|
||||
PositionData00* {.pure.} = object
|
||||
x*: int32
|
||||
y*: int32
|
||||
PositionData* = ref object
|
||||
impl*: ptr PositionData00
|
||||
|
||||
proc rsvg_handle_get_position_sub*(self: ptr Handle00; positionData: var PositionData00;
|
||||
id: cstring): gboolean {.
|
||||
importc: "rsvg_handle_get_position_sub", libprag.}
|
||||
|
||||
proc getPositionSub*(self: ptr Handle00; positionData: var PositionData00;
|
||||
id: cstring): gboolean {.
|
||||
importc: "rsvg_handle_get_position_sub", libprag.}
|
||||
|
||||
proc positionSub*(self: ptr Handle00; positionData: var PositionData00;
|
||||
id: cstring): gboolean {.
|
||||
importc: "rsvg_handle_get_position_sub", libprag.}
|
||||
|
||||
type
|
||||
HandleClass00* {.pure.} = object
|
||||
parent*: gobject.ObjectClass00
|
||||
abiPadding*: array[15, pointer]
|
||||
HandleClass* = ref object
|
||||
impl*: ptr HandleClass00
|
||||
|
||||
const MAJOR_VERSION* = 2'i32
|
||||
|
||||
const MICRO_VERSION* = 17'i32
|
||||
|
||||
const MINOR_VERSION* = 40'i32
|
||||
|
||||
const VERSION* = "2.40.17"
|
||||
|
||||
proc rsvg_cleanup*() {.
|
||||
importc: "rsvg_cleanup", libprag.}
|
||||
|
||||
proc cleanup*() {.
|
||||
importc: "rsvg_cleanup", libprag.}
|
||||
|
||||
proc rsvg_error_quark*(): uint32 {.
|
||||
importc: "rsvg_error_quark", libprag.}
|
||||
|
||||
proc rsvg_set_default_dpi*(dpi: cdouble) {.
|
||||
importc: "rsvg_set_default_dpi", libprag.}
|
||||
|
||||
proc setDefaultDpi*(dpi: cdouble) {.
|
||||
importc: "rsvg_set_default_dpi", libprag.}
|
||||
|
||||
proc `defaultDpi=`*(dpi: cdouble) {.
|
||||
importc: "rsvg_set_default_dpi", libprag.}
|
||||
|
||||
proc rsvg_set_default_dpi_x_y*(dpiX: cdouble; dpiY: cdouble) {.
|
||||
importc: "rsvg_set_default_dpi_x_y", libprag.}
|
||||
|
||||
proc setDefaultDpiXY*(dpiX: cdouble; dpiY: cdouble) {.
|
||||
importc: "rsvg_set_default_dpi_x_y", libprag.}
|
||||
|
||||
proc `defaultDpiXY=`*(dpiX: cdouble; dpiY: cdouble) {.
|
||||
importc: "rsvg_set_default_dpi_x_y", libprag.}
|
||||
# === remaining symbols:
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
# dependencies:
|
||||
# immediate dependencies:
|
||||
# libraries:
|
||||
#
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
const Lib* = ""
|
||||
{.pragma: libprag, cdecl, dynlib: Lib.}
|
||||
|
||||
type
|
||||
Display00* {.pure.} = object
|
||||
Display* = ref object
|
||||
impl*: ptr Display00
|
||||
|
||||
type
|
||||
Screen00* {.pure.} = object
|
||||
Screen* = ref object
|
||||
impl*: ptr Screen00
|
||||
|
||||
type
|
||||
Visual00* {.pure.} = object
|
||||
Visual* = ref object
|
||||
impl*: ptr Visual00
|
||||
|
||||
type
|
||||
XEvent00* = object {.union.}
|
||||
XEvent* = ref object
|
||||
impl*: ptr XEvent00
|
||||
|
||||
type
|
||||
XConfigureEvent00* {.pure.} = object
|
||||
XConfigureEvent* = ref object
|
||||
impl*: ptr XConfigureEvent00
|
||||
|
||||
type
|
||||
XImage00* {.pure.} = object
|
||||
XImage* = ref object
|
||||
impl*: ptr XImage00
|
||||
|
||||
type
|
||||
XFontStruct00* {.pure.} = object
|
||||
XFontStruct* = ref object
|
||||
impl*: ptr XFontStruct00
|
||||
|
||||
type
|
||||
XTrapezoid00* {.pure.} = object
|
||||
XTrapezoid* = ref object
|
||||
impl*: ptr XTrapezoid00
|
||||
|
||||
type
|
||||
XVisualInfo00* {.pure.} = object
|
||||
XVisualInfo* = ref object
|
||||
impl*: ptr XVisualInfo00
|
||||
|
||||
type
|
||||
XWindowAttributes00* {.pure.} = object
|
||||
XWindowAttributes* = ref object
|
||||
impl*: ptr XWindowAttributes00
|
||||
|
||||
proc XOpenDisplay*() {.
|
||||
importc: "XOpenDisplay", libprag.}
|
||||
|
||||
proc openDisplay*() {.
|
||||
importc: "XOpenDisplay", libprag.}
|
||||
# === remaining symbols:
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# High level gobject-introspection based GTK3 bindings for the Nim programming language
|
||||
# v 0.1 2017-JUL-12
|
||||
# v 0.1 2017-JUL-21
|
||||
# (c) S. Salewski 2017
|
||||
|
||||
# https://wiki.gnome.org/Projects/GObjectIntrospection
|
||||
|
|
@ -108,6 +108,8 @@ var fixedProcNames = newTable[string, string]()
|
|||
var mangledNames = newTable[string, string]()
|
||||
var gdkKeys = newTable[string, seq[string]]()
|
||||
var allSyms: HashSet[string]
|
||||
var provInt = newTable[string, seq[string]]()
|
||||
var interfaceProvider = newTable[string, seq[string]]()
|
||||
var priList: seq[string]
|
||||
var knownSyms: HashSet[string]
|
||||
var suppressType = false
|
||||
|
|
@ -352,6 +354,17 @@ proc genP(info: GICallableInfo; genProxy = false; binfo: GIBaseInfo = nil): (str
|
|||
if callerAlloc.contains(genRec(t, true, true)):
|
||||
userAlloc = true
|
||||
str = genRec(t, true)
|
||||
|
||||
if genProxy:
|
||||
let tag = gTypeInfoGetTag(t)
|
||||
if tag == GITypeTag.INTERFACE:
|
||||
let iface = gTypeInfoGetInterface(t)
|
||||
if gBaseInfoGetType(iface) == GIInfoType.INTERFACE:
|
||||
if interfaceProvider.contains(str):
|
||||
let provider = interfaceProvider[str]
|
||||
for i in provider: discard mangleType(i)
|
||||
str = str & " | " & provider.join(" | ")
|
||||
|
||||
let name = mangleName(gBaseInfoGetName(arg))
|
||||
if isProxyCandidate(t) and not gArgInfoIsCallerAllocates(arg) and not userAlloc:
|
||||
arglist.add("cast[" & genRec(t, false) & "](" & name & ".impl)")
|
||||
|
|
@ -385,7 +398,7 @@ proc genP(info: GICallableInfo; genProxy = false; binfo: GIBaseInfo = nil): (str
|
|||
resul.add("\n ")
|
||||
if not genProxy and gCallableInfoCanThrowGerror(info):
|
||||
if resul[^1] != '(': resul.add("; ")
|
||||
resul.add("error: GError = nil")
|
||||
resul.add("error: ptr ptr Error00 = nil")
|
||||
resul.add(')')
|
||||
arglist.add(')')
|
||||
var ret = gCallableInfoGetReturnType(info)
|
||||
|
|
@ -412,6 +425,7 @@ proc genP(info: GICallableInfo; genProxy = false; binfo: GIBaseInfo = nil): (str
|
|||
proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) =
|
||||
assert(isCallableInfo(mInfo))
|
||||
assert(isFunctionInfo(mInfo))
|
||||
|
||||
var plist, arglist: string
|
||||
var replist: TableRef[string, string]
|
||||
let p = methodBuffer.getPosition
|
||||
|
|
@ -464,6 +478,7 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) =
|
|||
if gBaseInfoGetType(iface) == GIInfoType.Object:
|
||||
isGObject = true
|
||||
(plist, arglist, replist) = genP(mInfo, true, info)
|
||||
|
||||
if (gFunctionInfoGetFlags(mInfo).int and GIFunctionInfoFlags.IS_CONSTRUCTOR.int) != 0:
|
||||
if info != nil:
|
||||
asym = asym.replace("new", "new" & manglename(gBaseInfoGetName(info)))
|
||||
|
|
@ -478,6 +493,9 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) =
|
|||
hhh = hhh.replace("new", "init")
|
||||
hhh = hhh.replace("*(", "*[T](result: var T" & semi)
|
||||
methodBuffer.writeLine(hhh & " =")
|
||||
if gCallableInfoCanThrowGerror(minfo):
|
||||
methodBuffer.writeLine(" var gerror: ptr Error00")
|
||||
if i == 0: arglist.insert(", addr gerror", arglist.high)
|
||||
if i > 0:
|
||||
methodBuffer.writeLine(" assert(result is $1)" % [manglename(gBaseInfoGetName(info))])
|
||||
assert(replist.len == 0)
|
||||
|
|
@ -503,6 +521,9 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) =
|
|||
if info != nil:
|
||||
asym = asym.replace("new", "new" & manglename(gBaseInfoGetName(info)))
|
||||
methodBuffer.writeLine("\nproc " & asym & EM & plist & " =")
|
||||
if gCallableInfoCanThrowGerror(minfo):
|
||||
methodBuffer.writeLine(" var gerror: ptr Error00")
|
||||
arglist.insert(", addr gerror", arglist.high)
|
||||
for k, v in replist:
|
||||
let kk = if k[0] == '`': k[1 .. ^2] else: k
|
||||
methodBuffer.writeLine(" var $1_00 = $2($3)" % [kk, v, k])
|
||||
|
|
@ -533,6 +554,9 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) =
|
|||
if asym == "newFromStreamAsync" and sym.contains("gdk_pixbuf_animation_new"):
|
||||
asym = "newAnimationFromStreamAsync"
|
||||
methodBuffer.writeLine("\nproc " & asym & EM & plist & " =")
|
||||
if gCallableInfoCanThrowGerror(minfo):
|
||||
methodBuffer.writeLine(" var gerror: ptr Error00")
|
||||
arglist.insert(", addr gerror", arglist.high)
|
||||
for k, v in replist:
|
||||
let kk = if k[0] == '`': k[1 .. ^2] else: k
|
||||
methodBuffer.writeLine(" var $1_00 = $2($3)" % [kk, v, k])
|
||||
|
|
@ -543,7 +567,7 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) =
|
|||
assert(gCallableInfoGetCallerOwns(minfo) in {GITransfer.EVERYTHING, GITransfer.NOTHING})
|
||||
if gCallableInfoGetCallerOwns(minfo) == GITransfer.EVERYTHING:
|
||||
methodBuffer.writeLine(" cogfree(resul0)")
|
||||
elif replist.len > 0 and genRec(ret2) != "void":
|
||||
elif (replist.len > 0 or gCallableInfoCanThrowGerror(minfo)) and genRec(ret2) != "void":
|
||||
methodBuffer.write(" result = ")
|
||||
if ct2nt.contains(genRec(ret2)):
|
||||
methodBuffer.writeLine(ct3nt(genRec(ret2)) & '(' & sym & arglist & ')')
|
||||
|
|
@ -556,6 +580,13 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) =
|
|||
for k, v in replist:
|
||||
let kk = if k[0] == '`': k[1 .. ^2] else: k
|
||||
methodBuffer.writeLine(" $1 = $2($3_00)" % [k, ct3nt(v), kk])
|
||||
|
||||
if gCallableInfoCanThrowGerror(minfo):
|
||||
methodBuffer.writeLine(" if gerror != nil:")
|
||||
methodBuffer.writeLine(" let msg = $gerror.message")
|
||||
methodBuffer.writeLine(" g_error_free(gerror)")
|
||||
methodBuffer.writeLine(" raise newException(GException, msg)")
|
||||
|
||||
else:
|
||||
(plist, arglist, replist) = genP(mInfo, genProxy, info)
|
||||
if asym != "errorQuark" and asym != "getPlugin" and asym != "quark":
|
||||
|
|
@ -564,9 +595,9 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) =
|
|||
if sym == "gtk_window_set_default_size":
|
||||
methodBuffer.writeLine("\nproc `defaultSize=`*(self: Window; dim: tuple[width: int; height: int]) =")
|
||||
methodBuffer.writeLine(" gtk_window_set_default_size(cast[ptr Window00](self.impl), int32(dim[0]), int32(dim[1]))")
|
||||
|
||||
except UndefEx:
|
||||
echo "delay ", sym
|
||||
echo "delay ", sym#, delayedMethods.len
|
||||
processedFunctions.excl(sym)
|
||||
delayedMethods.add((info, minfo))
|
||||
methodBuffer.cut(p)
|
||||
|
||||
|
|
@ -687,6 +718,15 @@ proc writeEnum(info: GIEnumInfo) =
|
|||
|
||||
proc writeObj(info: GIObjectInfo) =
|
||||
assert(gBaseInfoGetType(info) == GIInfoType.OBJECT)
|
||||
|
||||
let ninterfaces = info.gObjectInfoGetNInterfaces
|
||||
#if ninterfaces > 0:
|
||||
# stdout.write "||| ", gBaseInfoGetName(info), " has ", ninterfaces, " interf: "
|
||||
# for i in 0 .. < ninterfaces:
|
||||
# stdout.write " ", gBaseInfoGetName(info.gObjectInfoGetInterface(i)), ","
|
||||
# stdout.writeLine("")
|
||||
# stdout.flushFile
|
||||
|
||||
let class = gObjectInfoGetClassStruct(info)
|
||||
let n = info.gObjectInfoGetNFields
|
||||
let parent = gObjectInfoGetParent(info) # nil for Object of module gobject!
|
||||
|
|
@ -759,9 +799,9 @@ proc writeObj(info: GIObjectInfo) =
|
|||
###output.writeLine(" echo \"GC_unref(cast[RootRef](data)\"")
|
||||
###output.writeLine(" echo \"toggleNotify\"")
|
||||
###output.writeLine(" echo obj.ref_count")
|
||||
methodBuffer.writeLine("\nproc finalizeGObject*[T](o: T) =")
|
||||
output.writeLine("\nproc finalizeGObject*[T](o: T) =")
|
||||
###methodBuffer.writeLine(" echo(\"finalizeGObject\")")
|
||||
methodBuffer.writeLine(" g_object_remove_toggle_ref(o.impl, toggleNotify, addr(o[]))")
|
||||
output.writeLine(" g_object_remove_toggle_ref(o.impl, toggleNotify, addr(o[]))")
|
||||
|
||||
let numsig = info.gObjectInfoGetNSignals
|
||||
if numsig > 0: output.writeLine("")
|
||||
|
|
@ -897,6 +937,9 @@ proc init* =
|
|||
var argv: cstringArray = nil
|
||||
gtk_init(argc, argv)
|
||||
|
||||
proc loadFromData*(self: CssProvider; data: cstring): bool =
|
||||
loadFromData(self, uint8Array(data), -1)
|
||||
|
||||
import macros, strutils
|
||||
|
||||
var ProcID: int
|
||||
|
|
@ -961,6 +1004,8 @@ proc main(namespace: string) =
|
|||
ct = initCountTable[string]()
|
||||
var delayedSyms = newSeq[GIBaseInfo]()
|
||||
allSyms = initSet[string]()
|
||||
provInt.clear
|
||||
interfaceProvider.clear
|
||||
var ig = initSet[string]()
|
||||
knownSyms = initSet[string]()
|
||||
let gi = gIrepositoryGetDefault()
|
||||
|
|
@ -1008,7 +1053,7 @@ proc main(namespace: string) =
|
|||
output.writeLine("type\n VaClosureMarshal* = pointer")
|
||||
output.writeLine("type\n TypePlugin00* = object")
|
||||
elif namespace == "GLib":
|
||||
output.writeLine("type\n GError* = pointer")
|
||||
output.writeLine("type\n GException* = object of Exception")
|
||||
output.writeLine("type\n OptionEntry00Array* = pointer")
|
||||
output.writeLine("type\n int8Array* = pointer")
|
||||
output.writeLine("type\n uintArray* = pointer")
|
||||
|
|
@ -1091,6 +1136,36 @@ proc main(namespace: string) =
|
|||
for i in s:
|
||||
if gBaseInfoGetType(i) == GIInfoType.OBJECT or gBaseInfoGetType(i) == GIInfoType.INTERFACE or gBaseInfoGetType(i) == GIInfoType.STRUCT or gBaseInfoGetType(i) == GIInfoType.UNION or isEnumInfo(i) or isCallbackInfo(i):
|
||||
allSyms.incl(mangleName(gBaseInfoGetName(i)))
|
||||
|
||||
for i in 0 .. s.high:
|
||||
if namespace == "GLib" and gBaseInfoGetType(s[i]) == GIInfoType.STRUCT and gBaseInfoGetName(s[i]) == "Error":
|
||||
let h = s[i]
|
||||
s.delete(i, i)
|
||||
s.insert([h])
|
||||
break
|
||||
|
||||
for info in s:
|
||||
if gBaseInfoGetType(info) == GIInfoType.OBJECT:
|
||||
let ninterfaces = info.gObjectInfoGetNInterfaces
|
||||
if ninterfaces > 0:
|
||||
var interf = newSeq[string]()
|
||||
let name = $gBaseInfoGetName(info)
|
||||
|
||||
for i in 0 .. < ninterfaces:
|
||||
interf.add($gBaseInfoGetName(info.gObjectInfoGetInterface(i)))
|
||||
|
||||
if provInt.contains(name):
|
||||
assert false
|
||||
else:
|
||||
provInt[name] = interf
|
||||
|
||||
for obj, ifaces in provInt:
|
||||
for i in ifaces:
|
||||
if not interfaceProvider.contains(i):
|
||||
interfaceProvider[i] = @[obj]
|
||||
else:
|
||||
interfaceProvider[i].add(obj)
|
||||
|
||||
if namespace == "Gdk": # special care for gdk keys due to nim's style insensitivity!
|
||||
for i in s:
|
||||
var h = $gBaseInfoGetName(i)
|
||||
|
|
@ -1173,6 +1248,7 @@ proc main(namespace: string) =
|
|||
for k in t:
|
||||
knownSyms.excl(mangleName(gBaseInfoGetName(k)))
|
||||
output.setPosition(pos)
|
||||
assert delayedMethods.len >= x
|
||||
delayedMethods.setLen(x)
|
||||
suppressType = false
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue