New feature: a GUI proxy for BaCon
Jun 25, 2020 20:31:21 GMT 1
Post by Pjot on Jun 25, 2020 20:31:21 GMT 1
Gents,
The memory usage in GTK is very choppy. GTK is very lazy freeing structures etc., but overall, the memory consumption should not keep growing.
So I tried to find another way to display an inline SVG, below my sample code, which displays an SVG in a GtkImage widget. I am not sure if it helps for your programs, but maybe you could try it.
HTH
Peter
The memory usage in GTK is very choppy. GTK is very lazy freeing structures etc., but overall, the memory consumption should not keep growing.
So I tried to find another way to display an inline SVG, below my sample code, which displays an SVG in a GtkImage widget. I am not sure if it helps for your programs, but maybe you could try it.
HTH
Peter
OPTION GUI TRUE
PRAGMA GUI gtk3
' svg for icon and gui
kitty$ = "<svg width='128' height='128' viewBox='0 0 352 352'>" \
"<g fill='black'>" \
"<path d='M18 4C2 12-2 104 12 165l2 12-2 10c-5 24-7 56-4 65 11 30 66 " \
"75 112 90 69 22 143 1 198-55 28-30 31-46 20-102l-2-13 2-15c13-71 " \
"7-154-12-154s-69 27-107 57l-11 9-22-1c-13 0-27 0-33 1l-11 1-11-9C85 " \
"25 32-2 18 4zm45 57c9 4 33 17 34 19l-8 4c-17 8-34 21-45 33-2 3-5 6-5 " \
"6-3 0 1-54 5-62 2-6 3-6 19 0zm240-3c4 4 7 26 7 " \
"49v14l-5-5c-13-15-31-27-52-36-4-1 23-16 39-21 9-3 9-3 11-1zM92 " \
"173h2l-3 5c-8 16-3 56 7 51 8-4 9-32 2-53 0-2 0-2 7 1 11 6 19 15 23 " \
"27s4 11-3 18c-26 28-69 16-78-22-4-14 25-32 43-27zm181 0c13 2 30 15 30 " \
"22 0 38-52 56-79 28l-6-7 1-5c2-14 13-28 25-34 8-4 7-4 5 3-5 15-3 45 4 " \
"49 9 6 14-35 7-51-3-6 0-7 13-5zm-89 26c6 4 12 10 24 27 5 7 12 15 15 " \
"18 12 12 42 26 86 42 7 2-49 37-77 48-59 23-119 10-183-41-9-7-9-7 0-10 " \
"56-20 77-33 95-58 18-26 28-33 40-26z'/> " \
"<path d='M161 247c-14 3-11 22 6 32 2 1 5 2 5 3 0 0-3 7-5 11-11 16-36 " \
"15-48-1-4-5-3-2 1 5 8 14 27 18 45 9 1 0 1 1 1 3 0 16 17 18 19 2v-5l6 " \
"3c15 6 32 1 40-12 5-7 5-10 0-4-14 18-43 14-50-7l-2-4c0-1 3-2 5-3 12-7 " \
"19-24 12-29-6-4-24-6-35-3z'/> " \
"</g>" \
"</svg>"
id = GUIDEFINE(" \
{ type=WINDOW name=window callback=delete-event title=\"GtkImage demo\" } \
{ type=BOX name=box parent=window orientation=GTK_ORIENTATION_VERTICAL } \
{ type=IMAGE name=image parent=box width-request=350 height-request=350 } \
{ type=BUTTON_BOX name=bbox parent=box layout-style=GTK_BUTTONBOX_END } \
{ type=BUTTON name=exit parent=bbox callback=clicked label=\"Exit\" }")
CALL Draw
WHILE TRUE
event$ = GUIEVENT$(id)
SELECT event$
CASE "window"
BREAK
CASE "exit"
BREAK
ENDSELECT
WEND
SUB Draw
LOCAL stream TYPE GInputStream*
LOCAL pixbuf TYPE GdkPixbuf*
stream = g_memory_input_stream_new_from_data(kitty$, -1, g_free)
pixbuf = gdk_pixbuf_new_from_stream(stream, NULL, NULL)
CALL gtk_image_set_from_pixbuf(GTK_IMAGE(GUIWIDGET(id, "image")), pixbuf)
CALL g_object_unref(pixbuf)
CALL g_input_stream_close(stream, NULL, NULL)
ENDSUB