summaryrefslogtreecommitdiff
path: root/examples/motifButtonIvy.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/motifButtonIvy.c')
-rw-r--r--examples/motifButtonIvy.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/motifButtonIvy.c b/examples/motifButtonIvy.c
new file mode 100644
index 0000000..f4336aa
--- /dev/null
+++ b/examples/motifButtonIvy.c
@@ -0,0 +1,37 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <strings.h>
+#include <Xm/PushB.h>
+#include <ivy.h>
+#include <ivyxtloop.h>
+
+void myMotifCallback(Widget w,XtPointer client_d,XtPointer call_d){
+ // sends the string on the bus
+ IvySendMsg (*((char**)client_d));
+}
+
+void textCallback(IvyClientPtr app, void *user_data, int argc, char *argv[]){
+ printf("%s sent %s\n",IvyGetApplicationName(app),argv[0]);
+ // updates the string we want to send
+ *((char **)user_data)=argv[0];
+}
+
+void DieCallback (IvyClientPtr app, void *data, int id){ exit(0); }
+
+int main(int argc,char *argv[]){
+ Widget toplevel,pushb;
+ XtAppContext app_context;
+ Arg myargs[10];
+ char *bus=getenv("IVYBUS");
+ char *tosend="foo";
+ toplevel=XtAppInitialize(&app_context,"Ivy Button",NULL,0,&argc,argv,NULL,myargs,0);
+ pushb=XmCreatePushButton(toplevel,"send message",myargs,1);
+ XtManageChild(pushb);
+ XtAddCallback(pushb,XmNactivateCallback,myMotifCallback,&tosend);
+ XtRealizeWidget(toplevel);
+ IvyXtChannelAppContext(app_context);
+ IvyInit("IvyMotif","IvyMotif connected",NULL,NULL,DieCallback,NULL);
+ IvyBindMsg(textCallback,&tosend,"^Ivy Button text=(.*)");
+ IvyStart(bus);
+ XtAppMainLoop(app_context);
+}