1 /* $XConsortium: i18ninput.c /main/5 1995/07/15 20:45:37 drk $ */
2 /*
3 * Motif
4 *
5 * Copyright (c) 1987-2012, The Open Group. All rights reserved.
6 *
7 * These libraries and programs are free software; you can
8 * redistribute them and/or modify them under the terms of the GNU
9 * Lesser General Public License as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * These libraries and programs are distributed in the hope that
14 * they will be useful, but WITHOUT ANY WARRANTY; without even the
15 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU Lesser General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with these librararies and programs; if not, write
21 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
22 * Floor, Boston, MA 02110-1301 USA
23 */
24 /*
25 * HISTORY
26 */
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <ctype.h>
31 #include <string.h>
32
33 #include <X11/Xlib.h>
34 #include <X11/Intrinsic.h>
35 #include <Xm/Xm.h>
36
37 static XtAppContext app_context;
38
39 static String fallback_reslist[] = {
40 "*font.label.labelString: Select font",
41 "*font*button1.labelString: Small",
42 "*font*button1.renderTable: *medium*-r-*--14*:",
43 "*font*button2.labelString: Medium",
44 "*font*button2.renderTable: *medium*-r-*--18*:",
45 "*font*button3.labelString: Large",
46 "*font*button3.renderTable: *medium*-r-*--24*:",
47 "*color.label.labelString: Select color",
48 "*color*button1.labelString: Red",
49 "*color*button1.foreground: #fe5151",
50 "*color*button2.labelString: Green",
51 "*color*button2.foreground: #00be51",
52 "*color*button3.labelString: Blue",
53 "*color*button3.foreground: #2aa1fd",
54 "*XmText.renderTable: *medium*-r-*--18*:",
55 "*XmTextField.renderTable: *medium*-r-*--18*:",
56 NULL
57 };
58
59 extern int dialog_init(int *argc, char **argv, Display *dpy);
60
61 /****************************************************************
62 * base:
63 ****************************************************************/
base(char * str)64 static char *base(char *str)
65 {
66 static char basename[300];
67 char *p;
68
69 if ((p = strrchr(str, '/')))
70 (void) strcpy(basename, p+1);
71 else
72 (void) strcpy(basename, str);
73 if ((p = strrchr(basename, '.')))
74 *p ='\0';
75 return basename;
76 }
77
78
79 /**************************************************************
80 * main:
81 **************************************************************/
main(int argc,char ** argv)82 int main(int argc, char **argv)
83 {
84 Display * display;
85 char name[132];
86
87 (void) strncpy(name, base(argv[0]), 132);
88
89 /* Initialize the X Intrinsics */
90 XtToolkitInitialize();
91
92 /* Set up language environment for X */
93 XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL);
94
95 /* Create application context */
96 app_context = XtCreateApplicationContext();
97 XtAppSetFallbackResources(app_context, fallback_reslist);
98
99 /* open up one display */
100 display = XtOpenDisplay(app_context,
101 NULL,
102 name, "XmdI18nInput",
103 (XrmOptionDescRec *)NULL, 0,
104 &argc, argv);
105 if (!display) {
106 (void) fprintf(stderr, "Unable to open display\n");
107 exit(0);
108 }
109
110 /* Call init functions. This creates the user interface
111 (placed in input.c) */
112 if (dialog_init(&argc, argv, display) != 0)
113 exit(1);
114
115 XtAppMainLoop(app_context);
116
117 return 0; /* make compiler happy */
118 }
119
120