2 *------------------------------------------------------------------
3 * Copyright (c) 2005-2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
29 GtkWidget *g_mainwindow; /* The main window */
31 /* Graphical object heirarchy
35 * [main (e.g. file) menubar]
40 GtkWidget *g_mainvbox;
41 GtkWidget *g_mainhbox;
43 gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
45 /* Allow window to be destroyed */
49 void destroy(GtkWidget *widget, gpointer data)
54 int main (int argc, char **argv)
65 gtk_init(&argc, &argv);
67 homedir = getenv ("HOME");
71 sprintf(tmpbuf, "%s/.g2", homedir);
73 pw = getpwuid(geteuid());
75 sprintf(tmpbuf, "%s/.g2", pw->pw_dir);
81 g_mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
83 gtk_signal_connect (GTK_OBJECT(g_mainwindow), "delete_event",
84 GTK_SIGNAL_FUNC (delete_event), NULL);
86 gtk_signal_connect (GTK_OBJECT(g_mainwindow), "destroy",
87 GTK_SIGNAL_FUNC (destroy), NULL);
89 gtk_container_set_border_width(GTK_CONTAINER(g_mainwindow), 5);
91 g_mainvbox = gtk_vbox_new(FALSE, 0);
92 g_mainhbox = gtk_hbox_new(FALSE, 0);
99 point_selector_init();
104 * Now that we're ready to rock 'n roll, see if we've been asked to
105 * press a few buttons...
108 while (curarg < argc) {
109 if (!strncmp(argv[curarg], "--cpel-input", 4)) {
112 cpel_file = argv[curarg];
116 g_error("Missing filename after --cpel-input");
118 if (!strncmp(argv[curarg], "--clib-input", 4)) {
121 clib_file = argv[curarg];
125 g_error("Missing filename after --cpel-input");
128 if (!strncmp(argv[curarg], "--pointdefs", 3)) {
131 read_event_definitions(argv[curarg]);
135 g_error ("Missing filename after --pointdefs\n");
137 if (!strncmp(argv[curarg], "--event-log", 3)) {
140 event_file = argv[curarg];
144 g_error ("Missing filename after --event-log\n");
147 if (!strncmp(argv[curarg], "--ticks-per-us", 3)) {
151 ticks_per_ns = atof(argv[curarg]);
152 if (ticks_per_ns == 0.0) {
153 g_error("ticks-per-ns (%s) didn't convert properly\n",
156 ticks_per_ns_set = TRUE;
160 g_error ("Missing filename after --event-log\n");
164 "g2 [--pointdefs <filename>] [--event-log <filename>]\n");
165 fprintf(stderr, " [--ticks-per-us <value>]\n");
167 " [--cpel-input <filename>] [--clib-input <filename]>\n");
169 "%s\n%s\n", version_string, minor_v_string);
174 read_clib_file (clib_file);
176 } else if (cpel_file) {
177 read_cpel_file(cpel_file);
179 } else if (event_file) {
180 read_events(event_file);
184 set_window_title(title);
186 gtk_signal_connect (GTK_OBJECT (g_mainwindow), "key_press_event",
187 (GtkSignalFunc) view1_handle_key_press_event, NULL);
188 gtk_container_add(GTK_CONTAINER(g_mainvbox), g_mainhbox);
189 gtk_widget_show(g_mainhbox);
190 gtk_container_add(GTK_CONTAINER(g_mainwindow), g_mainvbox);
191 gtk_widget_show(g_mainvbox);
192 gtk_widget_show(g_mainwindow);