examples/lib use the new wrappers
This commit is contained in:
parent
ddb7185482
commit
b559285b78
133 changed files with 17038 additions and 151734 deletions
|
|
@ -3,50 +3,49 @@ import
|
|||
glib2, gtk2
|
||||
|
||||
type
|
||||
TButtonSignalState = record
|
||||
Obj: PgtkObject
|
||||
TButtonSignalState = object
|
||||
Obj: gtk2.PObject
|
||||
SignalID: int32
|
||||
Disable: bool
|
||||
|
||||
PButtonSignalState = ptr TButtonSignalState
|
||||
|
||||
proc destroy(widget: pGtkWidget, data: pgpointer){.cdecl.} =
|
||||
gtk_main_quit()
|
||||
proc destroy(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
main_quit()
|
||||
|
||||
proc disablesignal(widget: pGtkWidget, data: pgpointer){.cdecl.} =
|
||||
if PButtonSignalState(Data).Disable:
|
||||
gtk_signal_handler_block(PButtonSignalState(Data).Obj, SignalID)
|
||||
proc widgetDestroy(w: PWidget) {.cdecl.} = destroy(w)
|
||||
|
||||
proc disablesignal(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
var s = cast[PButtonSignalState](Data)
|
||||
if s.Disable:
|
||||
signal_handler_block(s.Obj, s.SignalID)
|
||||
else:
|
||||
gtk_signal_handler_unblock(PButtonSignalState(Data).Obj, SignalID)
|
||||
PButtonSignalState(Data).disable = not PButtonSignalState(Data).disable
|
||||
signal_handler_unblock(s.Obj, s.SignalID)
|
||||
s.disable = not s.disable
|
||||
|
||||
var
|
||||
window: PGtkWidget
|
||||
quitbutton: PGtkWidget
|
||||
disablebutton: PGTKWidget
|
||||
windowbox: PGTKWidget
|
||||
quitsignal: guint
|
||||
QuitState: TButtonSignalState
|
||||
|
||||
gtk_nimrod_init()
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL)
|
||||
quitbutton = gtk_button_new_with_label("Quit program")
|
||||
disablebutton = gtk_button_new_with_label("Disable button")
|
||||
windowbox = gtk_vbox_new(TRUE, 10)
|
||||
gtk_box_pack_start(GTK_BOX(windowbox), disablebutton, True, false, 0)
|
||||
gtk_box_pack_start(GTK_BOX(windowbox), quitbutton, True, false, 0)
|
||||
gtk_container_set_border_width(GTK_CONTAINER(Window), 10)
|
||||
gtk_container_add(GTK_Container(window), windowbox)
|
||||
gtk_signal_connect(GTKOBJECT(window), "destroy",
|
||||
GTK_SIGNAL_FUNC(destroy), nil)
|
||||
QuitState.Obj = GTKObject(QuitButton)
|
||||
SignalID = gtk_signal_connect_object(QuitState.Obj, "clicked", GTK_SIGNAL_FUNC(
|
||||
gtk_widget_destroy), GTKOBJECT(window))
|
||||
nimrod_init()
|
||||
var window = window_new(WINDOW_TOPLEVEL)
|
||||
var quitbutton = button_new_with_label("Quit program")
|
||||
var disablebutton = button_new_with_label("Disable button")
|
||||
var windowbox = vbox_new(TRUE, 10)
|
||||
pack_start(windowbox, disablebutton, True, false, 0)
|
||||
pack_start(windowbox, quitbutton, True, false, 0)
|
||||
set_border_width(Window, 10)
|
||||
add(window, windowbox)
|
||||
discard signal_connect(window, "destroy", SIGNAL_FUNC(ex6.destroy), nil)
|
||||
QuitState.Obj = QuitButton
|
||||
quitState.SignalID = signal_connect_object(QuitState.Obj, "clicked",
|
||||
SIGNAL_FUNC(widgetDestroy), window)
|
||||
QuitState.Disable = True
|
||||
discard gtk_signal_connect(GTKOBJECT(disablebutton), "clicked",
|
||||
GTK_SIGNAL_FUNC(disablesignal), addr(QuitState))
|
||||
gtk_widget_show(quitbutton)
|
||||
gtk_widget_show(disablebutton)
|
||||
gtk_widget_show(windowbox)
|
||||
gtk_widget_show(window)
|
||||
gtk_main()
|
||||
discard signal_connect(disablebutton, "clicked",
|
||||
SIGNAL_FUNC(disablesignal), addr(QuitState))
|
||||
show(quitbutton)
|
||||
show(disablebutton)
|
||||
show(windowbox)
|
||||
show(window)
|
||||
main()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue