Migrated the types and functions of child.c.
This commit is contained in:
parent
afaec644cc
commit
70fd8cbf8e
|
@ -1,17 +1,3 @@
|
|||
|
||||
|
||||
|
||||
// child.c
|
||||
extern struct child *newChild(uiControl *child, uiControl *parent, GtkContainer *parentContainer);
|
||||
extern struct child *newChildWithBox(uiControl *child, uiControl *parent, GtkContainer *parentContainer, int margined);
|
||||
extern void childRemove(struct child *c);
|
||||
extern void childDestroy(struct child *c);
|
||||
extern GtkWidget *childWidget(struct child *c);
|
||||
extern int childFlag(struct child *c);
|
||||
extern void childSetFlag(struct child *c, int flag);
|
||||
extern GtkWidget *childBox(struct child *c);
|
||||
extern void childSetMargined(struct child *c, int margined);
|
||||
|
||||
// draw.c
|
||||
extern uiDrawContext *newContext(cairo_t *cr, GtkStyleContext *style);
|
||||
extern void freeContext(uiDrawContext *);
|
||||
|
|
32
unix/child.c
32
unix/child.c
|
@ -3,7 +3,7 @@
|
|||
|
||||
// This file contains helpers for managing child controls.
|
||||
|
||||
struct child {
|
||||
struct uiprivChild {
|
||||
uiControl *c;
|
||||
GtkWidget *widget;
|
||||
|
||||
|
@ -26,14 +26,14 @@ struct child {
|
|||
int flag;
|
||||
};
|
||||
|
||||
struct child *newChild(uiControl *child, uiControl *parent, GtkContainer *parentContainer)
|
||||
uiprivChild *uiprivNewChild(uiControl *child, uiControl *parent, GtkContainer *parentContainer)
|
||||
{
|
||||
struct child *c;
|
||||
uiprivChild *c;
|
||||
|
||||
if (child == NULL)
|
||||
return NULL;
|
||||
|
||||
c = uiprivNew(struct child);
|
||||
c = uiprivNew(uiprivChild);
|
||||
c->c = child;
|
||||
c->widget = GTK_WIDGET(uiControlHandle(c->c));
|
||||
|
||||
|
@ -49,27 +49,27 @@ struct child *newChild(uiControl *child, uiControl *parent, GtkContainer *parent
|
|||
return c;
|
||||
}
|
||||
|
||||
struct child *newChildWithBox(uiControl *child, uiControl *parent, GtkContainer *parentContainer, int margined)
|
||||
uiprivChild *uiprivNewChildWithBox(uiControl *child, uiControl *parent, GtkContainer *parentContainer, int margined)
|
||||
{
|
||||
struct child *c;
|
||||
uiprivChild *c;
|
||||
GtkWidget *box;
|
||||
|
||||
if (child == NULL)
|
||||
return NULL;
|
||||
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_show(box);
|
||||
c = newChild(child, parent, GTK_CONTAINER(box));
|
||||
c = uiprivNewChild(child, parent, GTK_CONTAINER(box));
|
||||
gtk_widget_set_hexpand(c->widget, TRUE);
|
||||
gtk_widget_set_halign(c->widget, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_vexpand(c->widget, TRUE);
|
||||
gtk_widget_set_valign(c->widget, GTK_ALIGN_FILL);
|
||||
c->box = box;
|
||||
gtk_container_add(parentContainer, c->box);
|
||||
childSetMargined(c, margined);
|
||||
uiprivChildSetMargined(c, margined);
|
||||
return c;
|
||||
}
|
||||
|
||||
void childRemove(struct child *c)
|
||||
void uiprivChildRemove(uiprivChild *c)
|
||||
{
|
||||
uiControlSetParent(c->c, NULL);
|
||||
uiUnixControlSetContainer(uiUnixControl(c->c), c->parent, TRUE);
|
||||
|
@ -85,36 +85,36 @@ void childRemove(struct child *c)
|
|||
uiprivFree(c);
|
||||
}
|
||||
|
||||
void childDestroy(struct child *c)
|
||||
void uiprivChildDestroy(uiprivChild *c)
|
||||
{
|
||||
uiControl *child;
|
||||
|
||||
child = c->c;
|
||||
childRemove(c);
|
||||
uiprivChildRemove(c);
|
||||
uiControlDestroy(child);
|
||||
}
|
||||
|
||||
GtkWidget *childWidget(struct child *c)
|
||||
GtkWidget *uiprivChildWidget(uiprivChild *c)
|
||||
{
|
||||
return c->widget;
|
||||
}
|
||||
|
||||
int childFlag(struct child *c)
|
||||
int uiprivChildFlag(uiprivChild *c)
|
||||
{
|
||||
return c->flag;
|
||||
}
|
||||
|
||||
void childSetFlag(struct child *c, int flag)
|
||||
void uiprivChildSetFlag(uiprivChild *c, int flag)
|
||||
{
|
||||
c->flag = flag;
|
||||
}
|
||||
|
||||
GtkWidget *childBox(struct child *c)
|
||||
GtkWidget *uiprivChildBox(uiprivChild *c)
|
||||
{
|
||||
return c->box;
|
||||
}
|
||||
|
||||
void childSetMargined(struct child *c, int margined)
|
||||
void uiprivChildSetMargined(uiprivChild *c, int margined)
|
||||
{
|
||||
uiprivSetMargined(GTK_CONTAINER(c->box), margined);
|
||||
}
|
||||
|
|
12
unix/group.c
12
unix/group.c
|
@ -8,8 +8,8 @@ struct uiGroup {
|
|||
GtkBin *bin;
|
||||
GtkFrame *frame;
|
||||
|
||||
// unfortunately, even though a GtkFrame is a GtkBin, calling gtk_container_set_border_width() on it /includes/ the GtkFrame's label; we don't want tht
|
||||
struct child *child;
|
||||
// unfortunately, even though a GtkFrame is a GtkBin, calling gtk_container_set_border_width() on it /includes/ the GtkFrame's label; we don't want that
|
||||
uiprivChild *child;
|
||||
|
||||
int margined;
|
||||
};
|
||||
|
@ -21,7 +21,7 @@ static void uiGroupDestroy(uiControl *c)
|
|||
uiGroup *g = uiGroup(c);
|
||||
|
||||
if (g->child != NULL)
|
||||
childDestroy(g->child);
|
||||
uiprivChildDestroy(g->child);
|
||||
g_object_unref(g->widget);
|
||||
uiFreeControl(uiControl(g));
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ void uiGroupSetTitle(uiGroup *g, const char *text)
|
|||
void uiGroupSetChild(uiGroup *g, uiControl *child)
|
||||
{
|
||||
if (g->child != NULL)
|
||||
childRemove(g->child);
|
||||
g->child = newChildWithBox(child, uiControl(g), g->container, g->margined);
|
||||
uiprivChildRemove(g->child);
|
||||
g->child = uiprivNewChildWithBox(child, uiControl(g), g->container, g->margined);
|
||||
}
|
||||
|
||||
int uiGroupMargined(uiGroup *g)
|
||||
|
@ -52,7 +52,7 @@ void uiGroupSetMargined(uiGroup *g, int margined)
|
|||
{
|
||||
g->margined = margined;
|
||||
if (g->child != NULL)
|
||||
childSetMargined(g->child, g->margined);
|
||||
uiprivChildSetMargined(g->child, g->margined);
|
||||
}
|
||||
|
||||
uiGroup *uiNewGroup(const char *text)
|
||||
|
|
38
unix/tab.c
38
unix/tab.c
|
@ -8,7 +8,7 @@ struct uiTab {
|
|||
GtkContainer *container;
|
||||
GtkNotebook *notebook;
|
||||
|
||||
GArray *pages; // []*struct child
|
||||
GArray *pages; // []*uiprivChild
|
||||
};
|
||||
|
||||
uiUnixControlAllDefaultsExceptDestroy(uiTab)
|
||||
|
@ -17,11 +17,11 @@ static void uiTabDestroy(uiControl *c)
|
|||
{
|
||||
uiTab *t = uiTab(c);
|
||||
guint i;
|
||||
struct child *page;
|
||||
uiprivChild *page;
|
||||
|
||||
for (i = 0; i < t->pages->len; i++) {
|
||||
page = g_array_index(t->pages, struct child *, i);
|
||||
childDestroy(page);
|
||||
page = g_array_index(t->pages, uiprivChild *, i);
|
||||
uiprivChildDestroy(page);
|
||||
}
|
||||
g_array_free(t->pages, TRUE);
|
||||
// and free ourselves
|
||||
|
@ -36,24 +36,24 @@ void uiTabAppend(uiTab *t, const char *name, uiControl *child)
|
|||
|
||||
void uiTabInsertAt(uiTab *t, const char *name, int n, uiControl *child)
|
||||
{
|
||||
struct child *page;
|
||||
uiprivChild *page;
|
||||
|
||||
// this will create a tab, because of gtk_container_add()
|
||||
page = newChildWithBox(child, uiControl(t), t->container, 0);
|
||||
page = uiprivNewChildWithBox(child, uiControl(t), t->container, 0);
|
||||
|
||||
gtk_notebook_set_tab_label_text(t->notebook, childBox(page), name);
|
||||
gtk_notebook_reorder_child(t->notebook, childBox(page), n);
|
||||
gtk_notebook_set_tab_label_text(t->notebook, uiprivChildBox(page), name);
|
||||
gtk_notebook_reorder_child(t->notebook, uiprivChildBox(page), n);
|
||||
|
||||
g_array_insert_val(t->pages, n, page);
|
||||
}
|
||||
|
||||
void uiTabDelete(uiTab *t, int n)
|
||||
{
|
||||
struct child *page;
|
||||
uiprivChild *page;
|
||||
|
||||
page = g_array_index(t->pages, struct child *, n);
|
||||
page = g_array_index(t->pages, uiprivChild *, n);
|
||||
// this will remove the tab, because gtk_widget_destroy() calls gtk_container_remove()
|
||||
childRemove(page);
|
||||
uiprivChildRemove(page);
|
||||
g_array_remove_index(t->pages, n);
|
||||
}
|
||||
|
||||
|
@ -64,19 +64,19 @@ int uiTabNumPages(uiTab *t)
|
|||
|
||||
int uiTabMargined(uiTab *t, int n)
|
||||
{
|
||||
struct child *page;
|
||||
uiprivChild *page;
|
||||
|
||||
page = g_array_index(t->pages, struct child *, n);
|
||||
return childFlag(page);
|
||||
page = g_array_index(t->pages, uiprivChild *, n);
|
||||
return uiprivChildFlag(page);
|
||||
}
|
||||
|
||||
void uiTabSetMargined(uiTab *t, int n, int margined)
|
||||
{
|
||||
struct child *page;
|
||||
uiprivChild *page;
|
||||
|
||||
page = g_array_index(t->pages, struct child *, n);
|
||||
childSetFlag(page, margined);
|
||||
childSetMargined(page, childFlag(page));
|
||||
page = g_array_index(t->pages, uiprivChild *, n);
|
||||
uiprivChildSetFlag(page, margined);
|
||||
uiprivChildSetMargined(page, uiprivChildFlag(page));
|
||||
}
|
||||
|
||||
uiTab *uiNewTab(void)
|
||||
|
@ -91,7 +91,7 @@ uiTab *uiNewTab(void)
|
|||
|
||||
gtk_notebook_set_scrollable(t->notebook, TRUE);
|
||||
|
||||
t->pages = g_array_new(FALSE, TRUE, sizeof (struct child *));
|
||||
t->pages = g_array_new(FALSE, TRUE, sizeof (uiprivChild *));
|
||||
|
||||
return t;
|
||||
}
|
||||
|
|
|
@ -31,4 +31,16 @@ extern void uiprivUninitAlloc(void);
|
|||
// util.c
|
||||
extern void uiprivSetMargined(GtkContainer *, int);
|
||||
|
||||
// child.c
|
||||
typedef struct uiprivChild uiprivChild;
|
||||
extern uiprivChild *uiprivNewChild(uiControl *child, uiControl *parent, GtkContainer *parentContainer);
|
||||
extern uiprivChild *uiprivNewChildWithBox(uiControl *child, uiControl *parent, GtkContainer *parentContainer, int margined);
|
||||
extern void uiprivChildRemove(uiprivChild *c);
|
||||
extern void uiprivChildDestroy(uiprivChild *c);
|
||||
extern GtkWidget *uiprivChildWidget(uiprivChild *c);
|
||||
extern int uiprivChildFlag(uiprivChild *c);
|
||||
extern void uiprivChildSetFlag(uiprivChild *c, int flag);
|
||||
extern GtkWidget *uiprivChildBox(uiprivChild *c);
|
||||
extern void uiprivChildSetMargined(uiprivChild *c, int margined);
|
||||
|
||||
#include "OLD_uipriv_unix.h"
|
||||
|
|
Loading…
Reference in New Issue