From afaec644cc5e14bb6bedca884d041cb506a8f647 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 12 May 2018 12:47:21 -0400 Subject: [PATCH] Migrated the margin and padding constants and functions in menu.c, alloc.c, and util.c. --- unix/OLD_uipriv_unix.h | 14 -------------- unix/alloc.c | 4 ++-- unix/box.c | 4 ++-- unix/child.c | 2 +- unix/form.c | 4 ++-- unix/grid.c | 4 ++-- unix/main.c | 6 +++--- unix/menu.c | 6 +++--- unix/uipriv_unix.h | 17 +++++++++++++++++ unix/util.c | 4 ++-- unix/window.c | 6 +++--- 11 files changed, 37 insertions(+), 34 deletions(-) diff --git a/unix/OLD_uipriv_unix.h b/unix/OLD_uipriv_unix.h index 94f97fae..53305ae6 100644 --- a/unix/OLD_uipriv_unix.h +++ b/unix/OLD_uipriv_unix.h @@ -1,19 +1,5 @@ -#define gtkXMargin 12 -#define gtkYMargin 12 -#define gtkXPadding 12 -#define gtkYPadding 6 -// menu.c -extern GtkWidget *makeMenubar(uiWindow *); -extern void freeMenubar(GtkWidget *); -extern void uninitMenus(void); -// alloc.c -extern void initAlloc(void); -extern void uninitAlloc(void); - -// util.c -extern void setMargined(GtkContainer *, int); // child.c extern struct child *newChild(uiControl *child, uiControl *parent, GtkContainer *parentContainer); diff --git a/unix/alloc.c b/unix/alloc.c index 2fdd2052..3fa0fd41 100644 --- a/unix/alloc.c +++ b/unix/alloc.c @@ -13,7 +13,7 @@ static GPtrArray *allocations; #define CCHAR(p) ((const char **) (p)) #define TYPE(p) CCHAR(UINT8(p) + sizeof (size_t)) -void initAlloc(void) +void uiprivInitAlloc(void) { allocations = g_ptr_array_new(); } @@ -30,7 +30,7 @@ static void uninitComplain(gpointer ptr, gpointer data) *str = str2; } -void uninitAlloc(void) +void uiprivUninitAlloc(void) { char *str = NULL; diff --git a/unix/box.c b/unix/box.c index 23fb7f7c..82cf2dd1 100644 --- a/unix/box.c +++ b/unix/box.c @@ -119,9 +119,9 @@ void uiBoxSetPadded(uiBox *b, int padded) b->padded = padded; if (b->padded) if (b->vertical) - gtk_box_set_spacing(b->box, gtkYPadding); + gtk_box_set_spacing(b->box, uiprivGTKYPadding); else - gtk_box_set_spacing(b->box, gtkXPadding); + gtk_box_set_spacing(b->box, uiprivGTKXPadding); else gtk_box_set_spacing(b->box, 0); } diff --git a/unix/child.c b/unix/child.c index b6e48807..a0644c89 100644 --- a/unix/child.c +++ b/unix/child.c @@ -116,5 +116,5 @@ GtkWidget *childBox(struct child *c) void childSetMargined(struct child *c, int margined) { - setMargined(GTK_CONTAINER(c->box), margined); + uiprivSetMargined(GTK_CONTAINER(c->box), margined); } diff --git a/unix/form.c b/unix/form.c index 54422b3d..36ad77d5 100644 --- a/unix/form.c +++ b/unix/form.c @@ -133,8 +133,8 @@ void uiFormSetPadded(uiForm *f, int padded) { f->padded = padded; if (f->padded) { - gtk_grid_set_row_spacing(f->grid, gtkYPadding); - gtk_grid_set_column_spacing(f->grid, gtkXPadding); + gtk_grid_set_row_spacing(f->grid, uiprivGTKYPadding); + gtk_grid_set_column_spacing(f->grid, uiprivGTKXPadding); } else { gtk_grid_set_row_spacing(f->grid, 0); gtk_grid_set_column_spacing(f->grid, 0); diff --git a/unix/grid.c b/unix/grid.c index 6d9813b3..7759cecc 100644 --- a/unix/grid.c +++ b/unix/grid.c @@ -117,8 +117,8 @@ void uiGridSetPadded(uiGrid *g, int padded) { g->padded = padded; if (g->padded) { - gtk_grid_set_row_spacing(g->grid, gtkYPadding); - gtk_grid_set_column_spacing(g->grid, gtkXPadding); + gtk_grid_set_row_spacing(g->grid, uiprivGTKYPadding); + gtk_grid_set_column_spacing(g->grid, uiprivGTKXPadding); } else { gtk_grid_set_row_spacing(g->grid, 0); gtk_grid_set_column_spacing(g->grid, 0); diff --git a/unix/main.c b/unix/main.c index 650fe06f..c065449a 100644 --- a/unix/main.c +++ b/unix/main.c @@ -14,15 +14,15 @@ const char *uiInit(uiInitOptions *o) g_error_free(err); return msg; } - initAlloc(); + uiprivInitAlloc(); loadFutures(); return NULL; } void uiUninit(void) { - uninitMenus(); - uninitAlloc(); + uiprivUninitMenus(); + uiprivUninitAlloc(); } void uiFreeInitError(const char *err) diff --git a/unix/menu.c b/unix/menu.c index 17189c8e..a3142ee0 100644 --- a/unix/menu.c +++ b/unix/menu.c @@ -266,7 +266,7 @@ static void appendMenuItem(GtkMenuShell *submenu, uiMenuItem *item, uiWindow *w) g_hash_table_insert(item->windows, menuitem, ww); } -GtkWidget *makeMenubar(uiWindow *w) +GtkWidget *uiprivMakeMenubar(uiWindow *w) { GtkWidget *menubar; guint i, j; @@ -330,7 +330,7 @@ static void freeMenu(GtkWidget *widget, gpointer data) (*i)++; } -void freeMenubar(GtkWidget *mb) +void uiprivFreeMenubar(GtkWidget *mb) { 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 } -void uninitMenus(void) +void uiprivUninitMenus(void) { uiMenu *m; uiMenuItem *item; diff --git a/unix/uipriv_unix.h b/unix/uipriv_unix.h index 7d2a3e0e..0f45c123 100644 --- a/unix/uipriv_unix.h +++ b/unix/uipriv_unix.h @@ -14,4 +14,21 @@ #include "../ui_unix.h" #include "../common/uipriv.h" +#define uiprivGTKXMargin 12 +#define uiprivGTKYMargin 12 +#define uiprivGTKXPadding 12 +#define uiprivGTKYPadding 6 + +// menu.c +extern GtkWidget *uiprivMakeMenubar(uiWindow *); +extern void uiprivFreeMenubar(GtkWidget *); +extern void uiprivUninitMenus(void); + +// alloc.c +extern void uiprivInitAlloc(void); +extern void uiprivUninitAlloc(void); + +// util.c +extern void uiprivSetMargined(GtkContainer *, int); + #include "OLD_uipriv_unix.h" diff --git a/unix/util.c b/unix/util.c index 7f4f43fb..f3929ccb 100644 --- a/unix/util.c +++ b/unix/util.c @@ -1,10 +1,10 @@ // 18 april 2015 #include "uipriv_unix.h" -void setMargined(GtkContainer *c, int margined) +void uiprivSetMargined(GtkContainer *c, int margined) { if (margined) - gtk_container_set_border_width(c, gtkXMargin); + gtk_container_set_border_width(c, uiprivGTKXMargin); else gtk_container_set_border_width(c, 0); } diff --git a/unix/window.c b/unix/window.c index ea9ba370..c5ba2038 100644 --- a/unix/window.c +++ b/unix/window.c @@ -70,7 +70,7 @@ static void uiWindowDestroy(uiControl *c) } // now destroy the menus, if any if (w->menubar != NULL) - freeMenubar(w->menubar); + uiprivFreeMenubar(w->menubar); gtk_widget_destroy(w->childHolderWidget); gtk_widget_destroy(w->vboxWidget); // and finally free ourselves @@ -226,7 +226,7 @@ int uiWindowMargined(uiWindow *w) void uiWindowSetMargined(uiWindow *w, int 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) @@ -250,7 +250,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) gtk_container_add(w->container, w->vboxWidget); if (hasMenubar) { - w->menubar = makeMenubar(uiWindow(w)); + w->menubar = uiprivMakeMenubar(uiWindow(w)); gtk_container_add(w->vboxContainer, w->menubar); }