summaryrefslogtreecommitdiff
path: root/app/wlib/gtklib/button.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/wlib/gtklib/button.c')
-rw-r--r--app/wlib/gtklib/button.c903
1 files changed, 456 insertions, 447 deletions
diff --git a/app/wlib/gtklib/button.c b/app/wlib/gtklib/button.c
index 9a8ec77..7193b11 100644
--- a/app/wlib/gtklib/button.c
+++ b/app/wlib/gtklib/button.c
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
@@ -53,17 +53,17 @@
void wButtonSetBusy(wButton_p bb, int value)
{
- bb->recursion++;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bb->widget), value);
- bb->recursion--;
- bb->busy = value;
- if (!value) {
- if (bb->timer_id) {
- g_source_remove(bb->timer_id);
- bb->timer_id = 0;
- }
- bb->timer_state = -1;
- }
+ bb->recursion++;
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bb->widget), value);
+ bb->recursion--;
+ bb->busy = value;
+ if (!value) {
+ if (bb->timer_id) {
+ g_source_remove(bb->timer_id);
+ bb->timer_id = 0;
+ }
+ bb->timer_state = -1;
+ }
}
/**
@@ -77,57 +77,58 @@ void wButtonSetBusy(wButton_p bb, int value)
*/
void wlibSetLabel(
- GtkWidget *widget,
- long option,
- const char * labelStr,
- GtkLabel * * labelG,
- GtkWidget * * imageG)
+ GtkWidget *widget,
+ long option,
+ const char * labelStr,
+ GtkLabel * * labelG,
+ GtkWidget * * imageG)
{
- wIcon_p bm;
- GdkBitmap * mask;
-
- if (widget == 0) {
- abort();
- }
-
- if (labelStr) {
- if (option&BO_ICON) {
- GdkPixbuf *pixbuf;
-
- bm = (wIcon_p)labelStr;
-
- if (bm->gtkIconType == gtkIcon_pixmap) {
- pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)bm->bits);
- } else {
- pixbuf = wlibPixbufFromXBM( bm );
- }
- double scaleicon;
- wPrefGetFloat(PREFSECTION, LARGEICON, &scaleicon, 1.0);
- if (scaleicon<1.0) scaleicon=1.0;
- if (scaleicon>2.0) scaleicon=2.0;
- GdkPixbuf *pixbuf2 =
- gdk_pixbuf_scale_simple(pixbuf, gdk_pixbuf_get_width(pixbuf)*scaleicon, gdk_pixbuf_get_height(pixbuf)*scaleicon, GDK_INTERP_BILINEAR);
- g_object_ref_sink(pixbuf);
- g_object_unref((gpointer)pixbuf);
- if (*imageG==NULL) {
- *imageG = gtk_image_new_from_pixbuf(pixbuf2);
- gtk_container_add(GTK_CONTAINER(widget), *imageG);
- gtk_widget_show(*imageG);
- } else {
- gtk_image_set_from_pixbuf(GTK_IMAGE(*imageG), pixbuf2);
- }
- g_object_ref_sink(pixbuf2);
- g_object_unref((gpointer)pixbuf2);
- } else {
- if (*labelG==NULL) {
- *labelG = (GtkLabel*)gtk_label_new(wlibConvertInput(labelStr));
- gtk_container_add(GTK_CONTAINER(widget), (GtkWidget*)*labelG);
- gtk_widget_show((GtkWidget*)*labelG);
- } else {
- gtk_label_set_text(*labelG, wlibConvertInput(labelStr));
- }
- }
- }
+ wIcon_p bm;
+// GdkBitmap * mask;
+
+ if (widget == 0) {
+ abort();
+ }
+
+ if (labelStr) {
+ if (option&BO_ICON) {
+ GdkPixbuf *pixbuf;
+
+ bm = (wIcon_p)labelStr;
+
+ if (bm->gtkIconType == gtkIcon_pixmap) {
+ pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)bm->bits);
+ } else {
+ pixbuf = wlibPixbufFromXBM( bm );
+ }
+ double scaleicon;
+ wPrefGetFloat(PREFSECTION, LARGEICON, &scaleicon, 1.0);
+ if (scaleicon<1.0) { scaleicon=1.0; }
+ if (scaleicon>2.0) { scaleicon=2.0; }
+ GdkPixbuf *pixbuf2 =
+ gdk_pixbuf_scale_simple(pixbuf, gdk_pixbuf_get_width(pixbuf)*scaleicon,
+ gdk_pixbuf_get_height(pixbuf)*scaleicon, GDK_INTERP_BILINEAR);
+ g_object_ref_sink(pixbuf);
+ g_object_unref((gpointer)pixbuf);
+ if (*imageG==NULL) {
+ *imageG = gtk_image_new_from_pixbuf(pixbuf2);
+ gtk_container_add(GTK_CONTAINER(widget), *imageG);
+ gtk_widget_show(*imageG);
+ } else {
+ gtk_image_set_from_pixbuf(GTK_IMAGE(*imageG), pixbuf2);
+ }
+ g_object_ref_sink(pixbuf2);
+ g_object_unref((gpointer)pixbuf2);
+ } else {
+ if (*labelG==NULL) {
+ *labelG = (GtkLabel*)gtk_label_new(wlibConvertInput(labelStr));
+ gtk_container_add(GTK_CONTAINER(widget), (GtkWidget*)*labelG);
+ gtk_widget_show((GtkWidget*)*labelG);
+ } else {
+ gtk_label_set_text(*labelG, wlibConvertInput(labelStr));
+ }
+ }
+ }
}
/**
@@ -138,7 +139,7 @@ void wlibSetLabel(
void wButtonSetLabel(wButton_p bb, const char * labelStr)
{
- wlibSetLabel(bb->widget, bb->option, labelStr, &bb->labelG, &bb->imageG);
+ wlibSetLabel(bb->widget, bb->option, labelStr, &bb->labelG, &bb->imageG);
}
/**
@@ -148,11 +149,11 @@ void wButtonSetLabel(wButton_p bb, const char * labelStr)
*/
void wlibButtonDoAction(
- wButton_p bb)
+ wButton_p bb)
{
- if (bb->action) {
- bb->action(bb->data);
- }
+ if (bb->action) {
+ bb->action(bb->data);
+ }
}
@@ -163,23 +164,23 @@ void wlibButtonDoAction(
*/
static void pushButt(
- GtkWidget *widget,
- gpointer value)
+ GtkWidget *widget,
+ gpointer value)
{
- wButton_p b = (wButton_p)value;
+ wButton_p b = (wButton_p)value;
- if (debugWindow >= 2) {
- printf("%s button pushed\n", b->labelStr?b->labelStr:"No label");
- }
+ if (debugWindow >= 2) {
+ printf("%s button pushed\n", b->labelStr?b->labelStr:"No label");
+ }
- if (b->recursion) {
- return;
- }
+ if (b->recursion) {
+ return;
+ }
- wlibStringUpdate();
- if (b->action) {
- b->action(b->data);
- }
+ wlibStringUpdate();
+ if (b->action) {
+ b->action(b->data);
+ }
}
@@ -192,52 +193,55 @@ static void pushButt(
static int timer_func ( void * data)
{
wButton_p bb = (wButton_p)data;
- if (bb->timer_id == 0) {
- bb->timer_state = -1;
- return FALSE;
- }
- /* Autorepeat state machine */
- switch (bb->timer_state) {
- case 0: /* Enable slow auto-repeat */
- g_source_remove(bb->timer_id);
- bb->timer_id = 0;
- bb->timer_state = 1;
- bb->timer_id = g_timeout_add( REPEAT_STAGE1_DELAY, timer_func, bb);
- bb->timer_count = 0;
- break;
- case 1: /* Check if it's time for fast repeat yet */
- if (bb->timer_count++ > 10)
- bb->timer_state = 2;
- break;
- case 2: /* Start fast auto-repeat */
- g_source_remove(bb->timer_id);
- bb->timer_id = 0;
- bb->timer_state = 3;
- bb->timer_id = g_timeout_add( REPEAT_STAGE2_DELAY, timer_func, bb);
- break;
- case 3:
- break;
- default:
- g_source_remove(bb->timer_id);
- bb->timer_id = 0;
- bb->timer_state = -1;
- return FALSE;
- break;
- }
-
- pushButt(NULL,bb);
-
- return TRUE;
+ if (bb->timer_id == 0) {
+ bb->timer_state = -1;
+ return FALSE;
+ }
+ /* Autorepeat state machine */
+ switch (bb->timer_state) {
+ case 0: /* Enable slow auto-repeat */
+ g_source_remove(bb->timer_id);
+ bb->timer_id = 0;
+ bb->timer_state = 1;
+ bb->timer_id = g_timeout_add( REPEAT_STAGE1_DELAY, timer_func, bb);
+ bb->timer_count = 0;
+ break;
+ case 1: /* Check if it's time for fast repeat yet */
+ if (bb->timer_count++ > 10) {
+ bb->timer_state = 2;
+ }
+ break;
+ case 2: /* Start fast auto-repeat */
+ g_source_remove(bb->timer_id);
+ bb->timer_id = 0;
+ bb->timer_state = 3;
+ bb->timer_id = g_timeout_add( REPEAT_STAGE2_DELAY, timer_func, bb);
+ break;
+ case 3:
+ break;
+ default:
+ g_source_remove(bb->timer_id);
+ bb->timer_id = 0;
+ bb->timer_state = -1;
+ return FALSE;
+ break;
+ }
+
+ pushButt(NULL,bb);
+
+ return TRUE;
}
static gint pressButt(
- GtkWidget *widget,
- GdkEventButton *event,
- wButton_p bb) {
+ GtkWidget *widget,
+ GdkEventButton *event,
+ wButton_p bb)
+{
- if ( debugWindow >= 1 )
+ if ( debugWindow >= 1 ) {
printf( "buttonPress: %s\n", bb->labelStr );
+ }
if (bb->recursion) {
return TRUE;
@@ -246,20 +250,22 @@ static gint pressButt(
if (bb->option & BO_REPEAT) {
/* Remove an existing timer */
- if (bb->timer_id)
- g_source_remove(bb->timer_id);
+ if (bb->timer_id) {
+ g_source_remove(bb->timer_id);
+ }
- /* Setup a timer */
- bb->timer_id = g_timeout_add( REPEAT_STAGE0_DELAY, timer_func, bb);
- bb->timer_state = 0;
+ /* Setup a timer */
+ bb->timer_id = g_timeout_add( REPEAT_STAGE0_DELAY, timer_func, bb);
+ bb->timer_state = 0;
}
if (!bb->busy) {
bb->recursion++;
int sensitive = gtk_widget_get_sensitive (GTK_WIDGET(bb->widget));
- if (sensitive)
+ if (sensitive) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bb->widget), TRUE);
+ }
bb->recursion--;
}
@@ -269,16 +275,18 @@ static gint pressButt(
}
static gint releaseButt(
- GtkWidget *widget,
- GdkEventButton *event,
- wButton_p bb) {
+ GtkWidget *widget,
+ GdkEventButton *event,
+ wButton_p bb)
+{
- if ( debugWindow >= 1 )
+ if ( debugWindow >= 1 ) {
printf( "buttonRelease: %s\n", bb->labelStr );
+ }
/* Remove any existing timer */
if (bb->timer_id) {
- g_source_remove(bb->timer_id);
- bb->timer_id = 0;
+ g_source_remove(bb->timer_id);
+ bb->timer_id = 0;
}
bb->timer_state = -1;
@@ -298,9 +306,9 @@ static gint releaseButt(
* Called after expose event default hander - allows the button to be outlined
*/
static wBool_t exposeButt(
- GtkWidget *widget,
- GdkEventExpose *event,
- gpointer g)
+ GtkWidget *widget,
+ GdkEventExpose *event,
+ gpointer g)
{
wControl_p b = (wControl_p)g;
return wControlExpose(widget,event,b);
@@ -322,61 +330,62 @@ static wBool_t exposeButt(
*/
wButton_p wButtonCreate(
- wWin_p parent,
- wWinPix_t x,
- wWinPix_t y,
- const char * helpStr,
- const char * labelStr,
- long option,
- wWinPix_t width,
- wButtonCallBack_p action,
- void * data)
+ wWin_p parent,
+ wWinPix_t x,
+ wWinPix_t y,
+ const char * helpStr,
+ const char * labelStr,
+ long option,
+ wWinPix_t width,
+ wButtonCallBack_p action,
+ void * data)
{
- wButton_p b;
- if (option&BO_ICON) //The labelStr here is a wIcon_p
- b = wlibAlloc(parent, B_BUTTON, x, y, " ", sizeof *b, data);
- else
- b = wlibAlloc(parent, B_BUTTON, x, y, labelStr, sizeof *b, data);
- b->option = option;
- b->action = action;
- wlibComputePos((wControl_p)b);
-
- b->widget = gtk_toggle_button_new();
- g_signal_connect(GTK_OBJECT(b->widget), "button_press_event",
- G_CALLBACK(pressButt), b);
- g_signal_connect(GTK_OBJECT(b->widget), "button_release_event",
- G_CALLBACK(releaseButt), b);
- //g_signal_connect(GTK_OBJECT(b->widget), "clicked",
- // G_CALLBACK(pushButt), b);
- g_signal_connect_after(GTK_OBJECT(b->widget), "expose-event",
- G_CALLBACK(exposeButt), b);
- if (width > 0) {
- gtk_widget_set_size_request(b->widget, width, -1);
- }
-
- if( labelStr ){
- wButtonSetLabel(b, labelStr);
- }
-
- gtk_fixed_put(GTK_FIXED(parent->widget), b->widget, b->realX, b->realY);
-
- if (option & BB_DEFAULT) {
- gtk_widget_set_can_default(b->widget, GTK_CAN_DEFAULT);
- gtk_widget_grab_default(b->widget);
- gtk_window_set_default(GTK_WINDOW(parent->gtkwin), b->widget);
- }
-
- wlibControlGetSize((wControl_p)b);
-
- if (width == 0 && b->w < MIN_BUTTON_WIDTH && (b->option&BO_ICON)==0) {
- b->w = MIN_BUTTON_WIDTH;
- gtk_widget_set_size_request(b->widget, b->w, b->h);
- }
-
- gtk_widget_show(b->widget);
- wlibAddButton((wControl_p)b);
- wlibAddHelpString(b->widget, helpStr);
- return b;
+ wButton_p b;
+ if (option&BO_ICON) { //The labelStr here is a wIcon_p
+ b = wlibAlloc(parent, B_BUTTON, x, y, " ", sizeof *b, data);
+ } else {
+ b = wlibAlloc(parent, B_BUTTON, x, y, labelStr, sizeof *b, data);
+ }
+ b->option = option;
+ b->action = action;
+ wlibComputePos((wControl_p)b);
+
+ b->widget = gtk_toggle_button_new();
+ g_signal_connect(GTK_OBJECT(b->widget), "button_press_event",
+ G_CALLBACK(pressButt), b);
+ g_signal_connect(GTK_OBJECT(b->widget), "button_release_event",
+ G_CALLBACK(releaseButt), b);
+ //g_signal_connect(GTK_OBJECT(b->widget), "clicked",
+ // G_CALLBACK(pushButt), b);
+ g_signal_connect_after(GTK_OBJECT(b->widget), "expose-event",
+ G_CALLBACK(exposeButt), b);
+ if (width > 0) {
+ gtk_widget_set_size_request(b->widget, width, -1);
+ }
+
+ if( labelStr ) {
+ wButtonSetLabel(b, labelStr);
+ }
+
+ gtk_fixed_put(GTK_FIXED(parent->widget), b->widget, b->realX, b->realY);
+
+ if (option & BB_DEFAULT) {
+ gtk_widget_set_can_default(b->widget, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default(b->widget);
+ gtk_window_set_default(GTK_WINDOW(parent->gtkwin), b->widget);
+ }
+
+ wlibControlGetSize((wControl_p)b);
+
+ if (width == 0 && b->w < MIN_BUTTON_WIDTH && (b->option&BO_ICON)==0) {
+ b->w = MIN_BUTTON_WIDTH;
+ gtk_widget_set_size_request(b->widget, b->w, b->h);
+ }
+
+ gtk_widget_show(b->widget);
+ wlibAddButton((wControl_p)b);
+ wlibAddHelpString(b->widget, helpStr);
+ return b;
}
@@ -389,10 +398,10 @@ wButton_p wButtonCreate(
*/
struct wChoice_t {
- WOBJ_COMMON
- long *valueP;
- wChoiceCallBack_p action;
- int recursion;
+ WOBJ_COMMON
+ long *valueP;
+ wChoiceCallBack_p action;
+ int recursion;
};
@@ -407,33 +416,33 @@ struct wChoice_t {
*/
static long choiceGetValue(
- wChoice_p bc)
+ wChoice_p bc)
{
- GList * child, * children;
- long value, inx;
-
- if (bc->type == B_TOGGLE) {
- value = 0;
- } else {
- value = -1;
- }
-
- for (children=child=gtk_container_get_children(GTK_CONTAINER(bc->widget)),inx=0;
- child; child=child->next,inx++) {
- if (gtk_toggle_button_get_active(child->data)) {
- if (bc->type == B_TOGGLE) {
- value |= (1<<inx);
- } else {
- value = inx;
- }
- }
- }
-
- if (children) {
- g_list_free(children);
- }
-
- return value;
+ GList * child, * children;
+ long value, inx;
+
+ if (bc->type == B_TOGGLE) {
+ value = 0;
+ } else {
+ value = -1;
+ }
+
+ for (children=child=gtk_container_get_children(GTK_CONTAINER(bc->widget)),inx=0;
+ child; child=child->next,inx++) {
+ if (gtk_toggle_button_get_active(child->data)) {
+ if (bc->type == B_TOGGLE) {
+ value |= (1<<inx);
+ } else {
+ value = inx;
+ }
+ }
+ }
+
+ if (children) {
+ g_list_free(children);
+ }
+
+ return value;
}
/**
@@ -444,24 +453,24 @@ static long choiceGetValue(
*/
void wRadioSetValue(
- wChoice_p bc, /* Radio box */
- long value) /* Value */
+ wChoice_p bc, /* Radio box */
+ long value) /* Value */
{
- GList * child, * children;
- long inx;
-
- for (children=child=gtk_container_get_children(GTK_CONTAINER(bc->widget)),inx=0;
- child; child=child->next,inx++) {
- if (inx == value) {
- bc->recursion++;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(child->data), TRUE);
- bc->recursion--;
- }
- }
-
- if (children) {
- g_list_free(children);
- }
+ GList * child, * children;
+ long inx;
+
+ for (children=child=gtk_container_get_children(GTK_CONTAINER(bc->widget)),inx=0;
+ child; child=child->next,inx++) {
+ if (inx == value) {
+ bc->recursion++;
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(child->data), TRUE);
+ bc->recursion--;
+ }
+ }
+
+ if (children) {
+ g_list_free(children);
+ }
}
/**
@@ -472,9 +481,9 @@ void wRadioSetValue(
*/
long wRadioGetValue(
- wChoice_p bc) /* Radio box */
+ wChoice_p bc) /* Radio box */
{
- return choiceGetValue(bc);
+ return choiceGetValue(bc);
}
/**
@@ -485,24 +494,24 @@ long wRadioGetValue(
*/
void wToggleSetValue(
- wChoice_p bc, /* Toggle box */
- long value) /* Values */
+ wChoice_p bc, /* Toggle box */
+ long value) /* Values */
{
- GList * child, * children;
- long inx;
- bc->recursion++;
-
- for (children=child=gtk_container_get_children(GTK_CONTAINER(bc->widget)),inx=0;
- child; child=child->next,inx++) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(child->data),
- (value&(1<<inx))!=0);
- }
+ GList * child, * children;
+ long inx;
+ bc->recursion++;
+
+ for (children=child=gtk_container_get_children(GTK_CONTAINER(bc->widget)),inx=0;
+ child; child=child->next,inx++) {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(child->data),
+ (value&(1<<inx))!=0);
+ }
- if (children) {
- g_list_free(children);
- }
+ if (children) {
+ g_list_free(children);
+ }
- bc->recursion--;
+ bc->recursion--;
}
@@ -514,9 +523,9 @@ void wToggleSetValue(
*/
long wToggleGetValue(
- wChoice_p b) /* Toggle box */
+ wChoice_p b) /* Toggle box */
{
- return choiceGetValue(b);
+ return choiceGetValue(b);
}
/**
@@ -529,35 +538,35 @@ long wToggleGetValue(
*/
static int pushChoice(
- GtkWidget *widget,
- gpointer b)
+ GtkWidget *widget,
+ gpointer b)
{
- wChoice_p bc = (wChoice_p)b;
- long value = choiceGetValue(bc);
+ wChoice_p bc = (wChoice_p)b;
+ long value = choiceGetValue(bc);
- if (debugWindow >= 2) {
- printf("%s choice pushed = %ld\n", bc->labelStr?bc->labelStr:"No label",
- value);
- }
+ if (debugWindow >= 2) {
+ printf("%s choice pushed = %ld\n", bc->labelStr?bc->labelStr:"No label",
+ value);
+ }
- if (bc->type == B_RADIO &&
- !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))) {
- return 1;
- }
+ if (bc->type == B_RADIO &&
+ !(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))) {
+ return 1;
+ }
- if (bc->recursion) {
- return 1;
- }
+ if (bc->recursion) {
+ return 1;
+ }
- if (bc->valueP) {
- *bc->valueP = value;
- }
+ if (bc->valueP) {
+ *bc->valueP = value;
+ }
- if (bc->action) {
- bc->action(value, bc->data);
- }
+ if (bc->action) {
+ bc->action(value, bc->data);
+ }
- return 1;
+ return 1;
}
/**
@@ -568,13 +577,13 @@ static int pushChoice(
*/
static void choiceRepaint(
- wControl_p b)
+ wControl_p b)
{
- wChoice_p bc = (wChoice_p)b;
+ wChoice_p bc = (wChoice_p)b;
- if (gtk_widget_get_visible(b->widget)) {
- wlibDrawBox(bc->parent, wBoxBelow, bc->realX-1, bc->realY-1, bc->w+1, bc->h+1);
- }
+ if (gtk_widget_get_visible(b->widget)) {
+ wlibDrawBox(bc->parent, wBoxBelow, bc->realX-1, bc->realY-1, bc->w+1, bc->h+1);
+ }
}
/**
@@ -594,95 +603,95 @@ static void choiceRepaint(
*/
wChoice_p wRadioCreate(
- wWin_p parent,
- wWinPix_t x,
- wWinPix_t y,
- const char * helpStr,
- const char * labelStr,
- long option,
- const char * const *labels,
- long *valueP,
- wChoiceCallBack_p action,
- void *data)
+ wWin_p parent,
+ wWinPix_t x,
+ wWinPix_t y,
+ const char * helpStr,
+ const char * labelStr,
+ long option,
+ const char * const *labels,
+ long *valueP,
+ wChoiceCallBack_p action,
+ void *data)
{
- wChoice_p b;
- const char * const * label;
- GtkWidget *butt0=NULL, *butt;
-
- if ((option & BC_NOBORDER)==0) {
- if (x>=0) {
- x++;
- } else {
- x--;
- }
-
- if (y>=0) {
- y++;
- } else {
- y--;
- }
- }
-
- b = wlibAlloc(parent, B_RADIO, x, y, labelStr, sizeof *b, data);
- b->option = option;
- b->action = action;
- b->valueP = valueP;
- wlibComputePos((wControl_p)b);
-
- ((wControl_p)b)->outline = FALSE;
-
- if (option&BC_HORZ) {
- b->widget = gtk_hbox_new(FALSE, 0);
- } else {
- b->widget = gtk_vbox_new(FALSE, 0);
- }
-
- if (b->widget == 0) {
- abort();
- }
-
- for (label=labels; *label; label++) {
- butt = gtk_radio_button_new_with_label(
- butt0?gtk_radio_button_get_group(GTK_RADIO_BUTTON(butt0)):NULL, _(*label));
-
- if (butt0==NULL) {
- butt0 = butt;
- }
-
- gtk_box_pack_start(GTK_BOX(b->widget), butt, TRUE, TRUE, 0);
- gtk_widget_show(butt);
- g_signal_connect(GTK_OBJECT(butt), "toggled",
- G_CALLBACK(pushChoice), b);
- g_signal_connect_after(GTK_OBJECT(b->widget), "expose-event",
- G_CALLBACK(exposeButt), b);
- wlibAddHelpString(butt, helpStr);
- }
-
- if (option & BB_DEFAULT) {
- gtk_widget_set_can_default(b->widget, TRUE);
- gtk_widget_grab_default(b->widget);
- }
-
- if (valueP) {
- wRadioSetValue(b, *valueP);
- }
-
- if ((option & BC_NOBORDER)==0) {
- b->repaintProc = choiceRepaint;
- b->w += 2;
- b->h += 2;
- }
-
- gtk_fixed_put(GTK_FIXED(parent->widget), b->widget, b->realX, b->realY);
- wlibControlGetSize((wControl_p)b);
-
- if (labelStr) {
- b->labelW = wlibAddLabel((wControl_p)b, labelStr);
- }
-
- gtk_widget_show(b->widget);
- wlibAddButton((wControl_p)b);
- return b;
+ wChoice_p b;
+ const char * const * label;
+ GtkWidget *butt0=NULL, *butt;
+
+ if ((option & BC_NOBORDER)==0) {
+ if (x>=0) {
+ x++;
+ } else {
+ x--;
+ }
+
+ if (y>=0) {
+ y++;
+ } else {
+ y--;
+ }
+ }
+
+ b = wlibAlloc(parent, B_RADIO, x, y, labelStr, sizeof *b, data);
+ b->option = option;
+ b->action = action;
+ b->valueP = valueP;
+ wlibComputePos((wControl_p)b);
+
+ ((wControl_p)b)->outline = FALSE;
+
+ if (option&BC_HORZ) {
+ b->widget = gtk_hbox_new(FALSE, 0);
+ } else {
+ b->widget = gtk_vbox_new(FALSE, 0);
+ }
+
+ if (b->widget == 0) {
+ abort();
+ }
+
+ for (label=labels; *label; label++) {
+ butt = gtk_radio_button_new_with_label(
+ butt0?gtk_radio_button_get_group(GTK_RADIO_BUTTON(butt0)):NULL, _(*label));
+
+ if (butt0==NULL) {
+ butt0 = butt;
+ }
+
+ gtk_box_pack_start(GTK_BOX(b->widget), butt, TRUE, TRUE, 0);
+ gtk_widget_show(butt);
+ g_signal_connect(GTK_OBJECT(butt), "toggled",
+ G_CALLBACK(pushChoice), b);
+ g_signal_connect_after(GTK_OBJECT(b->widget), "expose-event",
+ G_CALLBACK(exposeButt), b);
+ wlibAddHelpString(butt, helpStr);
+ }
+
+ if (option & BB_DEFAULT) {
+ gtk_widget_set_can_default(b->widget, TRUE);
+ gtk_widget_grab_default(b->widget);
+ }
+
+ if (valueP) {
+ wRadioSetValue(b, *valueP);
+ }
+
+ if ((option & BC_NOBORDER)==0) {
+ b->repaintProc = choiceRepaint;
+ b->w += 2;
+ b->h += 2;
+ }
+
+ gtk_fixed_put(GTK_FIXED(parent->widget), b->widget, b->realX, b->realY);
+ wlibControlGetSize((wControl_p)b);
+
+ if (labelStr) {
+ b->labelW = wlibAddLabel((wControl_p)b, labelStr);
+ }
+
+ gtk_widget_show(b->widget);
+ wlibAddButton((wControl_p)b);
+ return b;
}
/**
@@ -702,82 +711,82 @@ wChoice_p wRadioCreate(
*/
wChoice_p wToggleCreate(
- wWin_p parent,
- wWinPix_t x,
- wWinPix_t y,
- const char * helpStr,
- const char * labelStr,
- long option,
- const char * const * labels,
- long *valueP,
- wChoiceCallBack_p action,
- void *data)
+ wWin_p parent,
+ wWinPix_t x,
+ wWinPix_t y,
+ const char * helpStr,
+ const char * labelStr,
+ long option,
+ const char * const * labels,
+ long *valueP,
+ wChoiceCallBack_p action,
+ void *data)
{
- wChoice_p b;
- const char * const * label;
-
- if ((option & BC_NOBORDER)==0) {
- if (x>=0) {
- x++;
- } else {
- x--;
- }
-
- if (y>=0) {
- y++;
- } else {
- y--;
- }
- }
-
- b = wlibAlloc(parent, B_TOGGLE, x, y, labelStr, sizeof *b, data);
- b->option = option;
- b->action = action;
- wlibComputePos((wControl_p)b);
-
- ((wControl_p)b)->outline = FALSE;
-
- if (option&BC_HORZ) {
- b->widget = gtk_hbox_new(FALSE, 0);
- } else {
- b->widget = gtk_vbox_new(FALSE, 0);
- }
-
- if (b->widget == 0) {
- abort();
- }
-
- for (label=labels; *label; label++) {
- GtkWidget *butt;
-
- butt = gtk_check_button_new_with_label(_(*label));
- gtk_box_pack_start(GTK_BOX(b->widget), butt, TRUE, TRUE, 0);
- gtk_widget_show(butt);
- g_signal_connect(GTK_OBJECT(butt), "toggled",
- G_CALLBACK(pushChoice), b);
- g_signal_connect_after(GTK_OBJECT(b->widget), "expose-event",
- G_CALLBACK(exposeButt), b);
- wlibAddHelpString(butt, helpStr);
- }
-
- if (valueP) {
- wToggleSetValue(b, *valueP);
- }
-
- if ((option & BC_NOBORDER)==0) {
- b->repaintProc = choiceRepaint;
- b->w += 2;
- b->h += 2;
- }
-
- gtk_fixed_put(GTK_FIXED(parent->widget), b->widget, b->realX, b->realY);
- wlibControlGetSize((wControl_p)b);
-
- if (labelStr) {
- b->labelW = wlibAddLabel((wControl_p)b, labelStr);
- }
-
- gtk_widget_show(b->widget);
- wlibAddButton((wControl_p)b);
- return b;
+ wChoice_p b;
+ const char * const * label;
+
+ if ((option & BC_NOBORDER)==0) {
+ if (x>=0) {
+ x++;
+ } else {
+ x--;
+ }
+
+ if (y>=0) {
+ y++;
+ } else {
+ y--;
+ }
+ }
+
+ b = wlibAlloc(parent, B_TOGGLE, x, y, labelStr, sizeof *b, data);
+ b->option = option;
+ b->action = action;
+ wlibComputePos((wControl_p)b);
+
+ ((wControl_p)b)->outline = FALSE;
+
+ if (option&BC_HORZ) {
+ b->widget = gtk_hbox_new(FALSE, 0);
+ } else {
+ b->widget = gtk_vbox_new(FALSE, 0);
+ }
+
+ if (b->widget == 0) {
+ abort();
+ }
+
+ for (label=labels; *label; label++) {
+ GtkWidget *butt;
+
+ butt = gtk_check_button_new_with_label(_(*label));
+ gtk_box_pack_start(GTK_BOX(b->widget), butt, TRUE, TRUE, 0);
+ gtk_widget_show(butt);
+ g_signal_connect(GTK_OBJECT(butt), "toggled",
+ G_CALLBACK(pushChoice), b);
+ g_signal_connect_after(GTK_OBJECT(b->widget), "expose-event",
+ G_CALLBACK(exposeButt), b);
+ wlibAddHelpString(butt, helpStr);
+ }
+
+ if (valueP) {
+ wToggleSetValue(b, *valueP);
+ }
+
+ if ((option & BC_NOBORDER)==0) {
+ b->repaintProc = choiceRepaint;
+ b->w += 2;
+ b->h += 2;
+ }
+
+ gtk_fixed_put(GTK_FIXED(parent->widget), b->widget, b->realX, b->realY);
+ wlibControlGetSize((wControl_p)b);
+
+ if (labelStr) {
+ b->labelW = wlibAddLabel((wControl_p)b, labelStr);
+ }
+
+ gtk_widget_show(b->widget);
+ wlibAddButton((wControl_p)b);
+ return b;
}