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.
24 #include <vppinfra/mem.h>
30 GtkWidget *g_mainwindow; /* The main window */
32 /* Graphical object heirarchy
36 * [main (e.g. file) menubar]
41 GtkWidget *g_mainvbox;
42 GtkWidget *g_mainhbox;
44 gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
46 /* Allow window to be destroyed */
50 void destroy(GtkWidget *widget, gpointer data)
55 int main (int argc, char **argv)
66 clib_mem_init (0, ((uword)3<<30));
68 gtk_init(&argc, &argv);
70 homedir = getenv ("HOME");
74 sprintf(tmpbuf, "%s/.g2", homedir);
76 pw = getpwuid(geteuid());
78 sprintf(tmpbuf, "%s/.g2", pw->pw_dir);
84 g_mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
86 gtk_signal_connect (GTK_OBJECT(g_mainwindow), "delete_event",
87 GTK_SIGNAL_FUNC (delete_event), NULL);
89 gtk_signal_connect (GTK_OBJECT(g_mainwindow), "destroy",
90 GTK_SIGNAL_FUNC (destroy), NULL);
92 gtk_container_set_border_width(GTK_CONTAINER(g_mainwindow), 5);
94 g_mainvbox = gtk_vbox_new(FALSE, 0);
95 g_mainhbox = gtk_hbox_new(FALSE, 0);
102 point_selector_init();
107 * Now that we're ready to rock 'n roll, see if we've been asked to
108 * press a few buttons...
111 while (curarg < argc) {
112 if (!strncmp(argv[curarg], "--cpel-input", 4)) {
115 cpel_file = argv[curarg];
119 g_error("Missing filename after --cpel-input");
121 if (!strncmp(argv[curarg], "--clib-input", 4)) {
124 clib_file = argv[curarg];
128 g_error("Missing filename after --cpel-input");
131 if (!strncmp(argv[curarg], "--pointdefs", 3)) {
134 read_event_definitions(argv[curarg]);
138 g_error ("Missing filename after --pointdefs\n");
140 if (!strncmp(argv[curarg], "--event-log", 3)) {
143 event_file = argv[curarg];
147 g_error ("Missing filename after --event-log\n");
150 if (!strncmp(argv[curarg], "--ticks-per-us", 3)) {
154 ticks_per_ns = atof(argv[curarg]);
155 if (ticks_per_ns == 0.0) {
156 g_error("ticks-per-ns (%s) didn't convert properly\n",
159 ticks_per_ns_set = TRUE;
163 g_error ("Missing filename after --event-log\n");
167 "g2 [--pointdefs <filename>] [--event-log <filename>]\n");
168 fprintf(stderr, " [--ticks-per-us <value>]\n");
170 " [--cpel-input <filename>] [--clib-input <filename]>\n");
172 "%s\n%s\n", version_string, minor_v_string);
177 read_clib_file (clib_file);
179 } else if (cpel_file) {
180 read_cpel_file(cpel_file);
182 } else if (event_file) {
183 read_events(event_file);
187 set_window_title(title);
189 gtk_signal_connect (GTK_OBJECT (g_mainwindow), "key_press_event",
190 (GtkSignalFunc) view1_handle_key_press_event, NULL);
191 gtk_container_add(GTK_CONTAINER(g_mainvbox), g_mainhbox);
192 gtk_widget_show(g_mainhbox);
193 gtk_container_add(GTK_CONTAINER(g_mainwindow), g_mainvbox);
194 gtk_widget_show(g_mainvbox);
195 gtk_widget_show(g_mainwindow);