summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-08-11 14:04:58 +0200
committerRobin Gareus <robin@gareus.org>2015-08-11 15:38:26 +0200
commit9bc85a553c542bc3bff108a066a1da9493078491 (patch)
tree89759df5fc3b68ce3d94ac6c98061cf5e641c1d2
parenta3b2b1bcfae110c01d47b256e5a4e973a86d2f71 (diff)
add API to get combobox option count.
The data model needs to be checked to count available options. Directly using ComboBoxText::children()::size() counts widgets.
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/utils.h2
-rw-r--r--libs/gtkmm2ext/utils.cc10
2 files changed, 12 insertions, 0 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/utils.h b/libs/gtkmm2ext/gtkmm2ext/utils.h
index ab70464ea0..6ed5d77428 100644
--- a/libs/gtkmm2ext/gtkmm2ext/utils.h
+++ b/libs/gtkmm2ext/gtkmm2ext/utils.h
@@ -101,6 +101,8 @@ namespace Gtkmm2ext {
LIBGTKMM2EXT_API void get_popdown_strings (Gtk::ComboBoxText&,
std::vector<std::string>&);
+ LIBGTKMM2EXT_API size_t get_popdown_string_count (Gtk::ComboBoxText&);
+
LIBGTKMM2EXT_API bool contains_value (Gtk::ComboBoxText&,
const std::string);
diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc
index 6efa95ac1a..f1616f16a1 100644
--- a/libs/gtkmm2ext/utils.cc
+++ b/libs/gtkmm2ext/utils.cc
@@ -322,6 +322,16 @@ Gtkmm2ext::get_popdown_strings (Gtk::ComboBoxText& cr, std::vector<std::string>&
}
}
+size_t
+Gtkmm2ext::get_popdown_string_count (Gtk::ComboBoxText& cr)
+{
+ Glib::RefPtr<const Gtk::TreeModel> m = cr.get_model();
+ if (!m) {
+ return 0;
+ }
+ return m->children().size();
+}
+
bool
Gtkmm2ext::contains_value (Gtk::ComboBoxText& cr, const std::string text)
{