Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,85 @@
import os
import gintro/[glib, gobject, gtk, gio]
from gintro/gdk import processAllUpdates
type MyWindow = ref object of ApplicationWindow
isShifted: bool
#---------------------------------------------------------------------------------------------------
proc wMaximize(button: Button; window: MyWindow) =
window.maximize()
proc wUnmaximize(button: Button; window: MyWindow) =
window.unmaximize()
proc wIconify(button: Button; window: MyWindow) =
window.iconify()
proc wDeiconify(button: Button; window: MyWindow) =
window.deiconify()
proc wHide(button: Button; window: MyWindow) =
window.hide()
processAllUpdates()
os.sleep(2000)
window.show()
proc wShow(button: Button; window: MyWindow) =
window.show()
proc wMove(button: Button; window: MyWindow) =
var x, y: int
window.getPosition(x, y)
if window.isShifted:
window.move(x - 10, y - 10)
else:
window.move(x + 10, y + 10)
window.isShifted = not window.isShifted
proc wQuit(button: Button; window: MyWindow) =
window.destroy()
#---------------------------------------------------------------------------------------------------
proc activate(app: Application) =
## Activate the application.
let window = newApplicationWindow(MyWindow, app)
window.setTitle("Window management")
let stackBox = newBox(Orientation.vertical, 10)
stackBox.setHomogeneous(true)
let
bMax = newButton("maximize")
bUnmax = newButton("unmaximize")
bIcon = newButton("iconize")
bDeicon = newButton("deiconize")
bHide = newButton("hide")
bShow = newButton("show")
bMove = newButton("move")
bQuit = newButton("Quit")
for button in [bMax, bUnmax, bIcon, bDeicon, bHide, bShow, bMove, bQuit]:
stackBox.add button
window.setBorderWidth(5)
window.add(stackBox)
discard bMax.connect("clicked", wMaximize, window)
discard bUnmax.connect("clicked", wUnmaximize, window)
discard bIcon.connect("clicked", wIconify, window)
discard bDeicon.connect("clicked", wDeiconify, window)
discard bHide.connect("clicked", wHide, window)
discard bShow.connect("clicked", wShow, window)
discard bMove.connect("clicked", wMove, window)
discard bQuit.connect("clicked", wQuit, window)
window.showAll()
#———————————————————————————————————————————————————————————————————————————————————————————————————
let app = newApplication(Application, "Rosetta.Window.Management")
discard app.connect("activate", activate)
discard app.run()

View file

@ -0,0 +1,76 @@
import os
import gdk2, glib2, gtk2
proc thisDestroy(widget: PWidget; data: Pgpointer) {.cdecl.} =
main_quit()
proc thisMax(widget: PWidget; data: Pgpointer) {.cdecl.} =
widget.get_parent_window().maximize()
proc thisUnmax(widget: PWidget; data: Pgpointer) {.cdecl.} =
widget.get_parent_window().unmaximize()
proc thisIcon(widget: PWidget; data: Pgpointer) {.cdecl.} =
widget.get_parent_window().iconify()
proc thisDeicon(widget: PWidget; data: Pgpointer) {.cdecl.} =
widget.get_parent_window().deiconify()
proc thisHide(widget: PWidget; data: Pgpointer) {.cdecl.} =
widget.get_parent_window().hide()
window_process_all_updates()
sleep(2000)
widget.get_parent_window().show()
proc thisShow(widget: PWidget; data: Pgpointer) {.cdecl.} =
widget.get_parent_window().show()
var isShifted = false
proc thisMove(widget: PWidget; data: Pgpointer) {.cdecl.} =
var x, y: gint
widget.get_parent_window().get_position(addr(x), addr(y))
if isshifted:
widget.get_parent_window().move(x - 10, y - 10)
else:
widget.get_parent_window().move(x + 10, y + 10)
isShifted = not isShifted
nim_init()
let window = window_new(gtk2.WINDOW_TOPLEVEL)
discard window.allow_grow()
window.set_title("Window management")
let
stackbox = vbox_new(true, 10)
bMax = button_new("maximize")
bUnmax = button_new("unmaximize")
bIcon = button_new("iconize")
bDeicon = button_new("deiconize")
bHide = button_new("hide")
bShow = button_new("show")
bMove = button_new("move")
bQuit = button_new("Quit")
stackbox.pack_start(bMax, true, true, 0)
stackbox.pack_start(bUnmax, true, true, 0)
stackbox.pack_start(bIcon, true, true, 0)
stackbox.pack_start(bDeicon, true, true, 0)
stackbox.pack_start(bHide, true, true, 0)
stackbox.pack_start(bShow, true, true, 0)
stackbox.pack_start(bMove, true, true, 0)
stackbox.pack_start(bQuit, true, true, 0)
window.set_border_width(5)
window.add(stackbox)
discard window.signal_connect("destroy", SIGNAL_FUNC(thisDestroy), nil)
discard bIcon.signal_connect("clicked", SIGNAL_FUNC(thisIcon), nil)
discard bDeicon.signal_connect("clicked", SIGNAL_FUNC(thisDeicon), nil)
discard bMax.signal_connect("clicked", SIGNAL_FUNC(thisMax), nil)
discard bUnmax.signal_connect("clicked", SIGNAL_FUNC(thisUnmax), nil)
discard bHide.signal_connect("clicked", SIGNAL_FUNC(thisHide), nil)
discard bShow.signal_connect("clicked", SIGNAL_FUNC(thisShow), nil)
discard bMove.signal_connect("clicked", SIGNAL_FUNC(thismove), nil)
discard bQuit.signal_connect("clicked", SIGNAL_FUNC(thisDestroy), nil)
window.show_all()
main()

