]> 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 c64835154b818bb21d5a04e2a3775c33ce3a9bf4..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>,
@@ -175,7 +177,7 @@ namespace ui {
         using native = _GtkObject *;
         native _handle;
 
-        Object(native h) : _handle(h)
+        explicit Object(native h) : _handle(h)
         {}
 
         explicit operator bool() const
@@ -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, (),
-         Editable();
     ,
          void editable(bool value);
     );
@@ -234,8 +236,12 @@ namespace ui {
 
     // GObject
 
+    struct Dimensions {
+        int width;
+        int height;
+    };
+
     WRAP(Widget, Object, _GtkWidget, (),
-         Widget();
     ,
          alert_response alert(
                  std::string text,
@@ -252,7 +258,10 @@ namespace ui {
                  bool want_import = false,
                  bool want_save = false
          );
+         bool visible();
          void show();
+         Dimensions dimensions();
+         void dimensions(int width, int height);
     );
 
     WRAP(Container, Widget, _GtkContainer, (),
@@ -271,7 +280,7 @@ namespace ui {
 
     class AccelGroup;
     WRAP(Window, Bin, _GtkWindow, (),
-         Window(window_type type);
+         explicit Window(window_type type);
     ,
          Window create_dialog_window(
                  const char *title,
@@ -308,13 +317,12 @@ namespace ui {
     );
 
     WRAP(Frame, Bin, _GtkFrame, (),
-         Frame(const char *label = nullptr);
+         explicit Frame(const char *label = nullptr);
     ,
     );
 
     WRAP(Button, Bin, _GtkButton, (),
-         Button();
-         Button(const char *label);
+         explicit Button(const char *label);
     ,
     );
 
@@ -324,7 +332,7 @@ namespace ui {
     );
 
     WRAP(CheckButton, ToggleButton, _GtkCheckButton, (),
-         CheckButton(const char *label);
+         explicit CheckButton(const char *label);
     ,
     );
 
@@ -337,8 +345,7 @@ namespace ui {
     );
 
     WRAP(MenuItem, Item, _GtkMenuItem, (),
-         MenuItem();
-         MenuItem(const char *label, bool mnemonic = false);
+         explicit MenuItem(const char *label, bool mnemonic = false);
     ,
     );
 
@@ -351,7 +358,6 @@ namespace ui {
     );
 
     WRAP(TearoffMenuItem, MenuItem, _GtkTearoffMenuItem, (),
-         TearoffMenuItem();
     ,
     );
 
@@ -360,7 +366,6 @@ namespace ui {
     );
 
     WRAP(ComboBoxText, ComboBox, _GtkComboBoxText, (),
-         ComboBoxText();
     ,
     );
 
@@ -381,8 +386,8 @@ namespace ui {
     );
 
     WRAP(ScrolledWindow, Bin, _GtkScrolledWindow, (),
-         ScrolledWindow();
     ,
+         void overflow(Policy x, Policy y);
     );
 
     WRAP(Box, Container, _GtkBox, (),
@@ -404,12 +409,10 @@ namespace ui {
     );
 
     WRAP(HPaned, Paned, _GtkHPaned, (),
-         HPaned();
     ,
     );
 
     WRAP(VPaned, Paned, _GtkVPaned, (),
-         VPaned();
     ,
     );
 
@@ -422,7 +425,6 @@ namespace ui {
     );
 
     WRAP(Menu, MenuShell, _GtkMenu, (),
-         Menu();
     ,
     );
 
@@ -432,8 +434,8 @@ namespace ui {
     );
 
     WRAP(TextView, Container, _GtkTextView, (),
-         TextView();
     ,
+         void text(char const *str);
     );
 
     WRAP(Toolbar, Container, _GtkToolbar, (),
@@ -442,7 +444,6 @@ namespace ui {
 
     class TreeModel;
     WRAP(TreeView, Widget, _GtkTreeView, (),
-         TreeView();
          TreeView(TreeModel model);
     ,
     );
@@ -452,19 +453,20 @@ namespace ui {
     );
 
     WRAP(Label, Widget, _GtkLabel, (),
-         Label(const char *label);
+         explicit Label(const char *label);
     ,
+         void text(char const *str);
     );
 
     WRAP(Image, Widget, _GtkImage, (),
-         Image();
     ,
     );
 
     WRAP(Entry, Widget, _GtkEntry, (IEditable, ICellEditable),
-         Entry();
-         Entry(std::size_t max_length);
+         explicit Entry(std::size_t max_length);
     ,
+        char const *text();
+        void text(char const *str);
     );
 
     class Adjustment;
@@ -482,7 +484,7 @@ namespace ui {
     );
 
     WRAP(HScale, Scale, _GtkHScale, (),
-         HScale(Adjustment adjustment);
+         explicit HScale(Adjustment adjustment);
          HScale(double min, double max, double step);
     ,
     );
@@ -500,7 +502,6 @@ namespace ui {
     );
 
     WRAP(CellRendererText, CellRenderer, _GtkCellRendererText, (),
-         CellRendererText();
     ,
     );
 
@@ -514,7 +515,6 @@ namespace ui {
     );
 
     WRAP(AccelGroup, Object, _GtkAccelGroup, (),
-         AccelGroup();
     ,
     );
 
@@ -525,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, (),
@@ -534,8 +539,7 @@ namespace ui {
     // GBoxed
 
     WRAP(TreePath, Object, _GtkTreePath, (),
-         TreePath();
-         TreePath(const char *path);
+         explicit TreePath(const char *path);
     ,
     );
 
@@ -582,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
 
 }