Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GtkNodes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Luntzer
GtkNodes
Commits
5cacde86
Commit
5cacde86
authored
4 years ago
by
Armin Luntzer
Browse files
Options
Downloads
Patches
Plain Diff
add vala example
parent
407981ec
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/example.vala
+64
-0
64 additions, 0 deletions
examples/example.vala
with
64 additions
and
0 deletions
examples/example.vala
0 → 100644
+
64
−
0
View file @
5cacde86
/**
* I don't know vala, so this is as much as I can give you for an example.
*
* This demo allows you to connect the output socket to the input and receive
* an event which will change the label of the input node.
*
* The cast of to GtkNodes.NodeSocket seems necessary, because vala does not
* consider the socket_connect signal to be part of the socket's signals if it
* is returned as a GtkWidget on item_add() (which is done intentionally).
*
* Compile with 'valac --pkg gtknodes example.vala' with the library installed.
* There is no makefile integration for now, sorry.
*/
using
Gtk
;
using
GtkNodes
;
int
main
(
string
[]
args
)
{
Gtk
.
init
(
ref
args
);
var
window
=
new
Window
();
window
.
title
=
"Nodes Demo"
;
window
.
border_width
=
10
;
window
.
window_position
=
WindowPosition
.
CENTER
;
window
.
set_default_size
(
300
,
300
);
window
.
destroy
.
connect
(
Gtk
.
main_quit
);
var
node_view
=
new
GtkNodes
.
NodeView
();
var
node
=
new
GtkNodes
.
Node
();
node
.
set_label
(
"Demo"
);
var
ilbl
=
new
Gtk
.
Label
(
"Input"
);
ilbl
.
set_xalign
(
0.0f
);
unowned
var
input
=
(
GtkNodes
.
NodeSocket
)
node
.
item_add
(
ilbl
,
GtkNodes
.
NodeSocketIO
.
SINK
);
input
.
socket_connect
.
connect
(()
=>
{
ilbl
.
label
=
"connected"
;
});
input
.
socket_disconnect
.
connect
(()
=>
{
ilbl
.
label
=
"disconnected"
;
});
var
olbl
=
new
Gtk
.
Label
(
"Output"
);
olbl
.
set_xalign
(
1.0f
);
node
.
item_add
(
olbl
,
GtkNodes
.
NodeSocketIO
.
SOURCE
);
node_view
.
add
(
node
);
window
.
add
(
node_view
);
window
.
show_all
();
Gtk
.
main
();
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment