[gtkmm] ListBox: Add some methods.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] ListBox: Add some methods.
- Date: Mon, 15 Sep 2014 15:24:35 +0000 (UTC)
commit 6eb3705f3aac56ec44a2a2dcd3ed67e2b0423520
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Sep 15 17:13:25 2014 +0200
ListBox: Add some methods.
* gtk/src/listbox.[hg|ccg]: Add selected_foreach(),
get_selected_rows(), unselect_row(), select_all() and unselect_all().
gtk/src/listbox.ccg | 24 ++++++++++++++++++++++++
gtk/src/listbox.hg | 21 +++++++++++++++++++++
2 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/gtk/src/listbox.ccg b/gtk/src/listbox.ccg
index 23fbe68..4e46265 100644
--- a/gtk/src/listbox.ccg
+++ b/gtk/src/listbox.ccg
@@ -79,6 +79,23 @@ void SignalProxy_UpdateHeader_gtk_callback_destroy(void* data)
delete static_cast<Gtk::ListBox::SlotUpdateHeader*>(data);
}
+
+static void proxy_foreach_callback(GtkListBox* /* list_box */, GtkListBoxRow* row, void* data)
+{
+ typedef Gtk::ListBox::SlotForeach SlotType;
+ SlotType& slot = *static_cast<SlotType*>(data);
+
+ try
+ {
+ slot(Glib::wrap(row, true));
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+}
+
+
} // anonymous namespace
namespace Gtk
@@ -150,4 +167,11 @@ void ListBox::append(Widget& child)
insert(child, -1);
}
+void ListBox::selected_foreach(const SlotForeach& slot)
+{
+ SlotForeach slot_copy(slot); //TODO: Is this necessary?
+ gtk_list_box_selected_foreach(gobj(), &proxy_foreach_callback, &slot_copy);
+
+}
+
} //namespace Gtk
diff --git a/gtk/src/listbox.hg b/gtk/src/listbox.hg
index 3968e1f..fcf9dc8 100644
--- a/gtk/src/listbox.hg
+++ b/gtk/src/listbox.hg
@@ -132,6 +132,27 @@ public:
_WRAP_METHOD(void set_adjustment(const Glib::RefPtr<Adjustment>& adjustment), gtk_list_box_set_adjustment)
_WRAP_METHOD(Glib::RefPtr<Adjustment> get_adjustment(), gtk_list_box_get_adjustment, refreturn)
_WRAP_METHOD(Glib::RefPtr<const Adjustment> get_adjustment() const, gtk_list_box_get_adjustment,
refreturn, constversion)
+
+ /** For instance,
+ * void on_foreach(ListBoxRow* row);
+ */
+ typedef sigc::slot<void, ListBoxRow*> SlotForeach;
+
+ void selected_foreach(const SlotForeach& slot);
+ _IGNORE(gtk_list_box_selected_foreach)
+
+#m4 _CONVERSION(`GList*',`std::vector<ListBoxRow*>',`Glib::ListHandler<ListBoxRow*>::list_to_vector($3,
Glib::OWNERSHIP_SHALLOW)')
+ _WRAP_METHOD(std::vector<ListBoxRow*> get_selected_rows(), gtk_list_box_get_selected_rows)
+
+#m4 _CONVERSION(`GList*',`std::vector<const
ListBoxRow*>',`Glib::ListHandler<ListBoxRow*>::list_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
+ _WRAP_METHOD(std::vector<ListBoxRow*> get_selected_rows() const, gtk_list_box_get_selected_rows)
+
+
+ _WRAP_METHOD(void unselect_row(ListBoxRow* row), gtk_list_box_unselect_row)
+ _WRAP_METHOD(void select_all(), gtk_list_box_select_all)
+ _WRAP_METHOD(void unselect_all(), gtk_list_box_unselect_all)
+
+
_WRAP_METHOD(void set_selection_mode(SelectionMode mode), gtk_list_box_set_selection_mode)
_WRAP_METHOD(SelectionMode get_selection_mode() const, gtk_list_box_get_selection_mode)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]