[gtkmm: 1/2] Fix DropDown strings constructor
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm: 1/2] Fix DropDown strings constructor
- Date: Sun, 2 Aug 2020 13:03:56 +0000 (UTC)
commit f8e8c9b4b0052cc1919ce676b275b798ad5f1f0f
Author: Andreas Persson <andreasp56 outlook com>
Date: Sat Aug 1 18:33:06 2020 +0200
Fix DropDown strings constructor
gtk/src/dropdown.ccg | 11 +++++++++++
gtk/src/dropdown.hg | 14 +++++++++-----
2 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/gtk/src/dropdown.ccg b/gtk/src/dropdown.ccg
index 57b87fdc..d2d53da3 100644
--- a/gtk/src/dropdown.ccg
+++ b/gtk/src/dropdown.ccg
@@ -15,3 +15,14 @@
*/
#include <gtk/gtk.h>
+#include <stringlist.h>
+
+namespace Gtk
+{
+
+DropDown::DropDown(const std::vector<Glib::ustring>& strings)
+:
+ _CONSTRUCT("model", StringList::create(strings)->gobj())
+{}
+
+}
diff --git a/gtk/src/dropdown.hg b/gtk/src/dropdown.hg
index c0bb546a..ba917907 100644
--- a/gtk/src/dropdown.hg
+++ b/gtk/src/dropdown.hg
@@ -36,9 +36,9 @@ namespace Gtk
* and expects to obtain these from the model by evaluating an expression
* that has to be provided via set_expression().
*
- * The convenience method set_from_strings() can be used to set up a
- * model that is populated from an array of strings and an expression
- * for obtaining those strings.
+ * %Gtk::DropDown knows how to obtain strings from the items in a
+ * Gtk::StringList; for other models, you have to provide an expression
+ * to find the strings.
*
* %Gtk::DropDown can optionally allow search in the popup, which is
* useful if the list of options is long. To enable the search entry,
@@ -61,8 +61,12 @@ class GTKMM_API DropDown : public Widget
public:
_CTOR_DEFAULT
-#m4 _CONVERSION(`const std::vector<Glib::ustring>&',`const
char*-const*',`Glib::ArrayHandler<Glib::ustring>::vector_to_array($3).data()')
- _WRAP_CTOR(DropDown(const std::vector<Glib::ustring>& strings), gtk_drop_down_new_from_strings)
+
+ /** Creates a new %DropDown that is populated with the strings in @a strings.
+ *
+ * @param strings The strings to put in the dropdown.
+ */
+ explicit DropDown(const std::vector<Glib::ustring>& strings);
_WRAP_METHOD(void set_model(const Glib::RefPtr<Gio::ListModel>& model), gtk_drop_down_set_model)
_WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_model(), gtk_drop_down_get_model, refreturn)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]