Added uiContainer, the GtkFixed equivalent for use by the GTK+ backend. Fixed up formatting of the uipriv_*.h files.
This commit is contained in:
parent
4b13f93dbe
commit
79d1877202
|
@ -0,0 +1,78 @@
|
|||
// 13 august 2014
|
||||
#include "uipriv_unix.h"
|
||||
|
||||
G_DEFINE_TYPE(uiContainer, uiContainer, GTK_TYPE_CONTAINER)
|
||||
|
||||
static void uiContainer_init(uiContainer *c)
|
||||
{
|
||||
c->children = g_ptr_array_new();
|
||||
gtk_widget_set_has_window(GTK_WIDGET(c), FALSE);
|
||||
}
|
||||
|
||||
static void uiContainer_dispose(GObject *obj)
|
||||
{
|
||||
g_ptr_array_unref(uiContainer(obj)->children);
|
||||
G_OBJECT_CLASS(uiContainer_parent_class)->dispose(obj);
|
||||
}
|
||||
|
||||
static void uiContainer_finalize(GObject *obj)
|
||||
{
|
||||
G_OBJECT_CLASS(uiContainer_parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static void uiContainer_add(GtkContainer *container, GtkWidget *widget)
|
||||
{
|
||||
gtk_widget_set_parent(widget, GTK_WIDGET(container));
|
||||
g_ptr_array_add(uiContainer(container)->children, widget);
|
||||
}
|
||||
|
||||
static void uiContainer_remove(GtkContainer *container, GtkWidget *widget)
|
||||
{
|
||||
gtk_widget_unparent(widget);
|
||||
g_ptr_array_remove(uiContainer(container)->children, widget);
|
||||
}
|
||||
|
||||
static void uiContainer_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
|
||||
{
|
||||
gtk_widget_set_allocation(widget, allocation);
|
||||
// TODO resize child
|
||||
}
|
||||
|
||||
struct forall {
|
||||
GtkCallback callback;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
static void doforall(gpointer obj, gpointer data)
|
||||
{
|
||||
struct forall *s = (struct forall *) data;
|
||||
|
||||
(*(s->callback))(uiContainer(obj), s->data);
|
||||
}
|
||||
|
||||
static void uiContainer_forall(GtkContainer *container, gboolean includeInternals, GtkCallback callback, gpointer data)
|
||||
{
|
||||
struct forall s;
|
||||
|
||||
s.callback = callback;
|
||||
s.data = data;
|
||||
g_ptr_array_foreach(uiContainer(container)->children, doforall, &s);
|
||||
}
|
||||
|
||||
static void uiContainer_class_init(uiContainerClass *class)
|
||||
{
|
||||
G_OBJECT_CLASS(class)->dispose = uiContainer_dispose;
|
||||
G_OBJECT_CLASS(class)->finalize = uiContainer_finalize;
|
||||
GTK_WIDGET_CLASS(class)->size_allocate = uiContainer_size_allocate;
|
||||
GTK_CONTAINER_CLASS(class)->add = uiContainer_add;
|
||||
GTK_CONTAINER_CLASS(class)->remove = uiContainer_remove;
|
||||
GTK_CONTAINER_CLASS(class)->forall = uiContainer_forall;
|
||||
}
|
||||
|
||||
GtkWidget *newContainer(void)
|
||||
{
|
||||
uiContainer *c;
|
||||
|
||||
c = uiContainer(g_object_new(uiContainerType, NULL));
|
||||
return GTK_WIDGET(c);
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
// 6 january 2015
|
||||
|
||||
#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_7
|
||||
#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_7
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// 6 april 2015
|
||||
|
||||
#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_32
|
||||
#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_32
|
||||
#define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_4
|
||||
|
@ -7,3 +6,23 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include "uipriv.h"
|
||||
#include "ui_unix.h"
|
||||
|
||||
// container_unix.c
|
||||
#define uiContainerType (uiContainer_get_type())
|
||||
#define uiContainer(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), uiContainerType, uiContainer))
|
||||
#define uiIsContainer(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), uiContainerType))
|
||||
#define uiContainerClass(class) (G_TYPE_CHECK_CLASS_CAST((class), uiContainerType, uiContainerClass))
|
||||
#define uiIsContainerClass(class) (G_TYPE_CHECK_CLASS_TYPE((class), uiContainer))
|
||||
#define uiGetContainerClass(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), uiContainerType, uiContainerClass))
|
||||
typedef struct uiContainer uiContainer;
|
||||
typedef struct uiContainerClass uiContainerClass;
|
||||
struct uiContainer {
|
||||
GtkContainer parent_instance;
|
||||
// TODO
|
||||
GPtrArray *children; // for forall()
|
||||
};
|
||||
struct uiContainerClass {
|
||||
GtkContainerClass parent_class;
|
||||
};
|
||||
extern GType uiContainer_get_type(void);
|
||||
extern GtkWidget *newContainer(void);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// 6 january 2015
|
||||
|
||||
#define UNICODE
|
||||
#define _UNICODE
|
||||
#define STRICT
|
||||
|
|
Loading…
Reference in New Issue