37b5dd5eee32c739c247972d788e9537df03768b
[nit.git] / lib / gtk / v3_10.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # GTK+ services added at version 3.10
16 module v3_10 is pkgconfig("gtk+-3.0")
17
18 import v3_8
19
20 redef class GtkWindow
21 fun titlebar=(widget: GtkWidget) `{ gtk_window_set_titlebar(self, widget); `}
22 end
23
24 # A vertical container of `GtkListBoxRow`
25 extern class GtkListBox `{ GtkListBox * `}
26 super GtkContainer
27
28 new `{ return (GtkListBox*)gtk_list_box_new(); `}
29
30 fun prepend(child: GtkWidget) `{ gtk_list_box_prepend(self, child); `}
31
32 fun insert(child: GtkWidget, position: Int) `{ gtk_list_box_insert(self, child, position); `}
33
34 fun selected_row: GtkListBoxRow `{ return gtk_list_box_get_selected_row(self); `}
35
36 fun row_at_index(index: Int): GtkListBoxRow`{ return gtk_list_box_get_row_at_index(self, index); `}
37
38 fun row_at_y(y: Int): GtkListBoxRow `{ return gtk_list_box_get_row_at_y(self, y); `}
39
40 fun select_row(row: GtkListBoxRow) `{ gtk_list_box_select_row(self, row); `}
41
42 fun placeholder=(placeholder: GtkWidget) `{ gtk_list_box_set_placeholder(self, placeholder); `}
43
44 fun adjustment=(adjustment: GtkAdjustment) `{ gtk_list_box_set_adjustment(self, adjustment); `}
45
46 fun selection_mode=(mode: GtkSelectionMode) `{ gtk_list_box_set_selection_mode(self, mode); `}
47
48 fun selection_mode: GtkSelectionMode `{ return gtk_list_box_get_selection_mode (self); `}
49
50 fun invalidate_filter `{ gtk_list_box_invalidate_filter(self); `}
51
52 fun invalidate_sort `{ gtk_list_box_invalidate_sort(self); `}
53
54 fun invalidate_headers `{ gtk_list_box_invalidate_headers(self); `}
55
56 fun activate_on_single_click=(single: Bool) `{ gtk_list_box_set_activate_on_single_click(self, single); `}
57
58 fun activate_on_single_click: Bool `{ return gtk_list_box_get_activate_on_single_click(self); `}
59
60 fun drag_unhighlight_row `{ gtk_list_box_drag_unhighlight_row(self); `}
61
62 fun drag_highlight_row(row: GtkListBoxRow) `{ gtk_list_box_drag_highlight_row(self, row); `}
63
64 # TODO
65 #fun (* GtkListBoxForeachFunc)(GtkListBoxRow *row, gpointer user_data) `{ (* GtkListBoxForeachFunc)(self, GtkListBoxRow *row, gpointer user_data); `}
66 #fun set_filter_func(GtkListBoxFilterFunc filter_func, gpointer user_data, GDestroyNotify destroy) `{ gtk_list_box_set_filter_func(self, GtkListBoxFilterFunc filter_func, gpointer user_data, GDestroyNotify destroy); `}
67 #fun set_header_func(GtkListBoxUpdateHeaderFunc update_header, gpointer user_data, GDestroyNotify destroy) `{ gtk_list_box_set_header_func(self, GtkListBoxUpdateHeaderFunc update_header, gpointer user_data, GDestroyNotify destroy); `}
68 #fun set_sort_func(GtkListBoxSortFunc sort_func, gpointer user_data, GDestroyNotify destroy) `{ gtk_list_box_set_sort_func(self, GtkListBoxSortFunc sort_func, gpointer user_data, GDestroyNotify destroy); `}
69 end
70
71 # A single row of a `GtkListBox`
72 extern class GtkListBoxRow `{ GtkListBoxRow* `}
73 super GtkBin
74
75 new `{ return (GtkListBoxRow*)gtk_list_box_row_new(); `}
76
77 fun header: GtkWidget `{ return gtk_list_box_row_get_header(self); `}
78
79 fun header=(header: GtkWidget) `{ gtk_list_box_row_set_header(self, header); `}
80
81 fun index: Int `{ return gtk_list_box_row_get_index(self); `}
82
83 fun changed `{ gtk_list_box_row_changed(self); `}
84 end
85
86 # Horizontal container with a title and subtitle
87 extern class GtkHeaderBar `{ GtkHeaderBar* `}
88 super GtkContainer
89
90 new `{ return (GtkHeaderBar*)gtk_header_bar_new(); `}
91
92 fun title=(title: Text) do native_title = title.to_cstring
93 private fun native_title=(title: NativeString) `{ gtk_header_bar_set_title(self, title); `}
94
95 fun title: String do return native_title.to_s
96 private fun native_title: NativeString `{ return (gchar *)gtk_header_bar_get_title(self); `}
97
98 fun subtitle=(subtitle: Text) do native_subtitle = subtitle.to_cstring
99 fun native_subtitle=(subtitle: NativeString) `{ gtk_header_bar_set_subtitle(self, subtitle); `}
100
101 fun subtitle: String do return native_subtitle.to_s
102 fun native_subtitle: NativeString `{ return (gchar *)gtk_header_bar_get_subtitle(self); `}
103
104 fun custom_title=(title_widget: GtkWidget) `{ gtk_header_bar_set_custom_title(self, title_widget); `}
105
106 fun custom_title: GtkWidget `{ return gtk_header_bar_get_custom_title(self); `}
107
108 fun pack_start(child: GtkWidget) `{ gtk_header_bar_pack_start(self, child); `}
109
110 fun pack_end(child: GtkWidget) `{ gtk_header_bar_pack_end(self, child); `}
111
112 fun show_close_button=(setting: Bool) `{ gtk_header_bar_set_show_close_button(self, setting); `}
113
114 fun show_close_button: Bool `{ return gtk_header_bar_get_show_close_button(self); `}
115 end
116
117 # Container with a single child visible at a time
118 extern class GtkStack `{ GtkStack * `}
119 super GtkContainer
120
121 new `{ return (GtkStack*)gtk_stack_new(); `}
122
123 fun stack_add(child: GtkWidget, name: String) do native_stack_add(child, name.to_cstring)
124 private fun native_stack_add(child: GtkWidget, name: NativeString) `{ gtk_stack_add_named(self, child, name); `}
125
126 fun add_titled(child: GtkWidget, name, title: NativeString) `{ gtk_stack_add_titled(self, child, name, title); `}
127 fun native_add_titled(child: GtkWidget, name, title: NativeString) `{ gtk_stack_add_titled(self, child, name, title); `}
128
129 fun visible_child=(child: GtkWidget) `{ gtk_stack_set_visible_child(self, child); `}
130
131 fun visible_child: GtkWidget `{ return gtk_stack_get_visible_child(self); `}
132
133 fun visible_child_name=(name: Text) do native_visible_child_name = name.to_cstring
134 fun native_visible_child_name=(name: NativeString) `{ gtk_stack_set_visible_child_name(self, name); `}
135
136 fun visible_child_name: Text do return native_visible_child_name.to_s
137 fun native_visible_child_name: NativeString `{ return (gchar *)gtk_stack_get_visible_child_name(self); `}
138
139 fun set_visible_child_full(name: Text, transition: GtkStackTransitionType) do native_set_visible_child_full(name.to_cstring, transition)
140 fun native_set_visible_child_full(name: NativeString, transition: GtkStackTransitionType) `{
141 gtk_stack_set_visible_child_full(self, name, transition);
142 `}
143
144 fun homogeneous=(homogeneous: Bool) `{ gtk_stack_set_homogeneous(self, homogeneous); `}
145
146 fun homogeneous: Bool `{ return gtk_stack_get_homogeneous(self); `}
147
148 fun transition_duration=(duration: Int) `{ gtk_stack_set_transition_duration(self, duration); `}
149
150 fun transition_duration: Int `{ return gtk_stack_get_transition_duration(self); `}
151
152 fun transition_type=(transition: GtkStackTransitionType) `{ gtk_stack_set_transition_type(self, transition); `}
153
154 fun transition_type: GtkStackTransitionType `{ return gtk_stack_get_transition_type(self); `}
155 end
156
157 # Type of animation used for transitions between pages in a `GtkStack`
158 extern class GtkStackTransitionType `{ GtkStackTransitionType `}
159 new none `{ return GTK_STACK_TRANSITION_TYPE_NONE; `}
160 new crossfade `{ return GTK_STACK_TRANSITION_TYPE_CROSSFADE; `}
161 new slide_right `{ return GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT; `}
162 new slide_left `{ return GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT; `}
163 new slide_up `{ return GTK_STACK_TRANSITION_TYPE_SLIDE_UP; `}
164 new slide_down `{ return GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN; `}
165 new slide_left_right `{ return GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT; `}
166 new slide_up_down `{ return GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN; `}
167 end