1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
// Generated by gir (https://github.com/gtk-rs/gir @ d7c0763cacbc)
// from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70)
// DO NOT EDIT

use crate::{ffi, AbyssPolicy, Buffer, CachePolicy, Operation, Processor, Rectangle};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    ///
    ///
    /// ## Properties
    ///
    ///
    /// #### `cache-policy`
    ///  Readable | Writeable | Construct
    ///
    ///
    /// #### `dont-cache`
    ///  Readable | Writeable | Construct
    ///
    ///
    /// #### `gegl-operation`
    ///  Readable | Writeable | Construct
    ///
    ///
    /// #### `name`
    ///  Readable | Writeable | Construct
    ///
    ///
    /// #### `operation`
    ///  Readable | Writeable | Construct
    ///
    ///
    /// #### `passthrough`
    ///  Readable | Writeable | Construct
    ///
    ///
    /// #### `use-opencl`
    ///  Readable | Writeable | Construct
    ///
    /// ## Signals
    ///
    ///
    /// #### `computed`
    ///
    ///
    ///
    /// #### `invalidated`
    ///
    ///
    ///
    /// #### `progress`
    ///
    #[doc(alias = "GeglNode")]
    pub struct Node(Object<ffi::GeglNode>);

    match fn {
        type_ => || ffi::gegl_node_get_type(),
    }
}

impl Node {
    /// Create a new graph that can contain further processing nodes.
    ///
    /// # Returns
    ///
    /// A new top level [`Node`][crate::Node] (which can be used as a graph). When you
    /// are done using this graph instance it should be unreferenced with g_object_unref.
    /// This will also free any sub nodes created from this node.
    #[doc(alias = "gegl_node_new")]
    pub fn new() -> Node {
        unsafe { from_glib_full(ffi::gegl_node_new()) }
    }

    /// The [`Node`][crate::Node] returned contains the graph described by the tree of stacks
    /// in the XML document. The tree is connected to the "output" pad of the
    /// returned node and thus can be used directly for processing.
    /// ## `path`
    /// the path to a file on the local file system to be parsed.
    ///
    /// # Returns
    ///
    /// a GeglNode containing the parsed XML as a subgraph.
    #[doc(alias = "gegl_node_new_from_file")]
    #[doc(alias = "new_from_file")]
    pub fn from_file(path: &str) -> Node {
        unsafe { from_glib_full(ffi::gegl_node_new_from_file(path.to_glib_none().0)) }
    }

    #[doc(alias = "gegl_node_new_from_serialized")]
    #[doc(alias = "new_from_serialized")]
    pub fn from_serialized(chaindata: &str, path_root: &str) -> Node {
        unsafe {
            from_glib_full(ffi::gegl_node_new_from_serialized(
                chaindata.to_glib_none().0,
                path_root.to_glib_none().0,
            ))
        }
    }

    /// The [`Node`][crate::Node] returned contains the graph described by the tree of stacks
    /// in the XML document. The tree is connected to the "output" pad of the
    /// returned node and thus can be used directly for processing.
    /// ## `xmldata`
    /// a \0 terminated string containing XML data to be parsed.
    /// ## `path_root`
    /// a file system path that relative paths in the XML will be
    /// resolved in relation to.
    ///
    /// # Returns
    ///
    /// a GeglNode containing the parsed XML as a subgraph.
    #[doc(alias = "gegl_node_new_from_xml")]
    #[doc(alias = "new_from_xml")]
    pub fn from_xml(xmldata: &str, path_root: &str) -> Node {
        unsafe {
            from_glib_full(ffi::gegl_node_new_from_xml(
                xmldata.to_glib_none().0,
                path_root.to_glib_none().0,
            ))
        }
    }

    // rustdoc-stripper-ignore-next
    /// Creates a new builder-pattern struct instance to construct [`Node`] objects.
    ///
    /// This method returns an instance of [`NodeBuilder`](crate::builders::NodeBuilder) which can be used to create [`Node`] objects.
    pub fn builder() -> NodeBuilder {
        NodeBuilder::new()
    }

    /// Make the GeglNode `self`, take a reference on child. This reference
    /// will be dropped when the reference count on the graph reaches zero.
    /// ## `child`
    /// a GeglNode.
    ///
    /// # Returns
    ///
    /// the child.
    #[doc(alias = "gegl_node_add_child")]
    #[must_use]
    pub fn add_child(&self, child: &Node) -> Option<Node> {
        unsafe {
            from_glib_none(ffi::gegl_node_add_child(
                self.to_glib_none().0,
                child.to_glib_none().0,
            ))
        }
    }

    /// Render a rectangular region from a node to the given buffer.
    /// ## `buffer`
    /// the [`Buffer`][crate::Buffer] to render to.
    /// ## `roi`
    /// the rectangle to render.
    /// ## `level`
    /// mipmap level to render (0 for all)
    #[doc(alias = "gegl_node_blit_buffer")]
    pub fn blit_buffer(
        &self,
        buffer: Option<&Buffer>,
        roi: Option<&Rectangle>,
        level: i32,
        abyss_policy: AbyssPolicy,
    ) {
        unsafe {
            ffi::gegl_node_blit_buffer(
                self.to_glib_none().0,
                buffer.to_glib_none().0,
                roi.to_glib_none().0,
                level,
                abyss_policy.into_glib(),
            );
        }
    }

    /// Makes a connection between the pads of two nodes, one pad should
    /// be a source pad the other a sink pad, order does not matter.
    ///
    /// Returns TRUE if the connection was successfully made.
    /// ## `a_pad_name`
    /// and the pad of the node we want connected.
    /// ## `b`
    /// another node
    /// ## `b_pad_name`
    /// and its pad to be connected.
    #[doc(alias = "gegl_node_connect")]
    pub fn connect(&self, a_pad_name: &str, b: &Node, b_pad_name: &str) -> bool {
        unsafe {
            from_glib(ffi::gegl_node_connect(
                self.to_glib_none().0,
                a_pad_name.to_glib_none().0,
                b.to_glib_none().0,
                b_pad_name.to_glib_none().0,
            ))
        }
    }

    /// Makes a connection between the pads of two nodes.
    ///
    /// Returns TRUE if the connection was successfully made.
    /// ## `input_pad_name`
    /// the name of the input pad we are connecting to
    /// ## `source`
    /// the node producing data we want to connect.
    /// ## `output_pad_name`
    /// the output pad we want to use on the source.
    #[doc(alias = "gegl_node_connect_from")]
    pub fn connect_from(&self, input_pad_name: &str, source: &Node, output_pad_name: &str) -> bool {
        unsafe {
            from_glib(ffi::gegl_node_connect_from(
                self.to_glib_none().0,
                input_pad_name.to_glib_none().0,
                source.to_glib_none().0,
                output_pad_name.to_glib_none().0,
            ))
        }
    }

    /// Makes a connection between the pads of two nodes.
    ///
    /// Returns TRUE if the connection was successfully made.
    /// ## `output_pad_name`
    /// the output pad we want to use on the source.
    /// ## `sink`
    /// the node we're connecting an input to
    /// ## `input_pad_name`
    /// the name of the input pad we are connecting to
    #[doc(alias = "gegl_node_connect_to")]
    pub fn connect_to(&self, output_pad_name: &str, sink: &Node, input_pad_name: &str) -> bool {
        unsafe {
            from_glib(ffi::gegl_node_connect_to(
                self.to_glib_none().0,
                output_pad_name.to_glib_none().0,
                sink.to_glib_none().0,
                input_pad_name.to_glib_none().0,
            ))
        }
    }

    /// Creates a new processing node that performs the specified operation.
    /// All properties of the operation will have their default values. This
    /// is included as an addition to `gegl_node_new_child` in the public API to have
    /// a non varargs entry point for bindings as well as sometimes simpler more
    /// readable code.
    /// ## `operation`
    /// the type of node to create.
    ///
    /// # Returns
    ///
    /// a newly created node. The node will be destroyed by the parent.
    /// Calling g_object_unref on a node will cause the node to be dropped by the
    /// parent. (You may also add additional references using
    /// g_object_ref/g_object_unref, but in general relying on the parents reference
    /// counting is easiest.)
    #[doc(alias = "gegl_node_create_child")]
    #[must_use]
    pub fn create_child(&self, operation: &str) -> Option<Node> {
        unsafe {
            from_glib_none(ffi::gegl_node_create_child(
                self.to_glib_none().0,
                operation.to_glib_none().0,
            ))
        }
    }

    /// Performs hit detection by returning the node providing data at a given
    /// coordinate pair. Currently operates only on bounding boxes and not
    /// pixel data.
    /// ## `x`
    /// x coordinate
    /// ## `y`
    /// y coordinate
    ///
    /// # Returns
    ///
    /// the GeglNode providing the
    /// data ending up at `x`,`y` in the output of `self`.
    #[doc(alias = "gegl_node_detect")]
    #[must_use]
    pub fn detect(&self, x: i32, y: i32) -> Option<Node> {
        unsafe { from_glib_none(ffi::gegl_node_detect(self.to_glib_none().0, x, y)) }
    }

    /// Disconnects node connected to `input_pad` of `self` (if any).
    ///
    /// Returns TRUE if a connection was broken.
    /// ## `input_pad`
    /// the input pad to disconnect.
    #[doc(alias = "gegl_node_disconnect")]
    pub fn disconnect(&self, input_pad: &str) -> bool {
        unsafe {
            from_glib(ffi::gegl_node_disconnect(
                self.to_glib_none().0,
                input_pad.to_glib_none().0,
            ))
        }
    }

    /// ## `property_name`
    /// the name of the property to get a paramspec for.
    ///
    /// # Returns
    ///
    /// the GParamSpec of property or NULL
    /// if no such property exists.
    #[doc(alias = "gegl_node_find_property")]
    pub fn find_property(&self, property_name: &str) -> Option<glib::ParamSpec> {
        unsafe {
            from_glib_none(ffi::gegl_node_find_property(
                self.to_glib_none().0,
                property_name.to_glib_none().0,
            ))
        }
    }

    //#[doc(alias = "gegl_node_get")]
    //pub fn get(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
    //    unsafe { TODO: call ffi:gegl_node_get() }
    //}

    ///
    /// # Returns
    ///
    /// a list
    /// of the nodes contained within a GeglNode that is a subgraph.
    /// Use g_list_free () on the list when done.
    #[doc(alias = "gegl_node_get_children")]
    #[doc(alias = "get_children")]
    pub fn children(&self) -> Vec<Node> {
        unsafe {
            FromGlibPtrContainer::from_glib_container(ffi::gegl_node_get_children(
                self.to_glib_none().0,
            ))
        }
    }

    /// Retrieve which pads on which nodes are connected to a named output_pad,
    /// and the number of connections. Both the location for the generated
    /// nodes array and pads array can be left as NULL. If they are non NULL
    /// both should be freed with g_free. The arrays are NULL terminated.
    ///
    /// Returns the number of consumers connected to this output_pad.
    /// ## `output_pad`
    /// the output pad we want to know who uses.
    ///
    /// # Returns
    ///
    ///
    /// ## `nodes`
    /// optional return location for array of nodes.
    ///
    /// ## `pads`
    /// optional return location for array of pad names.
    #[doc(alias = "gegl_node_get_consumers")]
    #[doc(alias = "get_consumers")]
    pub fn consumers(&self, output_pad: &str) -> (i32, Vec<Node>, Vec<glib::GString>) {
        unsafe {
            let mut nodes = std::ptr::null_mut();
            let mut pads = std::ptr::null_mut();
            let ret = ffi::gegl_node_get_consumers(
                self.to_glib_none().0,
                output_pad.to_glib_none().0,
                &mut nodes,
                &mut pads,
            );
            (
                ret,
                FromGlibPtrContainer::from_glib_full(nodes),
                FromGlibPtrContainer::from_glib_full(pads),
            )
        }
    }

    ///
    /// # Returns
    ///
    /// The operation object
    /// associated with this node or NULL if there is no op associated.
    #[doc(alias = "gegl_node_get_gegl_operation")]
    #[doc(alias = "get_gegl_operation")]
    #[doc(alias = "gegl-operation")]
    pub fn gegl_operation(&self) -> Option<Operation> {
        unsafe { from_glib_none(ffi::gegl_node_get_gegl_operation(self.to_glib_none().0)) }
    }

    /// Proxies are used to route between nodes of a subgraph contained within
    /// a node.
    /// ## `pad_name`
    /// the name of the pad.
    ///
    /// # Returns
    ///
    /// Returns an input proxy for the named pad.
    /// If no input proxy exists with this name a new one will be created.
    #[doc(alias = "gegl_node_get_input_proxy")]
    #[doc(alias = "get_input_proxy")]
    #[must_use]
    pub fn input_proxy(&self, pad_name: &str) -> Option<Node> {
        unsafe {
            from_glib_none(ffi::gegl_node_get_input_proxy(
                self.to_glib_none().0,
                pad_name.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// The type of processing operation associated with this
    /// node, or NULL if there is no op associated. The special name
    /// "GraphNode" is returned if the node is the container of a subgraph.
    #[doc(alias = "gegl_node_get_operation")]
    #[doc(alias = "get_operation")]
    pub fn operation(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::gegl_node_get_operation(self.to_glib_none().0)) }
    }

    /// Proxies are used to route between nodes of a subgraph contained within
    /// a node.
    /// ## `pad_name`
    /// the name of the pad.
    ///
    /// # Returns
    ///
    /// Returns a output proxy for the named pad.
    /// If no output proxy exists with this name a new one will be created.
    #[doc(alias = "gegl_node_get_output_proxy")]
    #[doc(alias = "get_output_proxy")]
    #[must_use]
    pub fn output_proxy(&self, pad_name: &str) -> Option<Node> {
        unsafe {
            from_glib_none(ffi::gegl_node_get_output_proxy(
                self.to_glib_none().0,
                pad_name.to_glib_none().0,
            ))
        }
    }

    /// Returns a GeglNode that keeps a reference on a child.
    ///
    /// # Returns
    ///
    /// the parent of a node or NULL.
    #[doc(alias = "gegl_node_get_parent")]
    #[doc(alias = "get_parent")]
    #[must_use]
    pub fn parent(&self) -> Option<Node> {
        unsafe { from_glib_none(ffi::gegl_node_get_parent(self.to_glib_none().0)) }
    }

    #[doc(alias = "gegl_node_get_passthrough")]
    #[doc(alias = "get_passthrough")]
    #[doc(alias = "passthrough")]
    pub fn is_passthrough(&self) -> bool {
        unsafe { from_glib(ffi::gegl_node_get_passthrough(self.to_glib_none().0)) }
    }

    /// This is mainly included for language bindings. Using `gegl_node_get` is
    /// more convenient when programming in C.
    /// ## `property_name`
    /// the name of the property to get
    ///
    /// # Returns
    ///
    ///
    /// ## `value`
    /// pointer to a GValue where the value of the property should be stored
    #[doc(alias = "gegl_node_get_property")]
    #[doc(alias = "get_property")]
    pub fn property(&self, property_name: &str) -> glib::Value {
        unsafe {
            let mut value = glib::Value::uninitialized();
            ffi::gegl_node_get_property(
                self.to_glib_none().0,
                property_name.to_glib_none().0,
                value.to_glib_none_mut().0,
            );
            value
        }
    }

    //#[doc(alias = "gegl_node_get_valist")]
    //#[doc(alias = "get_valist")]
    //pub fn valist(&self, first_property_name: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
    //    unsafe { TODO: call ffi:gegl_node_get_valist() }
    //}

    /// Returns TRUE if the node has a pad with the specified name
    /// ## `pad_name`
    /// the pad name we are looking for
    #[doc(alias = "gegl_node_has_pad")]
    pub fn has_pad(&self, pad_name: &str) -> bool {
        unsafe {
            from_glib(ffi::gegl_node_has_pad(
                self.to_glib_none().0,
                pad_name.to_glib_none().0,
            ))
        }
    }

    /// Returns the position and dimensions of a rectangle spanning the area
    /// defined by a node.
    ///
    /// # Returns
    ///
    /// pointer a [`Rectangle`][crate::Rectangle]
    #[doc(alias = "gegl_node_introspectable_get_bounding_box")]
    pub fn introspectable_get_bounding_box(&self) -> Option<Rectangle> {
        unsafe {
            from_glib_full(ffi::gegl_node_introspectable_get_bounding_box(
                self.to_glib_none().0,
            ))
        }
    }

    /// ## `property_name`
    /// the name of the property to get
    ///
    /// # Returns
    ///
    /// pointer to a GValue containing the value of the property
    #[doc(alias = "gegl_node_introspectable_get_property")]
    pub fn introspectable_get_property(&self, property_name: &str) -> Option<glib::Value> {
        unsafe {
            from_glib_full(ffi::gegl_node_introspectable_get_property(
                self.to_glib_none().0,
                property_name.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gegl_node_is_graph")]
    pub fn is_graph(&self) -> bool {
        unsafe { from_glib(ffi::gegl_node_is_graph(self.to_glib_none().0)) }
    }

    /// Synthetic sugar for linking the "output" pad of `self` to the "input"
    /// pad of `sink`.
    /// ## `sink`
    /// the consumer of data.
    #[doc(alias = "gegl_node_link")]
    pub fn link(&self, sink: &Node) {
        unsafe {
            ffi::gegl_node_link(self.to_glib_none().0, sink.to_glib_none().0);
        }
    }

    /// If the node has any input pads this function returns a null terminated
    /// array of pad names, otherwise it returns NULL. The return value can be
    /// freed with `g_strfreev()`.
    #[doc(alias = "gegl_node_list_input_pads")]
    pub fn list_input_pads(&self) -> Vec<glib::GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::gegl_node_list_input_pads(
                self.to_glib_none().0,
            ))
        }
    }

    /// If the node has any output pads this function returns a null terminated
    /// array of pad names, otherwise it returns NULL. The return value can be
    /// freed with `g_strfreev()`.
    #[doc(alias = "gegl_node_list_output_pads")]
    pub fn list_output_pads(&self) -> Vec<glib::GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::gegl_node_list_output_pads(
                self.to_glib_none().0,
            ))
        }
    }

    /// ## `rectangle`
    /// the [`Rectangle`][crate::Rectangle] to work on or NULL to work on all available
    /// data.
    ///
    /// # Returns
    ///
    /// a new [`Processor`][crate::Processor].
    #[doc(alias = "gegl_node_new_processor")]
    pub fn new_processor(&self, rectangle: &Rectangle) -> Option<Processor> {
        unsafe {
            from_glib_full(ffi::gegl_node_new_processor(
                self.to_glib_none().0,
                rectangle.to_glib_none().0,
            ))
        }
    }

    /// Render a composition. This can be used for instance on a node with a "png-save"
    /// operation to render all necessary data, and make it be written to file. This
    /// function wraps the usage of a GeglProcessor in a single blocking function
    /// call. If you need a non-blocking operation, then make a direct use of
    /// `gegl_processor_work`. See [`Processor`][crate::Processor].
    ///
    /// ---
    /// GeglNode *gegl;
    /// GeglRectangle roi;
    /// GeglNode *png_save;
    /// unsigned char *buffer;
    ///
    /// gegl = gegl_parse_xml (xml_data);
    /// roi = gegl_node_get_bounding_box (gegl);
    /// # create png_save from the graph, the parent/child relationship
    /// # only mean anything when it comes to memory management.
    /// png_save = gegl_node_new_child (gegl,
    ///  "operation", "gegl:png-save",
    ///  "path", "output.png",
    ///  NULL);
    ///
    /// gegl_node_link (gegl, png_save);
    /// gegl_node_process (png_save);
    ///
    /// buffer = malloc (roi.w*roi.h*4);
    /// gegl_node_blit (gegl,
    ///  1.0,
    ///  &roi,
    ///  babl_format("R'G'B'A u8"),
    ///  buffer,
    ///  GEGL_AUTO_ROWSTRIDE,
    ///  GEGL_BLIT_DEFAULT);
    #[doc(alias = "gegl_node_process")]
    pub fn process(&self) {
        unsafe {
            ffi::gegl_node_process(self.to_glib_none().0);
        }
    }

    #[doc(alias = "gegl_node_progress")]
    pub fn progress(&self, progress: f64, message: &str) {
        unsafe {
            ffi::gegl_node_progress(self.to_glib_none().0, progress, message.to_glib_none().0);
        }
    }

    /// Removes a child from a GeglNode. The reference previously held will be
    /// dropped so increase the reference count before removing when reparenting
    /// a child between two graphs.
    /// ## `child`
    /// a GeglNode.
    ///
    /// # Returns
    ///
    /// the child.
    #[doc(alias = "gegl_node_remove_child")]
    #[must_use]
    pub fn remove_child(&self, child: &Node) -> Option<Node> {
        unsafe {
            from_glib_none(ffi::gegl_node_remove_child(
                self.to_glib_none().0,
                child.to_glib_none().0,
            ))
        }
    }

    //#[doc(alias = "gegl_node_set")]
    //pub fn set(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
    //    unsafe { TODO: call ffi:gegl_node_set() }
    //}

    #[doc(alias = "gegl_node_set_enum_as_string")]
    pub fn set_enum_as_string(&self, key: &str, value: &str) {
        unsafe {
            ffi::gegl_node_set_enum_as_string(
                self.to_glib_none().0,
                key.to_glib_none().0,
                value.to_glib_none().0,
            );
        }
    }

    #[doc(alias = "gegl_node_set_passthrough")]
    #[doc(alias = "passthrough")]
    pub fn set_passthrough(&self, passthrough: bool) {
        unsafe {
            ffi::gegl_node_set_passthrough(self.to_glib_none().0, passthrough.into_glib());
        }
    }

    /// This is mainly included for language bindings. Using `gegl_node_set` is
    /// more convenient when programming in C.
    /// ## `property_name`
    /// the name of the property to set
    /// ## `value`
    /// a GValue containing the value to be set in the property.
    #[doc(alias = "gegl_node_set_property")]
    pub fn set_property(&self, property_name: &str, value: &glib::Value) {
        unsafe {
            ffi::gegl_node_set_property(
                self.to_glib_none().0,
                property_name.to_glib_none().0,
                value.to_glib_none().0,
            );
        }
    }

    /// Sets the right value in animated properties of this node and all its
    /// dependendcies to be the specified time position.
    /// ## `time`
    /// the time to set the properties which have keyfraes attached to
    #[doc(alias = "gegl_node_set_time")]
    pub fn set_time(&self, time: f64) {
        unsafe {
            ffi::gegl_node_set_time(self.to_glib_none().0, time);
        }
    }

    //#[doc(alias = "gegl_node_set_valist")]
    //pub fn set_valist(&self, first_property_name: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
    //    unsafe { TODO: call ffi:gegl_node_set_valist() }
    //}

    /// Returns a freshly allocated \0 terminated string containing a XML
    /// serialization of the composition produced by a node (and thus also
    /// the nodes contributing data to the specified node). To export a
    /// gegl graph, connect the internal output node to an output proxy (see
    /// `gegl_node_get_output_proxy`.) and use the proxy node as the basis
    /// for the serialization.
    /// ## `path_root`
    /// filesystem path to construct relative paths from.
    #[doc(alias = "gegl_node_to_xml")]
    pub fn to_xml(&self, path_root: &str) -> Option<glib::GString> {
        unsafe {
            from_glib_full(ffi::gegl_node_to_xml(
                self.to_glib_none().0,
                path_root.to_glib_none().0,
            ))
        }
    }

