From: <jmk...@us...> - 2003-11-25 06:29:27
|
Update of /cvsroot/emc/emc2/src/hal In directory sc8-pr-cvs1:/tmp/cvs-serv6142/src/hal Modified Files: Makefile halgtk.h probe.c Log Message: fixed a bug related to creation/destruction of a window in probe.c Index: Makefile =================================================================== RCS file: /cvsroot/emc/emc2/src/hal/Makefile,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Makefile 17 Nov 2003 02:46:10 -0000 1.9 --- Makefile 25 Nov 2003 04:49:01 -0000 1.10 *************** *** 14,18 **** PRIVHDRS = \ hal_priv.h \ ! halgtk.h SRCS = \ --- 14,19 ---- PRIVHDRS = \ hal_priv.h \ ! halgtk.h \ ! #halscope.h SRCS = \ *************** *** 20,27 **** halcmd.c \ halmeter.c \ ! probe.c RT_SRCS = \ ! hal_lib.c LIBS = \ --- 21,30 ---- halcmd.c \ halmeter.c \ ! probe.c \ ! #halscope.c RT_SRCS = \ ! hal_lib.c \ ! #halscope_rt.c LIBS = \ *************** *** 29,35 **** $(LIB_DIR)/hal_lib.o ifdef GTK_VERSION GTK_BINS = \ ! $(BIN_DIR)/halmeter endif --- 32,40 ---- $(LIB_DIR)/hal_lib.o + ifdef GTK_VERSION GTK_BINS = \ ! $(BIN_DIR)/halmeter \ ! #$(BIN_DIR)/halscope endif *************** *** 68,71 **** --- 73,81 ---- # rule to link halmeter $(BIN_DIR)/halmeter : $(TMP_DIR)/halmeter.o $(TMP_DIR)/probe.o $(LIB_DIR)/ulapi.o $(LIB_DIR)/hal_lib.o + @ echo "Linking $@" + $(CC) $(GTK_LIBS) $(CFLAGS) $(ULFLAGS) $^ -o $@ + + # rule to link halscope + $(BIN_DIR)/halscope : $(TMP_DIR)/halscope.o $(TMP_DIR)/probe.o $(LIB_DIR)/ulapi.o $(LIB_DIR)/hal_lib.o @ echo "Linking $@" $(CC) $(GTK_LIBS) $(CFLAGS) $(ULFLAGS) $^ -o $@ Index: halgtk.h =================================================================== RCS file: /cvsroot/emc/emc2/src/hal/halgtk.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** halgtk.h 17 Nov 2003 02:46:10 -0000 1.1 --- halgtk.h 25 Nov 2003 04:49:01 -0000 1.2 *************** *** 3,7 **** /** This file, 'halgtk.h', contains declarations for various code ! used by GTK based hal programs such as 'halmeter'. */ --- 3,7 ---- /** This file, 'halgtk.h', contains declarations for various code ! used by GTK based hal programs such as 'halmeter' and 'halscope'. */ *************** *** 43,46 **** --- 43,48 ---- */ + #define PROBE_NAME_LEN 63 + typedef struct { int listnum; /* 0 = pin, 1 = signal, 2 = parameter */ *************** *** 51,54 **** --- 53,57 ---- GtkWidget *window; /* selection dialog window */ GtkWidget *lists[3]; /* lists for pins, sigs, and params */ + char probe_name[PROBE_NAME_LEN + 1]; /* name of this probe */ } probe_t; Index: probe.c =================================================================== RCS file: /cvsroot/emc/emc2/src/hal/probe.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** probe.c 17 Nov 2003 02:46:10 -0000 1.1 --- probe.c 25 Nov 2003 04:49:01 -0000 1.2 *************** *** 54,57 **** --- 54,58 ---- ************************************************************************/ + static void create_probe_window(probe_t * probe); static void accept_selection(GtkWidget * widget, gpointer data); static void accept_selection_and_close(GtkWidget * widget, gpointer data); *************** *** 67,75 **** { probe_t *new; - GtkWidget *vbox, *hbox, *notebk; - GtkWidget *button_OK, *button_accept, *button_cancel; - GtkWidget *tab_label, *scrolled_window; - gchar *tab_label_text[3]; - gint n; if (probe_name != NULL) { --- 68,71 ---- *************** *** 88,99 **** new->data = NULL; new->listnum = -1; /* create window, set it's size, and leave it re-sizeable */ ! new->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); ! gtk_widget_set_usize(GTK_WIDGET(new->window), 300, 400); ! gtk_window_set_policy(GTK_WINDOW(new->window), TRUE, TRUE, FALSE); /* window should appear in center of screen */ ! gtk_window_set_position(GTK_WINDOW(new->window), GTK_WIN_POS_CENTER); /* set set_probe window title */ ! gtk_window_set_title(GTK_WINDOW(new->window), probe_name); /* a vbox to hold everything */ --- 84,160 ---- new->data = NULL; new->listnum = -1; + strncpy(new->probe_name, probe_name, HAL_NAME_LEN); + /* window will be created just before it is displayed */ + new->window = NULL; + /* done */ + return new; + } + + /* this function displays the probe window */ + void popup_probe_window(GtkWidget * widget, gpointer data) + { + probe_t *probe; + int next; + hal_pin_t *pin; + hal_sig_t *sig; + hal_param_t *param; + gchar *name; + + /* get a pointer to the probe data structure */ + probe = (probe_t *) data; + + /* create window if needed */ + if (probe->window == NULL) { + create_probe_window(probe); + } + gtk_clist_clear(GTK_CLIST(probe->lists[0])); + gtk_clist_clear(GTK_CLIST(probe->lists[1])); + gtk_clist_clear(GTK_CLIST(probe->lists[2])); + rtapi_mutex_get(&(hal_data->mutex)); + next = hal_data->pin_list_ptr; + while (next != 0) { + pin = SHMPTR(next); + name = pin->name; + gtk_clist_append(GTK_CLIST(probe->lists[0]), &name); + next = pin->next_ptr; + } + next = hal_data->sig_list_ptr; + while (next != 0) { + sig = SHMPTR(next); + name = sig->name; + gtk_clist_append(GTK_CLIST(probe->lists[1]), &name); + next = sig->next_ptr; + } + next = hal_data->param_list_ptr; + while (next != 0) { + param = SHMPTR(next); + name = param->name; + gtk_clist_append(GTK_CLIST(probe->lists[2]), &name); + next = param->next_ptr; + } + rtapi_mutex_give(&(hal_data->mutex)); + gtk_widget_show_all(probe->window); + } + + /*********************************************************************** + * LOCAL FUNCTION CODE * + ************************************************************************/ + + static void create_probe_window(probe_t * probe) + { + GtkWidget *vbox, *hbox, *notebk; + GtkWidget *button_OK, *button_accept, *button_cancel; + GtkWidget *tab_label, *scrolled_window; + gchar *tab_label_text[3]; + gint n; + /* create window, set it's size, and leave it re-sizeable */ ! probe->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); ! gtk_widget_set_usize(GTK_WIDGET(probe->window), 300, 400); ! gtk_window_set_policy(GTK_WINDOW(probe->window), TRUE, TRUE, FALSE); /* window should appear in center of screen */ ! gtk_window_set_position(GTK_WINDOW(probe->window), GTK_WIN_POS_CENTER); /* set set_probe window title */ ! gtk_window_set_title(GTK_WINDOW(probe->window), probe->probe_name); /* a vbox to hold everything */ *************** *** 101,105 **** gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); /* add the vbox to the window */ ! gtk_container_add(GTK_CONTAINER(new->window), vbox); gtk_widget_show(vbox); --- 162,166 ---- gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); /* add the vbox to the window */ ! gtk_container_add(GTK_CONTAINER(probe->window), vbox); gtk_widget_show(vbox); *************** *** 122,134 **** /* activate the new selection if 'OK' button is clicked */ gtk_signal_connect(GTK_OBJECT(button_OK), "clicked", ! GTK_SIGNAL_FUNC(accept_selection_and_close), new); /* activate the new selection if 'accept' button is clicked */ gtk_signal_connect(GTK_OBJECT(button_accept), "clicked", ! GTK_SIGNAL_FUNC(accept_selection), new); /* make the window disappear if 'cancel' button is clicked */ gtk_signal_connect(GTK_OBJECT(button_cancel), "clicked", ! GTK_SIGNAL_FUNC(close_selection), new); gtk_widget_show(button_OK); --- 183,195 ---- /* activate the new selection if 'OK' button is clicked */ gtk_signal_connect(GTK_OBJECT(button_OK), "clicked", ! GTK_SIGNAL_FUNC(accept_selection_and_close), probe); /* activate the new selection if 'accept' button is clicked */ gtk_signal_connect(GTK_OBJECT(button_accept), "clicked", ! GTK_SIGNAL_FUNC(accept_selection), probe); /* make the window disappear if 'cancel' button is clicked */ gtk_signal_connect(GTK_OBJECT(button_cancel), "clicked", ! GTK_SIGNAL_FUNC(close_selection), probe); gtk_widget_show(button_OK); *************** *** 136,139 **** --- 197,204 ---- gtk_widget_show(button_cancel); + /* set probe->window to NULL if window is destroyed */ + gtk_signal_connect(GTK_OBJECT(probe->window), "destroy", + GTK_SIGNAL_FUNC(gtk_widget_destroyed), &(probe->window)); + /* create a notebook to hold pin, signal, and parameter lists */ notebk = gtk_notebook_new(); *************** *** 154,170 **** gtk_widget_show(scrolled_window); /* create a list to hold the data */ ! new->lists[n] = gtk_clist_new(1); /* set up a callback for when the user selects a line */ ! gtk_signal_connect(GTK_OBJECT(new->lists[n]), "select_row", ! GTK_SIGNAL_FUNC(selection_made), new); /* It isn't necessary to shadow the border, but it looks nice :) */ ! gtk_clist_set_shadow_type(GTK_CLIST(new->lists[n]), GTK_SHADOW_OUT); /* set list for single selection only */ ! gtk_clist_set_selection_mode(GTK_CLIST(new->lists[n]), GTK_SELECTION_BROWSE); /* put the list into the scrolled window */ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW ! (scrolled_window), new->lists[n]); ! gtk_widget_show(new->lists[n]); /* create a label for the page */ tab_label = gtk_label_new(tab_label_text[n]); --- 219,235 ---- gtk_widget_show(scrolled_window); /* create a list to hold the data */ ! probe->lists[n] = gtk_clist_new(1); /* set up a callback for when the user selects a line */ ! gtk_signal_connect(GTK_OBJECT(probe->lists[n]), "select_row", ! GTK_SIGNAL_FUNC(selection_made), probe); /* It isn't necessary to shadow the border, but it looks nice :) */ ! gtk_clist_set_shadow_type(GTK_CLIST(probe->lists[n]), GTK_SHADOW_OUT); /* set list for single selection only */ ! gtk_clist_set_selection_mode(GTK_CLIST(probe->lists[n]), GTK_SELECTION_BROWSE); /* put the list into the scrolled window */ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW ! (scrolled_window), probe->lists[n]); ! gtk_widget_show(probe->lists[n]); /* create a label for the page */ tab_label = gtk_label_new(tab_label_text[n]); *************** *** 185,237 **** /* done */ gtk_widget_show(notebk); - return new; - } - - /* this function displays the probe window */ - void popup_probe_window(GtkWidget * widget, gpointer data) - { - probe_t *probe; - int next; - hal_pin_t *pin; - hal_sig_t *sig; - hal_param_t *param; - gchar *name; - - /* get a pointer to the probe data structure */ - probe = (probe_t *) data; - - gtk_clist_clear(GTK_CLIST(probe->lists[0])); - gtk_clist_clear(GTK_CLIST(probe->lists[1])); - gtk_clist_clear(GTK_CLIST(probe->lists[2])); - rtapi_mutex_get(&(hal_data->mutex)); - next = hal_data->pin_list_ptr; - while (next != 0) { - pin = SHMPTR(next); - name = pin->name; - gtk_clist_append(GTK_CLIST(probe->lists[0]), &name); - next = pin->next_ptr; - } - next = hal_data->sig_list_ptr; - while (next != 0) { - sig = SHMPTR(next); - name = sig->name; - gtk_clist_append(GTK_CLIST(probe->lists[1]), &name); - next = sig->next_ptr; - } - next = hal_data->param_list_ptr; - while (next != 0) { - param = SHMPTR(next); - name = param->name; - gtk_clist_append(GTK_CLIST(probe->lists[2]), &name); - next = param->next_ptr; - } - rtapi_mutex_give(&(hal_data->mutex)); - gtk_widget_show_all(probe->window); } - /*********************************************************************** - * LOCAL FUNCTION CODE * - ************************************************************************/ - static void accept_selection(GtkWidget * widget, gpointer data) { --- 250,255 ---- *************** *** 310,314 **** /* get a pointer to the probe data structure */ probe = (probe_t *) data; ! gtk_widget_hide_all(probe->window); } --- 328,332 ---- /* get a pointer to the probe data structure */ probe = (probe_t *) data; ! /* hide the window */ gtk_widget_hide_all(probe->window); } |