[gtkmm: 4/5] Fix things mentioned in merge request comment



commit 63dd158408c6cfc66b3c7b1e97c3050b7b35c301
Author: Andreas Persson <andreasp56 outlook com>
Date:   Fri Jul 17 18:29:56 2020 +0200

    Fix things mentioned in merge request comment
    
    Extract StringObject to separate files. Fix DropDown::set_list_factory.
    Add ListItem::unset_child. Ignore gtk_string_list_take. Documentation
    fixes. Replace brokern StringObject ctor with a create function.

 .gitignore                       |  2 ++
 gtk/gtkmm.h                      |  1 +
 gtk/gtkmm/meson.build            |  1 +
 gtk/src/dropdown.hg              |  2 +-
 gtk/src/filelist.am              |  1 +
 gtk/src/listitem.ccg             | 10 ++++++++++
 gtk/src/listitem.hg              |  3 ++-
 gtk/src/signallistitemfactory.hg | 12 +++++++-----
 gtk/src/stringlist.hg            | 13 +------------
 gtk/src/stringobject.ccg         | 17 +++++++++++++++++
 gtk/src/stringobject.hg          | 41 ++++++++++++++++++++++++++++++++++++++++
 tools/m4/convert_gtk.m4          |  1 +
 12 files changed, 85 insertions(+), 19 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 0e25c57ff..7b8f436f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -519,6 +519,8 @@ gtk/gtkmm/statusbar.cc
 gtk/gtkmm/statusbar.h
 gtk/gtkmm/stringlist.cc
 gtk/gtkmm/stringlist.h
+gtk/gtkmm/stringobject.cc
+gtk/gtkmm/stringobject.h
 gtk/gtkmm/stylecontext.cc
 gtk/gtkmm/stylecontext.h
 gtk/gtkmm/styleprovider.cc
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index edae1a088..b888ac876 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -257,6 +257,7 @@ extern const int gtkmm_micro_version;
 #include <gtkmm/stackswitcher.h>
 #include <gtkmm/statusbar.h>
 #include <gtkmm/stringlist.h>
+#include <gtkmm/stringobject.h>
 #include <gtkmm/stylecontext.h>
 #include <gtkmm/switch.h>
 #include <gtkmm/text.h>
