diff options
Diffstat (limited to 'src/tools/g2/menu1.c')
-rw-r--r-- | src/tools/g2/menu1.c | 124 |
1 files changed, 63 insertions, 61 deletions
diff --git a/src/tools/g2/menu1.c b/src/tools/g2/menu1.c index fce81fa66b2..ab06a6b9abd 100644 --- a/src/tools/g2/menu1.c +++ b/src/tools/g2/menu1.c @@ -1,4 +1,4 @@ -/* +/* *------------------------------------------------------------------ * Copyright (c) 2006-2016 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -118,7 +118,7 @@ static void get_dialog_value (GtkWidget *dialog, gpointer user_data) { md_t *md = (md_t *)user_data; char * cb_arg; - + cb_arg = (char *) gtk_entry_get_text(GTK_ENTRY(md->entry)); if ((*md->callback)(cb_arg)) { @@ -133,7 +133,7 @@ static void get_dialog_value (GtkWidget *dialog, gpointer user_data) * modal_dialog ****************************************************************************/ -void modal_dialog (char *label_text, char *retry_text, char *default_value, +void modal_dialog (char *label_text, char *retry_text, char *default_value, boolean (*cb)(char *)) { GtkWidget *dialog, *label, *ok_button, *entry; @@ -158,10 +158,10 @@ void modal_dialog (char *label_text, char *retry_text, char *default_value, else md->callback = debug_dialog_callback; - gtk_signal_connect (GTK_OBJECT (ok_button), "clicked", + gtk_signal_connect (GTK_OBJECT (ok_button), "clicked", GTK_SIGNAL_FUNC(get_dialog_value), (gpointer) md); - gtk_signal_connect (GTK_OBJECT (entry), "activate", + gtk_signal_connect (GTK_OBJECT (entry), "activate", GTK_SIGNAL_FUNC(get_dialog_value), (gpointer) md); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), @@ -193,26 +193,26 @@ static void get_eventdef_name (GtkFileSelection *sel, gpointer user_data) static void read_eventdef_callback(GtkToggleButton *item, gpointer data) { - + s_filesel = gtk_file_selection_new("Read Event Definitions From..."); - - gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), + + gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), "../h/elog.h"); gtk_signal_connect (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC(get_eventdef_name), NULL); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_filesel); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->cancel_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_filesel); gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_filesel)); @@ -261,21 +261,21 @@ static void read_events_callback(GtkToggleButton *item, gpointer data) char tmpbuf [32]; s_eventsel = gtk_file_selection_new("Read Events From..."); - + gtk_signal_connect (GTK_OBJECT ( GTK_FILE_SELECTION(s_eventsel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC(get_events_name), NULL); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_eventsel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_eventsel); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_eventsel)->cancel_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_eventsel); gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_eventsel)); @@ -283,7 +283,7 @@ static void read_events_callback(GtkToggleButton *item, gpointer data) if (ticks_per_ns_set) gtk_widget_show (s_eventsel); else { - sprintf(tmpbuf, "%.3f", ticks_per_ns); + snprintf(tmpbuf, sizeof(tmpbuf), "%.3f", ticks_per_ns); modal_dialog ("Please enter clock ticks per nanosecond", "Invalid: Please enter clock ticks per nanosecond", tmpbuf, get_ticks_per_ns); @@ -312,10 +312,10 @@ void infobox_size_request (GtkWidget *widget, GtkRequisition *req, int widest_line_in_chars; int w; int nlines; - + /* * You'd think that the string extent function would work here. - * You'd be wrong. + * You'd be wrong. */ nlines = w = widest_line_in_chars = 0; for (cp = text; *cp; cp++) { @@ -349,8 +349,8 @@ void infobox(char *label_text, char *text) entry = gtk_text_new(NULL, NULL); - gtk_signal_connect (GTK_OBJECT (entry), "size-request", - GTK_SIGNAL_FUNC(infobox_size_request), + gtk_signal_connect (GTK_OBJECT (entry), "size-request", + GTK_SIGNAL_FUNC(infobox_size_request), (gpointer) text); gtk_text_insert(GTK_TEXT(entry), g_font, &fg_black, &bg_white, @@ -360,8 +360,8 @@ void infobox(char *label_text, char *text) ok_button = gtk_button_new_with_label("OK"); - gtk_signal_connect_object (GTK_OBJECT (ok_button), "clicked", - GTK_SIGNAL_FUNC(gtk_widget_destroy), + gtk_signal_connect_object (GTK_OBJECT (ok_button), "clicked", + GTK_SIGNAL_FUNC(gtk_widget_destroy), (gpointer) GTK_OBJECT(dialog)); box = gtk_vbox_new(FALSE, 5); @@ -393,12 +393,14 @@ static void help_general_callback(GtkToggleButton *item, gpointer data) static void help_about_callback(GtkToggleButton *item, gpointer data) { char tmpbuf [1024]; - sprintf (tmpbuf, "G2 -- Graphical Event Viewer\n\n"); + snprintf (tmpbuf, sizeof(tmpbuf), "G2 -- Graphical Event Viewer\n\n"); view1_about(tmpbuf); pointsel_about(tmpbuf); events_about(tmpbuf); - sprintf (tmpbuf+strlen(tmpbuf), "\n%s\n", version_string); - sprintf (tmpbuf+strlen(tmpbuf), "%s\n", minor_v_string); + snprintf (tmpbuf+strlen(tmpbuf), sizeof(tmpbuf) - strlen(tmpbuf), + "\n%s\n", version_string); + snprintf (tmpbuf+strlen(tmpbuf), sizeof(tmpbuf) - strlen(tmpbuf), + "%s\n", minor_v_string); infobox("About", tmpbuf); } @@ -433,26 +435,26 @@ static void get_clib_name (GtkFileSelection *sel, gpointer user_data) static void read_cpel_callback(GtkToggleButton *item, gpointer data) { - + s_filesel = gtk_file_selection_new("Read CPEL data from..."); - - gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), + + gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), "cpel.out"); gtk_signal_connect (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC(get_cpel_name), NULL); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_filesel); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->cancel_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_filesel); gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_filesel)); @@ -465,26 +467,26 @@ static void read_cpel_callback(GtkToggleButton *item, gpointer data) static void read_clib_callback(GtkToggleButton *item, gpointer data) { - + s_filesel = gtk_file_selection_new("Read clib data From..."); - - gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), + + gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), "clib.out"); gtk_signal_connect (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC(get_clib_name), NULL); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_filesel); - + gtk_signal_connect_object (GTK_OBJECT ( GTK_FILE_SELECTION(s_filesel)->cancel_button), - "clicked", + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) s_filesel); gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_filesel)); @@ -500,42 +502,42 @@ void menu1_init(void) s_filemenu = gtk_menu_new(); - s_readcpel = gtk_menu_item_new_with_label + s_readcpel = gtk_menu_item_new_with_label ("Read CPEL file"); gtk_menu_append(GTK_MENU(s_filemenu), s_readcpel); - gtk_signal_connect(GTK_OBJECT(s_readcpel), "activate", + gtk_signal_connect(GTK_OBJECT(s_readcpel), "activate", GTK_SIGNAL_FUNC(read_cpel_callback), 0); - s_readclib = gtk_menu_item_new_with_label + s_readclib = gtk_menu_item_new_with_label ("Read CLIB file"); gtk_menu_append(GTK_MENU(s_filemenu), s_readclib); - gtk_signal_connect(GTK_OBJECT(s_readclib), "activate", + gtk_signal_connect(GTK_OBJECT(s_readclib), "activate", GTK_SIGNAL_FUNC(read_clib_callback), 0); - + s_readdefs = gtk_menu_item_new_with_label ("Read Event Definitions"); gtk_menu_append(GTK_MENU(s_filemenu), s_readdefs); - gtk_signal_connect(GTK_OBJECT(s_readdefs), "activate", + gtk_signal_connect(GTK_OBJECT(s_readdefs), "activate", GTK_SIGNAL_FUNC(read_eventdef_callback), 0); - + s_readevents = gtk_menu_item_new_with_label ("Read Event Log"); gtk_menu_append(GTK_MENU(s_filemenu), s_readevents); - gtk_signal_connect(GTK_OBJECT(s_readevents), "activate", + gtk_signal_connect(GTK_OBJECT(s_readevents), "activate", GTK_SIGNAL_FUNC(read_events_callback), 0); - - s_readeventsclock = gtk_menu_item_new_with_label + + s_readeventsclock = gtk_menu_item_new_with_label ("Read Event Log with Different Clock Rate"); gtk_menu_append(GTK_MENU(s_filemenu), s_readeventsclock); - gtk_signal_connect(GTK_OBJECT(s_readeventsclock), "activate", + gtk_signal_connect(GTK_OBJECT(s_readeventsclock), "activate", GTK_SIGNAL_FUNC(read_eventsclock_callback), 0); s_print = gtk_menu_item_new_with_label ("Print"); gtk_menu_append(GTK_MENU(s_filemenu), s_print); - gtk_signal_connect(GTK_OBJECT(s_print), "activate", + gtk_signal_connect(GTK_OBJECT(s_print), "activate", GTK_SIGNAL_FUNC(view1_print_callback), 0); - + s_quit = gtk_menu_item_new_with_label ("Exit"); gtk_menu_append(GTK_MENU(s_filemenu), s_quit); - gtk_signal_connect(GTK_OBJECT(s_quit), "activate", + gtk_signal_connect(GTK_OBJECT(s_quit), "activate", GTK_SIGNAL_FUNC(gtk_main_quit), 0); s_mainfilemenu = gtk_menu_item_new_with_label("File"); @@ -545,12 +547,12 @@ void menu1_init(void) s_help_general = gtk_menu_item_new_with_label ("General"); gtk_menu_append(GTK_MENU(s_helpmenu), s_help_general); - gtk_signal_connect(GTK_OBJECT(s_help_general), "activate", + gtk_signal_connect(GTK_OBJECT(s_help_general), "activate", GTK_SIGNAL_FUNC(help_general_callback), 0); s_help_about = gtk_menu_item_new_with_label ("About"); gtk_menu_append(GTK_MENU(s_helpmenu), s_help_about); - gtk_signal_connect(GTK_OBJECT(s_help_about), "activate", + gtk_signal_connect(GTK_OBJECT(s_help_about), "activate", GTK_SIGNAL_FUNC(help_about_callback), 0); s_mainhelpmenu = gtk_menu_item_new_with_label("Help"); |