From 12751e3fc02e45da1198b82dadf83fe861ebfd1e Mon Sep 17 00:00:00 2001 From: drouin Date: Wed, 1 Sep 2004 15:54:51 +0000 Subject: replaced the gtk mainloop with a glib one. added -Wall compile directive . fixed some warnings --- examples/Makefile | 11 ++++++----- examples/gtkIvyButton.c | 38 +++++++++++++++++++------------------- examples/motifButtonIvy.c | 1 + 3 files changed, 26 insertions(+), 24 deletions(-) (limited to 'examples') diff --git a/examples/Makefile b/examples/Makefile index 659c8a0..d119c1e 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,18 +1,19 @@ .SUFFIXES: .c .o - CC = gcc -g + CC = gcc -g -Wall TARGETS = motifButtonIvy gtkIvyButton testUnbind SRCS = motifButtonIvy.c gtkIvyButton.c testUnbind.c OBJS = $(SRCS:.c=.o) PCRELIB = `pcre-config --libs` EXTRALIB= -L../src +EXTRAINC=-I../src GTKLIB = `pkg-config gtk+-x11-2.0 --libs` GTKINC = `pkg-config gtk+-x11-2.0 --cflags` MOTIFINC= MOTIFLIB= -L/usr/X11R6/lib -lXm -lXt -lX11 #MOTIFINC= -I/sw/include #MOTIFLIB= -L/sw/lib -L/usr/X11R6/lib -lXm -lXt -lX11 - + all: $(TARGETS) @@ -20,10 +21,10 @@ testUnbind: testUnbind.o $(CC) -o $@ $< -livy $(PCRELIB) $(EXTRALIB) gtkIvyButton.o: gtkIvyButton.c - $(CC) -c $< $(GTKINC) + $(CC) -c $< $(GTKINC) $(EXTRAINC) gtkIvyButton: gtkIvyButton.o - $(CC) -o $@ $< $(GTKLIB) -lgivy $(EXTRALIB) + $(CC) -o $@ $< $(GTKLIB) $(EXTRALIB) $(PCRELIB) -lglibivy motifButtonIvy.o: motifButtonIvy.c $(CC) -c $< $(MOTIFINC) $(EXTRALIB) @@ -32,4 +33,4 @@ motifButtonIvy: motifButtonIvy.o $(CC) -o $@ $< $(MOTIFLIB) -lxtivy -lpcre $(EXTRALIB) clean: - rm -fR $(OBJS) $(TARGETS) + rm -fR $(OBJS) $(TARGETS) *~ diff --git a/examples/gtkIvyButton.c b/examples/gtkIvyButton.c index be8cc4a..aba5ea7 100644 --- a/examples/gtkIvyButton.c +++ b/examples/gtkIvyButton.c @@ -1,34 +1,34 @@ #include #include -#include +#include #include #include -void hello( GtkWidget *widget, gpointer data ) { - fprintf(stderr,"%s\n",*((char**)data)); - IvySendMsg(*((char**)data)); + + + +void sendText( GtkWidget *widget, gpointer user_data ) { + IvySendMsg(gtk_label_get_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(widget))))); } -void textCallback(IvyClientPtr app, void *user_data, int argc, char *argv[]){ - *((char **)user_data)=argv[0]; +void setText(IvyClientPtr app, void *user_data, int argc, char *argv[]){ + gtk_label_set_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(user_data))), argv[0]); } int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *button; char *bus=getenv("IVYBUS"); - char *tosend="foo"; - gtk_init (&argc, &argv); - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - button = gtk_button_new_with_label ("send message"); - g_signal_connect (G_OBJECT(button),"clicked",G_CALLBACK(hello),&tosend); - gtk_container_add (GTK_CONTAINER(window),button); - gtk_widget_show (button); - gtk_widget_show (window); - IvyInit ("IvyGtkButton", "IvyGtkButton READY",NULL,NULL,NULL,NULL); - IvyBindMsg(textCallback,&tosend,"^Ivy Button text=(.*)"); - IvyStart (bus); - gtk_main (); + gtk_init(&argc, &argv); + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_container_set_border_width(GTK_CONTAINER (window), 10); + button = gtk_button_new_with_label("ivy is cool"); + gtk_container_add (GTK_CONTAINER(window), button); + g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(sendText), NULL); + gtk_widget_show_all (window); + IvyInit ("IvyGtkButton", "IvyGtkButton READY", NULL, NULL, NULL, NULL); + IvyBindMsg(setText, button, "^Ivy Button text=(.*)"); + IvyStart(bus); + gtk_main(); return 0; } diff --git a/examples/motifButtonIvy.c b/examples/motifButtonIvy.c index f4336aa..084359f 100644 --- a/examples/motifButtonIvy.c +++ b/examples/motifButtonIvy.c @@ -34,4 +34,5 @@ int main(int argc,char *argv[]){ IvyBindMsg(textCallback,&tosend,"^Ivy Button text=(.*)"); IvyStart(bus); XtAppMainLoop(app_context); + return 0; } -- cgit v1.1