More work. Guess I'm creating all the widgets now...

This commit is contained in:
Pietro Gagliardi 2015-06-26 21:52:42 -04:00
parent 9f6043153c
commit 5ae4afd0d5
6 changed files with 42 additions and 24 deletions

View File

@ -4,6 +4,7 @@
struct button {
uiButton b;
GtkWidget *widget;
GtkButton *button;
void (*onClicked)(uiButton *, void *);
void *onClickedData;
};
@ -52,7 +53,9 @@ uiButton *uiNewButton(const char *text)
b = (struct button *) uiNewControl(uiTypeButton());
PUT_CODE_HERE;
b->widget = gtk_button_new_with_label(text);
b->button = GTK_BUTTON(b->widget);
uiUnixMakeSingleWidgetControl(uiControl(b), b->widget);
b->onClicked = defaultOnClicked;

View File

@ -60,14 +60,14 @@ static void singleWidgetCommitDisable(uiControl *c)
static uintptr_t singleWidgetStartZOrder(uiControl *c)
{
complain("singleWidgetStartZOrder() meaningless on GTK+");
return 0; // keep compiler happy
// we don't need to do anything; GTK+ does it for us
return 0;
}
static uintptr_t singleWidgetSetZOrder(uiControl *c, uintptr_t insertAfter)
{
complain("singleWidgetSetZOrder() meaningless on GTK+");
return 0; // keep compiler happy
// we don't need to do anything; GTK+ does it for us
return 0;
}
static int singleWidgetHasTabStops(uiControl *c)

View File

@ -4,6 +4,8 @@
struct group {
uiGroup g;
GtkWidget *widget;
GtkContainer *container;
GtkFrame *frame;
uiControl *child;
int margined;
};
@ -72,10 +74,32 @@ static void groupSetMargined(uiGroup *gg, int margined)
uiGroup *uiNewGroup(const char *text)
{
struct group *g;
gfloat yalign;
GtkLabel *label;
PangoAttribute *bold;
PangoAttrList *boldlist;
g = (struct group *) uiNewControl(uiTypeGroup());
PUT_CODE_HERE;
g->widget = gtk_frame_new(text);
g->container = GTK_CONTAINER(g->widget);
g->frame = GTK_FRAME(g->widget);
uiUnixMakeSingleWidgetControl(uiControl(g), g->widget);
// with GTK+, groupboxes by default have frames and slightly x-offset regular text
// they should have no frame and fully left-justified, bold text
// preserve default y-alignment
gtk_frame_get_label_align(g->frame, NULL, &yalign);
gtk_frame_set_label_align(g->frame, 0, yalign);
gtk_frame_set_shadow_type(g->frame, GTK_SHADOW_NONE);
label = GTK_LABEL(gtk_frame_get_label_widget(g->frame));
// this is the boldness level used by GtkPrintUnixDialog
// (it technically uses "bold" but see pango's pango-enum-types.c for the name conversion; GType is weird)
bold = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
boldlist = pango_attr_list_new();
pango_attr_list_insert(boldlist, bold);
gtk_label_set_attributes(label, boldlist);
pango_attr_list_unref(boldlist); // thanks baedert in irc.gimp.net/#gtk+
uiControl(g)->Handle = groupHandle;
uiControl(g)->ContainerUpdateState = groupContainerUpdateState;

View File

@ -3,7 +3,10 @@
struct tab {
uiTab t;
GtkWidget *widget;
GtkContainer *container;
GtkNotebook *notebook;
};
uiDefineControlType(uiTab, uiTypeTab, struct tab)
@ -63,7 +66,12 @@ uiTab *uiNewTab(void)
t = (struct tab *) uiNewControl(uiTypeTab());
PUT_CODE_HERE;
t->widget = gtk_notebook_new();
t->container = GTK_CONTAINER(t->widget);
t->notebook = GTK_NOTEBOOK(t->widget);
uiUnixMakeSingleWidgetControl(uiControl(t), t->widget);
gtk_notebook_set_scrollable(t->notebook, TRUE);
uiControl(t)->Handle = tabHandle;

View File

@ -56,14 +56,6 @@ uiButton *uiNewButton(const char *text)
b = uiNew(struct button);
uiUnixMakeControl(uiControl(b), GTK_TYPE_BUTTON,
FALSE, FALSE, onDestroy, b,
"label", text,
NULL);
b->widget = GTK_WIDGET(uiControlHandle(uiControl(b)));
b->button = GTK_BUTTON(b->widget);
g_signal_connect(b->widget, "clicked", G_CALLBACK(onClicked), b);
b->onClicked = defaultOnClicked;

View File

@ -135,17 +135,8 @@ uiTab *uiNewTab(void)
t = uiNew(struct tab);
uiUnixMakeControl(uiControl(t), GTK_TYPE_NOTEBOOK,
FALSE, FALSE, onDestroy, t,
"scrollable", TRUE,
NULL);
t->pages = g_array_new(FALSE, TRUE, sizeof (struct tabPage));
t->widget = GTK_WIDGET(uiControlHandle(uiControl(t)));
t->container = GTK_CONTAINER(t->widget);
t->notebook = GTK_NOTEBOOK(t->widget);
uiControl(t)->Show = tabShow;
uiTab(t)->AppendPage = tabAppendPage;