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    ///  This signal gets emitted when a cell starts to be edited.
410    /// The intended use of this signal is to do special setup
411    /// on `editable`, e.g. adding a [`EntryCompletion`][crate::EntryCompletion] or setting
412    /// up additional columns in a [`ComboBox`][crate::ComboBox].
413    ///
414    /// See [`CellEditableExt::start_editing()`][crate::prelude::CellEditableExt::start_editing()] for information on the lifecycle of
415    /// the `editable` and a way to do setup that doesn’t depend on the `renderer`.
416    ///
417    /// Note that GTK+ doesn't guarantee that cell renderers will
418    /// continue to use the same kind of widget for editing in future
419    /// releases, therefore you should check the type of `editable`
420    /// before doing any specific setup, as in the following example:
421    ///
422    ///
423    /// **⚠️ The following code is in C ⚠️**
424    ///
425    /// ```C
426    /// static void
427    /// text_editing_started (GtkCellRenderer *cell,
428    ///                       GtkCellEditable *editable,
429    ///                       const gchar     *path,
430    ///                       gpointer         data)
431    /// {
432    ///   if (GTK_IS_ENTRY (editable))
433    ///     {
434    ///       GtkEntry *entry = GTK_ENTRY (editable);
435    ///
436    ///       // ... create a GtkEntryCompletion
437    ///
438    ///       gtk_entry_set_completion (entry, completion);
439    ///     }
440    /// }
441    /// ```
442    ///
443    ///
444    /// </details>
445    ///
446    /// # Implements
447    ///
448    /// [`CellRendererComboExt`][trait@crate::prelude::CellRendererComboExt], [`CellRendererTextExt`][trait@crate::prelude::CellRendererTextExt], [`CellRendererExt`][trait@crate::prelude::CellRendererExt], [`trait@glib::ObjectExt`]
449    #[doc(alias = "GtkCellRendererCombo")]
450    pub struct CellRendererCombo(Object<ffi::GtkCellRendererCombo, ffi::GtkCellRendererComboClass>) @extends CellRendererText, CellRenderer;
451
452    match fn {
453        type_ => || ffi::gtk_cell_renderer_combo_get_type(),
454    }
455}
456
457impl CellRendererCombo {
458    pub const NONE: Option<&'static CellRendererCombo> = None;
459
460    /// Creates a new [`CellRendererCombo`][crate::CellRendererCombo].
461    /// Adjust how text is drawn using object properties.
462    /// Object properties can be set globally (with [`ObjectExt::set()`][crate::glib::prelude::ObjectExt::set()]).
463    /// Also, with [`TreeViewColumn`][crate::TreeViewColumn], you can bind a property to a value
464    /// in a [`TreeModel`][crate::TreeModel]. For example, you can bind the “text” property
465    /// on the cell renderer to a string value in the model, thus rendering
466    /// a different string in each row of the [`TreeView`][crate::TreeView].
467    ///
468    /// # Returns
469    ///
470    /// the new cell renderer
471    #[doc(alias = "gtk_cell_renderer_combo_new")]
472    pub fn new() -> CellRendererCombo {
473        assert_initialized_main_thread!();
474        unsafe { CellRenderer::from_glib_none(ffi::gtk_cell_renderer_combo_new()).unsafe_cast() }
475    }
476
477    // rustdoc-stripper-ignore-next
478    /// Creates a new builder-pattern struct instance to construct [`CellRendererCombo`] objects.
479    ///
480    /// This method returns an instance of [`CellRendererComboBuilder`](crate::builders::CellRendererComboBuilder) which can be used to create [`CellRendererCombo`] objects.
481    pub fn builder() -> CellRendererComboBuilder {
482        CellRendererComboBuilder::new()
483    }
484}
485
486impl Default for CellRendererCombo {
487    fn default() -> Self {
488        Self::new()
489    }
490}
491
492// rustdoc-stripper-ignore-next
493/// A [builder-pattern] type to construct [`CellRendererCombo`] objects.
494///
495/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
496#[must_use = "The builder must be built to be used"]
497pub struct CellRendererComboBuilder {
498    builder: glib::object::ObjectBuilder<'static, CellRendererCombo>,
499}
500
501impl CellRendererComboBuilder {
502    fn new() -> Self {
503        Self {
504            builder: glib::object::Object::builder(),
505        }
506    }
507
508    /// If [`true`], the cell renderer will include an entry and allow to enter
509    /// values other than the ones in the popup list.
510    pub fn has_entry(self, has_entry: bool) -> Self {
511        Self {
512            builder: self.builder.property("has-entry", has_entry),
513        }
514    }
515
516    /// Holds a tree model containing the possible values for the combo box.
517    /// Use the text_column property to specify the column holding the values.
518    pub fn model(self, model: &impl IsA<TreeModel>) -> Self {
519        Self {
520            builder: self.builder.property("model", model.clone().upcast()),
521        }
522    }
523
524    /// Specifies the model column which holds the possible values for the
525    /// combo box.
526    ///
527    /// Note that this refers to the model specified in the model property,
528    /// not the model backing the tree view to which
529    /// this cell renderer is attached.
530    ///
531    /// [`CellRendererCombo`][crate::CellRendererCombo] automatically adds a text cell renderer for
532    /// this column to its combo box.
533    pub fn text_column(self, text_column: i32) -> Self {
534        Self {
535            builder: self.builder.property("text-column", text_column),
536        }
537    }
538
539    pub fn align_set(self, align_set: bool) -> Self {
540        Self {
541            builder: self.builder.property("align-set", align_set),
542        }
543    }
544
545    /// Specifies how to align the lines of text with respect to each other.
546    ///
547    /// Note that this property describes how to align the lines of text in
548    /// case there are several of them. The "xalign" property of [`CellRenderer`][crate::CellRenderer],
549    /// on the other hand, sets the horizontal alignment of the whole text.
550    pub fn alignment(self, alignment: pango::Alignment) -> Self {
551        Self {
552            builder: self.builder.property("alignment", alignment),
553        }
554    }
555
556    pub fn attributes(self, attributes: &pango::AttrList) -> Self {
557        Self {
558            builder: self.builder.property("attributes", attributes.clone()),
559        }
560    }
561
562    pub fn background(self, background: impl Into<glib::GString>) -> Self {
563        Self {
564            builder: self.builder.property("background", background.into()),
565        }
566    }
567
568    /// Background color as a [`gdk::RGBA`][crate::gdk::RGBA]
569    pub fn background_rgba(self, background_rgba: &gdk::RGBA) -> Self {
570        Self {
571            builder: self.builder.property("background-rgba", background_rgba),
572        }
573    }
574
575    pub fn background_set(self, background_set: bool) -> Self {
576        Self {
577            builder: self.builder.property("background-set", background_set),
578        }
579    }
580
581    pub fn editable(self, editable: bool) -> Self {
582        Self {
583            builder: self.builder.property("editable", editable),
584        }
585    }
586
587    pub fn editable_set(self, editable_set: bool) -> Self {
588        Self {
589            builder: self.builder.property("editable-set", editable_set),
590        }
591    }
592
593    /// Specifies the preferred place to ellipsize the string, if the cell renderer
594    /// does not have enough room to display the entire string. Setting it to
595    /// [`pango::EllipsizeMode::None`][crate::pango::EllipsizeMode::None] turns off ellipsizing. See the wrap-width property
596    /// for another way of making the text fit into a given width.
597    pub fn ellipsize(self, ellipsize: pango::EllipsizeMode) -> Self {
598        Self {
599            builder: self.builder.property("ellipsize", ellipsize),
600        }
601    }
602
603    pub fn ellipsize_set(self, ellipsize_set: bool) -> Self {
604        Self {
605            builder: self.builder.property("ellipsize-set", ellipsize_set),
606        }
607    }
608
609    pub fn family(self, family: impl Into<glib::GString>) -> Self {
610        Self {
611            builder: self.builder.property("family", family.into()),
612        }
613    }
614
615    pub fn family_set(self, family_set: bool) -> Self {
616        Self {
617            builder: self.builder.property("family-set", family_set),
618        }
619    }
620
621    pub fn font(self, font: impl Into<glib::GString>) -> Self {
622        Self {
623            builder: self.builder.property("font", font.into()),
624        }
625    }
626
627    pub fn font_desc(self, font_desc: &pango::FontDescription) -> Self {
628        Self {
629            builder: self.builder.property("font-desc", font_desc),
630        }
631    }
632
633    pub fn foreground(self, foreground: impl Into<glib::GString>) -> Self {
634        Self {
635            builder: self.builder.property("foreground", foreground.into()),
636        }
637    }
638
639    /// Foreground color as a [`gdk::RGBA`][crate::gdk::RGBA]
640    pub fn foreground_rgba(self, foreground_rgba: &gdk::RGBA) -> Self {
641        Self {
642            builder: self.builder.property("foreground-rgba", foreground_rgba),
643        }
644    }
645
646    pub fn foreground_set(self, foreground_set: bool) -> Self {
647        Self {
648            builder: self.builder.property("foreground-set", foreground_set),
649        }
650    }
651
652    pub fn language(self, language: impl Into<glib::GString>) -> Self {
653        Self {
654            builder: self.builder.property("language", language.into()),
655        }
656    }
657
658    pub fn language_set(self, language_set: bool) -> Self {
659        Self {
660            builder: self.builder.property("language-set", language_set),
661        }
662    }
663
664    pub fn markup(self, markup: impl Into<glib::GString>) -> Self {
665        Self {
666            builder: self.builder.property("markup", markup.into()),
667        }
668    }
669
670    /// The desired maximum width of the cell, in characters. If this property
671    /// is set to -1, the width will be calculated automatically.
672    ///
673    /// For cell renderers that ellipsize or wrap text; this property
674    /// controls the maximum reported width of the cell. The
675    /// cell should not receive any greater allocation unless it is
676    /// set to expand in its [`CellLayout`][crate::CellLayout] and all of the cell's siblings
677    /// have received their natural width.
678    pub fn max_width_chars(self, max_width_chars: i32) -> Self {
679        Self {
680            builder: self.builder.property("max-width-chars", max_width_chars),
681        }
682    }
683
684    /// The text that will be displayed in the [`CellRenderer`][crate::CellRenderer] if
685    /// [`editable`][struct@crate::CellRendererText#editable] is [`true`] and the cell is empty.
686    ///
687    /// Since 3.6
688    pub fn placeholder_text(self, placeholder_text: impl Into<glib::GString>) -> Self {
689        Self {
690            builder: self
691                .builder
692                .property("placeholder-text", placeholder_text.into()),
693        }
694    }
695
696    pub fn rise(self, rise: i32) -> Self {
697        Self {
698            builder: self.builder.property("rise", rise),
699        }
700    }
701
702    pub fn rise_set(self, rise_set: bool) -> Self {
703        Self {
704            builder: self.builder.property("rise-set", rise_set),
705        }
706    }
707
708    pub fn scale(self, scale: f64) -> Self {
709        Self {
710            builder: self.builder.property("scale", scale),
711        }
712    }
713
714    pub fn scale_set(self, scale_set: bool) -> Self {
715        Self {
716            builder: self.builder.property("scale-set", scale_set),
717        }
718    }
719
720    pub fn single_paragraph_mode(self, single_paragraph_mode: bool) -> Self {
721        Self {
722            builder: self
723                .builder
724                .property("single-paragraph-mode", single_paragraph_mode),
725        }
726    }
727
728    pub fn size(self, size: i32) -> Self {
729        Self {
730            builder: self.builder.property("size", size),
731        }
732    }
733
734    pub fn size_points(self, size_points: f64) -> Self {
735        Self {
736            builder: self.builder.property("size-points", size_points),
737        }
738    }
739
740    pub fn size_set(self, size_set: bool) -> Self {
741        Self {
742            builder: self.builder.property("size-set", size_set),
743        }
744    }
745
746    pub fn stretch(self, stretch: pango::Stretch) -> Self {
747        Self {
748            builder: self.builder.property("stretch", stretch),
749        }
750    }
751
752    pub fn stretch_set(self, stretch_set: bool) -> Self {
753        Self {
754            builder: self.builder.property("stretch-set", stretch_set),
755        }
756    }
757
758    pub fn strikethrough(self, strikethrough: bool) -> Self {
759        Self {
760            builder: self.builder.property("strikethrough", strikethrough),
761        }
762    }
763
764    pub fn strikethrough_set(self, strikethrough_set: bool) -> Self {
765        Self {
766            builder: self
767                .builder
768                .property("strikethrough-set", strikethrough_set),
769        }
770    }
771
772    pub fn style(self, style: pango::Style) -> Self {
773        Self {
774            builder: self.builder.property("style", style),
775        }
776    }
777
778    pub fn style_set(self, style_set: bool) -> Self {
779        Self {
780            builder: self.builder.property("style-set", style_set),
781        }
782    }
783
784    pub fn text(self, text: impl Into<glib::GString>) -> Self {
785        Self {
786            builder: self.builder.property("text", text.into()),
787        }
788    }
789
790    pub fn underline(self, underline: pango::Underline) -> Self {
791        Self {
792            builder: self.builder.property("underline", underline),
793        }
794    }
795
796    pub fn underline_set(self, underline_set: bool) -> Self {
797        Self {
798            builder: self.builder.property("underline-set", underline_set),
799        }
800    }
801
802    pub fn variant(self, variant: pango::Variant) -> Self {
803        Self {
804            builder: self.builder.property("variant", variant),
805        }
806    }
807
808    pub fn variant_set(self, variant_set: bool) -> Self {
809        Self {
810            builder: self.builder.property("variant-set", variant_set),
811        }
812    }
813
814    pub fn weight(self, weight: i32) -> Self {
815        Self {
816            builder: self.builder.property("weight", weight),
817        }
818    }
819
820    pub fn weight_set(self, weight_set: bool) -> Self {
821        Self {
822            builder: self.builder.property("weight-set", weight_set),
823        }
824    }
825
826    /// The desired width of the cell, in characters. If this property is set to
827    /// -1, the width will be calculated automatically, otherwise the cell will
828    /// request either 3 characters or the property value, whichever is greater.
829    pub fn width_chars(self, width_chars: i32) -> Self {
830        Self {
831            builder: self.builder.property("width-chars", width_chars),
832        }
833    }
834
835    /// Specifies how to break the string into multiple lines, if the cell
836    /// renderer does not have enough room to display the entire string.
837    /// This property has no effect unless the wrap-width property is set.
838    pub fn wrap_mode(self, wrap_mode: pango::WrapMode) -> Self {
839        Self {
840            builder: self.builder.property("wrap-mode", wrap_mode),
841        }
842    }
843
844    /// Specifies the minimum width at which the text is wrapped. The wrap-mode property can
845    /// be used to influence at what character positions the line breaks can be placed.
846    /// Setting wrap-width to -1 turns wrapping off.
847    pub fn wrap_width(self, wrap_width: i32) -> Self {
848        Self {
849            builder: self.builder.property("wrap-width", wrap_width),
850        }
851    }
852
853    pub fn cell_background(self, cell_background: impl Into<glib::GString>) -> Self {
854        Self {
855            builder: self
856                .builder
857                .property("cell-background", cell_background.into()),
858        }
859    }
860
861    /// Cell background as a [`gdk::RGBA`][crate::gdk::RGBA]
862    pub fn cell_background_rgba(self, cell_background_rgba: &gdk::RGBA) -> Self {
863        Self {
864            builder: self
865                .builder
866                .property("cell-background-rgba", cell_background_rgba),
867        }
868    }
869
870    pub fn cell_background_set(self, cell_background_set: bool) -> Self {
871        Self {
872            builder: self
873                .builder
874                .property("cell-background-set", cell_background_set),
875        }
876    }
877
878    pub fn height(self, height: i32) -> Self {
879        Self {
880            builder: self.builder.property("height", height),
881        }
882    }
883
884    pub fn is_expanded(self, is_expanded: bool) -> Self {
885        Self {
886            builder: self.builder.property("is-expanded", is_expanded),
887        }
888    }
889
890    pub fn is_expander(self, is_expander: bool) -> Self {
891        Self {
892            builder: self.builder.property("is-expander", is_expander),
893        }
894    }
895
896    pub fn mode(self, mode: CellRendererMode) -> Self {
897        Self {
898            builder: self.builder.property("mode", mode),
899        }
900    }
901
902    pub fn sensitive(self, sensitive: bool) -> Self {
903        Self {
904            builder: self.builder.property("sensitive", sensitive),
905        }
906    }
907
908    pub fn visible(self, visible: bool) -> Self {
909        Self {
910            builder: self.builder.property("visible", visible),
911        }
912    }
913
914    pub fn width(self, width: i32) -> Self {
915        Self {
916            builder: self.builder.property("width", width),
917        }
918    }
919
920    pub fn xalign(self, xalign: f32) -> Self {
921        Self {
922            builder: self.builder.property("xalign", xalign),
923        }
924    }
925
926    pub fn xpad(self, xpad: u32) -> Self {
927        Self {
928            builder: self.builder.property("xpad", xpad),
929        }
930    }
931
932    pub fn yalign(self, yalign: f32) -> Self {
933        Self {
934            builder: self.builder.property("yalign", yalign),
935        }
936    }
937
938    pub fn ypad(self, ypad: u32) -> Self {
939        Self {
940            builder: self.builder.property("ypad", ypad),
941        }
942    }
943
944    // rustdoc-stripper-ignore-next
945    /// Build the [`CellRendererCombo`].
946    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
947    pub fn build(self) -> CellRendererCombo {
948        assert_initialized_main_thread!();
949        self.builder.build()
950    }
951}
952
953/// Trait containing all [`struct@CellRendererCombo`] methods.
954///
955/// # Implementors
956///
957/// [`CellRendererCombo`][struct@crate::CellRendererCombo]
958pub trait CellRendererComboExt: IsA<CellRendererCombo> + 'static {
959    /// If [`true`], the cell renderer will include an entry and allow to enter
960    /// values other than the ones in the popup list.
961    #[doc(alias = "has-entry")]
962    fn has_entry(&self) -> bool {
963        ObjectExt::property(self.as_ref(), "has-entry")
964    }
965
966    /// If [`true`], the cell renderer will include an entry and allow to enter
967    /// values other than the ones in the popup list.
968    #[doc(alias = "has-entry")]
969    fn set_has_entry(&self, has_entry: bool) {
970        ObjectExt::set_property(self.as_ref(), "has-entry", has_entry)
971    }
972
973    /// Holds a tree model containing the possible values for the combo box.
974    /// Use the text_column property to specify the column holding the values.
975    fn model(&self) -> Option<TreeModel> {
976        ObjectExt::property(self.as_ref(), "model")
977    }
978
979    /// Holds a tree model containing the possible values for the combo box.
980    /// Use the text_column property to specify the column holding the values.
981    fn set_model<P: IsA<TreeModel>>(&self, model: Option<&P>) {
982        ObjectExt::set_property(self.as_ref(), "model", model)
983    }
984
985    /// Specifies the model column which holds the possible values for the
986    /// combo box.
987    ///
988    /// Note that this refers to the model specified in the model property,
989    /// not the model backing the tree view to which
990    /// this cell renderer is attached.
991    ///
992    /// [`CellRendererCombo`][crate::CellRendererCombo] automatically adds a text cell renderer for
993    /// this column to its combo box.
994    #[doc(alias = "text-column")]
995    fn text_column(&self) -> i32 {
996        ObjectExt::property(self.as_ref(), "text-column")
997    }
998
999    /// Specifies the model column which holds the possible values for the
1000    /// combo box.
1001    ///
1002    /// Note that this refers to the model specified in the model property,
1003    /// not the model backing the tree view to which
1004    /// this cell renderer is attached.
1005    ///
1006    /// [`CellRendererCombo`][crate::CellRendererCombo] automatically adds a text cell renderer for
1007    /// this column to its combo box.
1008    #[doc(alias = "text-column")]
1009    fn set_text_column(&self, text_column: i32) {
1010        ObjectExt::set_property(self.as_ref(), "text-column", text_column)
1011    }
1012
1013    /// This signal is emitted each time after the user selected an item in
1014    /// the combo box, either by using the mouse or the arrow keys. Contrary
1015    /// to GtkComboBox, GtkCellRendererCombo::changed is not emitted for
1016    /// changes made to a selected item in the entry. The argument `new_iter`
1017    /// corresponds to the newly selected item in the combo box and it is relative
1018    /// to the GtkTreeModel set via the model property on GtkCellRendererCombo.
1019    ///
1020    /// Note that as soon as you change the model displayed in the tree view,
1021    /// the tree view will immediately cease the editing operating. This
1022    /// means that you most probably want to refrain from changing the model
1023    /// until the combo cell renderer emits the edited or editing_canceled signal.
1024    /// ## `path_string`
1025    /// a string of the path identifying the edited cell
1026    ///  (relative to the tree view model)
1027    /// ## `new_iter`
1028    /// the new iter selected in the combo box
1029    ///  (relative to the combo box model)
1030    #[doc(alias = "changed")]
1031    fn connect_changed<F: Fn(&Self, TreePath, &TreeIter) + 'static>(
1032        &self,
1033        f: F,
1034    ) -> SignalHandlerId {
1035        unsafe extern "C" fn changed_trampoline<
1036            P: IsA<CellRendererCombo>,
1037            F: Fn(&P, TreePath, &TreeIter) + 'static,
1038        >(
1039            this: *mut ffi::GtkCellRendererCombo,
1040            path_string: *mut std::ffi::c_char,
1041            new_iter: *mut ffi::GtkTreeIter,
1042            f: glib::ffi::gpointer,
1043        ) {
1044            unsafe {
1045                let f: &F = &*(f as *const F);
1046                let path = from_glib_full(crate::ffi::gtk_tree_path_new_from_string(path_string));
1047                f(
1048                    CellRendererCombo::from_glib_borrow(this).unsafe_cast_ref(),
1049                    path,
1050                    &from_glib_borrow(new_iter),
1051                )
1052            }
1053        }
1054        unsafe {
1055            let f: Box_<F> = Box_::new(f);
1056            connect_raw(
1057                self.as_ptr() as *mut _,
1058                c"changed".as_ptr(),
1059                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1060                    changed_trampoline::<Self, F> as *const (),
1061                )),
1062                Box_::into_raw(f),
1063            )
1064        }
1065    }
1066
1067    #[doc(alias = "has-entry")]
1068    fn connect_has_entry_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1069        unsafe extern "C" fn notify_has_entry_trampoline<
1070            P: IsA<CellRendererCombo>,
1071            F: Fn(&P) + 'static,
1072        >(
1073            this: *mut ffi::GtkCellRendererCombo,
1074            _param_spec: glib::ffi::gpointer,
1075            f: glib::ffi::gpointer,
1076        ) {
1077            unsafe {
1078                let f: &F = &*(f as *const F);
1079                f(CellRendererCombo::from_glib_borrow(this).unsafe_cast_ref())
1080            }
1081        }
1082        unsafe {
1083            let f: Box_<F> = Box_::new(f);
1084            connect_raw(
1085                self.as_ptr() as *mut _,
1086                c"notify::has-entry".as_ptr(),
1087                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1088                    notify_has_entry_trampoline::<Self, F> as *const (),
1089                )),
1090                Box_::into_raw(f),
1091            )
1092        }
1093    }
1094
1095    #[doc(alias = "model")]
1096    fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1097        unsafe extern "C" fn notify_model_trampoline<
1098            P: IsA<CellRendererCombo>,
1099            F: Fn(&P) + 'static,
1100        >(
1101            this: *mut ffi::GtkCellRendererCombo,
1102            _param_spec: glib::ffi::gpointer,
1103            f: glib::ffi::gpointer,
1104        ) {
1105            unsafe {
1106                let f: &F = &*(f as *const F);
1107                f(CellRendererCombo::from_glib_borrow(this).unsafe_cast_ref())
1108            }
1109        }
1110        unsafe {
1111            let f: Box_<F> = Box_::new(f);
1112            connect_raw(
1113                self.as_ptr() as *mut _,
1114                c"notify::model".as_ptr(),
1115                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1116                    notify_model_trampoline::<Self, F> as *const (),
1117                )),
1118                Box_::into_raw(f),
1119            )
1120        }
1121    }
1122
1123    #[doc(alias = "text-column")]
1124    fn connect_text_column_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1125        unsafe extern "C" fn notify_text_column_trampoline<
1126            P: IsA<CellRendererCombo>,
1127            F: Fn(&P) + 'static,
1128        >(
1129            this: *mut ffi::GtkCellRendererCombo,
1130            _param_spec: glib::ffi::gpointer,
1131            f: glib::ffi::gpointer,
1132        ) {
1133            unsafe {
1134                let f: &F = &*(f as *const F);
1135                f(CellRendererCombo::from_glib_borrow(this).unsafe_cast_ref())
1136            }
1137        }
1138        unsafe {
1139            let f: Box_<F> = Box_::new(f);
1140            connect_raw(
1141                self.as_ptr() as *mut _,
1142                c"notify::text-column".as_ptr(),
1143                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1144                    notify_text_column_trampoline::<Self, F> as *const (),
1145                )),
1146                Box_::into_raw(f),
1147            )
1148        }
1149    }
1150}
1151
1152impl<O: IsA<CellRendererCombo>> CellRendererComboExt for O {}