Merge branch 'unix-namespace-cleanup'

This commit is contained in:
Pietro Gagliardi 2018-05-12 13:48:44 -04:00
commit 1b23cd4e72
22 changed files with 125 additions and 138 deletions

View File

@ -55,28 +55,8 @@ list(APPEND _LIBUI_INCLUDEDIRS
set(_LIBUI_INCLUDEDIRS _LIBUI_INCLUDEDIRS PARENT_SCOPE) set(_LIBUI_INCLUDEDIRS _LIBUI_INCLUDEDIRS PARENT_SCOPE)
set(_LIBUINAME libui PARENT_SCOPE) set(_LIBUINAME libui PARENT_SCOPE)
if(NOT BUILD_SHARED_LIBS)
set(_LIBUINAME libui-temporary PARENT_SCOPE)
endif()
# TODO remove all these temporary files after linking the final archive file
macro(_handle_static) macro(_handle_static)
set_target_properties(${_LIBUINAME} PROPERTIES # do nothing
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
set(_aname $<TARGET_FILE:${_LIBUINAME}>)
set(_oname libui-combined.o)
add_custom_command(
OUTPUT ${_oname}
COMMAND
ld -r --whole-archive ${_aname} -o ${_oname}
COMMAND
objcopy --localize-hidden ${_oname}
COMMENT "Removing hidden symbols")
add_library(libui STATIC ${_oname})
# otherwise cmake won't know which linker to use
set_target_properties(libui PROPERTIES
LINKER_LANGUAGE C)
set(_aname)
set(_oname)
endmacro() endmacro()
# TODO the other variables don't work? # TODO the other variables don't work?

View File

@ -13,7 +13,7 @@ static GPtrArray *allocations;
#define CCHAR(p) ((const char **) (p)) #define CCHAR(p) ((const char **) (p))
#define TYPE(p) CCHAR(UINT8(p) + sizeof (size_t)) #define TYPE(p) CCHAR(UINT8(p) + sizeof (size_t))
void initAlloc(void) void uiprivInitAlloc(void)
{ {
allocations = g_ptr_array_new(); allocations = g_ptr_array_new();
} }
@ -30,7 +30,7 @@ static void uninitComplain(gpointer ptr, gpointer data)
*str = str2; *str = str2;
} }
void uninitAlloc(void) void uiprivUninitAlloc(void)
{ {
char *str = NULL; char *str = NULL;

View File

@ -122,7 +122,7 @@ static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
uiAreaDrawParams dp; uiAreaDrawParams dp;
double clipX0, clipY0, clipX1, clipY1; double clipX0, clipY0, clipX1, clipY1;
dp.Context = newContext(cr, dp.Context = uiprivNewContext(cr,
gtk_widget_get_style_context(a->widget)); gtk_widget_get_style_context(a->widget));
loadAreaSize(a, &(dp.AreaWidth), &(dp.AreaHeight)); loadAreaSize(a, &(dp.AreaWidth), &(dp.AreaHeight));
@ -136,7 +136,7 @@ static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
// no need to save or restore the graphics state to reset transformations; GTK+ does that for us // no need to save or restore the graphics state to reset transformations; GTK+ does that for us
(*(a->ah->Draw))(a->ah, a, &dp); (*(a->ah->Draw))(a->ah, a, &dp);
freeContext(dp.Context); uiprivFreeContext(dp.Context);
return FALSE; return FALSE;
} }

View File