View file

@ -0,0 +1,68 @@
import iup
# assumes you have the iup .dll or .so installed
proc toCB(fp: proc): ICallback =
return cast[ICallback](fp)
discard iup.open(nil,nil)
var btnRestore = button("restore","")
var btnFull = button("Full screen","")
var btnMin = button("minimize","")
var btnMax = button("maximize","")
var btnHide = button("Transparent","")
#var btnHide = button("Hide (close)","")
var btnShow = button("Show","")
var hbox = Hbox(btnRestore, btnFull, btnMax, btnMin, btnShow, btnHide, nil)
setAttribute(hbox,"MARGIN", "10x10")
setAttribute(hbox,"PADDING", "5x5")
var dlg = Dialog(hbox)
#SetAttribute(dlg, "SIZE", "100x50")
proc doFull(ih:PIhandle): cint {.cdecl.} =
setAttribute(dlg,"FULLSCREEN","YES")
return IUP_DEFAULT
proc doMax(ih:PIhandle): cint {.cdecl.} =
#setAttribute(dlg,"FULLSCREEN","YES")
setAttribute(dlg,"PLACEMENT","MAXIMIZED")
# this is a work-around to get the dialog minimised (on win platform)
setAttribute(dlg,"VISIBLE","YES")
return IUP_DEFAULT
proc doMin(ih:PIhandle): cint {.cdecl.} =
setAttribute(dlg,"PLACEMENT","MINIMIZED")
# this is a work-around to get the dialog minimised (on win platform)
setAttribute(dlg,"VISIBLE","YES")
return IUP_DEFAULT
proc doRestore(ih:PIhandle): cint {.cdecl.} =
setAttribute(dlg,"OPACITY","255")
setAttribute(dlg,"FULLSCREEN","NO")
setAttribute(dlg,"PLACEMENT","NORMAL")
setAttribute(dlg,"VISIBLE","YES")
return IUP_DEFAULT
proc doHide(ih:PIhandle): cint {.cdecl.} =
#setAttribute(dlg,"VISIBLE","NO")
setAttribute(dlg,"OPACITY","60")
return IUP_DEFAULT
proc doShow(ih:PIhandle): cint {.cdecl.} =
setAttribute(dlg,"OPACITY","255")
setAttribute(dlg,"VISIBLE","YES")
return IUP_DEFAULT
discard setCallback(btnRestore,"ACTION", toCB(doRestore))
discard setCallback(btnFull,"ACTION", toCB(doFull))
discard setCallback(btnMax,"ACTION", toCB(doMax))
discard setCallback(btnMin,"ACTION", toCB(doMin))
discard setCallback(btnShow,"ACTION", toCB(doShow))
discard setCallback(btnHide,"ACTION", toCB(doHide))
discard dlg.show()
discard mainloop()
iup.Close()