support for GTK 3.98.3
This commit is contained in:
parent
e20c95abf5
commit
a725770ff0
15 changed files with 386 additions and 193 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# app0.nim -- minimal application style example
|
||||
# nim c app0.nim
|
||||
import gintro/[gtk, glib, gobject, gio]
|
||||
import gintro/[gtk, gobject, gio]
|
||||
|
||||
proc appActivate(app: Application) =
|
||||
let window = newApplicationWindow(app)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# https://developer.gnome.org/gtk3/stable/ch01s03.html
|
||||
# builder.nim -- application style example using builder/glade xml file for user interface
|
||||
# nim c builder.nim
|
||||
import gintro/[gtk, glib, gobject, gio]
|
||||
import gintro/[gtk, gobject, gio]
|
||||
|
||||
proc hello(b: Button; msg: string) =
|
||||
echo "Hello", msg
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# This example shows how to apply a CellDataFunc to a GtkTreeView
|
||||
# C example code was provided by A.Krause in chapter 8 of his book
|
||||
import gintro/[gtk, gobject, glib]
|
||||
import gintro/[gtk, gobject]
|
||||
|
||||
const
|
||||
Color = 0
|
||||
|
|
|
|||
55
examples/gtk3/colorpickers.nim
Normal file
55
examples/gtk3/colorpickers.nim
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
# nim c button.nim
|
||||
import gintro/[gtk, glib, gobject, gio, cairo]
|
||||
from math import Tau
|
||||
|
||||
type
|
||||
ColorPicker = ref object of Button
|
||||
c: array[4, float]
|
||||
|
||||
proc newColorPicker(c: array[4, float]): ColorPicker =
|
||||
result = newButton(ColorPicker)
|
||||
result.c = c
|
||||
|
||||
proc buttonClicked (button: ColorPicker) =
|
||||
#button.label = utf8Strreverse(button.label, -1)
|
||||
echo "clicked"
|
||||
|
||||
proc draw(b: ColorPicker; cr: cairo.Context): bool =
|
||||
echo "draw"
|
||||
let x = getAllocatedWidth(b).float / 2
|
||||
let y = getAllocatedHeight(b).float / 2
|
||||
cr.moveTo(x, y)
|
||||
cr.newPath
|
||||
cr.arc(x, y, 10, 0, math.Tau)
|
||||
cr.setSource(b.c)
|
||||
cr.setLineWidth(5)
|
||||
cr.stroke
|
||||
|
||||
proc appActivate (app: Application) =
|
||||
let window = newApplicationWindow(app)
|
||||
window.title = "GNOME Button"
|
||||
window.defaultSize = (250, 50)
|
||||
let box = newBox(Orientation.horizontal, 0)
|
||||
var button = newColorPicker([1.0, 0, 0, 1])#newButton(ColorPicker)#"Click Me")
|
||||
box.add(button)
|
||||
button.connect("clicked", buttonClicked)
|
||||
button.connectAfter("draw", draw)
|
||||
button = newColorPicker([0.0, 0, 1, 1])#newButton(ColorPicker)#"Click Me")
|
||||
box.add(button)
|
||||
button.connect("clicked", buttonClicked)
|
||||
button.connectAfter("draw", draw)
|
||||
button = newColorPicker([0.0, 1, 0, 1])#newButton(ColorPicker)#"Click Me")
|
||||
box.add(button)
|
||||
button.connect("clicked", buttonClicked)
|
||||
button.connectAfter("draw", draw)
|
||||
window.add(box)
|
||||
|
||||
window.showAll
|
||||
|
||||
proc main =
|
||||
let app = newApplication("org.gtk.example")
|
||||
connect(app, "activate", appActivate)
|
||||
discard app.run
|
||||
|
||||
main()
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ type
|
|||
handlerID: uint64
|
||||
|
||||
proc newPosAdj: PosAdj =
|
||||
initAdjustment(result, 0, 0, 1, 1, 10, 1)
|
||||
newAdjustment(PosAdj, 0, 0, 1, 1, 10, 1)
|
||||
|
||||
type
|
||||
PDA_Data* = object
|
||||
|
|
@ -104,7 +104,7 @@ proc drawingAreaDrawCb(darea: DrawingArea; cr: Context; this: PDA): bool =
|
|||
if this.selecting:
|
||||
cr.rectangle(this.lastButtonDownPosX, this.lastButtonDownPosY,
|
||||
this.zoomRectX1 - this.lastButtonDownPosX, this.zoomRectY1 - this.lastButtonDownPosY)
|
||||
cr.setSource(0, 0, 1, 0.5) # SELECT_RECT_COL) # 0, 0, 1, 0.5
|
||||
cr.setSource(SelectRectCol) # SELECT_RECT_COL) # 0, 0, 1, 0.5
|
||||
cr.fillPreserve
|
||||
cr.setSource(0, 0, 0)
|
||||
cr.setLineWidth(2)
|
||||
|
|
@ -256,7 +256,7 @@ proc onAdjustmentEvent(this: PosAdj; pda: PDA) =
|
|||
pda.darea.queueDrawArea(0, 0, pda.darea.allocatedWidth, pda.darea.allocatedHeight)
|
||||
|
||||
proc newPDA: PDA =
|
||||
initGrid(result)
|
||||
result = newGrid(PDA)
|
||||
let da = newDrawingArea()
|
||||
result.darea = da
|
||||
da.setHExpand
|
||||
|
|
|
|||
|
|
@ -62,9 +62,9 @@ proc radio(action: SimpleAction; parameter: Variant; label: Label) =
|
|||
let str: string = "From Radio menu item " & getString(newState, l)
|
||||
label.setLabel(str)
|
||||
|
||||
proc bye(w: Window) =
|
||||
mainQuit()
|
||||
echo "Bye..."
|
||||
#proc bye(w: Window) =
|
||||
# mainQuit()
|
||||
# echo "Bye..."
|
||||
|
||||
proc main =
|
||||
gtk.init()
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
# gsettings.nim -- basic use of gsettings
|
||||
# nim c gsettings.nim
|
||||
# https://blog.gtk.org/2017/05/01/first-steps-with-gsettings/
|
||||
import gintro/[gtk, glib, gobject, gio]
|
||||
import gintro/[gtk, gobject, gio]
|
||||
|
||||
# unused
|
||||
proc toggle(b: CheckButton) =
|
||||
echo b.active
|
||||
let s = newSettings("org.gnome.Recipes")
|
||||
discard s.setBoolean("like-nim", b.active)
|
||||
#proc toggle(b: CheckButton) =
|
||||
# echo b.active
|
||||
# let s = newSettings("org.gnome.Recipes")
|
||||
# discard s.setBoolean("like-nim", b.active)
|
||||
|
||||
proc appActivate(app: Application) =
|
||||
let window = newApplicationWindow(app)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ proc main =
|
|||
## Wait until error or EOS
|
||||
bus = gst.getBus(pipeline)
|
||||
msg = gst.timedPopFiltered(bus, gst.Clock_Time_None, {gst.MessageFlag.error, gst.MessageFlag.eos})
|
||||
echo msg.getType
|
||||
discard gst.setState(pipeline, gst.State.null) # is this necessary?
|
||||
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ type
|
|||
handlerID: uint64
|
||||
|
||||
proc newPosAdj: PosAdj =
|
||||
initAdjustment(result, 0, 0, 1, 1, 10, 1)
|
||||
newAdjustment(PosAdj, 0, 0, 1, 1, 10, 1)
|
||||
|
||||
type
|
||||
PDA_Data* = object
|
||||
|
|
@ -98,7 +98,7 @@ proc drawingAreaDrawCb(darea: DrawingArea; cr: Context; this: PDA): bool =
|
|||
if this.selecting:
|
||||
cr.rectangle(this.lastButtonDownPosX, this.lastButtonDownPosY,
|
||||
this.zoomRectX1 - this.lastButtonDownPosX, this.zoomRectY1 - this.lastButtonDownPosY)
|
||||
cr.setSource(0, 0, 1, 0.5) # SELECT_RECT_COL) # 0, 0, 1, 0.5
|
||||
cr.setSource(SelectRectCol) # SELECT_RECT_COL) # 0, 0, 1, 0.5
|
||||
cr.fillPreserve
|
||||
cr.setSource(0, 0, 0)
|
||||
cr.setLineWidth(2)
|
||||
|
|
@ -227,7 +227,7 @@ proc onAdjustmentEvent(this: PosAdj; pda: PDA) =
|
|||
pda.darea.queueDrawArea(0, 0, pda.darea.allocatedWidth, pda.darea.allocatedHeight)
|
||||
|
||||
proc newPDA: PDA =
|
||||
initGrid(result)
|
||||
result = newGrid(PDA)
|
||||
let da = newDrawingArea()
|
||||
result.darea = da
|
||||
da.setHExpand
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import gintro/[gtk, glib, gobject, gio, gtksource]
|
||||
import gintro/[gtk, gobject, gio, gtksource]
|
||||
|
||||
proc appActivate (app: Application) =
|
||||
let window = newApplicationWindow(app)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue