1 /* This file is part of Ganv.
2  * Copyright 2007-2014 David Robillard <http://drobilla.net>
3  *
4  * Ganv is free software: you can redistribute it and/or modify it under the
5  * terms of the GNU General Public License as published by the Free Software
6  * Foundation, either version 3 of the License, or any later version.
7  *
8  * Ganv is distributed in the hope that it will be useful, but WITHOUT ANY
9  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
11  *
12  * You should have received a copy of the GNU General Public License along
13  * with Ganv.  If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 // IWYU pragma: no_include "ganv-private.h"
17 
18 #ifndef GANV_MODULE_H
19 #define GANV_MODULE_H
20 
21 #include "ganv/types.h"
22 
23 #include <glib-object.h>
24 #include <glib.h>
25 #include <gtk/gtk.h>
26 
27 #include "ganv/box.h"
28 #include "ganv/canvas.h"
29 
30 G_BEGIN_DECLS
31 
32 #define GANV_TYPE_MODULE            (ganv_module_get_type())
33 #define GANV_MODULE(obj)            (GTK_CHECK_CAST((obj), GANV_TYPE_MODULE, GanvModule))
34 #define GANV_MODULE_CLASS(klass)    (GTK_CHECK_CLASS_CAST((klass), GANV_TYPE_MODULE, GanvModuleClass))
35 #define GANV_IS_MODULE(obj)         (GTK_CHECK_TYPE((obj), GANV_TYPE_MODULE))
36 #define GANV_IS_MODULE_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GANV_TYPE_MODULE))
37 #define GANV_MODULE_GET_CLASS(obj)  (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_MODULE, GanvModuleClass))
38 
39 struct _GanvModuleClass;
40 
41 typedef struct _GanvModuleClass   GanvModuleClass;
42 typedef struct _GanvModulePrivate GanvModulePrivate;
43 
44 typedef void (*GanvPortFunc)(GanvPort* port, void* data);
45 
46 struct _GanvModule {
47 	GanvBox            box;
48 	GanvModulePrivate* impl;
49 };
50 
51 struct _GanvModuleClass {
52 	GanvBoxClass parent_class;
53 
54 	/* Reserved for future expansion */
55 	gpointer spare_vmethods[4];
56 };
57 
58 GType ganv_module_get_type(void) G_GNUC_CONST;
59 
60 GanvModule*
61 ganv_module_new(GanvCanvas* canvas,
62                 const char* first_prop_name, ...);
63 
64 guint
65 ganv_module_num_ports(const GanvModule* module);
66 
67 /**
68  * ganv_module_get_port:
69  *
70  * Get a port by index.
71  *
72  * Return value: (transfer none): The port on @module at @index.
73  */
74 GanvPort*
75 ganv_module_get_port(GanvModule* module,
76                      guint       index);
77 
78 double
79 ganv_module_get_empty_port_breadth(const GanvModule* module);
80 
81 double
82 ganv_module_get_empty_port_depth(const GanvModule* module);
83 
84 void
85 ganv_module_embed(GanvModule* module, GtkWidget* widget);
86 
87 void
88 ganv_module_set_direction(GanvModule* module, GanvDirection direction);
89 
90 /**
91  * ganv_module_for_each_port:
92  * @module: The module.
93  * @f: (scope call): A function to call on every port on @module.
94  * @data: User data to pass to @f.
95  */
96 void
97 ganv_module_for_each_port(GanvModule*  module,
98                           GanvPortFunc f,
99                           void*        data);
100 
101 G_END_DECLS
102 
103 #endif  /* GANV_MODULE_H */
104