    /// Returns a freshly allocated \0 terminated string containing a XML
    /// serialization of a segment of a graph from `self` to `tail` nodes.
    /// If `tail` is [`None`] then this behaves just like `gegl_node_to_xml`.
    /// ## `tail`
    /// a [`Node`][crate::Node]
    /// ## `path_root`
    /// filesystem path to construct relative paths from.
    ///
    /// # Returns
    ///
    /// XML serialization of a graph segment.
    #[doc(alias = "gegl_node_to_xml_full")]
    pub fn to_xml_full(&self, tail: Option<&Node>, path_root: &str) -> Option<glib::GString> {
        unsafe {
            from_glib_full(ffi::gegl_node_to_xml_full(
                self.to_glib_none().0,
                tail.to_glib_none().0,
                path_root.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "cache-policy")]
    pub fn cache_policy(&self) -> CachePolicy {
        ObjectExt::property(self, "cache-policy")
    }

    #[doc(alias = "cache-policy")]
    pub fn set_cache_policy(&self, cache_policy: CachePolicy) {
        ObjectExt::set_property(self, "cache-policy", cache_policy)
    }

    #[doc(alias = "dont-cache")]
    pub fn is_dont_cache(&self) -> bool {
        ObjectExt::property(self, "dont-cache")
    }

    #[doc(alias = "dont-cache")]
    pub fn set_dont_cache(&self, dont_cache: bool) {
        ObjectExt::set_property(self, "dont-cache", dont_cache)
    }

    #[doc(alias = "gegl-operation")]
    pub fn set_gegl_operation(&self, gegl_operation: Option<&Operation>) {
        ObjectExt::set_property(self, "gegl-operation", gegl_operation)
    }

    pub fn name(&self) -> Option<glib::GString> {
        ObjectExt::property(self, "name")
    }

    pub fn set_name(&self, name: Option<&str>) {
        ObjectExt::set_property(self, "name", name)
    }

    pub fn set_operation(&self, operation: Option<&str>) {
        ObjectExt::set_property(self, "operation", operation)
    }

    #[doc(alias = "use-opencl")]
    pub fn uses_opencl(&self) -> bool {
        ObjectExt::property(self, "use-opencl")
    }

    #[doc(alias = "use-opencl")]
    pub fn set_use_opencl(&self, use_opencl: bool) {
        ObjectExt::set_property(self, "use-opencl", use_opencl)
    }

    #[doc(alias = "computed")]
    pub fn connect_computed<F: Fn(&Self, &Rectangle) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn computed_trampoline<F: Fn(&Node, &Rectangle) + 'static>(
            this: *mut ffi::GeglNode,
            object: *mut ffi::GeglRectangle,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this), &from_glib_borrow(object))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"computed\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    computed_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "invalidated")]
    pub fn connect_invalidated<F: Fn(&Self, &Rectangle) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn invalidated_trampoline<F: Fn(&Node, &Rectangle) + 'static>(
            this: *mut ffi::GeglNode,
            object: *mut ffi::GeglRectangle,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this), &from_glib_borrow(object))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"invalidated\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    invalidated_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "progress")]
    pub fn connect_progress<F: Fn(&Self, f64) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn progress_trampoline<F: Fn(&Node, f64) + 'static>(
            this: *mut ffi::GeglNode,
            object: libc::c_double,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this), object)
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"progress\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    progress_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "cache-policy")]
    pub fn connect_cache_policy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_cache_policy_trampoline<F: Fn(&Node) + 'static>(
            this: *mut ffi::GeglNode,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::cache-policy\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_cache_policy_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "dont-cache")]
    pub fn connect_dont_cache_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_dont_cache_trampoline<F: Fn(&Node) + 'static>(
            this: *mut ffi::GeglNode,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::dont-cache\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_dont_cache_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "gegl-operation")]
    pub fn connect_gegl_operation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_gegl_operation_trampoline<F: Fn(&Node) + 'static>(
            this: *mut ffi::GeglNode,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::gegl-operation\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_gegl_operation_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "name")]
    pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_name_trampoline<F: Fn(&Node) + 'static>(
            this: *mut ffi::GeglNode,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::name\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_name_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "operation")]
    pub fn connect_operation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_operation_trampoline<F: Fn(&Node) + 'static>(
            this: *mut ffi::GeglNode,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::operation\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_operation_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "passthrough")]
    pub fn connect_passthrough_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_passthrough_trampoline<F: Fn(&Node) + 'static>(
            this: *mut ffi::GeglNode,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::passthrough\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_passthrough_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "use-opencl")]
    pub fn connect_use_opencl_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_use_opencl_trampoline<F: Fn(&Node) + 'static>(
            this: *mut ffi::GeglNode,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::use-opencl\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_use_opencl_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl Default for Node {
    fn default() -> Self {
        Self::new()
    }
}

// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`Node`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct NodeBuilder {
    builder: glib::object::ObjectBuilder<'static, Node>,
}

impl NodeBuilder {
    fn new() -> Self {
        Self {
            builder: glib::object::Object::builder(),
        }
    }

    pub fn cache_policy(self, cache_policy: CachePolicy) -> Self {
        Self {
            builder: self.builder.property("cache-policy", cache_policy),
        }
    }

    pub fn dont_cache(self, dont_cache: bool) -> Self {
        Self {
            builder: self.builder.property("dont-cache", dont_cache),
        }
    }

    pub fn gegl_operation(self, gegl_operation: &Operation) -> Self {
        Self {
            builder: self
                .builder
                .property("gegl-operation", gegl_operation.clone()),
        }
    }

    pub fn name(self, name: impl Into<glib::GString>) -> Self {
        Self {
            builder: self.builder.property("name", name.into()),
        }
    }

    pub fn operation(self, operation: impl Into<glib::GString>) -> Self {
        Self {
            builder: self.builder.property("operation", operation.into()),
        }
    }

    pub fn passthrough(self, passthrough: bool) -> Self {
        Self {
            builder: self.builder.property("passthrough", passthrough),
        }
    }

    pub fn use_opencl(self, use_opencl: bool) -> Self {
        Self {
            builder: self.builder.property("use-opencl", use_opencl),
        }
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`Node`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> Node {
        self.builder.build()
    }
}