Skip to main content

gtk/auto/
cell_renderer_combo.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{CellRenderer, CellRendererMode, CellRendererText, TreeIter, TreeModel, TreePath, ffi};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// [`CellRendererCombo`][crate::CellRendererCombo] renders text in a cell like [`CellRendererText`][crate::CellRendererText] from
16    /// which it is derived. But while [`CellRendererText`][crate::CellRendererText] offers a simple entry to
17    /// edit the text, [`CellRendererCombo`][crate::CellRendererCombo] offers a [`ComboBox`][crate::ComboBox]
18    /// widget to edit the text. The values to display in the combo box are taken from
19    /// the tree model specified in the [`model`][struct@crate::CellRendererCombo#model] property.
20    ///
21    /// The combo cell renderer takes care of adding a text cell renderer to the combo
22    /// box and sets it to display the column specified by its
23    /// [`text-column`][struct@crate::CellRendererCombo#text-column] property. Further properties of the combo box
24    /// can be set in a handler for the [`editing-started`][struct@crate::CellRenderer#editing-started] signal.
25    ///
26    /// The [`CellRendererCombo`][crate::CellRendererCombo] cell renderer was added in GTK+ 2.6.
27    ///
28    /// ## Properties
29    ///
30    ///
31    /// #### `has-entry`
32    ///  If [`true`], the cell renderer will include an entry and allow to enter
33    /// values other than the ones in the popup list.
34    ///
35    /// Readable | Writable
36    ///
37    ///
38    /// #### `model`
39    ///  Holds a tree model containing the possible values for the combo box.
40    /// Use the text_column property to specify the column holding the values.
41    ///
42    /// Readable | Writable
43    ///
44    ///
45    /// #### `text-column`
46    ///  Specifies the model column which holds the possible values for the
47    /// combo box.
48    ///
49    /// Note that this refers to the model specified in the model property,
50    /// not the model backing the tree view to which
51    /// this cell renderer is attached.
52    ///
53    /// [`CellRendererCombo`][crate::CellRendererCombo] automatically adds a text cell renderer for
54    /// this column to its combo box.
55    ///
56    /// Readable | Writable
57    /// <details><summary><h4>CellRendererText</h4></summary>
58    ///
59    ///
60    /// #### `align-set`
61    ///  Readable | Writable
62    ///
63    ///
64    /// #### `alignment`
65    ///  Specifies how to align the lines of text with respect to each other.
66    ///
67    /// Note that this property describes how to align the lines of text in
68    /// case there are several of them. The "xalign" property of [`CellRenderer`][crate::CellRenderer],
69    /// on the other hand, sets the horizontal alignment of the whole text.
70    ///
71    /// Readable | Writable
72    ///
73    ///
74    /// #### `attributes`
75    ///  Readable | Writable
76    ///
77    ///
78    /// #### `background`
79    ///  Writable
80    ///
81    ///
82    /// #### `background-gdk`
83    ///  Background color as a `GdkColor`
84    ///
85    /// Readable | Writable
86    ///
87    ///
88    /// #### `background-rgba`
89    ///  Background color as a [`gdk::RGBA`][crate::gdk::RGBA]
90    ///
91    /// Readable | Writable
92    ///
93    ///
94    /// #### `background-set`
95    ///  Readable | Writable
96    ///
97    ///
98    /// #### `editable`
99    ///  Readable | Writable
100    ///
101    ///
102    /// #### `editable-set`
103    ///  Readable | Writable
104    ///
105    ///
106    /// #### `ellipsize`
107    ///  Specifies the preferred place to ellipsize the string, if the cell renderer
108    /// does not have enough room to display the entire string. Setting it to
109    /// [`pango::EllipsizeMode::None`][crate::pango::EllipsizeMode::None] turns off ellipsizing. See the wrap-width property
110    /// for another way of making the text fit into a given width.
111    ///
112    /// Readable | Writable
113    ///
114    ///
115    /// #### `ellipsize-set`
116    ///  Readable | Writable
117    ///
118    ///
119    /// #### `family`
120    ///  Readable | Writable
121    ///
122    ///
123    /// #### `family-set`
124    ///  Readable | Writable
125    ///
126    ///
127    /// #### `font`
128    ///  Readable | Writable
129    ///
130    ///
131    /// #### `font-desc`
132    ///  Readable | Writable
133    ///
134    ///
135    /// #### `foreground`
136    ///  Writable
137    ///
138    ///
139    /// #### `foreground-gdk`
140    ///  Foreground color as a `GdkColor`
141    ///
142    /// Readable | Writable
143    ///
144    ///
145    /// #### `foreground-rgba`
146    ///  Foreground color as a [`gdk::RGBA`][crate::gdk::RGBA]
147    ///
148    /// Readable | Writable
149    ///
150    ///
151    /// #### `foreground-set`
152    ///  Readable | Writable
153    ///
154    ///
155    /// #### `language`
156    ///  Readable | Writable
157    ///
158    ///
159    /// #### `language-set`
160    ///  Readable | Writable
161    ///
162    ///
163    /// #### `markup`
164    ///  Writable
165    ///
166    ///
167    /// #### `max-width-chars`
168    ///  The desired maximum width of the cell, in characters. If this property
169    /// is set to -1, the width will be calculated automatically.
170    ///
171    /// For cell renderers that ellipsize or wrap text; this property
172    /// controls the maximum reported width of the cell. The
173    /// cell should not receive any greater allocation unless it is
174    /// set to expand in its [`CellLayout`][crate::CellLayout] and all of the cell's siblings
175    /// have received their natural width.
176    ///
177    /// Readable | Writable
178    ///
179    ///
180    /// #### `placeholder-text`
181    ///  The text that will be displayed in the [`CellRenderer`][crate::CellRenderer] if
182    /// [`editable`][struct@crate::CellRendererText#editable] is [`true`] and the cell is empty.
183    ///
184    /// Since 3.6
185    ///
186    /// Readable | Writable
187    ///
188    ///
189    /// #### `rise`
190    ///  Readable | Writable
191    ///
192    ///
193    /// #### `rise-set`
194    ///  Readable | Writable
195    ///
196    ///
197    /// #### `scale`
198    ///  Readable | Writable
199    ///
200    ///
201    /// #### `scale-set`
202    ///  Readable | Writable
203    ///
204    ///
205    /// #### `single-paragraph-mode`
206    ///  Readable | Writable
207    ///
208    ///
209    /// #### `size`
210    ///  Readable | Writable
211    ///
212    ///
213    /// #### `size-points`
214    ///  Readable | Writable
215    ///
216    ///
217    /// #### `size-set`
218    ///  Readable | Writable
219    ///
220    ///
221    /// #### `stretch`
222    ///  Readable | Writable
223    ///
224    ///
225    /// #### `stretch-set`
226    ///  Readable | Writable
227    ///
228    ///
229    /// #### `strikethrough`
230    ///  Readable | Writable
231    ///
232    ///
233    /// #### `strikethrough-set`
234    ///  Readable | Writable
235    ///
236    ///
237    /// #### `style`
238    ///  Readable | Writable
239    ///
240    ///
241    /// #### `style-set`
242    ///  Readable | Writable
243    ///
244    ///
245    /// #### `text`
246    ///  Readable | Writable
247    ///
248    ///
249    /// #### `underline`
250    ///  Readable | Writable
251    ///
252    ///
253    /// #### `underline-set`
254    ///  Readable | Writable
255    ///
256    ///
257    /// #### `variant`
258    ///  Readable | Writable
259    ///
260    ///
261    /// #### `variant-set`
262    ///  Readable | Writable
263    ///
264    ///
265    /// #### `weight`
266    ///  Readable | Writable
267    ///
268    ///
269    /// #### `weight-set`
270    ///  Readable | Writable
271    ///
272    ///
273    /// #### `width-chars`
274    ///  The desired width of the cell, in characters. If this property is set to
275    /// -1, the width will be calculated automatically, otherwise the cell will
276    /// request either 3 characters or the property value, whichever is greater.
277    ///
278    /// Readable | Writable
279    ///
280    ///
281    /// #### `wrap-mode`
282    ///  Specifies how to break the string into multiple lines, if the cell
283    /// renderer does not have enough room to display the entire string.
284    /// This property has no effect unless the wrap-width property is set.
285    ///
286    /// Readable | Writable
287    ///
288    ///
289    /// #### `wrap-width`
290    ///  Specifies the minimum width at which the text is wrapped. The wrap-mode property can
291    /// be used to influence at what character positions the line breaks can be placed.
292    /// Setting wrap-width to -1 turns wrapping off.
293    ///
294    /// Readable | Writable
295    /// </details>
296    /// <details><summary><h4>CellRenderer</h4></summary>
297    ///
298    ///
299    /// #### `cell-background`
300    ///  Writable
301    ///
302    ///
303    /// #### `cell-background-gdk`
304    ///  Cell background as a `GdkColor`
305    ///
306    /// Readable | Writable
307    ///
308    ///
309    /// #### `cell-background-rgba`
310    ///  Cell background as a [`gdk::RGBA`][crate::gdk::RGBA]
311    ///
312    /// Readable | Writable
313    ///
314    ///
315    /// #### `cell-background-set`
316    ///  Readable | Writable
317    ///
318    ///
319    /// #### `editing`
320    ///  Readable
321    ///
322    ///
323    /// #### `height`
324    ///  Readable | Writable
325    ///
326    ///
327    /// #### `is-expanded`
328    ///  Readable | Writable
329    ///
330    ///
331    /// #### `is-expander`
332    ///  Readable | Writable
333    ///
334    ///
335    /// #### `mode`
336    ///  Readable | Writable
337    ///
338    ///
339    /// #### `sensitive`
340    ///  Readable | Writable
341    ///
342    ///
343    /// #### `visible`
344    ///  Readable | Writable
345    ///
346    ///
347    /// #### `width`
348    ///  Readable | Writable
349    ///
350    ///
351    /// #### `xalign`
352    ///  Readable | Writable
353    ///
354    ///
355    /// #### `xpad`
356    ///  Readable | Writable
357    ///
358    ///
359    /// #### `yalign`
360    ///  Readable | Writable
361    ///
362    ///
363    /// #### `ypad`
364    ///  Readable | Writable
365    /// </details>
366    ///
367    /// ## Signals
368    ///
369    ///
370    /// #### `changed`
371    ///  This signal is emitted each time after the user selected an item in
372    /// the combo box, either by using the mouse or the arrow keys. Contrary
373    /// to GtkComboBox, GtkCellRendererCombo::changed is not emitted for
374    /// changes made to a selected item in the entry. The argument `new_iter`
375    /// corresponds to the newly selected item in the combo box and it is relative
376    /// to the GtkTreeModel set via the model property on GtkCellRendererCombo.
377    ///
378    /// Note that as soon as you change the model displayed in the tree view,
379    /// the tree view will immediately cease the editing operating. This
380    /// means that you most probably want to refrain from changing the model
381    /// until the combo cell renderer emits the edited or editing_canceled signal.
382    ///
383    ///
384    /// <details><summary><h4>CellRendererText</h4></summary>
385    ///
386    ///
387    /// #### `edited`
388    ///  This signal is emitted after `renderer` has been edited.
389    ///
390    /// It is the responsibility of the application to update the model
391    /// and store `new_text` at the position indicated by `path`.
392    ///
393    ///
394    /// </details>
395    /// <details><summary><h4>CellRenderer</h4></summary>
396    ///
397    ///
398    /// #### `editing-canceled`
399    ///  This signal gets emitted when the user cancels the process of editing a
400    /// cell. For example, an editable cell renderer could be written to cancel
401    /// editing when the user presses Escape.
402    ///
403    /// See also: [`CellRendererExt::stop_editing()`][crate::prelude::CellRendererExt::stop_editing()].
404    ///
405    ///
406    ///
407    ///
408    /// #### `editing-started`
409    ///
410    /// static void
411    /// text_editing_started (GtkCellRenderer *cell,
412    ///  GtkCellEditable *editable,
413    ///  const gchar *path,
414    ///  gpointer data)
415    /// {
416    ///  if (GTK_IS_ENTRY (editable))
417    ///  {
418    ///  GtkEntry *entry = GTK_ENTRY (editable);
419    ///
420    ///  // ... create a GtkEntryCompletion
421    ///
422    ///  gtk_entry_set_completion (entry, completion);
423    ///  }
424    /// }
425    /// ]|
426    ///
427    ///
428    /// </details>
429    ///
430    /// # Implements
431    ///
432    /// [`CellRendererComboExt`][trait@crate::prelude::CellRendererComboExt], [`CellRendererTextExt`][trait@crate::prelude::CellRendererTextExt], [`CellRendererExt`][trait@crate::prelude::CellRendererExt], [`trait@glib::ObjectExt`]
433    #[doc(alias = "GtkCellRendererCombo")]
434    pub struct CellRendererCombo(Object<ffi::GtkCellRendererCombo, ffi::GtkCellRendererComboClass>) @extends CellRendererText, CellRenderer;
435
436    match fn {
437        type_ => || ffi::gtk_cell_renderer_combo_get_type(),
438    }
439}
440
441impl CellRendererCombo {
442    pub const NONE: Option<&'static CellRendererCombo> = None;
443
444    /// Creates a new [`CellRendererCombo`][crate::CellRendererCombo].
445    /// Adjust how text is drawn using object properties.
446    /// Object properties can be set globally (with [`ObjectExt::set()`][crate::glib::prelude::ObjectExt::set()]).
447    /// Also, with [`TreeViewColumn`][crate::TreeViewColumn], you can bind a property to a value
448    /// in a [`TreeModel`][crate::TreeModel]. For example, you can bind the “text” property
449    /// on the cell renderer to a string value in the model, thus rendering
450    /// a different string in each row of the [`TreeView`][crate::TreeView].
451    ///
452    /// # Returns
453    ///
454    /// the new cell renderer
455    #[doc(alias = "gtk_cell_renderer_combo_new")]
456    pub fn new() -> CellRendererCombo {
457        assert_initialized_main_thread!();
458        unsafe { CellRenderer::from_glib_none(ffi::gtk_cell_renderer_combo_new()).unsafe_cast() }
459    }
460
461    // rustdoc-stripper-ignore-next
462    /// Creates a new builder-pattern struct instance to construct [`CellRendererCombo`] objects.
463    ///
464    /// This method returns an instance of [`CellRendererComboBuilder`](crate::builders::CellRendererComboBuilder) which can be used to create [`CellRendererCombo`] objects.
465    pub fn builder() -> CellRendererComboBuilder {
466        CellRendererComboBuilder::new()
467    }
468}
469
470impl Default for CellRendererCombo {
471    fn default() -> Self {
472        Self::new()
473    }
474}
475
476// rustdoc-stripper-ignore-next
477/// A [builder-pattern] type to construct [`CellRendererCombo`] objects.
478///
479/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
480#[must_use = "The builder must be built to be used"]
481pub struct CellRendererComboBuilder {
482    builder: glib::object::ObjectBuilder<'static, CellRendererCombo>,
483}
484
485impl CellRendererComboBuilder {
486    fn new() -> Self {
487        Self {
488            builder: glib::object::Object::builder(),
489        }
490    }
491
492    /// If [`true`], the cell renderer will include an entry and allow to enter
493    /// values other than the ones in the popup list.
494    pub fn has_entry(self, has_entry: bool) -> Self {
495        Self {
496            builder: self.builder.property("has-entry", has_entry),
497        }
498    }
499
500    /// Holds a tree model containing the possible values for the combo box.
501    /// Use the text_column property to specify the column holding the values.
502    pub fn model(self, model: &impl IsA<TreeModel>) -> Self {
503        Self {
504            builder: self.builder.property("model", model.clone().upcast()),
505        }
506    }
507
508    /// Specifies the model column which holds the possible values for the
509    /// combo box.
510    ///
511    /// Note that this refers to the model specified in the model property,
512    /// not the model backing the tree view to which
513    /// this cell renderer is attached.
514    ///
515    /// [`CellRendererCombo`][crate::CellRendererCombo] automatically adds a text cell renderer for
516    /// this column to its combo box.
517    pub fn text_column(self, text_column: i32) -> Self {
518        Self {
519            builder: self.builder.property("text-column", text_column),
520        }
521    }
522
523    pub fn align_set(self, align_set: bool) -> Self {
524        Self {
525            builder: self.builder.property("align-set", align_set),
526        }
527    }
528
529    /// Specifies how to align the lines of text with respect to each other.
530    ///
531    /// Note that this property describes how to align the lines of text in
532    /// case there are several of them. The "xalign" property of [`CellRenderer`][crate::CellRenderer],
533    /// on the other hand, sets the horizontal alignment of the whole text.
534    pub fn alignment(self, alignment: pango::Alignment) -> Self {
535        Self {
536            builder: self.builder.property("alignment", alignment),
537        }
538    }
539
540    pub fn attributes(self, attributes: &pango::AttrList) -> Self {
541        Self {
542            builder: self.builder.property("attributes", attributes.clone()),
543        }
544    }
545
546    pub fn background(self, background: impl Into<glib::GString>) -> Self {
547        Self {
548            builder: self.builder.property("background", background.into()),
549        }
550    }
551
552    /// Background color as a [`gdk::RGBA`][crate::gdk::RGBA]
553    pub fn background_rgba(self, background_rgba: &gdk::RGBA) -> Self {
554        Self {
555            builder: self.builder.property("background-rgba", background_rgba),
556        }
557    }
558
559    pub fn background_set(self, background_set: bool) -> Self {
560        Self {
561            builder: self.builder.property("background-set", background_set),
562        }
563    }
564
565    pub fn editable(self, editable: bool) -> Self {
566        Self {
567            builder: self.builder.property("editable", editable),
568        }
569    }
570
571    pub fn editable_set(self, editable_set: bool) -> Self {
572        Self {
573            builder: self.builder.property("editable-set", editable_set),
574        }
575    }
576
577    /// Specifies the preferred place to ellipsize the string, if the cell renderer
578    /// does not have enough room to display the entire string. Setting it to
579    /// [`pango::EllipsizeMode::None`][crate::pango::EllipsizeMode::None] turns off ellipsizing. See the wrap-width property
580    /// for another way of making the text fit into a given width.
581    pub fn ellipsize(self, ellipsize: pango::EllipsizeMode) -> Self {
582        Self {
583            builder: self.builder.property("ellipsize", ellipsize),
584        }
585    }
586
587    pub fn ellipsize_set(self, ellipsize_set: bool) -> Self {
588        Self {
589            builder: self.builder.property("ellipsize-set", ellipsize_set),
590        }
591    }
592
593    pub fn family(self, family: impl Into<glib::GString>) -> Self {
594        Self {
595            builder: self.builder.property("family", family.into()),
596        }
597    }
598
599    pub fn family_set(self, family_set: bool) -> Self {
600        Self {
601            builder: self.builder.property("family-set", family_set),
602        }
603    }
604
605    pub fn font(self, font: impl Into<glib::GString>) -> Self {
606        Self {
607            builder: self.builder.property("font", font.into()),
608        }
609    }
610
611    pub fn font_desc(self, font_desc: &pango::FontDescription) -> Self {
612        Self {
613            builder: self.builder.property("font-desc", font_desc),
614        }
615    }
616
617    pub fn foreground(self, foreground: impl Into<glib::GString>) -> Self {
618        Self {
619            builder: self.builder.property("foreground", foreground.into()),
620        }
621    }
622
623    /// Foreground color as a [`gdk::RGBA`][crate::gdk::RGBA]
624    pub fn foreground_rgba(self, foreground_rgba: &gdk::RGBA) -> Self {
625        Self {
626            builder: self.builder.property("foreground-rgba", foreground_rgba),
627        }
628    }
629
630    pub fn foreground_set(self, foreground_set: bool) -> Self {
631        Self {
632            builder: self.builder.property("foreground-set", foreground_set),
633        }
634    }
635
636    pub fn language(self, language: impl Into<glib::GString>) -> Self {
637        Self {
638            builder: self.builder.property("language", language.into()),
639        }
640    }
641
642    pub fn language_set(self, language_set: bool) -> Self {
643        Self {
644            builder: self.builder.property("language-set", language_set),
645        }
646    }
647
648    pub fn markup(self, markup: impl Into<glib::GString>) -> Self {
649        Self {
650            builder: self.builder.property("markup", markup.into()),
651        }
652    }
653
654    /// The desired maximum width of the cell, in characters. If this property
655    /// is set to -1, the width will be calculated automatically.
656    ///
657    /// For cell renderers that ellipsize or wrap text; this property
658    /// controls the maximum reported width of the cell. The
659    /// cell should not receive any greater allocation unless it is
660    /// set to expand in its [`CellLayout`][crate::CellLayout] and all of the cell's siblings
661    /// have received their natural width.
662    pub fn max_width_chars(self, max_width_chars: i32) -> Self {
663        Self {
664            builder: self.builder.property("max-width-chars", max_width_chars),
665        }
666    }
667
668    /// The text that will be displayed in the [`CellRenderer`][crate::CellRenderer] if
669    /// [`editable`][struct@crate::CellRendererText#editable] is [`true`] and the cell is empty.
670    ///
671    /// Since 3.6
672    pub fn placeholder_text(self, placeholder_text: impl Into<glib::GString>) -> Self {
673        Self {
674            builder: self
675                .builder
676                .property("placeholder-text", placeholder_text.into()),
677        }
678    }
679
680    pub fn rise(self, rise: i32) -> Self {
681        Self {
682            builder: self.builder.property("rise", rise),
683        }
684    }
685
686    pub fn rise_set(self, rise_set: bool) -> Self {
687        Self {
688            builder: self.builder.property("rise-set", rise_set),
689        }
690    }
691
692    pub fn scale(self, scale: f64) -> Self {
693        Self {
694            builder: self.builder.property("scale", scale),
695        }
696    }
697
698    pub fn scale_set(self, scale_set: bool) -> Self {
699        Self {
700            builder: self.builder.property("scale-set", scale_set),
701        }
702    }
703
704    pub fn single_paragraph_mode(self, single_paragraph_mode: bool) -> Self {
705        Self {
706            builder: self
707                .builder
708                .property("single-paragraph-mode", single_paragraph_mode),
709        }
710    }
711
712    pub fn size(self, size: i32) -> Self {
713        Self {
714            builder: self.builder.property("size", size),
715        }
716    }
717
718    pub fn size_points(self, size_points: f64) -> Self {
719        Self {
720            builder: self.builder.property("size-points", size_points),
721        }
722    }
723
724    pub fn size_set(self, size_set: bool) -> Self {
725        Self {
726            builder: self.builder.property("size-set", size_set),
727        }
728    }
729
730    pub fn stretch(self, stretch: pango::Stretch) -> Self {
731        Self {
732            builder: self.builder.property("stretch", stretch),
733        }
734    }
735
736    pub fn stretch_set(self, stretch_set: bool) -> Self {
737        Self {
738            builder: self.builder.property("stretch-set", stretch_set),
739        }
740    }
741
742    pub fn strikethrough(self, strikethrough: bool) -> Self {
743        Self {
744            builder: self.builder.property("strikethrough", strikethrough),
745        }
746    }
747
748    pub fn strikethrough_set(self, strikethrough_set: bool) -> Self {
749        Self {
750            builder: self
751                .builder
752                .property("strikethrough-set", strikethrough_set),
753        }
754    }
755
756    pub fn style(self, style: pango::Style) -> Self {
757        Self {
758            builder: self.builder.property("style", style),
759        }
760    }
761
762    pub fn style_set(self, style_set: bool) -> Self {
763        Self {
764            builder: self.builder.property("style-set", style_set),
765        }
766    }
767
768    pub fn text(self, text: impl Into<glib::GString>) -> Self {
769        Self {
770            builder: self.builder.property("text", text.into()),
771        }
772    }
773
774    pub fn underline(self, underline: pango::Underline) -> Self {
775        Self {
776            builder: self.builder.property("underline", underline),
777        }
778    }
779
780    pub fn underline_set(self, underline_set: bool) -> Self {
781        Self {
782            builder: self.builder.property("underline-set", underline_set),
783        }
784    }
785
786    pub fn variant(self, variant: pango::Variant) -> Self {
787        Self {
788            builder: self.builder.property("variant", variant),
789        }
790    }
791
792    pub fn variant_set(self, variant_set: bool) -> Self {
793        Self {
794            builder: self.builder.property("variant-set", variant_set),
795        }
796    }
797
798    pub fn weight(self, weight: i32) -> Self {
799        Self {
800            builder: self.builder.property("weight", weight),
801        }
802    }
803
804    pub fn weight_set(self, weight_set: bool) -> Self {
805        Self {
806            builder: self.builder.property("weight-set", weight_set),
807        }
808    }
809
810    /// The desired width of the cell, in characters. If this property is set to
811    /// -1, the width will be calculated automatically, otherwise the cell will
812    /// request either 3 characters or the property value, whichever is greater.
813    pub fn width_chars(self, width_chars: i32) -> Self {
814        Self {
815            builder: self.builder.property("width-chars", width_chars),
816        }
817    }
818
819    /// Specifies how to break the string into multiple lines, if the cell
820    /// renderer does not have enough room to display the entire string.
821    /// This property has no effect unless the wrap-width property is set.
822    pub fn wrap_mode(self, wrap_mode: pango::WrapMode) -> Self {
823        Self {
824            builder: self.builder.property("wrap-mode", wrap_mode),
825        }
826    }
827
828    /// Specifies the minimum width at which the text is wrapped. The wrap-mode property can
829    /// be used to influence at what character positions the line breaks can be placed.
830    /// Setting wrap-width to -1 turns wrapping off.
831    pub fn wrap_width(self, wrap_width: i32) -> Self {
832        Self {
833            builder: self.builder.property("wrap-width", wrap_width),
834        }
835    }
836
837    pub fn cell_background(self, cell_background: impl Into<glib::GString>) -> Self {
838        Self {
839            builder: self
840                .builder
841                .property("cell-background", cell_background.into()),
842        }
843    }
844
845    /// Cell background as a [`gdk::RGBA`][crate::gdk::RGBA]
846    pub fn cell_background_rgba(self, cell_background_rgba: &gdk::RGBA) -> Self {
847        Self {
848            builder: self
849                .builder
850                .property("cell-background-rgba", cell_background_rgba),
851        }
852    }
853
854    pub fn cell_background_set(self, cell_background_set: bool) -> Self {
855        Self {
856            builder: self
857                .builder
858                .property("cell-background-set", cell_background_set),
859        }
860    }
861
862    pub fn height(self, height: i32) -> Self {
863        Self {
864            builder: self.builder.property("height", height),
865        }
866    }
867
868    pub fn is_expanded(self, is_expanded: bool) -> Self {
869        Self {
870            builder: self.builder.property("is-expanded", is_expanded),
871        }
872    }
873
874    pub fn is_expander(self, is_expander: bool) -> Self {
875        Self {
876            builder: self.builder.property("is-expander", is_expander),
877        }
878    }
879
880    pub fn mode(self, mode: CellRendererMode) -> Self {
881        Self {
882            builder: self.builder.property("mode", mode),
883        }
884    }
885
886    pub fn sensitive(self, sensitive: bool) -> Self {
887        Self {
888            builder: self.builder.property("sensitive", sensitive),
889        }
890    }
891
892    pub fn visible(self, visible: bool) -> Self {
893        Self {
894            builder: self.builder.property("visible", visible),
895        }
896    }
897
898    pub fn width(self, width: i32) -> Self {
899        Self {
900            builder: self.builder.property("width", width),
901        }
902    }
903
904    pub fn xalign(self, xalign: f32) -> Self {
905        Self {
906            builder: self.builder.property("xalign", xalign),
907        }
908    }
909
910    pub fn xpad(self, xpad: u32) -> Self {
911        Self {
912            builder: self.builder.property("xpad", xpad),
913        }
914    }
915
916    pub fn yalign(self, yalign: f32) -> Self {
917        Self {
918            builder: self.builder.property("yalign", yalign),
919        }
920    }
921
922    pub fn ypad(self, ypad: u32) -> Self {
923        Self {
924            builder: self.builder.property("ypad", ypad),
925        }
926    }
927
928    // rustdoc-stripper-ignore-next
929    /// Build the [`CellRendererCombo`].
930    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
931    pub fn build(self) -> CellRendererCombo {
932        assert_initialized_main_thread!();
933        self.builder.build()
934    }
935}
936
937/// Trait containing all [`struct@CellRendererCombo`] methods.
938///
939/// # Implementors
940///
941/// [`CellRendererCombo`][struct@crate::CellRendererCombo]
942pub trait CellRendererComboExt: IsA<CellRendererCombo> + 'static {
943    /// If [`true`], the cell renderer will include an entry and allow to enter
944    /// values other than the ones in the popup list.
945    #[doc(alias = "has-entry")]
946    fn has_entry(&self) -> bool {
947        ObjectExt::property(self.as_ref(), "has-entry")
948    }
949
950    /// If [`true`], the cell renderer will include an entry and allow to enter
951    /// values other than the ones in the popup list.
952    #[doc(alias = "has-entry")]
953    fn set_has_entry(&self, has_entry: bool) {
954        ObjectExt::set_property(self.as_ref(), "has-entry", has_entry)
955    }
956
957    /// Holds a tree model containing the possible values for the combo box.
958    /// Use the text_column property to specify the column holding the values.
959    fn model(&self) -> Option<TreeModel> {
960        ObjectExt::property(self.as_ref(), "model")
961    }
962
963    /// Holds a tree model containing the possible values for the combo box.
964    /// Use the text_column property to specify the column holding the values.
965    fn set_model<P: IsA<TreeModel>>(&self, model: Option<&P>) {
966        ObjectExt::set_property(self.as_ref(), "model", model)
967    }
968
969    /// Specifies the model column which holds the possible values for the
970    /// combo box.
971    ///
972    /// Note that this refers to the model specified in the model property,
973    /// not the model backing the tree view to which
974    /// this cell renderer is attached.
975    ///
976    /// [`CellRendererCombo`][crate::CellRendererCombo] automatically adds a text cell renderer for
977    /// this column to its combo box.
978    #[doc(alias = "text-column")]
979    fn text_column(&self) -> i32 {
980        ObjectExt::property(self.as_ref(), "text-column")
981    }
982
983    /// Specifies the model column which holds the possible values for the
984    /// combo box.
985    ///
986    /// Note that this refers to the model specified in the model property,
987    /// not the model backing the tree view to which
988    /// this cell renderer is attached.
989    ///
990    /// [`CellRendererCombo`][crate::CellRendererCombo] automatically adds a text cell renderer for
991    /// this column to its combo box.
992    #[doc(alias = "text-column")]
993    fn set_text_column(&self, text_column: i32) {
994        ObjectExt::set_property(self.as_ref(), "text-column", text_column)
995    }
996
997    /// This signal is emitted each time after the user selected an item in
998    /// the combo box, either by using the mouse or the arrow keys. Contrary
999    /// to GtkComboBox, GtkCellRendererCombo::changed is not emitted for
1000    /// changes made to a selected item in the entry. The argument `new_iter`
1001    /// corresponds to the newly selected item in the combo box and it is relative
1002    /// to the GtkTreeModel set via the model property on GtkCellRendererCombo.
1003    ///
1004    /// Note that as soon as you change the model displayed in the tree view,
1005    /// the tree view will immediately cease the editing operating. This
1006    /// means that you most probably want to refrain from changing the model
1007    /// until the combo cell renderer emits the edited or editing_canceled signal.
1008    /// ## `path_string`
1009    /// a string of the path identifying the edited cell
1010    ///  (relative to the tree view model)
1011    /// ## `new_iter`
1012    /// the new iter selected in the combo box
1013    ///  (relative to the combo box model)
1014    #[doc(alias = "changed")]
1015    fn connect_changed<F: Fn(&Self, TreePath, &TreeIter) + 'static>(
1016        &self,
1017        f: F,
1018    ) -> SignalHandlerId {
1019        unsafe extern "C" fn changed_trampoline<
1020            P: IsA<CellRendererCombo>,
1021            F: Fn(&P, TreePath, &TreeIter) + 'static,
1022        >(
1023            this: *mut ffi::GtkCellRendererCombo,
1024            path_string: *mut std::ffi::c_char,
1025            new_iter: *mut ffi::GtkTreeIter,
1026            f: glib::ffi::gpointer,
1027        ) {
1028            unsafe {
1029                let f: &F = &*(f as *const F);
1030                let path = from_glib_full(crate::ffi::gtk_tree_path_new_from_string(path_string));
1031                f(
1032                    CellRendererCombo::from_glib_borrow(this).unsafe_cast_ref(),
1033                    path,
1034                    &from_glib_borrow(new_iter),
1035                )
1036            }
1037        }
1038        unsafe {
1039            let f: Box_<F> = Box_::new(f);
1040            connect_raw(
1041                self.as_ptr() as *mut _,
1042                c"changed".as_ptr(),
1043                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1044                    changed_trampoline::<Self, F> as *const (),
1045                )),
1046                Box_::into_raw(f),
1047            )
1048        }
1049    }
1050
1051    #[doc(alias = "has-entry")]
1052    fn connect_has_entry_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1053        unsafe extern "C" fn notify_has_entry_trampoline<
1054            P: IsA<CellRendererCombo>,
1055            F: Fn(&P) + 'static,
1056        >(
1057            this: *mut ffi::GtkCellRendererCombo,
1058            _param_spec: glib::ffi::gpointer,
1059            f: glib::ffi::gpointer,
1060        ) {
1061            unsafe {
1062                let f: &F = &*(f as *const F);
1063                f(CellRendererCombo::from_glib_borrow(this).unsafe_cast_ref())
1064            }
1065        }
1066        unsafe {
1067            let f: Box_<F> = Box_::new(f);
1068            connect_raw(
1069                self.as_ptr() as *mut _,
1070                c"notify::has-entry".as_ptr(),
1071                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1072                    notify_has_entry_trampoline::<Self, F> as *const (),
1073                )),
1074                Box_::into_raw(f),
1075            )
1076        }
1077    }
1078
1079    #[doc(alias = "model")]
1080    fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1081        unsafe extern "C" fn notify_model_trampoline<
1082            P: IsA<CellRendererCombo>,
1083            F: Fn(&P) + 'static,
1084        >(
1085            this: *mut ffi::GtkCellRendererCombo,
1086            _param_spec: glib::ffi::gpointer,
1087            f: glib::ffi::gpointer,
1088        ) {
1089            unsafe {
1090                let f: &F = &*(f as *const F);
1091                f(CellRendererCombo::from_glib_borrow(this).unsafe_cast_ref())
1092            }
1093        }
1094        unsafe {
1095            let f: Box_<F> = Box_::new(f);
1096            connect_raw(
1097                self.as_ptr() as *mut _,
1098                c"notify::model".as_ptr(),
1099                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1100                    notify_model_trampoline::<Self, F> as *const (),
1101                )),
1102                Box_::into_raw(f),
1103            )
1104        }
1105    }
1106
1107    #[doc(alias = "text-column")]
1108    fn connect_text_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1109        unsafe extern "C" fn notify_text_column_trampoline<
1110            P: IsA<CellRendererCombo>,
1111            F: Fn(&P) + 'static,
1112        >(
1113            this: *mut ffi::GtkCellRendererCombo,
1114            _param_spec: glib::ffi::gpointer,
1115            f: glib::ffi::gpointer,
1116        ) {
1117            unsafe {
1118                let f: &F = &*(f as *const F);
1119                f(CellRendererCombo::from_glib_borrow(this).unsafe_cast_ref())
1120            }
1121        }
1122        unsafe {
1123            let f: Box_<F> = Box_::new(f);
1124            connect_raw(
1125                self.as_ptr() as *mut _,
1126                c"notify::text-column".as_ptr(),
1127                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1128                    notify_text_column_trampoline::<Self, F> as *const (),
1129                )),
1130                Box_::into_raw(f),
1131            )
1132        }
1133    }
1134}
1135
1136impl<O: IsA<CellRendererCombo>> CellRendererComboExt for O {}