void set_selection(int flag) { int k,i; k = cur_pid; if(process_count > 0) { for (i = 0; i < MAX_PID; i++) { cur_pid = i; if((flag == 0) && (table[cur_pid].process != NULL)) { if (GTK_IS_WIDGET (table[cur_pid].page.tree1) && GTK_IS_TREE(GTK_TREE(table[cur_pid].page.tree1))) { gtk_tree_select_child ( GTK_TREE (table[cur_pid].page.tree1), linklist[cur_pid][0].item); } } else if((flag == 1) && table[cur_pid].process != NULL ) { if((GTK_IS_WIDGET (table[cur_pid].page.tree1) && GTK_IS_TREE (GTK_TREE (table[cur_pid].page.tree1)))) gtk_tree_select_child ( GTK_TREE (table[cur_pid].page.tree1), linklist[cur_pid][table[cur_pid].page.index].item); } } } cur_pid = k; }
/* Emits the select_item signal for the child tree_item, and thus * selects it (unless it is unselected in a signal handler). */ int clip_GTK_TREESELECTCHILD(ClipMachine * cm) { C_widget *ctree = _fetch_cw_arg(cm); C_widget *citem = _fetch_cwidget(cm,_clip_spar(cm,2)); CHECKCWID(ctree,GTK_IS_TREE); CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCWID(citem,GTK_TREE_ITEM); gtk_tree_select_child(GTK_TREE(ctree->widget), citem->widget); return 0; err: return 1; }
/* Emits the select_item signal for the child tree_item, and thus * selects it (unless it is unselected in a signal handler). */ int clip_GTK_TREESELECTCHILD(ClipMachine * ClipMachineMemory) { C_widget *ctree = _fetch_cw_arg(ClipMachineMemory); C_widget *citem = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2)); CHECKCWID(ctree, GTK_IS_TREE); CHECKOPT2(2, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType); CHECKCWID(citem, GTK_TREE_ITEM); gtk_tree_select_child(GTK_TREE(ctree->widget), citem->widget); return 0; err: return 1; }
void on_Abort_clicked (GtkButton *button, gpointer user_data) { char *cmd, *name, buf[3]; int i, size; name = xmlGetProp(table[cur_pid].page.curr, "name"); size = strlen(exec_path) + strlen(" -n ") + sizeof(cur_pid) + strlen(buf) + strlen(" ") + strlen(name) + strlen(" abort ") + 1; cmd = (char *) malloc (size); size = 0; strcpy (cmd, exec_path); strcat (cmd, " -n "); sprintf(buf, "%d", cur_pid); strcat (cmd, buf); strcat (cmd, " "); strcat (cmd, name); strcat (cmd, " abort "); runPeos(cmd); free(cmd); cmd = NULL; freeAll_extra(); draw_tree (cur_pid); /* check state of current action and highlight item in jtree */ for ( i = 0; i < counting_action; i++) { if ((strcmp (xmlGetProp (linklist[cur_pid][i].cur, "state"), "NONE") == 0) || (strcmp (xmlGetProp (linklist[cur_pid][i].cur, "state"), "SUSPEND") == 0)) { table[cur_pid].page.curr = linklist[cur_pid][i].cur; if((GTK_IS_WIDGET (table[cur_pid].page.tree1) && GTK_IS_TREE (GTK_TREE (table[cur_pid].page.tree1)))) gtk_tree_select_child ( GTK_TREE (table[cur_pid].page.tree1), linklist[cur_pid][i].item); break; } } draw_text(table[cur_pid].page.curr); check_state(); }
void set_item_select(signed int factor, int feature) { int i = 0; if (table[cur_pid].process != NULL ) { /* find the current action page and use that index to highlight current item */ if (process_count > 0) while (linklist[cur_pid][i].cur != table[cur_pid].page.curr) i++; if ( (linklist[cur_pid][i].prev != NULL) || (linklist[cur_pid][i].next != NULL)) { /* determine what feature is calling this function values are mapped in the specification file */ if(feature == 1) table[cur_pid].page.curr = linklist[cur_pid][i].next; else table[cur_pid].page.curr = linklist[cur_pid][i].prev; /* previous uses factor -1 and next 1 */ table[cur_pid].page.index = i+factor; /* highlight the specified tree item */ if (GTK_IS_TREE (GTK_TREE (table[cur_pid].page.tree1))) gtk_tree_select_child (GTK_TREE (table[cur_pid].page.tree1), linklist[cur_pid][i+factor].item); } check_state(); } }
void on_Start_clicked(GtkButton *menuitem, gpointer user_data) { char *cmd = NULL, buf[3], *name = NULL, *res_qual = NULL, *res_val = NULL; int i, size = 0; static GtkWidget *input_dialog = NULL; xmlNode *cur = NULL; for ( cur = table[cur_pid].page.curr->children; cur;cur = cur->next) { if (cur->name && xmlStrcmp(cur->name, (const xmlChar*) "req_resource" ) == 0 ) { res_qual = xmlGetProp(cur, "qualifier"); res_val = xmlGetProp(cur, "value"); res_name = NULL; res_name = xmlGetProp(cur, "name"); if ( strcmp (res_val,"$$") == 0) { if ( strcmp ( res_qual, "abstract") != 0) { if (!input_dialog) { input_dialog = create_inputdialog((gchar *) res_name); gtk_widget_show (input_dialog); deactivate(); gtk_signal_connect (GTK_OBJECT(input_dialog), "destroy", (GtkSignalFunc) dialog_destroy, &input_dialog); } else { if (!GTK_WIDGET_MAPPED (input_dialog)) gtk_widget_show(input_dialog); else gdk_window_raise(input_dialog->window); } } } else if ( strcmp (res_qual, "new") == 0) { if (!input_dialog) { input_dialog = create_inputdialog((gchar *)res_name); gtk_widget_show (input_dialog); deactivate(); gtk_signal_connect (GTK_OBJECT(input_dialog), "destroy", (GtkSignalFunc) dialog_destroy, &input_dialog); } else { if (!GTK_WIDGET_MAPPED (input_dialog)) gtk_widget_show(input_dialog); else gdk_window_raise(input_dialog->window); } } else if (strcmp (res_val,"$$") != 0){ name = xmlGetProp (table[cur_pid].page.curr, "name"); sprintf(buf, "%d", cur_pid); size = strlen(exec_path) + strlen(" -n ") + strlen(buf) + strlen(" ") + strlen(name) + strlen(" start ") + 1; cmd = (char *) malloc(size*sizeof(char )); size = 0; strcpy (cmd, exec_path); strcat (cmd, " -n "); strcat (cmd, buf); strcat (cmd, " "); strcat (cmd, name); strcat (cmd, " start "); runPeos(cmd); free(cmd); cmd = NULL; freeAll_extra(); draw_tree (cur_pid); for ( i = 0; i < counting_action; i++) { if (strcmp (linklist[cur_pid][i].cur->name, "action") == 0) { if (strcmp (xmlGetProp (linklist[cur_pid][i].cur, "name"), name) == 0) { table[cur_pid].page.curr = linklist[cur_pid][i].cur; break; } } } if((GTK_IS_WIDGET (table[cur_pid].page.tree1) && GTK_IS_TREE (GTK_TREE (table[cur_pid].page.tree1)))) gtk_tree_select_child ( GTK_TREE (table[cur_pid].page.tree1), linklist[cur_pid][i].item); draw_text(table[cur_pid].page.curr); check_state(); return; } } } }
void on_Finish_clicked(GtkButton *button, gpointer user_data) { if ( table[cur_pid].page.curr) { char *cmd, *name, buf[3]; int i, size; if (table[cur_pid].process != NULL ) { sprintf(buf, "%d", cur_pid); /* Put this up here: fix */ name = xmlGetProp(table[cur_pid].page.curr, "name"); size = strlen(exec_path) + strlen(" -n ") + sizeof(cur_pid) + strlen(buf) + strlen(" ") + strlen(name) + strlen(" finish ") + 1; cmd = (char *) malloc (size); strcpy (cmd, exec_path); strcat (cmd, " -n "); strcat (cmd, buf); strcat (cmd, " "); strcat (cmd, name); strcat (cmd, " finish "); runPeos(cmd); free(cmd); cmd = NULL; } freeAll_extra(); if (table[cur_pid].process != NULL ) { draw_tree (cur_pid); /* search through actions and find the current page */ for ( i = 0; i < counting_action; i++) { if (strcmp (linklist[cur_pid][i].cur->name, "action") == 0) { if (strcmp (xmlGetProp (linklist[cur_pid][i].cur, "name"), name) == 0) { table[cur_pid].page.curr = linklist[cur_pid][i].cur; break; } } } draw_text(table[cur_pid].page.curr); if((GTK_IS_WIDGET (table[cur_pid].page.tree1) && GTK_IS_TREE (GTK_TREE (table[cur_pid].page.tree1)))) gtk_tree_select_child ( GTK_TREE (table[cur_pid].page.tree1), linklist[cur_pid][table[cur_pid].page.index].item); check_state(); } else { table[cur_pid].page.index = 0; gtk_widget_destroy (notebook); notebook = create_notebook(); gtk_widget_set_name (notebook, "notebook"); gtk_widget_ref (notebook); gtk_object_set_data_full (GTK_OBJECT (Peos), "notebook", notebook, (GtkDestroyNotify) gtk_widget_unref); set_selection(1); /* with current action selected */ gtk_widget_show (notebook); gtk_container_add (GTK_CONTAINER (vbox), notebook); for (i = 0; i < MAX_PID; i++) { if (table[i].process != NULL) cur_pid = i; } } redisplay_menu(); } }
int on_OK_clicked(GtkButton *button, gpointer user_data) { char *cmd, buf[3], *buf2, *input, *tmp, *name, *enter, *enter_tmp; int i, size; input = gtk_entry_get_text(GTK_ENTRY (entry1)); if(input == NULL) { perror("Inefficient memroy: input is NULL. Aborting."); RTN_ON_OK_CLICKED = EXIT_FAILURE; exit(1); } else { size = strlen("\'") + strlen(input) + strlen("\'") + 1; enter = (char *) malloc (size*sizeof(char)); strcpy (enter, "\'"); strcat (enter, input); strcat (enter, "\'"); size = 0; /* for reuse */ } if (table[cur_pid].process != NULL ) { if (input != NULL) { sprintf(buf, "%d", cur_pid); /* Moved here to satisfy below */ name = xmlGetProp(table[cur_pid].page.curr,"name"); size = strlen(exec_path) + strlen(" -n") + sizeof(cur_pid) + strlen(buf) + strlen(" ") + strlen(name) + strlen(" start ") + 1; cmd = (char *) malloc (size); size = 0; strcpy (cmd, exec_path); strcat (cmd, " -n "); strcat (cmd, buf); strcat (cmd, " "); strcat (cmd, name); strcat (cmd, " start "); runPeos(cmd); free(cmd); cmd = NULL; size = strlen(exec_path) + strlen(" -r ") + strlen(buf) + strlen(" ") + strlen(res_name) + strlen(" ") + strlen(enter) + strlen(" ") + 1; cmd = (char *) malloc (size); size = 0; /* ./peos -r pid resource_name resource_res_value */ strcpy (cmd, exec_path); strcat (cmd, " -r "); strcat (cmd, buf); strcat (cmd, " "); strcat (cmd, res_name); strcat (cmd, " "); strcat (cmd, enter); strcat (cmd, " "); tmp = get_current_dir_name(); if(tmp == NULL) { perror("No current directory found. Aborting. \n"); RTN_ON_OK_CLICKED = EXIT_FAILURE; exit(1); } else { //size = strlen(tmp) + strlen("/") + strlen(enter_tmp) + 1; size = strlen(tmp) + strlen("/") + 1; buf2 = (char *) malloc(size*sizeof(char)); size = 0; strcpy(buf2, tmp); strcat(buf2,"/"); } if(enter == NULL) { perror("Memory alloc error: enter = NULL \n"); RTN_ON_OK_CLICKED = EXIT_FAILURE; exit(1); } else enter[strlen(enter)] = '\0'; /* to eliminate the quotes and -2 in alloc to take into acount: '"', '"' */ size = strlen(enter) + 1; enter_tmp = (char *) malloc(size*sizeof(char)); strcpy(enter_tmp, enter); int j = 0; for(i = 1; i < size-3; i++) { /* integer value for the single quote character */ if(enter[i] != 39) { enter_tmp[j] = enter[i]; j++; } } enter_tmp[strlen(enter_tmp)-1] = '\0'; /* need more memory */ char *buf2_temp = NULL; size = 0; size = strlen(buf2) + strlen(enter_tmp) + 1; buf2_temp = (char *) malloc(size*sizeof(char)); strcpy(buf2_temp, buf2); free(buf2); buf2 = NULL; strcat(buf2_temp, enter_tmp); free(enter_tmp); enter_tmp = NULL; free(buf2_temp); buf2_temp = NULL; runPeos (cmd); free (cmd); cmd = NULL; freeAll_extra(); draw_tree (cur_pid); /* search through actions and find the current page */ for ( i = 0; i < counting_action; i++) { if (strcmp (linklist[cur_pid][i].cur->name, "action") == 0) { if (strcmp (xmlGetProp (linklist[cur_pid][i].cur, "name"), name) == 0) { table[cur_pid].page.curr = linklist[cur_pid][i].cur; break; } } } draw_text(table[cur_pid].page.curr); /* highlight the current item in the jtree */ if((GTK_IS_WIDGET (table[cur_pid].page.tree1) && GTK_IS_TREE (GTK_TREE (table[cur_pid].page.tree1)))) gtk_tree_select_child ( GTK_TREE (table[cur_pid].page.tree1), linklist[cur_pid][table[cur_pid].page.index].item); } free (enter); enter = NULL; /* check to maintain the next and previous states */ check_state(); } /* return global EXIT_SUCCESS */ RTN_ON_OK_CLICKED = EXIT_SUCCESS; return EXIT_SUCCESS; }