@ -57,7 +57,7 @@ static uiForEach processAttribute(const uiAttributedString *s, const uiAttribute
(guint16) (g * 65535.0), (guint16) (g * 65535.0),
(guint16) (b * 65535.0))); (guint16) (b * 65535.0)));
addattr(p, start, end, addattr(p, start, end,
FUTURE_pango_attr_foreground_alpha_new( uiprivFUTURE_pango_attr_foreground_alpha_new(
(guint16) (a * 65535.0))); (guint16) (a * 65535.0)));
break; break;
case uiAttributeTypeBackground: case uiAttributeTypeBackground:
@ -69,7 +69,7 @@ static uiForEach processAttribute(const uiAttributedString *s, const uiAttribute
(guint16) (g * 65535.0), (guint16) (g * 65535.0),
(guint16) (b * 65535.0))); (guint16) (b * 65535.0)));
addattr(p, start, end, addattr(p, start, end,
FUTURE_pango_attr_background_alpha_new( uiprivFUTURE_pango_attr_background_alpha_new(
(guint16) (a * 65535.0))); (guint16) (a * 65535.0)));
break; break;
case uiAttributeTypeUnderline: case uiAttributeTypeUnderline:
@ -125,7 +125,7 @@ static uiForEach processAttribute(const uiAttributedString *s, const uiAttribute
break; break;
featurestr = uiprivOpenTypeFeaturesToPangoCSSFeaturesString(features); featurestr = uiprivOpenTypeFeaturesToPangoCSSFeaturesString(features);
addattr(p, start, end, addattr(p, start, end,
FUTURE_pango_attr_font_features_new(featurestr->str)); uiprivFUTURE_pango_attr_font_features_new(featurestr->str));
g_string_free(featurestr, TRUE); g_string_free(featurestr, TRUE);
break; break;
default: default:

View File

@ -119,9 +119,9 @@ void uiBoxSetPadded(uiBox *b, int padded)
b->padded = padded; b->padded = padded;
if (b->padded) if (b->padded)
if (b->vertical) if (b->vertical)
gtk_box_set_spacing(b->box, gtkYPadding); gtk_box_set_spacing(b->box, uiprivGTKYPadding);
else else
gtk_box_set_spacing(b->box, gtkXPadding); gtk_box_set_spacing(b->box, uiprivGTKXPadding);
else else
gtk_box_set_spacing(b->box, 0); gtk_box_set_spacing(b->box, 0);
} }

View File

@ -68,7 +68,7 @@ static GtkStyleContext *setButtonStyle(GtkWidget *widget)
path = gtk_widget_path_copy(gtk_style_context_get_path(base)); path = gtk_widget_path_copy(gtk_style_context_get_path(base));
gtk_widget_path_append_type(path, G_TYPE_NONE); gtk_widget_path_append_type(path, G_TYPE_NONE);
if (!FUTURE_gtk_widget_path_iter_set_object_name(path, -1, "button")) if (!uiprivFUTURE_gtk_widget_path_iter_set_object_name(path, -1, "button"))
// not on 3.20; try the type // not on 3.20; try the type
gtk_widget_path_iter_set_object_type(path, -1, GTK_TYPE_BUTTON); gtk_widget_path_iter_set_object_type(path, -1, GTK_TYPE_BUTTON);
@ -293,7 +293,7 @@ static void cellRendererButton_class_init(cellRendererButtonClass *class)
1, G_TYPE_STRING); 1, G_TYPE_STRING);
} }
GtkCellRenderer *newCellRendererButton(void) GtkCellRenderer *uiprivNewCellRendererButton(void)
{ {
return GTK_CELL_RENDERER(g_object_new(cellRendererButtonType, NULL)); return GTK_CELL_RENDERER(g_object_new(cellRendererButtonType, NULL));
} }

View File

