From 39e397e27badd8e302e664d65ae74f09f5dda895 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 18 Oct 2012 16:27:57 +0200 Subject: [PATCH] Add optional callback to Label Options For some reason this does not work. The callback isn't called! --- dialogs.c | 4 ++-- xoptions.c | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dialogs.c b/dialogs.c index 93dce4a..2312c06 100644 --- a/dialogs.c +++ b/dialogs.c @@ -2060,8 +2060,8 @@ Option mainOptions[] = { // description of main window in terms of generic dialo { 0, 0, 0, NULL, (void*)&SizeKludge, "", NULL, BarEnd, "" }, { 0, LR|T2T|BORDER|SAME_ROW, 0, NULL, NULL, "", NULL, Label, "1" }, // optional title in window { 50, LL|TT, 100, NULL, (void*) &LogoW, NULL, NULL, -1, "LogoW" }, // white logo -{ 0, L2L|T2T, 200, NULL, (void*) &CCB, NULL, NULL, Label, "White" }, // white clock -{ 0, R2R|T2T|SAME_ROW, 200, NULL, (void*) &CCB, NULL, NULL, Label, "Black" }, // black clock +{ 12, L2L|T2T, 200, NULL, (void*) &CCB, NULL, NULL, Label, "White" }, // white clock +{ 13, R2R|T2T|SAME_ROW, 200, NULL, (void*) &CCB, NULL, NULL, Label, "Black" }, // black clock { 50, RR|TT|SAME_ROW, 100, NULL, (void*) &LogoB, NULL, NULL, -1, "LogoB" }, // black logo { 0, LR|T2T|BORDER, 401, NULL, NULL, "", NULL, -1, "2" }, // backup for title in window (if no room for other) { 0, LR|T2T|BORDER, 270, NULL, NULL, "", NULL, Label, "message" }, // message field diff --git a/xoptions.c b/xoptions.c index ee055f1..ae20ee1 100644 --- a/xoptions.c +++ b/xoptions.c @@ -525,6 +525,8 @@ MemoEvent(GtkWidget *widget, GdkEvent *event, gpointer gdata) gboolean res; gint index, x, y; + if(memo->type == Label) { ((ButtonCallback*) memo->target)(memo->value); return TRUE; } // only clock widgets use this + switch(event->type) { // figure out what's up case GDK_MOTION_NOTIFY: f = 0; @@ -1215,7 +1217,11 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent gtk_container_add(GTK_CONTAINER(frame), label); label = frame; } - Pack(hbox, table, label, left, left+3, top); + Pack(hbox, table, label, left, left+3, top); + if(option[i].target) { // allow user to specify event handler for button presses + gtk_widget_add_events(GTK_WIDGET(label), GDK_BUTTON_PRESS_MASK); + g_signal_connect(label, "button-press-event", G_CALLBACK(MemoEvent), (gpointer) &option[i]); + } break; case SaveButton: case Button: -- 1.7.0.4