]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/uilib/uilib.h
GTK: wrap gtk_list_store_append
[xonotic/netradiant.git] / libs / uilib / uilib.h
index 53241ec24716f696afa459c2706b01803eaa93a7..b4d315c96327dc72d0b0bf0d6638e4b8dd40595e 100644 (file)
@@ -31,6 +31,7 @@ struct _GtkImage;
 struct _GtkItem;
 struct _GtkLabel;
 struct _GtkListStore;
+struct _GtkTreeIter;
 struct _GtkMenu;
 struct _GtkMenuBar;
 struct _GtkMenuItem;
@@ -166,6 +167,7 @@ namespace ui {
     }
 
     extern struct Null {} null;
+    extern struct New_t {} New;
 
     class Object :
             public details::Convertible<Object, _GtkObject *, details::Convert::Explicit>,
@@ -208,6 +210,7 @@ namespace ui {
         using native = T *; \
         explicit name(native h) : super(reinterpret_cast<super::native>(h)) {} \
         explicit name(Null n) : name((native) nullptr) {} \
+        explicit name(New_t); \
         static name from(void *ptr) { return name((native) ptr); } \
         ctors \
     }; \
@@ -223,7 +226,6 @@ namespace ui {
     );
 
     WRAP(Editable, Object, _GtkEditable, (),
-         explicit Editable();
     ,
          void editable(bool value);
     );
@@ -240,7 +242,6 @@ namespace ui {
     };
 
     WRAP(Widget, Object, _GtkWidget, (),
-         explicit Widget();
     ,
          alert_response alert(
                  std::string text,
@@ -321,7 +322,6 @@ namespace ui {
     );
 
     WRAP(Button, Bin, _GtkButton, (),
-         explicit Button();
          explicit Button(const char *label);
     ,
     );
@@ -332,7 +332,6 @@ namespace ui {
     );
 
     WRAP(CheckButton, ToggleButton, _GtkCheckButton, (),
-         explicit CheckButton();
          explicit CheckButton(const char *label);
     ,
     );
@@ -346,7 +345,6 @@ namespace ui {
     );
 
     WRAP(MenuItem, Item, _GtkMenuItem, (),
-         explicit MenuItem();
          explicit MenuItem(const char *label, bool mnemonic = false);
     ,
     );
@@ -360,7 +358,6 @@ namespace ui {
     );
 
     WRAP(TearoffMenuItem, MenuItem, _GtkTearoffMenuItem, (),
-         explicit TearoffMenuItem();
     ,
     );
 
@@ -369,7 +366,6 @@ namespace ui {
     );
 
     WRAP(ComboBoxText, ComboBox, _GtkComboBoxText, (),
-         explicit ComboBoxText();
     ,
     );
 
@@ -390,7 +386,6 @@ namespace ui {
     );
 
     WRAP(ScrolledWindow, Bin, _GtkScrolledWindow, (),
-         explicit ScrolledWindow();
     ,
          void overflow(Policy x, Policy y);
     );
@@ -414,12 +409,10 @@ namespace ui {
     );
 
     WRAP(HPaned, Paned, _GtkHPaned, (),
-         explicit HPaned();
     ,
     );
 
     WRAP(VPaned, Paned, _GtkVPaned, (),
-         explicit VPaned();
     ,
     );
 
@@ -432,7 +425,6 @@ namespace ui {
     );
 
     WRAP(Menu, MenuShell, _GtkMenu, (),
-         explicit Menu();
     ,
     );
 
@@ -442,7 +434,6 @@ namespace ui {
     );
 
     WRAP(TextView, Container, _GtkTextView, (),
-         explicit TextView();
     ,
          void text(char const *str);
     );
@@ -453,7 +444,6 @@ namespace ui {
 
     class TreeModel;
     WRAP(TreeView, Widget, _GtkTreeView, (),
-         explicit TreeView();
          TreeView(TreeModel model);
     ,
     );
@@ -469,12 +459,10 @@ namespace ui {
     );
 
     WRAP(Image, Widget, _GtkImage, (),
-         explicit Image();
     ,
     );
 
     WRAP(Entry, Widget, _GtkEntry, (IEditable, ICellEditable),
-         explicit Entry();
          explicit Entry(std::size_t max_length);
     ,
         char const *text();
@@ -514,7 +502,6 @@ namespace ui {
     );
 
     WRAP(CellRendererText, CellRenderer, _GtkCellRendererText, (),
-         explicit CellRendererText();
     ,
     );
 
@@ -528,7 +515,6 @@ namespace ui {
     );
 
     WRAP(AccelGroup, Object, _GtkAccelGroup, (),
-         explicit AccelGroup();
     ,
     );
 
@@ -539,6 +525,11 @@ namespace ui {
     WRAP(ListStore, Object, _GtkListStore, (ITreeModel),
     ,
          void clear();
+
+         template<class... T>
+         void append(T... args);
+
+         void append();
     );
 
     WRAP(TreeSelection, Object, _GtkTreeSelection, (),
@@ -548,7 +539,6 @@ namespace ui {
     // GBoxed
 
     WRAP(TreePath, Object, _GtkTreePath, (),
-         explicit TreePath();
          explicit TreePath(const char *path);
     ,
     );
@@ -596,6 +586,18 @@ namespace ui {
         gtk_container_foreach(this, cb, &lambda);
     }
 
+    namespace {
+        extern "C" {
+        void gtk_list_store_insert_with_values(_GtkListStore *, _GtkTreeIter *, gint position, ...);
+        }
+    }
+
+    template<class... T>
+    void IListStore::append(T... args) {
+        static_assert(sizeof...(args) % 2 == 0, "received an odd number of arguments");
+        gtk_list_store_insert_with_values(this, NULL, -1, args..., -1);
+    }
+
 #undef this
 
 }