diff --git a/gtk/gtkmm/meson.build b/gtk/gtkmm/meson.build
index dfc45828f..c32b1a7e6 100644
--- a/gtk/gtkmm/meson.build
+++ b/gtk/gtkmm/meson.build
@@ -211,6 +211,7 @@ gtkmm_any_hg_ccg_basenames = [
   'stackswitcher',
   'statusbar',
   'stringlist',
+  'stringobject',
   'stylecontext',
   'styleprovider',
   'switch',
diff --git a/gtk/src/dropdown.hg b/gtk/src/dropdown.hg
index 595ac2f83..583ff7bd1 100644
--- a/gtk/src/dropdown.hg
+++ b/gtk/src/dropdown.hg
@@ -80,7 +80,7 @@ public:
   _WRAP_METHOD(void set_factory(const Glib::RefPtr<ListItemFactory>& factory), gtk_drop_down_set_factory)
   _WRAP_METHOD(Glib::RefPtr<ListItemFactory> get_factory(), gtk_drop_down_get_factory, refreturn)
   _WRAP_METHOD(Glib::RefPtr<const ListItemFactory> get_factory() const, gtk_drop_down_get_factory, 
refreturn, constversion)
-  _WRAP_METHOD(void set_list_factory(const Glib::RefPtr<ListItemFactory>& factory), 
gtk_drop_down_set_list_factory, constversion)
+  _WRAP_METHOD(void set_list_factory(const Glib::RefPtr<ListItemFactory>& factory), 
gtk_drop_down_set_list_factory)
   _WRAP_METHOD(Glib::RefPtr<ListItemFactory> get_list_factory(), gtk_drop_down_get_list_factory, refreturn)
   _WRAP_METHOD(Glib::RefPtr<const ListItemFactory> get_list_factory() const, gtk_drop_down_get_list_factory, 
refreturn, constversion)
 
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index d08ef3c9f..e92e284b3 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -196,6 +196,7 @@ gtkmm_files_any_hg =                \
        stackswitcher.hg        \
        statusbar.hg            \
        stringlist.hg \
+       stringobject.hg \
        stylecontext.hg         \
        styleprovider.hg        \
        switch.hg               \
diff --git a/gtk/src/listitem.ccg b/gtk/src/listitem.ccg
index 57b87fdcf..5fef14588 100644
--- a/gtk/src/listitem.ccg
+++ b/gtk/src/listitem.ccg
@@ -15,3 +15,13 @@
  */
 
 #include <gtk/gtk.h>
+
+namespace Gtk
+{
+
+void ListItem::unset_child()
+{
+  gtk_list_item_set_child(gobj(), nullptr);
+}
+
+} // namespace Gtk
diff --git a/gtk/src/listitem.hg b/gtk/src/listitem.hg
index e9383d406..0f721ca1d 100644
--- a/gtk/src/listitem.hg
+++ b/gtk/src/listitem.hg
@@ -22,7 +22,7 @@ _PINCLUDE(glibmm/private/object_p.h)
 namespace Gtk
 {
 
-/** %Object used to represent items of a ListModel.
+/** %Object used to represent items of a list model.
  *
  * %Gtk::ListItem is the object that list-handling containers such
  * as Gtk::ListView use to represent items in a Gio::ListModel. They are
@@ -58,6 +58,7 @@ public:
   _WRAP_METHOD(bool get_activatable() const, gtk_list_item_get_activatable)
   _WRAP_METHOD(void set_activatable(bool activatable = true), gtk_list_item_set_activatable)
   _WRAP_METHOD(void set_child(Widget& child), gtk_list_item_set_child)
+  void unset_child();
   _WRAP_METHOD(Widget* get_child(), gtk_list_item_get_child)
   _WRAP_METHOD(const Widget* get_child() const, gtk_list_item_get_child, constversion)
 
diff --git a/gtk/src/signallistitemfactory.hg b/gtk/src/signallistitemfactory.hg
index ef25c3380..643d17b4f 100644
--- a/gtk/src/signallistitemfactory.hg
+++ b/gtk/src/signallistitemfactory.hg
@@ -34,11 +34,12 @@ namespace Gtk
  *  row and adding them to the listitem.
  *
  *  2. signal_bind() is emitted to bind the item passed via
- *  Gtk::ListItem::item to the widgets that have been created in step 1 or to
- *  add item-specific widgets. Signals are connected to listen to changes -
- *  both to changes in the item to update the widgets or to changes in the
- *  widgets to update the item. After this signal has been called, the
- *  listitem may be shown in a list widget.
+ *  Gtk::ListItem::property_item() to the widgets that have been
+ *  created in step 1 or to add item-specific widgets. Signals are
+ *  connected to listen to changes - both to changes in the item to
+ *  update the widgets or to changes in the widgets to update the
+ *  item. After this signal has been called, the listitem may be shown
+ *  in a list widget.
  *
  *  3. signal_unbind() is emitted to undo everything done in step 2.
  *  Usually this means disconnecting signal handlers. Once this signal
@@ -77,6 +78,7 @@ protected:
 public:
   _WRAP_CREATE()
 
+  // no_default_handler because GtkSignalListItemFactoryClass is private.
 #m4 _CONVERSION(`GtkListItem*',`const Glib::RefPtr<ListItem>&',`Glib::wrap($3, true)')
   _WRAP_SIGNAL(void setup(const Glib::RefPtr<ListItem>& list_item), "setup", no_default_handler)
   _WRAP_SIGNAL(void bind(const Glib::RefPtr<ListItem>& list_item), "bind", no_default_handler)
diff --git a/gtk/src/stringlist.hg b/gtk/src/stringlist.hg
index 385637ddc..1c9bf72f1 100644
--- a/gtk/src/stringlist.hg
+++ b/gtk/src/stringlist.hg
@@ -23,18 +23,6 @@ _PINCLUDE(glibmm/private/object_p.h)
 
 namespace Gtk
 {
-class GTKMM_API StringObject : public Glib::Object
-{
-  _CLASS_GOBJECT(StringObject, GtkStringObject, GTK_STRING_OBJECT, Glib::Object, GObject, , , GTKMM_API)
-  _STRUCT_NOT_HIDDEN
-
-protected:
-  _WRAP_CTOR(StringObject(const Glib::ustring& string), gtk_string_object_new)
-
-public:
-  _WRAP_METHOD(Glib::ustring get_string() const, gtk_string_object_get_string)
-  _WRAP_PROPERTY("string", Glib::ustring)
-};
 
 /** A list model for strings.
  *
@@ -77,6 +65,7 @@ protected:
 public:
   _WRAP_CREATE(const std::vector<Glib::ustring>& strings)
   _WRAP_METHOD(void append(const Glib::ustring& string), gtk_string_list_append)
+  _IGNORE(gtk_string_list_take)
   _WRAP_METHOD(void remove(guint position), gtk_string_list_remove)
 #m4 _CONVERSION(`const std::vector<Glib::ustring>&',`const 
char*-const*',`Glib::ArrayHandler<Glib::ustring>::vector_to_array($3).data()')
   _WRAP_METHOD(void splice(guint position, guint n_removals, const std::vector<Glib::ustring>& additions),
diff --git a/gtk/src/stringobject.ccg b/gtk/src/stringobject.ccg
new file mode 100644
index 000000000..57b87fdcf
--- /dev/null
+++ b/gtk/src/stringobject.ccg
@@ -0,0 +1,17 @@
+/* Copyright (C) 2020 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
diff --git a/gtk/src/stringobject.hg b/gtk/src/stringobject.hg
new file mode 100644
index 000000000..cec752a6c
--- /dev/null
+++ b/gtk/src/stringobject.hg
@@ -0,0 +1,41 @@
+/* Copyright (C) 2020 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+_CONFIGINCLUDE(gtkmmconfig.h)
+
+#include <glibmm/object.h>
+#include <gtk/gtk.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gtk
+{
+class GTKMM_API StringObject : public Glib::Object
+{
+  _CLASS_GOBJECT(StringObject, GtkStringObject, GTK_STRING_OBJECT, Glib::Object, GObject, , , GTKMM_API)
+  _STRUCT_NOT_HIDDEN
+
+public:
+  // gtk_string_object_new() does more than call g_object_new().
+  // property_string() is read-only, can't be used in a _WRAP_CTOR().
+  _WRAP_METHOD(static Glib::RefPtr<StringObject> create(const Glib::ustring& string), gtk_string_object_new)
+
+  _WRAP_METHOD(Glib::ustring get_string() const, gtk_string_object_get_string)
+  _WRAP_PROPERTY("string", Glib::ustring)
+};
+
+} // namespace Gtk
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index e5211f45a..6ac2f8168 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -582,3 +582,4 @@ _CONVERSION(`const Glib::RefPtr<ConstraintTarget>&',`gpointer',__CONVERT_REFPTR_
 
 _CONVERSION(`const Glib::RefPtr<ListItemFactory>&', `GtkListItemFactory*', __CONVERT_REFPTR_TO_P)
 _CONVERSION(`GtkListItemFactory*',`Glib::RefPtr<ListItemFactory>',`Glib::wrap($3)')
+_CONVERSION(`GtkStringObject*',`Glib::RefPtr<StringObject>',`Glib::wrap($3)')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]