@ -3,7 +3,7 @@
// This file contains helpers for managing child controls. // This file contains helpers for managing child controls.
struct child { struct uiprivChild {
uiControl *c; uiControl *c;
GtkWidget *widget; GtkWidget *widget;
@ -26,14 +26,14 @@ struct child {
int flag; 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) if (child == NULL)
return NULL; return NULL;
c = uiprivNew(struct child); c = uiprivNew(uiprivChild);
c->c = child; c->c = child;
c->widget = GTK_WIDGET(uiControlHandle(c->c)); c->widget = GTK_WIDGET(uiControlHandle(c->c));
@ -49,27 +49,27 @@ struct child *newChild(uiControl *child, uiControl *parent, GtkContainer *parent
return c; 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; GtkWidget *box;
if (child == NULL) if (child == NULL)
return NULL; return NULL;
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_show(box); 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_hexpand(c->widget, TRUE);
gtk_widget_set_halign(c->widget, GTK_ALIGN_FILL); gtk_widget_set_halign(c->widget, GTK_ALIGN_FILL);
gtk_widget_set_vexpand(c->widget, TRUE); gtk_widget_set_vexpand(c->widget, TRUE);
gtk_widget_set_valign(c->widget, GTK_ALIGN_FILL); gtk_widget_set_valign(c->widget, GTK_ALIGN_FILL);
c->box = box; c->box = box;
gtk_container_add(parentContainer, c->box); gtk_container_add(parentContainer, c->box);
childSetMargined(c, margined); uiprivChildSetMargined(c, margined);
return c; return c;
} }
void childRemove(struct child *c) void uiprivChildRemove(uiprivChild *c)
{ {
uiControlSetParent(c->c, NULL); uiControlSetParent(c->c, NULL);
uiUnixControlSetContainer(uiUnixControl(c->c), c->parent, TRUE); uiUnixControlSetContainer(uiUnixControl(c->c), c->parent, TRUE);
@ -85,36 +85,36 @@ void childRemove(struct child *c)
uiprivFree(c); uiprivFree(c);
} }
void childDestroy(struct child *c) void uiprivChildDestroy(uiprivChild *c)
{ {
uiControl *child; uiControl *child;
child = c->c; child = c->c;
childRemove(c); uiprivChildRemove(c);
uiControlDestroy(child); uiControlDestroy(child);
} }
GtkWidget *childWidget(struct child *c) GtkWidget *uiprivChildWidget(uiprivChild *c)
{ {
return c->widget; return c->widget;
} }
int childFlag(struct child *c) int uiprivChildFlag(uiprivChild *c)
{ {
return c->flag; return c->flag;
} }
void childSetFlag(struct child *c, int flag) void uiprivChildSetFlag(uiprivChild *c, int flag)
{ {
c->flag = flag; c->flag = flag;
} }
GtkWidget *childBox(struct child *c) GtkWidget *uiprivChildBox(uiprivChild *c)
{ {
return c->box; return c->box;
} }
void childSetMargined(struct child *c, int margined) void uiprivChildSetMargined(uiprivChild *c, int margined)
{ {
setMargined(GTK_CONTAINER(c->box), margined); uiprivSetMargined(GTK_CONTAINER(c->box), margined);
} }

View File

@ -2,7 +2,7 @@
#include "uipriv_unix.h" #include "uipriv_unix.h"
#include "draw.h" #include "draw.h"
uiDrawContext *newContext(cairo_t *cr, GtkStyleContext *style) uiDrawContext *uiprivNewContext(cairo_t *cr, GtkStyleContext *style)
{ {
uiDrawContext *c; uiDrawContext *c;
@ -12,7 +12,7 @@ uiDrawContext *newContext(cairo_t *cr, GtkStyleContext *style)
return c; return c;
} }
void freeContext(uiDrawContext *c) void uiprivFreeContext(uiDrawContext *c)
{ {
// free neither cr nor style; we own neither // free neither cr nor style; we own neither
uiprivFree(c); uiprivFree(c);
@ -59,7 +59,7 @@ void uiDrawStroke(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b, uiDrawStro
{ {
cairo_pattern_t *pat; cairo_pattern_t *pat;
runPath(path, c->cr); uiprivRunPath(path, c->cr);
pat = mkbrush(b); pat = mkbrush(b);
cairo_set_source(c->cr, pat); cairo_set_source(c->cr, pat);
switch (p->Cap) { switch (p->Cap) {
@ -95,10 +95,10 @@ void uiDrawFill(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b)
{ {
cairo_pattern_t *pat; cairo_pattern_t *pat;
runPath(path, c->cr); uiprivRunPath(path, c->cr);
pat = mkbrush(b); pat = mkbrush(b);
cairo_set_source(c->cr, pat); cairo_set_source(c->cr, pat);
switch (pathFillMode(path)) { switch (uiprivPathFillMode(path)) {
case uiDrawFillModeWinding: case uiDrawFillModeWinding:
cairo_set_fill_rule(c->cr, CAIRO_FILL_RULE_WINDING); cairo_set_fill_rule(c->cr, CAIRO_FILL_RULE_WINDING);
break; break;
@ -114,14 +114,14 @@ void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m)
{ {
cairo_matrix_t cm; cairo_matrix_t cm;
m2c(m, &cm); uiprivM2C(m, &cm);
cairo_transform(c->cr, &cm); cairo_transform(c->cr, &cm);
} }
void uiDrawClip(uiDrawContext *c, uiDrawPath *path) void uiDrawClip(uiDrawContext *c, uiDrawPath *path)
{ {
runPath(path, c->cr); uiprivRunPath(path, c->cr);
switch (pathFillMode(path)) { switch (uiprivPathFillMode(path)) {
case uiDrawFillModeWinding: case uiDrawFillModeWinding:
cairo_set_fill_rule(c->cr, CAIRO_FILL_RULE_WINDING); cairo_set_fill_rule(c->cr, CAIRO_FILL_RULE_WINDING);
break; break;

View File

@ -7,8 +7,8 @@ struct uiDrawContext {
}; };
// drawpath.c // drawpath.c
extern void runPath(uiDrawPath *p, cairo_t *cr); extern void uiprivRunPath(uiDrawPath *p, cairo_t *cr);
extern uiDrawFillMode pathFillMode(uiDrawPath *path); extern uiDrawFillMode uiprivPathFillMode(uiDrawPath *path);
// drawmatrix.c // drawmatrix.c
extern void m2c(uiDrawMatrix *m, cairo_matrix_t *c); extern void uiprivM2C(uiDrawMatrix *m, cairo_matrix_t *c);

View File

@ -2,7 +2,7 @@
#include "uipriv_unix.h" #include "uipriv_unix.h"
#include "draw.h" #include "draw.h"
void m2c(uiDrawMatrix *m, cairo_matrix_t *c) static void m2c(uiDrawMatrix *m, cairo_matrix_t *c)
{ {
c->xx = m->M11; c->xx = m->M11;
c->yx = m->M12; c->yx = m->M12;
@ -12,6 +12,12 @@ void m2c(uiDrawMatrix *m, cairo_matrix_t *c)
c->y0 = m->M32; c->y0 = m->M32;
} }
// needed by uiDrawTransform()
void uiprivM2C(uiDrawMatrix *m, cairo_matrix_t *c)
{
m2c(m, c);
}
static void c2m(cairo_matrix_t *c, uiDrawMatrix *m) static void c2m(cairo_matrix_t *c, uiDrawMatrix *m)
{ {
m->M11 = c->xx; m->M11 = c->xx;

View File

@ -138,7 +138,7 @@ void uiDrawPathEnd(uiDrawPath *p)
p->ended = TRUE; p->ended = TRUE;
} }
void runPath(uiDrawPath *p, cairo_t *cr) void uiprivRunPath(uiDrawPath *p, cairo_t *cr)
{ {
guint i; guint i;
struct piece *piece; struct piece *piece;
@ -193,7 +193,7 @@ void runPath(uiDrawPath *p, cairo_t *cr)
} }
} }
uiDrawFillMode pathFillMode(uiDrawPath *path) uiDrawFillMode uiprivPathFillMode(uiDrawPath *path)
{ {
return path->fillMode; return path->fillMode;
} }

View File

@ -133,8 +133,8 @@ void uiFormSetPadded(uiForm *f, int padded)
{ {
f->padded = padded; f->padded = padded;
if (f->padded) { if (f->padded) {
gtk_grid_set_row_spacing(f->grid, gtkYPadding); gtk_grid_set_row_spacing(f->grid, uiprivGTKYPadding);
gtk_grid_set_column_spacing(f->grid, gtkXPadding); gtk_grid_set_column_spacing(f->grid, uiprivGTKXPadding);
} else { } else {
gtk_grid_set_row_spacing(f->grid, 0); gtk_grid_set_row_spacing(f->grid, 0);
gtk_grid_set_column_spacing(f->grid, 0); gtk_grid_set_column_spacing(f->grid, 0);

View File

@ -14,7 +14,7 @@ static PangoAttribute *(*newBGAlphaAttr)(guint16 alpha) = NULL;
static void (*gwpIterSetObjectName)(GtkWidgetPath *path, gint pos, const char *name) = NULL; static void (*gwpIterSetObjectName)(GtkWidgetPath *path, gint pos, const char *name) = NULL;
// note that we treat any error as "the symbols aren't there" (and don't care if dlclose() failed) // note that we treat any error as "the symbols aren't there" (and don't care if dlclose() failed)
void loadFutures(void) void uiprivLoadFutures(void)
{ {
void *handle; void *handle;
@ -30,28 +30,28 @@ void loadFutures(void)
dlclose(handle); dlclose(handle);
} }
PangoAttribute *FUTURE_pango_attr_font_features_new(const gchar *features) PangoAttribute *uiprivFUTURE_pango_attr_font_features_new(const gchar *features)
{ {
if (newFeaturesAttr == NULL) if (newFeaturesAttr == NULL)
return NULL; return NULL;
return (*newFeaturesAttr)(features); return (*newFeaturesAttr)(features);
} }
PangoAttribute *FUTURE_pango_attr_foreground_alpha_new(guint16 alpha) PangoAttribute *uiprivFUTURE_pango_attr_foreground_alpha_new(guint16 alpha)
{ {
if (newFGAlphaAttr == NULL) if (newFGAlphaAttr == NULL)
return NULL; return NULL;
return (*newFGAlphaAttr)(alpha); return (*newFGAlphaAttr)(alpha);
} }
PangoAttribute *FUTURE_pango_attr_background_alpha_new(guint16 alpha) PangoAttribute *uiprivFUTURE_pango_attr_background_alpha_new(guint16 alpha)
{ {
if (newBGAlphaAttr == NULL) if (newBGAlphaAttr == NULL)
return NULL; return NULL;
return (*newBGAlphaAttr)(alpha); return (*newBGAlphaAttr)(alpha);
} }
gboolean FUTURE_gtk_widget_path_iter_set_object_name(GtkWidgetPath *path, gint pos, const char *name) gboolean uiprivFUTURE_gtk_widget_path_iter_set_object_name(GtkWidgetPath *path, gint pos, const char *name)
{ {
if (gwpIterSetObjectName == NULL) if (gwpIterSetObjectName == NULL)
return FALSE; return FALSE;

View File

@ -117,8 +117,8 @@ void uiGridSetPadded(uiGrid *g, int padded)
{ {
g->padded = padded; g->padded = padded;
if (g->padded) { if (g->padded) {
gtk_grid_set_row_spacing(g->grid, gtkYPadding); gtk_grid_set_row_spacing(g->grid, uiprivGTKYPadding);
gtk_grid_set_column_spacing(g->grid, gtkXPadding); gtk_grid_set_column_spacing(g->grid, uiprivGTKXPadding);
} else { } else {
gtk_grid_set_row_spacing(g->grid, 0); gtk_grid_set_row_spacing(g->grid, 0);
gtk_grid_set_column_spacing(g->grid, 0); gtk_grid_set_column_spacing(g->grid, 0);

View File

@ -8,8 +8,8 @@ struct uiGroup {
GtkBin *bin; GtkBin *bin;
GtkFrame *frame; 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 // 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
struct child *child; uiprivChild *child;
int margined; int margined;
}; };
@ -21,7 +21,7 @@ static void uiGroupDestroy(uiControl *c)
uiGroup *g = uiGroup(c); uiGroup *g = uiGroup(c);
if (g->child != NULL) if (g->child != NULL)
childDestroy(g->child); uiprivChildDestroy(g->child);
g_object_unref(g->widget); g_object_unref(g->widget);
uiFreeControl(uiControl(g)); uiFreeControl(uiControl(g));
} }
@ -39,8 +39,8 @@ void uiGroupSetTitle(uiGroup *g, const char *text)
void uiGroupSetChild(uiGroup *g, uiControl *child) void uiGroupSetChild(uiGroup *g, uiControl *child)
{ {
if (g->child != NULL) if (g->child != NULL)
childRemove(g->child); uiprivChildRemove(g->child);
g->child = newChildWithBox(child, uiControl(g), g->container, g->margined); g->child = uiprivNewChildWithBox(child, uiControl(g), g->container, g->margined);
} }
int uiGroupMargined(uiGroup *g) int uiGroupMargined(uiGroup *g)
@ -52,7 +52,7 @@ void uiGroupSetMargined(uiGroup *g, int margined)
{ {
g->margined = margined; g->margined = margined;
if (g->child != NULL) if (g->child != NULL)
childSetMargined(g->child, g->margined); uiprivChildSetMargined(g->child, g->margined);
} }
uiGroup *uiNewGroup(const char *text) uiGroup *uiNewGroup(const char *text)

View File

@ -105,7 +105,7 @@ writeMatch:
m->distY = abs(m->targetY - y); m->distY = abs(m->targetY - y);
} }
cairo_surface_t *imageAppropriateSurface(uiImage *i, GtkWidget *w) cairo_surface_t *uiprivImageAppropriateSurface(uiImage *i, GtkWidget *w)
{ {
struct matcher m; struct matcher m;

View File

@ -14,15 +14,15 @@ const char *uiInit(uiInitOptions *o)
g_error_free(err); g_error_free(err);
return msg; return msg;
} }
initAlloc(); uiprivInitAlloc();
loadFutures(); uiprivLoadFutures();
return NULL; return NULL;
} }
void uiUninit(void) void uiUninit(void)
{ {
uninitMenus(); uiprivUninitMenus();
uninitAlloc(); uiprivUninitAlloc();
} }
void uiFreeInitError(const char *err) void uiFreeInitError(const char *err)

View File

@ -266,7 +266,7 @@ static void appendMenuItem(GtkMenuShell *submenu, uiMenuItem *item, uiWindow *w)
g_hash_table_insert(item->windows, menuitem, ww); g_hash_table_insert(item->windows, menuitem, ww);
} }
GtkWidget *makeMenubar(uiWindow *w) GtkWidget *uiprivMakeMenubar(uiWindow *w)
{ {
GtkWidget *menubar; GtkWidget *menubar;
guint i, j; guint i, j;
@ -330,7 +330,7 @@ static void freeMenu(GtkWidget *widget, gpointer data)
(*i)++; (*i)++;
} }
void freeMenubar(GtkWidget *mb) void uiprivFreeMenubar(GtkWidget *mb)
{ {
guint i; guint i;
@ -339,7 +339,7 @@ void freeMenubar(GtkWidget *mb)
// no need to worry about destroying any widgets; destruction of the window they're in will do it for us // no need to worry about destroying any widgets; destruction of the window they're in will do it for us
} }
void uninitMenus(void) void uiprivUninitMenus(void)
{ {
uiMenu *m; uiMenu *m;
uiMenuItem *item; uiMenuItem *item;

View File

@ -8,7 +8,7 @@ struct uiTab {
GtkContainer *container; GtkContainer *container;
GtkNotebook *notebook; GtkNotebook *notebook;
GArray *pages; // []*struct child GArray *pages; // []*uiprivChild
}; };
uiUnixControlAllDefaultsExceptDestroy(uiTab) uiUnixControlAllDefaultsExceptDestroy(uiTab)
@ -17,11 +17,11 @@ static void uiTabDestroy(uiControl *c)
{ {
uiTab *t = uiTab(c); uiTab *t = uiTab(c);
guint i; guint i;
struct child *page; uiprivChild *page;
for (i = 0; i < t->pages->len; i++) { for (i = 0; i < t->pages->len; i++) {
page = g_array_index(t->pages, struct child *, i); page = g_array_index(t->pages, uiprivChild *, i);
childDestroy(page); uiprivChildDestroy(page);
} }
g_array_free(t->pages, TRUE); g_array_free(t->pages, TRUE);
// and free ourselves // 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) 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() // 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_set_tab_label_text(t->notebook, uiprivChildBox(page), name);
gtk_notebook_reorder_child(t->notebook, childBox(page), n); gtk_notebook_reorder_child(t->notebook, uiprivChildBox(page), n);
g_array_insert_val(t->pages, n, page); g_array_insert_val(t->pages, n, page);
} }
void uiTabDelete(uiTab *t, int n) 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() // this will remove the tab, because gtk_widget_destroy() calls gtk_container_remove()
childRemove(page); uiprivChildRemove(page);
g_array_remove_index(t->pages, n); g_array_remove_index(t->pages, n);
} }
@ -64,19 +64,19 @@ int uiTabNumPages(uiTab *t)
int uiTabMargined(uiTab *t, int n) int uiTabMargined(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);
return childFlag(page); return uiprivChildFlag(page);
} }
void uiTabSetMargined(uiTab *t, int n, int margined) void uiTabSetMargined(uiTab *t, int n, int margined)
{ {
struct child *page; uiprivChild *page;
page = g_array_index(t->pages, struct child *, n); page = g_array_index(t->pages, uiprivChild *, n);
childSetFlag(page, margined); uiprivChildSetFlag(page, margined);
childSetMargined(page, childFlag(page)); uiprivChildSetMargined(page, uiprivChildFlag(page));
} }
uiTab *uiNewTab(void) uiTab *uiNewTab(void)
@ -91,7 +91,7 @@ uiTab *uiNewTab(void)
gtk_notebook_set_scrollable(t->notebook, TRUE); 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; return t;
} }

View File

@ -14,48 +14,49 @@
#include "../ui_unix.h" #include "../ui_unix.h"
#include "../common/uipriv.h" #include "../common/uipriv.h"
#define gtkXMargin 12 #define uiprivGTKXMargin 12
#define gtkYMargin 12 #define uiprivGTKYMargin 12
#define gtkXPadding 12 #define uiprivGTKXPadding 12
#define gtkYPadding 6 #define uiprivGTKYPadding 6
// menu.c // menu.c
extern GtkWidget *makeMenubar(uiWindow *); extern GtkWidget *uiprivMakeMenubar(uiWindow *);
extern void freeMenubar(GtkWidget *); extern void uiprivFreeMenubar(GtkWidget *);
extern void uninitMenus(void); extern void uiprivUninitMenus(void);
// alloc.c // alloc.c
extern void initAlloc(void); extern void uiprivInitAlloc(void);
extern void uninitAlloc(void); extern void uiprivUninitAlloc(void);
// util.c // util.c
extern void setMargined(GtkContainer *, int); extern void uiprivSetMargined(GtkContainer *, int);
// child.c // child.c
extern struct child *newChild(uiControl *child, uiControl *parent, GtkContainer *parentContainer); typedef struct uiprivChild uiprivChild;
extern struct child *newChildWithBox(uiControl *child, uiControl *parent, GtkContainer *parentContainer, int margined); extern uiprivChild *uiprivNewChild(uiControl *child, uiControl *parent, GtkContainer *parentContainer);
extern void childRemove(struct child *c); extern uiprivChild *uiprivNewChildWithBox(uiControl *child, uiControl *parent, GtkContainer *parentContainer, int margined);
extern void childDestroy(struct child *c); extern void uiprivChildRemove(uiprivChild *c);
extern GtkWidget *childWidget(struct child *c); extern void uiprivChildDestroy(uiprivChild *c);
extern int childFlag(struct child *c); extern GtkWidget *uiprivChildWidget(uiprivChild *c);
extern void childSetFlag(struct child *c, int flag); extern int uiprivChildFlag(uiprivChild *c);
extern GtkWidget *childBox(struct child *c); extern void uiprivChildSetFlag(uiprivChild *c, int flag);
extern void childSetMargined(struct child *c, int margined); extern GtkWidget *uiprivChildBox(uiprivChild *c);
extern void uiprivChildSetMargined(uiprivChild *c, int margined);
// draw.c // draw.c
extern uiDrawContext *newContext(cairo_t *cr, GtkStyleContext *style); extern uiDrawContext *uiprivNewContext(cairo_t *cr, GtkStyleContext *style);
extern void freeContext(uiDrawContext *); extern void uiprivFreeContext(uiDrawContext *);
// image.c // image.c
/*TODO remove this*/typedef struct uiImage uiImage; /*TODO remove this*/typedef struct uiImage uiImage;
extern cairo_surface_t *imageAppropriateSurface(uiImage *i, GtkWidget *w); extern cairo_surface_t *uiprivImageAppropriateSurface(uiImage *i, GtkWidget *w);
// cellrendererbutton.c // cellrendererbutton.c
extern GtkCellRenderer *newCellRendererButton(void); extern GtkCellRenderer *uiprivNewCellRendererButton(void);
// future.c // future.c
extern void loadFutures(void); extern void uiprivLoadFutures(void);
extern PangoAttribute *FUTURE_pango_attr_font_features_new(const gchar *features); extern PangoAttribute *uiprivFUTURE_pango_attr_font_features_new(const gchar *features);
extern PangoAttribute *FUTURE_pango_attr_foreground_alpha_new(guint16 alpha); extern PangoAttribute *uiprivFUTURE_pango_attr_foreground_alpha_new(guint16 alpha);
extern PangoAttribute *FUTURE_pango_attr_background_alpha_new(guint16 alpha); extern PangoAttribute *uiprivFUTURE_pango_attr_background_alpha_new(guint16 alpha);
extern gboolean FUTURE_gtk_widget_path_iter_set_object_name(GtkWidgetPath *path, gint pos, const char *name); extern gboolean uiprivFUTURE_gtk_widget_path_iter_set_object_name(GtkWidgetPath *path, gint pos, const char *name);

View File

@ -1,10 +1,10 @@
// 18 april 2015 // 18 april 2015
#include "uipriv_unix.h" #include "uipriv_unix.h"
void setMargined(GtkContainer *c, int margined) void uiprivSetMargined(GtkContainer *c, int margined)
{ {
if (margined) if (margined)
gtk_container_set_border_width(c, gtkXMargin); gtk_container_set_border_width(c, uiprivGTKXMargin);
else else
gtk_container_set_border_width(c, 0); gtk_container_set_border_width(c, 0);
} }

View File

@ -70,7 +70,7 @@ static void uiWindowDestroy(uiControl *c)
} }
// now destroy the menus, if any // now destroy the menus, if any
if (w->menubar != NULL) if (w->menubar != NULL)
freeMenubar(w->menubar); uiprivFreeMenubar(w->menubar);
gtk_widget_destroy(w->childHolderWidget); gtk_widget_destroy(w->childHolderWidget);
gtk_widget_destroy(w->vboxWidget); gtk_widget_destroy(w->vboxWidget);
// and finally free ourselves // and finally free ourselves
@ -226,7 +226,7 @@ int uiWindowMargined(uiWindow *w)
void uiWindowSetMargined(uiWindow *w, int margined) void uiWindowSetMargined(uiWindow *w, int margined)
{ {
w->margined = margined; w->margined = margined;
setMargined(w->childHolderContainer, w->margined); uiprivSetMargined(w->childHolderContainer, w->margined);
} }
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
@ -250,7 +250,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
gtk_container_add(w->container, w->vboxWidget); gtk_container_add(w->container, w->vboxWidget);
if (hasMenubar) { if (hasMenubar) {
w->menubar = makeMenubar(uiWindow(w)); w->menubar = uiprivMakeMenubar(uiWindow(w));
gtk_container_add(w->vboxContainer, w->menubar); gtk_container_add(w->vboxContainer, w->menubar);
} }