From da520af372ac0bf0a0b90c8b12bbf9b6ca6773ab Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 27 Jun 2015 19:46:11 -0400 Subject: [PATCH] More GTK+ control stubbing. --- redo/unix/checkbox.c | 9 ++++++++- redo/unix/entry.c | 7 ++++++- redo/unix/label.c | 9 ++++++++- redo/unix/progressbar.c | 5 ++++- redo/unix/slider.c | 10 +++++++++- redo/unix/spinbox.c | 11 ++++++++++- unix/checkbox.c | 10 ---------- unix/entry.c | 8 -------- unix/label.c | 7 ------- 9 files changed, 45 insertions(+), 31 deletions(-) diff --git a/redo/unix/checkbox.c b/redo/unix/checkbox.c index d4f9a5d4..92b4b375 100644 --- a/redo/unix/checkbox.c +++ b/redo/unix/checkbox.c @@ -4,6 +4,9 @@ struct checkbox { uiCheckbox c; GtkWidget *widget; + GtkButton *button; + GtkToggleButton *toggleButton; + GtkCheckButton *checkButton; void (*onToggled)(uiCheckbox *, void *); void *onToggledData; }; @@ -66,7 +69,11 @@ uiCheckbox *uiNewCheckbox(const char *text) c = (struct checkbox *) uiNewControl(uiTypeCheckbox()); - PUT_CODE_HERE; + c->widget = gtk_check_button_new_with_label(text); + c->button = GTK_BUTTON(c->widget); + c->toggleButton = GTK_TOGGLE_BUTTON(c->widget); + c->checkButton = GTK_CHECK_BUTTON(c->widget); + uiUnixMakeSingleWidgetControl(uiControl(c), c->widget); c->onToggled = defaultOnToggled; diff --git a/redo/unix/entry.c b/redo/unix/entry.c index d7a7d4ba..0b851ce8 100644 --- a/redo/unix/entry.c +++ b/redo/unix/entry.c @@ -4,6 +4,8 @@ struct entry { uiEntry e; GtkWidget *widget; + GtkEntry *entry; + GtkEditable *editable; void (*onChanged)(uiEntry *, void *); void *onChangedData; }; @@ -65,7 +67,10 @@ uiEntry *uiNewEntry(void) e = (struct entry *) uiNewControl(uiTypeEntry()); - PUT_CODE_HERE; + e->widget = gtk_entry_new(); + e->entry = GTK_ENTRY(e->widget); + e->editable = GTK_EDITABLE(e->widget); + uiUnixMakeSingleWidgetControl(uiControl(e), e->widget); e->onChanged = defaultOnChanged; diff --git a/redo/unix/label.c b/redo/unix/label.c index 79c3acfc..1111d681 100644 --- a/redo/unix/label.c +++ b/redo/unix/label.c @@ -4,6 +4,8 @@ struct label { uiLabel l; GtkWidget *widget; + GtkMisc *misc; + GtkLabel *label; }; uiDefineControlType(uiLabel, uiTypeLabel, struct label) @@ -37,7 +39,12 @@ uiLabel *uiNewLabel(const char *text) l = (struct label *) uiNewControl(uiTypeLabel()); - PUT_CODE_HERE; + l->widget = gtk_label_new(text); + l->misc = GTK_MISC(l->widget); + l->label = GTK_LABEL(l->widget); + uiUnixMakeSingleWidgetControl(uiControl(l), l->widget); + + gtk_misc_set_alignment(l->misc, 0, 0); uiControl(l)->Handle = labelHandle; diff --git a/redo/unix/progressbar.c b/redo/unix/progressbar.c index 42a444ee..d6ce1599 100644 --- a/redo/unix/progressbar.c +++ b/redo/unix/progressbar.c @@ -4,6 +4,7 @@ struct progressbar { uiProgressBar p; GtkWidget *widget; + GtkProgressBar *pbar; }; uiDefineControlType(uiProgressBar, uiTypeProgressBar, struct progressbar) @@ -30,7 +31,9 @@ uiProgressBar *uiNewProgressBar(void) p = (struct progressbar *) uiNewControl(uiTypeProgressBar()); - PUT_CODE_HERE; + p->widget = gtk_progress_bar_new(); + p->pbar = GTK_PROGRESS_BAR(p->widget); + uiUnixMakeSingleWidgetControl(uiControl(p), p->widget); uiControl(p)->Handle = progressbarHandle; diff --git a/redo/unix/slider.c b/redo/unix/slider.c index 75dbf5f9..9a1b927d 100644 --- a/redo/unix/slider.c +++ b/redo/unix/slider.c @@ -4,6 +4,8 @@ struct slider { uiSlider s; GtkWidget *widget; + GtkRange *range; + GtkScale *scale; void (*onChanged)(uiSlider *, void *); void *onChangedData; }; @@ -50,7 +52,13 @@ uiSlider *uiNewSlider(intmax_t min, intmax_t max) s = (struct slider *) uiNewControl(uiTypeSlider()); - PUT_CODE_HERE; + s->widget = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, min, max, 1); + s->range = GTK_RANGE(s->widget); + s->scale = GTK_SCALE(s->widget); + uiUnixMakeSingleWidgetControl(uiControl(s), s->widget); + + // TODO needed? + gtk_scale_set_digits(s->scale, 0); s->onChanged = defaultOnChanged; diff --git a/redo/unix/spinbox.c b/redo/unix/spinbox.c index cbd120d6..078335e5 100644 --- a/redo/unix/spinbox.c +++ b/redo/unix/spinbox.c @@ -3,6 +3,9 @@ struct spinbox { uiSpinbox s; + GtkWidget *widget; + GtkEntry *entry; + GtkSpinButton *spinButton; void (*onChanged)(uiSpinbox *, void *); void *onChangedData; }; @@ -52,7 +55,13 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) s = (struct spinbox *) uiNewControl(uiTypeSpinbox()); - PUT_CODE_HERE; + s->widget = gtk_spin_button_new_with_range(min, max, 1); + s->entry = GTK_ENTRY(s->widget); + s->spinButton = GTK_SPIN_BUTTON(s->widget); + uiUnixMakeSingleWidgetControl(uiControl(s), s->widget); + + // TODO needed? + gtk_spin_button_set_digits(s->spinButton, 0); s->onChanged = defaultOnChanged; diff --git a/unix/checkbox.c b/unix/checkbox.c index 7ecfe16c..c9e13d1b 100644 --- a/unix/checkbox.c +++ b/unix/checkbox.c @@ -80,16 +80,6 @@ uiCheckbox *uiNewCheckbox(const char *text) c = uiNew(struct checkbox); - uiUnixMakeControl(uiControl(c), GTK_TYPE_CHECK_BUTTON, - FALSE, FALSE, onDestroy, c, - "label", text, - NULL); - - c->widget = GTK_WIDGET(uiControlHandle(uiControl(c))); - c->button = GTK_BUTTON(c->widget); - c->toggleButton = GTK_TOGGLE_BUTTON(c->widget); - c->checkButton = GTK_CHECK_BUTTON(c->widget); - c->onToggledSignal = g_signal_connect(c->widget, "toggled", G_CALLBACK(onToggled), c); c->onToggled = defaultOnToggled; diff --git a/unix/entry.c b/unix/entry.c index 86feb057..301fbc05 100644 --- a/unix/entry.c +++ b/unix/entry.c @@ -79,14 +79,6 @@ uiEntry *uiNewEntry(void) e = uiNew(struct entry); - uiUnixMakeControl(uiControl(e), GTK_TYPE_ENTRY, - FALSE, FALSE, onDestroy, e, - NULL); - - e->widget = GTK_WIDGET(uiControlHandle(uiControl(e))); - e->entry = GTK_ENTRY(e->widget); - e->editable = GTK_EDITABLE(e->widget); - e->onChangedSignal = g_signal_connect(e->widget, "changed", G_CALLBACK(onChanged), e); e->onChanged = defaultOnChanged; diff --git a/unix/label.c b/unix/label.c index 5e4859c0..e437da5e 100644 --- a/unix/label.c +++ b/unix/label.c @@ -34,13 +34,6 @@ uiLabel *uiNewLabel(const char *text) l = uiNew(struct label); - uiUnixMakeControl(uiControl(l), GTK_TYPE_LABEL, - FALSE, FALSE, onDestroy, l, - "label", text, - "xalign", 0.0, // note: must be a float constant, otherwise the ... will turn it into an int and we get segfaults on some platforms (thanks ebassi in irc.gimp.net/#gtk+) - "yalign", 0.0, - NULL); - l->widget = GTK_WIDGET(uiControlHandle(uiControl(l))); l->label = GTK_LABEL(l->widget);