Create wrapper function for gtk_container_add()

I don't want to have to keep typing out the conversion macros, so this
function puts them all in one place.
This commit is contained in:
Bryan Schumaker 2011-08-20 11:36:29 -04:00
parent d75227b6af
commit 1413a31aa7
4 changed files with 9 additions and 2 deletions

View File

@ -7,7 +7,7 @@ GtkWidget *make_button(const gchar *stockid, GtkIconSize size)
GtkWidget *box = gtk_hbox_new(FALSE, 0); GtkWidget *box = gtk_hbox_new(FALSE, 0);
GtkWidget *image = gtk_image_new_from_stock(stockid, size); GtkWidget *image = gtk_image_new_from_stock(stockid, size);
box_pack_start(box, image, FALSE, FALSE, 0); box_pack_start(box, image, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(button), box); container_add(button, box);
gtk_widget_show_all(button); gtk_widget_show_all(button);
return button; return button;
} }

View File

@ -6,3 +6,8 @@ void box_pack_start(GtkWidget *box, GtkWidget *child, gboolean expand,
{ {
gtk_box_pack_start(GTK_BOX(box), child, expand, fill, padding); gtk_box_pack_start(GTK_BOX(box), child, expand, fill, padding);
} }
void container_add(GtkWidget *container, GtkWidget *widget)
{
gtk_container_add(GTK_CONTAINER(container), widget);
}

View File

@ -1,4 +1,5 @@
#include <ocarina/gtk.h>
#include <ocarina/ocarina.h> #include <ocarina/ocarina.h>
#include <ocarina/window.h> #include <ocarina/window.h>
@ -24,5 +25,5 @@ void window_init()
void window_add(GtkWidget *widget) void window_add(GtkWidget *widget)
{ {
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(widget)); container_add(window, widget);
} }

View File

@ -6,5 +6,6 @@ extern "C" {
} }
void box_pack_start(GtkWidget *, GtkWidget *, gboolean, gboolean, guint); void box_pack_start(GtkWidget *, GtkWidget *, gboolean, gboolean, guint);
void container_add(GtkWidget *, GtkWidget *);
#endif #endif