1use gdk;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::translate::*;
9use glib::StaticType;
10use glib::ToValue;
11use gtk_sys;
12use std::fmt;
13use Align;
14use BaselinePosition;
15use Box;
16use Buildable;
17use Container;
18use Orientable;
19use RecentChooser;
20use RecentManager;
21use ResizeMode;
22use Widget;
23
24glib_wrapper! {
25 pub struct RecentChooserWidget(Object<gtk_sys::GtkRecentChooserWidget, gtk_sys::GtkRecentChooserWidgetClass, RecentChooserWidgetClass>) @extends Box, Container, Widget, @implements Buildable, Orientable, RecentChooser;
26
27 match fn {
28 get_type => || gtk_sys::gtk_recent_chooser_widget_get_type(),
29 }
30}
31
32impl RecentChooserWidget {
33 pub fn new() -> RecentChooserWidget {
34 assert_initialized_main_thread!();
35 unsafe { Widget::from_glib_none(gtk_sys::gtk_recent_chooser_widget_new()).unsafe_cast() }
36 }
37
38 pub fn new_for_manager<P: IsA<RecentManager>>(manager: &P) -> RecentChooserWidget {
39 skip_assert_initialized!();
40 unsafe {
41 Widget::from_glib_none(gtk_sys::gtk_recent_chooser_widget_new_for_manager(
42 manager.as_ref().to_glib_none().0,
43 ))
44 .unsafe_cast()
45 }
46 }
47}
48
49impl Default for RecentChooserWidget {
50 fn default() -> Self {
51 Self::new()
52 }
53}
54
55pub struct RecentChooserWidgetBuilder {
56 baseline_position: Option<BaselinePosition>,
57 homogeneous: Option<bool>,
58 spacing: Option<i32>,
59 border_width: Option<u32>,
60 child: Option<Widget>,
61 resize_mode: Option<ResizeMode>,
62 app_paintable: Option<bool>,
63 can_default: Option<bool>,
64 can_focus: Option<bool>,
65 events: Option<gdk::EventMask>,
66 expand: Option<bool>,
67 #[cfg(any(feature = "v3_20", feature = "dox"))]
68 focus_on_click: Option<bool>,
69 halign: Option<Align>,
70 has_default: Option<bool>,
71 has_focus: Option<bool>,
72 has_tooltip: Option<bool>,
73 height_request: Option<i32>,
74 hexpand: Option<bool>,
75 hexpand_set: Option<bool>,
76 is_focus: Option<bool>,
77 margin: Option<i32>,
78 margin_bottom: Option<i32>,
79 margin_end: Option<i32>,
80 margin_start: Option<i32>,
81 margin_top: Option<i32>,
82 name: Option<String>,
83 no_show_all: Option<bool>,
84 opacity: Option<f64>,
85 parent: Option<Container>,
86 receives_default: Option<bool>,
87 sensitive: Option<bool>,
88 tooltip_markup: Option<String>,
90 tooltip_text: Option<String>,
91 valign: Option<Align>,
92 vexpand: Option<bool>,
93 vexpand_set: Option<bool>,
94 visible: Option<bool>,
95 width_request: Option<i32>,
96}
97
98impl RecentChooserWidgetBuilder {
99 pub fn new() -> Self {
100 Self {
101 baseline_position: None,
102 homogeneous: None,
103 spacing: None,
104 border_width: None,
105 child: None,
106 resize_mode: None,
107 app_paintable: None,
108 can_default: None,
109 can_focus: None,
110 events: None,
111 expand: None,
112 #[cfg(any(feature = "v3_20", feature = "dox"))]
113 focus_on_click: None,
114 halign: None,
115 has_default: None,
116 has_focus: None,
117 has_tooltip: None,
118 height_request: None,
119 hexpand: None,
120 hexpand_set: None,
121 is_focus: None,
122 margin: None,
123 margin_bottom: None,
124 margin_end: None,
125 margin_start: None,
126 margin_top: None,
127 name: None,
128 no_show_all: None,
129 opacity: None,
130 parent: None,
131 receives_default: None,
132 sensitive: None,
133 tooltip_markup: None,
134 tooltip_text: None,
135 valign: None,
136 vexpand: None,
137 vexpand_set: None,
138 visible: None,
139 width_request: None,
140 }
141 }
142
143 pub fn build(self) -> RecentChooserWidget {
144 let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
145 if let Some(ref baseline_position) = self.baseline_position {
146 properties.push(("baseline-position", baseline_position));
147 }
148 if let Some(ref homogeneous) = self.homogeneous {
149 properties.push(("homogeneous", homogeneous));
150 }
151 if let Some(ref spacing) = self.spacing {
152 properties.push(("spacing", spacing));
153 }
154 if let Some(ref border_width) = self.border_width {
155 properties.push(("border-width", border_width));
156 }
157 if let Some(ref child) = self.child {
158 properties.push(("child", child));
159 }
160 if let Some(ref resize_mode) = self.resize_mode {
161 properties.push(("resize-mode", resize_mode));
162 }
163 if let Some(ref app_paintable) = self.app_paintable {
164 properties.push(("app-paintable", app_paintable));
165 }
166 if let Some(ref can_default) = self.can_default {
167 properties.push(("can-default", can_default));
168 }
169 if let Some(ref can_focus) = self.can_focus {
170 properties.push(("can-focus", can_focus));
171 }
172 if let Some(ref events) = self.events {
173 properties.push(("events", events));
174 }
175 if let Some(ref expand) = self.expand {
176 properties.push(("expand", expand));
177 }
178 #[cfg(any(feature = "v3_20", feature = "dox"))]
179 {
180 if let Some(ref focus_on_click) = self.focus_on_click {
181 properties.push(("focus-on-click", focus_on_click));
182 }
183 }
184 if let Some(ref halign) = self.halign {
185 properties.push(("halign", halign));
186 }
187 if let Some(ref has_default) = self.has_default {
188 properties.push(("has-default", has_default));
189 }
190 if let Some(ref has_focus) = self.has_focus {
191 properties.push(("has-focus", has_focus));
192 }
193 if let Some(ref has_tooltip) = self.has_tooltip {
194 properties.push(("has-tooltip", has_tooltip));
195 }
196 if let Some(ref height_request) = self.height_request {
197 properties.push(("height-request", height_request));
198 }
199 if let Some(ref hexpand) = self.hexpand {
200 properties.push(("hexpand", hexpand));
201 }
202 if let Some(ref hexpand_set) = self.hexpand_set {
203 properties.push(("hexpand-set", hexpand_set));
204 }
205 if let Some(ref is_focus) = self.is_focus {
206 properties.push(("is-focus", is_focus));
207 }
208 if let Some(ref margin) = self.margin {
209 properties.push(("margin", margin));
210 }
211 if let Some(ref margin_bottom) = self.margin_bottom {
212 properties.push(("margin-bottom", margin_bottom));
213 }
214 if let Some(ref margin_end) = self.margin_end {
215 properties.push(("margin-end", margin_end));
216 }
217 if let Some(ref margin_start) = self.margin_start {
218 properties.push(("margin-start", margin_start));
219 }
220 if let Some(ref margin_top) = self.margin_top {
221 properties.push(("margin-top", margin_top));
222 }
223 if let Some(ref name) = self.name {
224 properties.push(("name", name));
225 }
226 if let Some(ref no_show_all) = self.no_show_all {
227 properties.push(("no-show-all", no_show_all));
228 }
229 if let Some(ref opacity) = self.opacity {
230 properties.push(("opacity", opacity));
231 }
232 if let Some(ref parent) = self.parent {
233 properties.push(("parent", parent));
234 }
235 if let Some(ref receives_default) = self.receives_default {
236 properties.push(("receives-default", receives_default));
237 }
238 if let Some(ref sensitive) = self.sensitive {
239 properties.push(("sensitive", sensitive));
240 }
241 if let Some(ref tooltip_markup) = self.tooltip_markup {
242 properties.push(("tooltip-markup", tooltip_markup));
243 }
244 if let Some(ref tooltip_text) = self.tooltip_text {
245 properties.push(("tooltip-text", tooltip_text));
246 }
247 if let Some(ref valign) = self.valign {
248 properties.push(("valign", valign));
249 }
250 if let Some(ref vexpand) = self.vexpand {
251 properties.push(("vexpand", vexpand));
252 }
253 if let Some(ref vexpand_set) = self.vexpand_set {
254 properties.push(("vexpand-set", vexpand_set));
255 }
256 if let Some(ref visible) = self.visible {
257 properties.push(("visible", visible));
258 }
259 if let Some(ref width_request) = self.width_request {
260 properties.push(("width-request", width_request));
261 }
262 glib::Object::new(RecentChooserWidget::static_type(), &properties)
263 .expect("object new")
264 .downcast()
265 .expect("downcast")
266 }
267
268 pub fn baseline_position(mut self, baseline_position: BaselinePosition) -> Self {
269 self.baseline_position = Some(baseline_position);
270 self
271 }
272
273 pub fn homogeneous(mut self, homogeneous: bool) -> Self {
274 self.homogeneous = Some(homogeneous);
275 self
276 }
277
278 pub fn spacing(mut self, spacing: i32) -> Self {
279 self.spacing = Some(spacing);
280 self
281 }
282
283 pub fn border_width(mut self, border_width: u32) -> Self {
284 self.border_width = Some(border_width);
285 self
286 }
287
288 pub fn child(mut self, child: &Widget) -> Self {
289 self.child = Some(child.clone());
290 self
291 }
292
293 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
294 self.resize_mode = Some(resize_mode);
295 self
296 }
297
298 pub fn app_paintable(mut self, app_paintable: bool) -> Self {
299 self.app_paintable = Some(app_paintable);
300 self
301 }
302
303 pub fn can_default(mut self, can_default: bool) -> Self {
304 self.can_default = Some(can_default);
305 self
306 }
307
308 pub fn can_focus(mut self, can_focus: bool) -> Self {
309 self.can_focus = Some(can_focus);
310 self
311 }
312
313 pub fn events(mut self, events: gdk::EventMask) -> Self {
314 self.events = Some(events);
315 self
316 }
317
318 pub fn expand(mut self, expand: bool) -> Self {
319 self.expand = Some(expand);
320 self
321 }
322
323 #[cfg(any(feature = "v3_20", feature = "dox"))]
324 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
325 self.focus_on_click = Some(focus_on_click);
326 self
327 }
328
329 pub fn halign(mut self, halign: Align) -> Self {
330 self.halign = Some(halign);
331 self
332 }
333
334 pub fn has_default(mut self, has_default: bool) -> Self {
335 self.has_default = Some(has_default);
336 self
337 }
338
339 pub fn has_focus(mut self, has_focus: bool) -> Self {
340 self.has_focus = Some(has_focus);
341 self
342 }
343
344 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
345 self.has_tooltip = Some(has_tooltip);
346 self
347 }
348
349 pub fn height_request(mut self, height_request: i32) -> Self {
350 self.height_request = Some(height_request);
351 self
352 }
353
354 pub fn hexpand(mut self, hexpand: bool) -> Self {
355 self.hexpand = Some(hexpand);
356 self
357 }
358
359 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
360 self.hexpand_set = Some(hexpand_set);
361 self
362 }
363
364 pub fn is_focus(mut self, is_focus: bool) -> Self {
365 self.is_focus = Some(is_focus);
366 self
367 }
368
369 pub fn margin(mut self, margin: i32) -> Self {
370 self.margin = Some(margin);
371 self
372 }
373
374 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
375 self.margin_bottom = Some(margin_bottom);
376 self
377 }
378
379 pub fn margin_end(mut self, margin_end: i32) -> Self {
380 self.margin_end = Some(margin_end);
381 self
382 }
383
384 pub fn margin_start(mut self, margin_start: i32) -> Self {
385 self.margin_start = Some(margin_start);
386 self
387 }
388
389 pub fn margin_top(mut self, margin_top: i32) -> Self {
390 self.margin_top = Some(margin_top);
391 self
392 }
393
394 pub fn name(mut self, name: &str) -> Self {
395 self.name = Some(name.to_string());
396 self
397 }
398
399 pub fn no_show_all(mut self, no_show_all: bool) -> Self {
400 self.no_show_all = Some(no_show_all);
401 self
402 }
403
404 pub fn opacity(mut self, opacity: f64) -> Self {
405 self.opacity = Some(opacity);
406 self
407 }
408
409 pub fn parent(mut self, parent: &Container) -> Self {
410 self.parent = Some(parent.clone());
411 self
412 }
413
414 pub fn receives_default(mut self, receives_default: bool) -> Self {
415 self.receives_default = Some(receives_default);
416 self
417 }
418
419 pub fn sensitive(mut self, sensitive: bool) -> Self {
420 self.sensitive = Some(sensitive);
421 self
422 }
423
424 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
425 self.tooltip_markup = Some(tooltip_markup.to_string());
426 self
427 }
428
429 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
430 self.tooltip_text = Some(tooltip_text.to_string());
431 self
432 }
433
434 pub fn valign(mut self, valign: Align) -> Self {
435 self.valign = Some(valign);
436 self
437 }
438
439 pub fn vexpand(mut self, vexpand: bool) -> Self {
440 self.vexpand = Some(vexpand);
441 self
442 }
443
444 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
445 self.vexpand_set = Some(vexpand_set);
446 self
447 }
448
449 pub fn visible(mut self, visible: bool) -> Self {
450 self.visible = Some(visible);
451 self
452 }
453
454 pub fn width_request(mut self, width_request: i32) -> Self {
455 self.width_request = Some(width_request);
456 self
457 }
458}
459
460pub const NONE_RECENT_CHOOSER_WIDGET: Option<&RecentChooserWidget> = None;
461
462impl fmt::Display for RecentChooserWidget {
463 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
464 write!(f, "RecentChooserWidget")
465 }
466}