1use gdk;
6use gdk_pixbuf;
7use gio;
8use glib::object::Cast;
9use glib::object::IsA;
10use glib::signal::connect_raw;
11use glib::signal::SignalHandlerId;
12use glib::translate::*;
13use glib::StaticType;
14use glib::ToValue;
15use glib::Value;
16use glib_sys;
17use gobject_sys;
18use gtk_sys;
19use pango;
20use std::boxed::Box as Box_;
21use std::fmt;
22use std::mem;
23use std::mem::transmute;
24use Adjustment;
25use Align;
26use Buildable;
27use CellEditable;
28use Container;
29use Editable;
30use Entry;
31use EntryBuffer;
32use EntryCompletion;
33use InputHints;
34use InputPurpose;
35use Orientable;
36use ShadowType;
37use SpinButtonUpdatePolicy;
38use SpinType;
39use Widget;
40
41glib_wrapper! {
42 pub struct SpinButton(Object<gtk_sys::GtkSpinButton, gtk_sys::GtkSpinButtonClass, SpinButtonClass>) @extends Entry, Widget, @implements Buildable, CellEditable, Editable, Orientable;
43
44 match fn {
45 get_type => || gtk_sys::gtk_spin_button_get_type(),
46 }
47}
48
49impl SpinButton {
50 pub fn new<P: IsA<Adjustment>>(
51 adjustment: Option<&P>,
52 climb_rate: f64,
53 digits: u32,
54 ) -> SpinButton {
55 assert_initialized_main_thread!();
56 unsafe {
57 Widget::from_glib_none(gtk_sys::gtk_spin_button_new(
58 adjustment.map(|p| p.as_ref()).to_glib_none().0,
59 climb_rate,
60 digits,
61 ))
62 .unsafe_cast()
63 }
64 }
65
66 pub fn new_with_range(min: f64, max: f64, step: f64) -> SpinButton {
67 assert_initialized_main_thread!();
68 unsafe {
69 Widget::from_glib_none(gtk_sys::gtk_spin_button_new_with_range(min, max, step))
70 .unsafe_cast()
71 }
72 }
73}
74
75pub struct SpinButtonBuilder {
76 adjustment: Option<Adjustment>,
77 climb_rate: Option<f64>,
78 digits: Option<u32>,
79 numeric: Option<bool>,
80 snap_to_ticks: Option<bool>,
81 update_policy: Option<SpinButtonUpdatePolicy>,
82 value: Option<f64>,
83 wrap: Option<bool>,
84 activates_default: Option<bool>,
85 attributes: Option<pango::AttrList>,
86 buffer: Option<EntryBuffer>,
87 caps_lock_warning: Option<bool>,
88 completion: Option<EntryCompletion>,
89 editable: Option<bool>,
90 enable_emoji_completion: Option<bool>,
91 has_frame: Option<bool>,
92 im_module: Option<String>,
93 input_hints: Option<InputHints>,
94 input_purpose: Option<InputPurpose>,
95 invisible_char: Option<u32>,
96 invisible_char_set: Option<bool>,
97 max_length: Option<i32>,
98 max_width_chars: Option<i32>,
99 overwrite_mode: Option<bool>,
100 placeholder_text: Option<String>,
101 populate_all: Option<bool>,
102 primary_icon_activatable: Option<bool>,
103 primary_icon_gicon: Option<gio::Icon>,
104 primary_icon_name: Option<String>,
105 primary_icon_pixbuf: Option<gdk_pixbuf::Pixbuf>,
106 primary_icon_sensitive: Option<bool>,
107 primary_icon_tooltip_markup: Option<String>,
108 primary_icon_tooltip_text: Option<String>,
109 progress_fraction: Option<f64>,
110 progress_pulse_step: Option<f64>,
111 secondary_icon_activatable: Option<bool>,
112 secondary_icon_gicon: Option<gio::Icon>,
113 secondary_icon_name: Option<String>,
114 secondary_icon_pixbuf: Option<gdk_pixbuf::Pixbuf>,
115 secondary_icon_sensitive: Option<bool>,
116 secondary_icon_tooltip_markup: Option<String>,
117 secondary_icon_tooltip_text: Option<String>,
118 shadow_type: Option<ShadowType>,
119 show_emoji_icon: Option<bool>,
120 tabs: Option<pango::TabArray>,
121 text: Option<String>,
122 truncate_multiline: Option<bool>,
123 visibility: Option<bool>,
124 width_chars: Option<i32>,
125 xalign: Option<f32>,
126 app_paintable: Option<bool>,
127 can_default: Option<bool>,
128 can_focus: Option<bool>,
129 events: Option<gdk::EventMask>,
130 expand: Option<bool>,
131 #[cfg(any(feature = "v3_20", feature = "dox"))]
132 focus_on_click: Option<bool>,
133 halign: Option<Align>,
134 has_default: Option<bool>,
135 has_focus: Option<bool>,
136 has_tooltip: Option<bool>,
137 height_request: Option<i32>,
138 hexpand: Option<bool>,
139 hexpand_set: Option<bool>,
140 is_focus: Option<bool>,
141 margin: Option<i32>,
142 margin_bottom: Option<i32>,
143 margin_end: Option<i32>,
144 margin_start: Option<i32>,
145 margin_top: Option<i32>,
146 name: Option<String>,
147 no_show_all: Option<bool>,
148 opacity: Option<f64>,
149 parent: Option<Container>,
150 receives_default: Option<bool>,
151 sensitive: Option<bool>,
152 tooltip_markup: Option<String>,
154 tooltip_text: Option<String>,
155 valign: Option<Align>,
156 vexpand: Option<bool>,
157 vexpand_set: Option<bool>,
158 visible: Option<bool>,
159 width_request: Option<i32>,
160}
161
162impl SpinButtonBuilder {
163 pub fn new() -> Self {
164 Self {
165 adjustment: None,
166 climb_rate: None,
167 digits: None,
168 numeric: None,
169 snap_to_ticks: None,
170 update_policy: None,
171 value: None,
172 wrap: None,
173 activates_default: None,
174 attributes: None,
175 buffer: None,
176 caps_lock_warning: None,
177 completion: None,
178 editable: None,
179 enable_emoji_completion: None,
180 has_frame: None,
181 im_module: None,
182 input_hints: None,
183 input_purpose: None,
184 invisible_char: None,
185 invisible_char_set: None,
186 max_length: None,
187 max_width_chars: None,
188 overwrite_mode: None,
189 placeholder_text: None,
190 populate_all: None,
191 primary_icon_activatable: None,
192 primary_icon_gicon: None,
193 primary_icon_name: None,
194 primary_icon_pixbuf: None,
195 primary_icon_sensitive: None,
196 primary_icon_tooltip_markup: None,
197 primary_icon_tooltip_text: None,
198 progress_fraction: None,
199 progress_pulse_step: None,
200 secondary_icon_activatable: None,
201 secondary_icon_gicon: None,
202 secondary_icon_name: None,
203 secondary_icon_pixbuf: None,
204 secondary_icon_sensitive: None,
205 secondary_icon_tooltip_markup: None,
206 secondary_icon_tooltip_text: None,
207 shadow_type: None,
208 show_emoji_icon: None,
209 tabs: None,
210 text: None,
211 truncate_multiline: None,
212 visibility: None,
213 width_chars: None,
214 xalign: None,
215 app_paintable: None,
216 can_default: None,
217 can_focus: None,
218 events: None,
219 expand: None,
220 #[cfg(any(feature = "v3_20", feature = "dox"))]
221 focus_on_click: None,
222 halign: None,
223 has_default: None,
224 has_focus: None,
225 has_tooltip: None,
226 height_request: None,
227 hexpand: None,
228 hexpand_set: None,
229 is_focus: None,
230 margin: None,
231 margin_bottom: None,
232 margin_end: None,
233 margin_start: None,
234 margin_top: None,
235 name: None,
236 no_show_all: None,
237 opacity: None,
238 parent: None,
239 receives_default: None,
240 sensitive: None,
241 tooltip_markup: None,
242 tooltip_text: None,
243 valign: None,
244 vexpand: None,
245 vexpand_set: None,
246 visible: None,
247 width_request: None,
248 }
249 }
250
251 pub fn build(self) -> SpinButton {
252 let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
253 if let Some(ref adjustment) = self.adjustment {
254 properties.push(("adjustment", adjustment));
255 }
256 if let Some(ref climb_rate) = self.climb_rate {
257 properties.push(("climb-rate", climb_rate));
258 }
259 if let Some(ref digits) = self.digits {
260 properties.push(("digits", digits));
261 }
262 if let Some(ref numeric) = self.numeric {
263 properties.push(("numeric", numeric));
264 }
265 if let Some(ref snap_to_ticks) = self.snap_to_ticks {
266 properties.push(("snap-to-ticks", snap_to_ticks));
267 }
268 if let Some(ref update_policy) = self.update_policy {
269 properties.push(("update-policy", update_policy));
270 }
271 if let Some(ref value) = self.value {
272 properties.push(("value", value));
273 }
274 if let Some(ref wrap) = self.wrap {
275 properties.push(("wrap", wrap));
276 }
277 if let Some(ref activates_default) = self.activates_default {
278 properties.push(("activates-default", activates_default));
279 }
280 if let Some(ref attributes) = self.attributes {
281 properties.push(("attributes", attributes));
282 }
283 if let Some(ref buffer) = self.buffer {
284 properties.push(("buffer", buffer));
285 }
286 if let Some(ref caps_lock_warning) = self.caps_lock_warning {
287 properties.push(("caps-lock-warning", caps_lock_warning));
288 }
289 if let Some(ref completion) = self.completion {
290 properties.push(("completion", completion));
291 }
292 if let Some(ref editable) = self.editable {
293 properties.push(("editable", editable));
294 }
295 if let Some(ref enable_emoji_completion) = self.enable_emoji_completion {
296 properties.push(("enable-emoji-completion", enable_emoji_completion));
297 }
298 if let Some(ref has_frame) = self.has_frame {
299 properties.push(("has-frame", has_frame));
300 }
301 if let Some(ref im_module) = self.im_module {
302 properties.push(("im-module", im_module));
303 }
304 if let Some(ref input_hints) = self.input_hints {
305 properties.push(("input-hints", input_hints));
306 }
307 if let Some(ref input_purpose) = self.input_purpose {
308 properties.push(("input-purpose", input_purpose));
309 }
310 if let Some(ref invisible_char) = self.invisible_char {
311 properties.push(("invisible-char", invisible_char));
312 }
313 if let Some(ref invisible_char_set) = self.invisible_char_set {
314 properties.push(("invisible-char-set", invisible_char_set));
315 }
316 if let Some(ref max_length) = self.max_length {
317 properties.push(("max-length", max_length));
318 }
319 if let Some(ref max_width_chars) = self.max_width_chars {
320 properties.push(("max-width-chars", max_width_chars));
321 }
322 if let Some(ref overwrite_mode) = self.overwrite_mode {
323 properties.push(("overwrite-mode", overwrite_mode));
324 }
325 if let Some(ref placeholder_text) = self.placeholder_text {
326 properties.push(("placeholder-text", placeholder_text));
327 }
328 if let Some(ref populate_all) = self.populate_all {
329 properties.push(("populate-all", populate_all));
330 }
331 if let Some(ref primary_icon_activatable) = self.primary_icon_activatable {
332 properties.push(("primary-icon-activatable", primary_icon_activatable));
333 }
334 if let Some(ref primary_icon_gicon) = self.primary_icon_gicon {
335 properties.push(("primary-icon-gicon", primary_icon_gicon));
336 }
337 if let Some(ref primary_icon_name) = self.primary_icon_name {
338 properties.push(("primary-icon-name", primary_icon_name));
339 }
340 if let Some(ref primary_icon_pixbuf) = self.primary_icon_pixbuf {
341 properties.push(("primary-icon-pixbuf", primary_icon_pixbuf));
342 }
343 if let Some(ref primary_icon_sensitive) = self.primary_icon_sensitive {
344 properties.push(("primary-icon-sensitive", primary_icon_sensitive));
345 }
346 if let Some(ref primary_icon_tooltip_markup) = self.primary_icon_tooltip_markup {
347 properties.push(("primary-icon-tooltip-markup", primary_icon_tooltip_markup));
348 }
349 if let Some(ref primary_icon_tooltip_text) = self.primary_icon_tooltip_text {
350 properties.push(("primary-icon-tooltip-text", primary_icon_tooltip_text));
351 }
352 if let Some(ref progress_fraction) = self.progress_fraction {
353 properties.push(("progress-fraction", progress_fraction));
354 }
355 if let Some(ref progress_pulse_step) = self.progress_pulse_step {
356 properties.push(("progress-pulse-step", progress_pulse_step));
357 }
358 if let Some(ref secondary_icon_activatable) = self.secondary_icon_activatable {
359 properties.push(("secondary-icon-activatable", secondary_icon_activatable));
360 }
361 if let Some(ref secondary_icon_gicon) = self.secondary_icon_gicon {
362 properties.push(("secondary-icon-gicon", secondary_icon_gicon));
363 }
364 if let Some(ref secondary_icon_name) = self.secondary_icon_name {
365 properties.push(("secondary-icon-name", secondary_icon_name));
366 }
367 if let Some(ref secondary_icon_pixbuf) = self.secondary_icon_pixbuf {
368 properties.push(("secondary-icon-pixbuf", secondary_icon_pixbuf));
369 }
370 if let Some(ref secondary_icon_sensitive) = self.secondary_icon_sensitive {
371 properties.push(("secondary-icon-sensitive", secondary_icon_sensitive));
372 }
373 if let Some(ref secondary_icon_tooltip_markup) = self.secondary_icon_tooltip_markup {
374 properties.push((
375 "secondary-icon-tooltip-markup",
376 secondary_icon_tooltip_markup,
377 ));
378 }
379 if let Some(ref secondary_icon_tooltip_text) = self.secondary_icon_tooltip_text {
380 properties.push(("secondary-icon-tooltip-text", secondary_icon_tooltip_text));
381 }
382 if let Some(ref shadow_type) = self.shadow_type {
383 properties.push(("shadow-type", shadow_type));
384 }
385 if let Some(ref show_emoji_icon) = self.show_emoji_icon {
386 properties.push(("show-emoji-icon", show_emoji_icon));
387 }
388 if let Some(ref tabs) = self.tabs {
389 properties.push(("tabs", tabs));
390 }
391 if let Some(ref text) = self.text {
392 properties.push(("text", text));
393 }
394 if let Some(ref truncate_multiline) = self.truncate_multiline {
395 properties.push(("truncate-multiline", truncate_multiline));
396 }
397 if let Some(ref visibility) = self.visibility {
398 properties.push(("visibility", visibility));
399 }
400 if let Some(ref width_chars) = self.width_chars {
401 properties.push(("width-chars", width_chars));
402 }
403 if let Some(ref xalign) = self.xalign {
404 properties.push(("xalign", xalign));
405 }
406 if let Some(ref app_paintable) = self.app_paintable {
407 properties.push(("app-paintable", app_paintable));
408 }
409 if let Some(ref can_default) = self.can_default {
410 properties.push(("can-default", can_default));
411 }
412 if let Some(ref can_focus) = self.can_focus {
413 properties.push(("can-focus", can_focus));
414 }
415 if let Some(ref events) = self.events {
416 properties.push(("events", events));
417 }
418 if let Some(ref expand) = self.expand {
419 properties.push(("expand", expand));
420 }
421 #[cfg(any(feature = "v3_20", feature = "dox"))]
422 {
423 if let Some(ref focus_on_click) = self.focus_on_click {
424 properties.push(("focus-on-click", focus_on_click));
425 }
426 }
427 if let Some(ref halign) = self.halign {
428 properties.push(("halign", halign));
429 }
430 if let Some(ref has_default) = self.has_default {
431 properties.push(("has-default", has_default));
432 }
433 if let Some(ref has_focus) = self.has_focus {
434 properties.push(("has-focus", has_focus));
435 }
436 if let Some(ref has_tooltip) = self.has_tooltip {
437 properties.push(("has-tooltip", has_tooltip));
438 }
439 if let Some(ref height_request) = self.height_request {
440 properties.push(("height-request", height_request));
441 }
442 if let Some(ref hexpand) = self.hexpand {
443 properties.push(("hexpand", hexpand));
444 }
445 if let Some(ref hexpand_set) = self.hexpand_set {
446 properties.push(("hexpand-set", hexpand_set));
447 }
448 if let Some(ref is_focus) = self.is_focus {
449 properties.push(("is-focus", is_focus));
450 }
451 if let Some(ref margin) = self.margin {
452 properties.push(("margin", margin));
453 }
454 if let Some(ref margin_bottom) = self.margin_bottom {
455 properties.push(("margin-bottom", margin_bottom));
456 }
457 if let Some(ref margin_end) = self.margin_end {
458 properties.push(("margin-end", margin_end));
459 }
460 if let Some(ref margin_start) = self.margin_start {
461 properties.push(("margin-start", margin_start));
462 }
463 if let Some(ref margin_top) = self.margin_top {
464 properties.push(("margin-top", margin_top));
465 }
466 if let Some(ref name) = self.name {
467 properties.push(("name", name));
468 }
469 if let Some(ref no_show_all) = self.no_show_all {
470 properties.push(("no-show-all", no_show_all));
471 }
472 if let Some(ref opacity) = self.opacity {
473 properties.push(("opacity", opacity));
474 }
475 if let Some(ref parent) = self.parent {
476 properties.push(("parent", parent));
477 }
478 if let Some(ref receives_default) = self.receives_default {
479 properties.push(("receives-default", receives_default));
480 }
481 if let Some(ref sensitive) = self.sensitive {
482 properties.push(("sensitive", sensitive));
483 }
484 if let Some(ref tooltip_markup) = self.tooltip_markup {
485 properties.push(("tooltip-markup", tooltip_markup));
486 }
487 if let Some(ref tooltip_text) = self.tooltip_text {
488 properties.push(("tooltip-text", tooltip_text));
489 }
490 if let Some(ref valign) = self.valign {
491 properties.push(("valign", valign));
492 }
493 if let Some(ref vexpand) = self.vexpand {
494 properties.push(("vexpand", vexpand));
495 }
496 if let Some(ref vexpand_set) = self.vexpand_set {
497 properties.push(("vexpand-set", vexpand_set));
498 }
499 if let Some(ref visible) = self.visible {
500 properties.push(("visible", visible));
501 }
502 if let Some(ref width_request) = self.width_request {
503 properties.push(("width-request", width_request));
504 }
505 glib::Object::new(SpinButton::static_type(), &properties)
506 .expect("object new")
507 .downcast()
508 .expect("downcast")
509 }
510
511 pub fn adjustment(mut self, adjustment: &Adjustment) -> Self {
512 self.adjustment = Some(adjustment.clone());
513 self
514 }
515
516 pub fn climb_rate(mut self, climb_rate: f64) -> Self {
517 self.climb_rate = Some(climb_rate);
518 self
519 }
520
521 pub fn digits(mut self, digits: u32) -> Self {
522 self.digits = Some(digits);
523 self
524 }
525
526 pub fn numeric(mut self, numeric: bool) -> Self {
527 self.numeric = Some(numeric);
528 self
529 }
530
531 pub fn snap_to_ticks(mut self, snap_to_ticks: bool) -> Self {
532 self.snap_to_ticks = Some(snap_to_ticks);
533 self
534 }
535
536 pub fn update_policy(mut self, update_policy: SpinButtonUpdatePolicy) -> Self {
537 self.update_policy = Some(update_policy);
538 self
539 }
540
541 pub fn value(mut self, value: f64) -> Self {
542 self.value = Some(value);
543 self
544 }
545
546 pub fn wrap(mut self, wrap: bool) -> Self {
547 self.wrap = Some(wrap);
548 self
549 }
550
551 pub fn activates_default(mut self, activates_default: bool) -> Self {
552 self.activates_default = Some(activates_default);
553 self
554 }
555
556 pub fn attributes(mut self, attributes: &pango::AttrList) -> Self {
557 self.attributes = Some(attributes.clone());
558 self
559 }
560
561 pub fn buffer(mut self, buffer: &EntryBuffer) -> Self {
562 self.buffer = Some(buffer.clone());
563 self
564 }
565
566 pub fn caps_lock_warning(mut self, caps_lock_warning: bool) -> Self {
567 self.caps_lock_warning = Some(caps_lock_warning);
568 self
569 }
570
571 pub fn completion(mut self, completion: &EntryCompletion) -> Self {
572 self.completion = Some(completion.clone());
573 self
574 }
575
576 pub fn editable(mut self, editable: bool) -> Self {
577 self.editable = Some(editable);
578 self
579 }
580
581 pub fn enable_emoji_completion(mut self, enable_emoji_completion: bool) -> Self {
582 self.enable_emoji_completion = Some(enable_emoji_completion);
583 self
584 }
585
586 pub fn has_frame(mut self, has_frame: bool) -> Self {
587 self.has_frame = Some(has_frame);
588 self
589 }
590
591 pub fn im_module(mut self, im_module: &str) -> Self {
592 self.im_module = Some(im_module.to_string());
593 self
594 }
595
596 pub fn input_hints(mut self, input_hints: InputHints) -> Self {
597 self.input_hints = Some(input_hints);
598 self
599 }
600
601 pub fn input_purpose(mut self, input_purpose: InputPurpose) -> Self {
602 self.input_purpose = Some(input_purpose);
603 self
604 }
605
606 pub fn invisible_char(mut self, invisible_char: u32) -> Self {
607 self.invisible_char = Some(invisible_char);
608 self
609 }
610
611 pub fn invisible_char_set(mut self, invisible_char_set: bool) -> Self {
612 self.invisible_char_set = Some(invisible_char_set);
613 self
614 }
615
616 pub fn max_length(mut self, max_length: i32) -> Self {
617 self.max_length = Some(max_length);
618 self
619 }
620
621 pub fn max_width_chars(mut self, max_width_chars: i32) -> Self {
622 self.max_width_chars = Some(max_width_chars);
623 self
624 }
625
626 pub fn overwrite_mode(mut self, overwrite_mode: bool) -> Self {
627 self.overwrite_mode = Some(overwrite_mode);
628 self
629 }
630
631 pub fn placeholder_text(mut self, placeholder_text: &str) -> Self {
632 self.placeholder_text = Some(placeholder_text.to_string());
633 self
634 }
635
636 pub fn populate_all(mut self, populate_all: bool) -> Self {
637 self.populate_all = Some(populate_all);
638 self
639 }
640
641 pub fn primary_icon_activatable(mut self, primary_icon_activatable: bool) -> Self {
642 self.primary_icon_activatable = Some(primary_icon_activatable);
643 self
644 }
645
646 pub fn primary_icon_gicon(mut self, primary_icon_gicon: &gio::Icon) -> Self {
647 self.primary_icon_gicon = Some(primary_icon_gicon.clone());
648 self
649 }
650
651 pub fn primary_icon_name(mut self, primary_icon_name: &str) -> Self {
652 self.primary_icon_name = Some(primary_icon_name.to_string());
653 self
654 }
655
656 pub fn primary_icon_pixbuf(mut self, primary_icon_pixbuf: &gdk_pixbuf::Pixbuf) -> Self {
657 self.primary_icon_pixbuf = Some(primary_icon_pixbuf.clone());
658 self
659 }
660
661 pub fn primary_icon_sensitive(mut self, primary_icon_sensitive: bool) -> Self {
662 self.primary_icon_sensitive = Some(primary_icon_sensitive);
663 self
664 }
665
666 pub fn primary_icon_tooltip_markup(mut self, primary_icon_tooltip_markup: &str) -> Self {
667 self.primary_icon_tooltip_markup = Some(primary_icon_tooltip_markup.to_string());
668 self
669 }
670
671 pub fn primary_icon_tooltip_text(mut self, primary_icon_tooltip_text: &str) -> Self {
672 self.primary_icon_tooltip_text = Some(primary_icon_tooltip_text.to_string());
673 self
674 }
675
676 pub fn progress_fraction(mut self, progress_fraction: f64) -> Self {
677 self.progress_fraction = Some(progress_fraction);
678 self
679 }
680
681 pub fn progress_pulse_step(mut self, progress_pulse_step: f64) -> Self {
682 self.progress_pulse_step = Some(progress_pulse_step);
683 self
684 }
685
686 pub fn secondary_icon_activatable(mut self, secondary_icon_activatable: bool) -> Self {
687 self.secondary_icon_activatable = Some(secondary_icon_activatable);
688 self
689 }
690
691 pub fn secondary_icon_gicon(mut self, secondary_icon_gicon: &gio::Icon) -> Self {
692 self.secondary_icon_gicon = Some(secondary_icon_gicon.clone());
693 self
694 }
695
696 pub fn secondary_icon_name(mut self, secondary_icon_name: &str) -> Self {
697 self.secondary_icon_name = Some(secondary_icon_name.to_string());
698 self
699 }
700
701 pub fn secondary_icon_pixbuf(mut self, secondary_icon_pixbuf: &gdk_pixbuf::Pixbuf) -> Self {
702 self.secondary_icon_pixbuf = Some(secondary_icon_pixbuf.clone());
703 self
704 }
705
706 pub fn secondary_icon_sensitive(mut self, secondary_icon_sensitive: bool) -> Self {
707 self.secondary_icon_sensitive = Some(secondary_icon_sensitive);
708 self
709 }
710
711 pub fn secondary_icon_tooltip_markup(mut self, secondary_icon_tooltip_markup: &str) -> Self {
712 self.secondary_icon_tooltip_markup = Some(secondary_icon_tooltip_markup.to_string());
713 self
714 }
715
716 pub fn secondary_icon_tooltip_text(mut self, secondary_icon_tooltip_text: &str) -> Self {
717 self.secondary_icon_tooltip_text = Some(secondary_icon_tooltip_text.to_string());
718 self
719 }
720
721 pub fn shadow_type(mut self, shadow_type: ShadowType) -> Self {
722 self.shadow_type = Some(shadow_type);
723 self
724 }
725
726 pub fn show_emoji_icon(mut self, show_emoji_icon: bool) -> Self {
727 self.show_emoji_icon = Some(show_emoji_icon);
728 self
729 }
730
731 pub fn tabs(mut self, tabs: &pango::TabArray) -> Self {
732 self.tabs = Some(tabs.clone());
733 self
734 }
735
736 pub fn text(mut self, text: &str) -> Self {
737 self.text = Some(text.to_string());
738 self
739 }
740
741 pub fn truncate_multiline(mut self, truncate_multiline: bool) -> Self {
742 self.truncate_multiline = Some(truncate_multiline);
743 self
744 }
745
746 pub fn visibility(mut self, visibility: bool) -> Self {
747 self.visibility = Some(visibility);
748 self
749 }
750
751 pub fn width_chars(mut self, width_chars: i32) -> Self {
752 self.width_chars = Some(width_chars);
753 self
754 }
755
756 pub fn xalign(mut self, xalign: f32) -> Self {
757 self.xalign = Some(xalign);
758 self
759 }
760
761 pub fn app_paintable(mut self, app_paintable: bool) -> Self {
762 self.app_paintable = Some(app_paintable);
763 self
764 }
765
766 pub fn can_default(mut self, can_default: bool) -> Self {
767 self.can_default = Some(can_default);
768 self
769 }
770
771 pub fn can_focus(mut self, can_focus: bool) -> Self {
772 self.can_focus = Some(can_focus);
773 self
774 }
775
776 pub fn events(mut self, events: gdk::EventMask) -> Self {
777 self.events = Some(events);
778 self
779 }
780
781 pub fn expand(mut self, expand: bool) -> Self {
782 self.expand = Some(expand);
783 self
784 }
785
786 #[cfg(any(feature = "v3_20", feature = "dox"))]
787 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
788 self.focus_on_click = Some(focus_on_click);
789 self
790 }
791
792 pub fn halign(mut self, halign: Align) -> Self {
793 self.halign = Some(halign);
794 self
795 }
796
797 pub fn has_default(mut self, has_default: bool) -> Self {
798 self.has_default = Some(has_default);
799 self
800 }
801
802 pub fn has_focus(mut self, has_focus: bool) -> Self {
803 self.has_focus = Some(has_focus);
804 self
805 }
806
807 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
808 self.has_tooltip = Some(has_tooltip);
809 self
810 }
811
812 pub fn height_request(mut self, height_request: i32) -> Self {
813 self.height_request = Some(height_request);
814 self
815 }
816
817 pub fn hexpand(mut self, hexpand: bool) -> Self {
818 self.hexpand = Some(hexpand);
819 self
820 }
821
822 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
823 self.hexpand_set = Some(hexpand_set);
824 self
825 }
826
827 pub fn is_focus(mut self, is_focus: bool) -> Self {
828 self.is_focus = Some(is_focus);
829 self
830 }
831
832 pub fn margin(mut self, margin: i32) -> Self {
833 self.margin = Some(margin);
834 self
835 }
836
837 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
838 self.margin_bottom = Some(margin_bottom);
839 self
840 }
841
842 pub fn margin_end(mut self, margin_end: i32) -> Self {
843 self.margin_end = Some(margin_end);
844 self
845 }
846
847 pub fn margin_start(mut self, margin_start: i32) -> Self {
848 self.margin_start = Some(margin_start);
849 self
850 }
851
852 pub fn margin_top(mut self, margin_top: i32) -> Self {
853 self.margin_top = Some(margin_top);
854 self
855 }
856
857 pub fn name(mut self, name: &str) -> Self {
858 self.name = Some(name.to_string());
859 self
860 }
861
862 pub fn no_show_all(mut self, no_show_all: bool) -> Self {
863 self.no_show_all = Some(no_show_all);
864 self
865 }
866
867 pub fn opacity(mut self, opacity: f64) -> Self {
868 self.opacity = Some(opacity);
869 self
870 }
871
872 pub fn parent(mut self, parent: &Container) -> Self {
873 self.parent = Some(parent.clone());
874 self
875 }
876
877 pub fn receives_default(mut self, receives_default: bool) -> Self {
878 self.receives_default = Some(receives_default);
879 self
880 }
881
882 pub fn sensitive(mut self, sensitive: bool) -> Self {
883 self.sensitive = Some(sensitive);
884 self
885 }
886
887 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
888 self.tooltip_markup = Some(tooltip_markup.to_string());
889 self
890 }
891
892 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
893 self.tooltip_text = Some(tooltip_text.to_string());
894 self
895 }
896
897 pub fn valign(mut self, valign: Align) -> Self {
898 self.valign = Some(valign);
899 self
900 }
901
902 pub fn vexpand(mut self, vexpand: bool) -> Self {
903 self.vexpand = Some(vexpand);
904 self
905 }
906
907 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
908 self.vexpand_set = Some(vexpand_set);
909 self
910 }
911
912 pub fn visible(mut self, visible: bool) -> Self {
913 self.visible = Some(visible);
914 self
915 }
916
917 pub fn width_request(mut self, width_request: i32) -> Self {
918 self.width_request = Some(width_request);
919 self
920 }
921}
922
923pub const NONE_SPIN_BUTTON: Option<&SpinButton> = None;
924
925pub trait SpinButtonExt: 'static {
926 fn configure<P: IsA<Adjustment>>(&self, adjustment: Option<&P>, climb_rate: f64, digits: u32);
927
928 fn get_adjustment(&self) -> Adjustment;
929
930 fn get_digits(&self) -> u32;
931
932 fn get_increments(&self) -> (f64, f64);
933
934 fn get_numeric(&self) -> bool;
935
936 fn get_range(&self) -> (f64, f64);
937
938 fn get_snap_to_ticks(&self) -> bool;
939
940 fn get_update_policy(&self) -> SpinButtonUpdatePolicy;
941
942 fn get_value(&self) -> f64;
943
944 fn get_value_as_int(&self) -> i32;
945
946 fn get_wrap(&self) -> bool;
947
948 fn set_adjustment<P: IsA<Adjustment>>(&self, adjustment: &P);
949
950 fn set_digits(&self, digits: u32);
951
952 fn set_increments(&self, step: f64, page: f64);
953
954 fn set_numeric(&self, numeric: bool);
955
956 fn set_range(&self, min: f64, max: f64);
957
958 fn set_snap_to_ticks(&self, snap_to_ticks: bool);
959
960 fn set_update_policy(&self, policy: SpinButtonUpdatePolicy);
961
962 fn set_value(&self, value: f64);
963
964 fn set_wrap(&self, wrap: bool);
965
966 fn spin(&self, direction: SpinType, increment: f64);
967
968 fn update(&self);
969
970 fn get_property_climb_rate(&self) -> f64;
971
972 fn set_property_climb_rate(&self, climb_rate: f64);
973
974 fn connect_property_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
975
976 fn connect_property_climb_rate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
977
978 fn connect_property_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
979
980 fn connect_property_numeric_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
981
982 fn connect_property_snap_to_ticks_notify<F: Fn(&Self) + 'static>(
983 &self,
984 f: F,
985 ) -> SignalHandlerId;
986
987 fn connect_property_update_policy_notify<F: Fn(&Self) + 'static>(
988 &self,
989 f: F,
990 ) -> SignalHandlerId;
991
992 fn connect_property_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
993
994 fn connect_property_wrap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
995}
996
997impl<O: IsA<SpinButton>> SpinButtonExt for O {
998 fn configure<P: IsA<Adjustment>>(&self, adjustment: Option<&P>, climb_rate: f64, digits: u32) {
999 unsafe {
1000 gtk_sys::gtk_spin_button_configure(
1001 self.as_ref().to_glib_none().0,
1002 adjustment.map(|p| p.as_ref()).to_glib_none().0,
1003 climb_rate,
1004 digits,
1005 );
1006 }
1007 }
1008
1009 fn get_adjustment(&self) -> Adjustment {
1010 unsafe {
1011 from_glib_none(gtk_sys::gtk_spin_button_get_adjustment(
1012 self.as_ref().to_glib_none().0,
1013 ))
1014 }
1015 }
1016
1017 fn get_digits(&self) -> u32 {
1018 unsafe { gtk_sys::gtk_spin_button_get_digits(self.as_ref().to_glib_none().0) }
1019 }
1020
1021 fn get_increments(&self) -> (f64, f64) {
1022 unsafe {
1023 let mut step = mem::uninitialized();
1024 let mut page = mem::uninitialized();
1025 gtk_sys::gtk_spin_button_get_increments(
1026 self.as_ref().to_glib_none().0,
1027 &mut step,
1028 &mut page,
1029 );
1030 (step, page)
1031 }
1032 }
1033
1034 fn get_numeric(&self) -> bool {
1035 unsafe {
1036 from_glib(gtk_sys::gtk_spin_button_get_numeric(
1037 self.as_ref().to_glib_none().0,
1038 ))
1039 }
1040 }
1041
1042 fn get_range(&self) -> (f64, f64) {
1043 unsafe {
1044 let mut min = mem::uninitialized();
1045 let mut max = mem::uninitialized();
1046 gtk_sys::gtk_spin_button_get_range(self.as_ref().to_glib_none().0, &mut min, &mut max);
1047 (min, max)
1048 }
1049 }
1050
1051 fn get_snap_to_ticks(&self) -> bool {
1052 unsafe {
1053 from_glib(gtk_sys::gtk_spin_button_get_snap_to_ticks(
1054 self.as_ref().to_glib_none().0,
1055 ))
1056 }
1057 }
1058
1059 fn get_update_policy(&self) -> SpinButtonUpdatePolicy {
1060 unsafe {
1061 from_glib(gtk_sys::gtk_spin_button_get_update_policy(
1062 self.as_ref().to_glib_none().0,
1063 ))
1064 }
1065 }
1066
1067 fn get_value(&self) -> f64 {
1068 unsafe { gtk_sys::gtk_spin_button_get_value(self.as_ref().to_glib_none().0) }
1069 }
1070
1071 fn get_value_as_int(&self) -> i32 {
1072 unsafe { gtk_sys::gtk_spin_button_get_value_as_int(self.as_ref().to_glib_none().0) }
1073 }
1074
1075 fn get_wrap(&self) -> bool {
1076 unsafe {
1077 from_glib(gtk_sys::gtk_spin_button_get_wrap(
1078 self.as_ref().to_glib_none().0,
1079 ))
1080 }
1081 }
1082
1083 fn set_adjustment<P: IsA<Adjustment>>(&self, adjustment: &P) {
1084 unsafe {
1085 gtk_sys::gtk_spin_button_set_adjustment(
1086 self.as_ref().to_glib_none().0,
1087 adjustment.as_ref().to_glib_none().0,
1088 );
1089 }
1090 }
1091
1092 fn set_digits(&self, digits: u32) {
1093 unsafe {
1094 gtk_sys::gtk_spin_button_set_digits(self.as_ref().to_glib_none().0, digits);
1095 }
1096 }
1097
1098 fn set_increments(&self, step: f64, page: f64) {
1099 unsafe {
1100 gtk_sys::gtk_spin_button_set_increments(self.as_ref().to_glib_none().0, step, page);
1101 }
1102 }
1103
1104 fn set_numeric(&self, numeric: bool) {
1105 unsafe {
1106 gtk_sys::gtk_spin_button_set_numeric(self.as_ref().to_glib_none().0, numeric.to_glib());
1107 }
1108 }
1109
1110 fn set_range(&self, min: f64, max: f64) {
1111 unsafe {
1112 gtk_sys::gtk_spin_button_set_range(self.as_ref().to_glib_none().0, min, max);
1113 }
1114 }
1115
1116 fn set_snap_to_ticks(&self, snap_to_ticks: bool) {
1117 unsafe {
1118 gtk_sys::gtk_spin_button_set_snap_to_ticks(
1119 self.as_ref().to_glib_none().0,
1120 snap_to_ticks.to_glib(),
1121 );
1122 }
1123 }
1124
1125 fn set_update_policy(&self, policy: SpinButtonUpdatePolicy) {
1126 unsafe {
1127 gtk_sys::gtk_spin_button_set_update_policy(
1128 self.as_ref().to_glib_none().0,
1129 policy.to_glib(),
1130 );
1131 }
1132 }
1133
1134 fn set_value(&self, value: f64) {
1135 unsafe {
1136 gtk_sys::gtk_spin_button_set_value(self.as_ref().to_glib_none().0, value);
1137 }
1138 }
1139
1140 fn set_wrap(&self, wrap: bool) {
1141 unsafe {
1142 gtk_sys::gtk_spin_button_set_wrap(self.as_ref().to_glib_none().0, wrap.to_glib());
1143 }
1144 }
1145
1146 fn spin(&self, direction: SpinType, increment: f64) {
1147 unsafe {
1148 gtk_sys::gtk_spin_button_spin(
1149 self.as_ref().to_glib_none().0,
1150 direction.to_glib(),
1151 increment,
1152 );
1153 }
1154 }
1155
1156 fn update(&self) {
1157 unsafe {
1158 gtk_sys::gtk_spin_button_update(self.as_ref().to_glib_none().0);
1159 }
1160 }
1161
1162 fn get_property_climb_rate(&self) -> f64 {
1163 unsafe {
1164 let mut value = Value::from_type(<f64 as StaticType>::static_type());
1165 gobject_sys::g_object_get_property(
1166 self.to_glib_none().0 as *mut gobject_sys::GObject,
1167 b"climb-rate\0".as_ptr() as *const _,
1168 value.to_glib_none_mut().0,
1169 );
1170 value.get().unwrap()
1171 }
1172 }
1173
1174 fn set_property_climb_rate(&self, climb_rate: f64) {
1175 unsafe {
1176 gobject_sys::g_object_set_property(
1177 self.to_glib_none().0 as *mut gobject_sys::GObject,
1178 b"climb-rate\0".as_ptr() as *const _,
1179 Value::from(&climb_rate).to_glib_none().0,
1180 );
1181 }
1182 }
1183
1184 fn connect_property_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1185 unsafe extern "C" fn notify_adjustment_trampoline<P, F: Fn(&P) + 'static>(
1186 this: *mut gtk_sys::GtkSpinButton,
1187 _param_spec: glib_sys::gpointer,
1188 f: glib_sys::gpointer,
1189 ) where
1190 P: IsA<SpinButton>,
1191 {
1192 let f: &F = &*(f as *const F);
1193 f(&SpinButton::from_glib_borrow(this).unsafe_cast())
1194 }
1195 unsafe {
1196 let f: Box_<F> = Box_::new(f);
1197 connect_raw(
1198 self.as_ptr() as *mut _,
1199 b"notify::adjustment\0".as_ptr() as *const _,
1200 Some(transmute(notify_adjustment_trampoline::<Self, F> as usize)),
1201 Box_::into_raw(f),
1202 )
1203 }
1204 }
1205
1206 fn connect_property_climb_rate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1207 unsafe extern "C" fn notify_climb_rate_trampoline<P, F: Fn(&P) + 'static>(
1208 this: *mut gtk_sys::GtkSpinButton,
1209 _param_spec: glib_sys::gpointer,
1210 f: glib_sys::gpointer,
1211 ) where
1212 P: IsA<SpinButton>,
1213 {
1214 let f: &F = &*(f as *const F);
1215 f(&SpinButton::from_glib_borrow(this).unsafe_cast())
1216 }
1217 unsafe {
1218 let f: Box_<F> = Box_::new(f);
1219 connect_raw(
1220 self.as_ptr() as *mut _,
1221 b"notify::climb-rate\0".as_ptr() as *const _,
1222 Some(transmute(notify_climb_rate_trampoline::<Self, F> as usize)),
1223 Box_::into_raw(f),
1224 )
1225 }
1226 }
1227
1228 fn connect_property_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1229 unsafe extern "C" fn notify_digits_trampoline<P, F: Fn(&P) + 'static>(
1230 this: *mut gtk_sys::GtkSpinButton,
1231 _param_spec: glib_sys::gpointer,
1232 f: glib_sys::gpointer,
1233 ) where
1234 P: IsA<SpinButton>,
1235 {
1236 let f: &F = &*(f as *const F);
1237 f(&SpinButton::from_glib_borrow(this).unsafe_cast())
1238 }
1239 unsafe {
1240 let f: Box_<F> = Box_::new(f);
1241 connect_raw(
1242 self.as_ptr() as *mut _,
1243 b"notify::digits\0".as_ptr() as *const _,
1244 Some(transmute(notify_digits_trampoline::<Self, F> as usize)),
1245 Box_::into_raw(f),
1246 )
1247 }
1248 }
1249
1250 fn connect_property_numeric_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1251 unsafe extern "C" fn notify_numeric_trampoline<P, F: Fn(&P) + 'static>(
1252 this: *mut gtk_sys::GtkSpinButton,
1253 _param_spec: glib_sys::gpointer,
1254 f: glib_sys::gpointer,
1255 ) where
1256 P: IsA<SpinButton>,
1257 {
1258 let f: &F = &*(f as *const F);
1259 f(&SpinButton::from_glib_borrow(this).unsafe_cast())
1260 }
1261 unsafe {
1262 let f: Box_<F> = Box_::new(f);
1263 connect_raw(
1264 self.as_ptr() as *mut _,
1265 b"notify::numeric\0".as_ptr() as *const _,
1266 Some(transmute(notify_numeric_trampoline::<Self, F> as usize)),
1267 Box_::into_raw(f),
1268 )
1269 }
1270 }
1271
1272 fn connect_property_snap_to_ticks_notify<F: Fn(&Self) + 'static>(
1273 &self,
1274 f: F,
1275 ) -> SignalHandlerId {
1276 unsafe extern "C" fn notify_snap_to_ticks_trampoline<P, F: Fn(&P) + 'static>(
1277 this: *mut gtk_sys::GtkSpinButton,
1278 _param_spec: glib_sys::gpointer,
1279 f: glib_sys::gpointer,
1280 ) where
1281 P: IsA<SpinButton>,
1282 {
1283 let f: &F = &*(f as *const F);
1284 f(&SpinButton::from_glib_borrow(this).unsafe_cast())
1285 }
1286 unsafe {
1287 let f: Box_<F> = Box_::new(f);
1288 connect_raw(
1289 self.as_ptr() as *mut _,
1290 b"notify::snap-to-ticks\0".as_ptr() as *const _,
1291 Some(transmute(
1292 notify_snap_to_ticks_trampoline::<Self, F> as usize,
1293 )),
1294 Box_::into_raw(f),
1295 )
1296 }
1297 }
1298
1299 fn connect_property_update_policy_notify<F: Fn(&Self) + 'static>(
1300 &self,
1301 f: F,
1302 ) -> SignalHandlerId {
1303 unsafe extern "C" fn notify_update_policy_trampoline<P, F: Fn(&P) + 'static>(
1304 this: *mut gtk_sys::GtkSpinButton,
1305 _param_spec: glib_sys::gpointer,
1306 f: glib_sys::gpointer,
1307 ) where
1308 P: IsA<SpinButton>,
1309 {
1310 let f: &F = &*(f as *const F);
1311 f(&SpinButton::from_glib_borrow(this).unsafe_cast())
1312 }
1313 unsafe {
1314 let f: Box_<F> = Box_::new(f);
1315 connect_raw(
1316 self.as_ptr() as *mut _,
1317 b"notify::update-policy\0".as_ptr() as *const _,
1318 Some(transmute(
1319 notify_update_policy_trampoline::<Self, F> as usize,
1320 )),
1321 Box_::into_raw(f),
1322 )
1323 }
1324 }
1325
1326 fn connect_property_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1327 unsafe extern "C" fn notify_value_trampoline<P, F: Fn(&P) + 'static>(
1328 this: *mut gtk_sys::GtkSpinButton,
1329 _param_spec: glib_sys::gpointer,
1330 f: glib_sys::gpointer,
1331 ) where
1332 P: IsA<SpinButton>,
1333 {
1334 let f: &F = &*(f as *const F);
1335 f(&SpinButton::from_glib_borrow(this).unsafe_cast())
1336 }
1337 unsafe {
1338 let f: Box_<F> = Box_::new(f);
1339 connect_raw(
1340 self.as_ptr() as *mut _,
1341 b"notify::value\0".as_ptr() as *const _,
1342 Some(transmute(notify_value_trampoline::<Self, F> as usize)),
1343 Box_::into_raw(f),
1344 )
1345 }
1346 }
1347
1348 fn connect_property_wrap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1349 unsafe extern "C" fn notify_wrap_trampoline<P, F: Fn(&P) + 'static>(
1350 this: *mut gtk_sys::GtkSpinButton,
1351 _param_spec: glib_sys::gpointer,
1352 f: glib_sys::gpointer,
1353 ) where
1354 P: IsA<SpinButton>,
1355 {
1356 let f: &F = &*(f as *const F);
1357 f(&SpinButton::from_glib_borrow(this).unsafe_cast())
1358 }
1359 unsafe {
1360 let f: Box_<F> = Box_::new(f);
1361 connect_raw(
1362 self.as_ptr() as *mut _,
1363 b"notify::wrap\0".as_ptr() as *const _,
1364 Some(transmute(notify_wrap_trampoline::<Self, F> as usize)),
1365 Box_::into_raw(f),
1366 )
1367 }
1368 }
1369}
1370
1371impl fmt::Display for SpinButton {
1372 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1373 write!(f, "SpinButton")
1374 }
1375}