void sigh_print_selection(GtkWidget *gtklist, struttura *str) { int revert,keycode; if (str->tp.luncodicet9==0) return; XGetInputFocus(str->display, &str->win,&revert); GList *dlist; GtkWidget *child; gtk_widget_set_usize(str->tp.scrolled_window, 0,S_W_MAIN); // Fetch the doubly linked list of selected items of the List, remember to treat this as read-only! //g_print("Selection\n"); dlist=GTK_LIST(gtklist)->selection; //g_print("Selection 1\n"); // Individuiamo l'elemento che ha emesso il segnale e calcoliamo la sua posizione all'interno della lista child=gtk_container_get_focus_child(GTK_CONTAINER(gtklist)); str->tp.indice=gtk_list_child_position((GtkList *)gtklist,child); //g_print("Selection 2\n"); int dim_parola = strlen(str->tp.vetparole[str->tp.indice].parola); //g_print("Selection 3\n"); // If there are no selected items there is nothing more to do than just telling the user so if(!dlist){ //g_print("Selection cleared\n"); return; } //g_print("Selection 4\n"); // Ok, we got a selection and so we print itbacca for (int kk=0,i=0; kk < dim_parola;i++, kk++) { if(strncmp(&str->tp.vetparole[str->tp.indice].parola[i],"à",2)==0) sendtofocus(str,XK_agrave); else if(strncmp(&str->tp.vetparole[str->tp.indice].parola[i],"è",2)==0) sendtofocus(str,XK_egrave); else if(strncmp(&str->tp.vetparole[str->tp.indice].parola[i],"ì",2)==0) sendtofocus(str,XK_igrave); else if(strncmp(&str->tp.vetparole[str->tp.indice].parola[i],"ò",2)==0) sendtofocus(str,XK_ograve); else if(strncmp(&str->tp.vetparole[str->tp.indice].parola[i],"ù",2)==0) sendtofocus(str,XK_ugrave); sendtofocus(str,(int)str->tp.vetparole[str->tp.indice].parola[i]); } char query[200]; bzero (query,200); sprintf (query, "update globale set frequenza=frequenza+1 where parola =\'%s\';",str->tp.vetparole[str->tp.indice].parola); //printf("\n%s\n",query); if (sqlite3_exec(str->tp.db,query,0,0,0)) fprintf(stderr,"error : programm %s ,function sigh_print_selection(..) sqlite3_exec return error\n ",NameProgramm); gtk_list_clear_items ((GtkList *) gtklist,0,N); str->tp.luncodicet9 = 0; bzero(str->tp.codicet9,LEN_WORD_DB+1); gdk_window_process_all_updates (); //XCloseDisplay(display); }
static gboolean panel_applet_focus (GtkWidget *widget, GtkDirectionType dir) { gboolean ret; GtkWidget *previous_focus_child; g_return_val_if_fail (PANEL_IS_APPLET (widget), FALSE); previous_focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget)); if (!previous_focus_child && !gtk_widget_has_focus (widget)) { if (gtk_widget_get_has_tooltip (widget)) { gtk_widget_set_can_focus (widget, TRUE); gtk_widget_grab_focus (widget); gtk_widget_set_can_focus (widget, FALSE); return TRUE; } } ret = GTK_WIDGET_CLASS (panel_applet_parent_class)->focus (widget, dir); if (!ret && !previous_focus_child) { if (!gtk_widget_has_focus (widget)) { /* * Applet does not have a widget which can focus so set * the focus on the applet unless it already had focus * because it had a tooltip. */ gtk_widget_set_can_focus (widget, TRUE); gtk_widget_grab_focus (widget); gtk_widget_set_can_focus (widget, FALSE); ret = TRUE; } } return ret; }
extern void _change_cluster_main(GtkComboBox *combo, gpointer extra) { GtkTreeModel *model; display_data_t *display_data; GtkTreeIter iter; slurmdb_cluster_rec_t *cluster_rec = NULL; char *tmp, *ui_description; GError *error = NULL; GtkWidget *node_tab = NULL; int rc; bool got_grid = 0; if (!gtk_combo_box_get_active_iter(combo, &iter)) { g_print("nothing selected\n"); return; } model = gtk_combo_box_get_model(combo); if (!model) { g_print("nothing selected\n"); return; } gtk_tree_model_get(model, &iter, 1, &cluster_rec, -1); if (!cluster_rec) { g_print("no cluster_rec pointer here!"); return; } /* From testing it doesn't appear you can get here without a legitimate change, so there isn't a need to check if we are going back to the same cluster we were just at. */ /* if (working_cluster_rec) { */ /* if (!xstrcmp(cluster_rec->name, working_cluster_rec->name)) */ /* return; */ /* } */ /* free old info under last cluster */ slurm_free_block_info_msg(g_block_info_ptr); g_block_info_ptr = NULL; slurm_free_front_end_info_msg(g_front_end_info_ptr); g_front_end_info_ptr = NULL; slurm_free_burst_buffer_info_msg(g_bb_info_ptr); g_bb_info_ptr = NULL; slurm_free_job_info_msg(g_job_info_ptr); g_job_info_ptr = NULL; slurm_free_node_info_msg(g_node_info_ptr); g_node_info_ptr = NULL; slurm_free_partition_info_msg(g_part_info_ptr); g_part_info_ptr = NULL; slurm_free_reservation_info_msg(g_resv_info_ptr); g_resv_info_ptr = NULL; slurm_free_ctl_conf(g_ctl_info_ptr); g_ctl_info_ptr = NULL; slurm_free_job_step_info_response_msg(g_step_info_ptr); g_step_info_ptr = NULL; slurm_free_topo_info_msg(g_topo_info_msg_ptr); g_topo_info_msg_ptr = NULL; /* set up working_cluster_rec */ if (cluster_dims > 1) { /* reset from a multi-dim cluster */ working_sview_config.grid_x_width = default_sview_config.grid_x_width; working_sview_config.grid_hori = default_sview_config.grid_hori; working_sview_config.grid_vert = default_sview_config.grid_vert; } gtk_table_set_col_spacings(main_grid_table, 0); gtk_table_set_row_spacings(main_grid_table, 0); if (!orig_cluster_name) orig_cluster_name = slurm_get_cluster_name(); if (!xstrcmp(cluster_rec->name, orig_cluster_name)) working_cluster_rec = NULL; else working_cluster_rec = cluster_rec; cluster_dims = slurmdb_setup_cluster_dims(); cluster_flags = slurmdb_setup_cluster_flags(); display_data = main_display_data; while (display_data++) { if (display_data->id == -1) break; if (cluster_flags & CLUSTER_FLAG_BG) { switch(display_data->id) { case BLOCK_PAGE: display_data->show = true; break; case NODE_PAGE: display_data->name = "Midplanes"; break; default: break; } } else { switch(display_data->id) { case BLOCK_PAGE: display_data->show = false; break; case NODE_PAGE: display_data->name = "Nodes"; break; default: break; } } } /* set up menu */ ui_description = _get_ui_description(); gtk_ui_manager_remove_ui(g_ui_manager, g_menu_id); if (!(g_menu_id = gtk_ui_manager_add_ui_from_string( g_ui_manager, ui_description, -1, &error))) { xfree(ui_description); g_error("building menus failed: %s", error->message); g_error_free (error); exit (0); } xfree(ui_description); /* make changes for each object */ cluster_change_block(); cluster_change_front_end(); cluster_change_resv(); cluster_change_part(); cluster_change_job(); cluster_change_node(); cluster_change_bb(); /* destroy old stuff */ if (grid_button_list) { FREE_NULL_LIST(grid_button_list); got_grid = 1; } select_g_ba_fini(); /* sorry popups can't survive a cluster change */ if (popup_list) list_flush(popup_list); if (signal_params_list) list_flush(signal_params_list); if (signal_params_list) list_flush(signal_params_list); if (g_switch_nodes_maps) free_switch_nodes_maps(g_switch_nodes_maps); /* change the node tab name if needed */ node_tab = gtk_notebook_get_nth_page( GTK_NOTEBOOK(main_notebook), NODE_PAGE); node_tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(main_notebook), node_tab); #ifdef GTK2_USE_GET_FOCUS /* ok, now we have a table which we have set up to contain an * event_box which contains the label we are interested. We * setup this label to be the focus child of the table, so all * we have to do is grab that and we are set. */ node_tab = gtk_container_get_focus_child(GTK_CONTAINER(node_tab)); #else /* See above comment. Since gtk_container_get_focus_child * doesn't exist yet we will just traverse the children until * we find the label widget and then break. */ { int i = 0; GList *children = gtk_container_get_children( GTK_CONTAINER(node_tab)); while ((node_tab = g_list_nth_data(children, i++))) { int j = 0; GList *children2 = gtk_container_get_children( GTK_CONTAINER(node_tab)); while ((node_tab = g_list_nth_data(children2, j++))) { if (GTK_IS_LABEL(node_tab)) break; } g_list_free(children2); if (node_tab) break; } g_list_free(children); } #endif if (node_tab) gtk_label_set_text(GTK_LABEL(node_tab), main_display_data[NODE_PAGE].name); /* The name in the visible tabs is easier since it is really just a button with a label on it. */ if (default_sview_config.page_check_widget[NODE_PAGE]) { gtk_button_set_label(GTK_BUTTON(default_sview_config. page_check_widget[NODE_PAGE]), main_display_data[NODE_PAGE].name); } /* reinit */ rc = get_system_stats(main_grid_table); if (rc == SLURM_SUCCESS) { /* It turns out if we didn't have the grid (cluster not responding) before the new grid doesn't get set up correctly. Redoing the system_stats fixes it. There is probably a better way of doing this, but it doesn't happen very often and isn't that bad to handle every once in a while. */ if (!got_grid) { /* I know we just did this before, but it needs to be done again here. */ FREE_NULL_LIST(grid_button_list); get_system_stats(main_grid_table); } refresh_main(NULL, NULL); } tmp = g_strdup_printf("Cluster changed to %s", cluster_rec->name); display_edit_note(tmp); g_free(tmp); }
void sigh_print_selection(GtkWidget *gtklist, struttura *str) { if (str->tp.luncodicet9==0) return; GList *dlist; GtkWidget *child; // Fetch the doubly linked list of selected items of the List, remember to treat this as read-only! g_print("Selection\n"); dlist=GTK_LIST(gtklist)->selection; g_print("Selection 1\n"); // Individuiamo l'elemento che ha emesso il segnale e calcoliamo la sua posizione all'interno della lista child=gtk_container_get_focus_child(GTK_CONTAINER(gtklist)); str->tp.indice=gtk_list_child_position((GtkList *)gtklist,child); g_print("Selection 2\n"); int dim_parola = strlen(str->tp.vetparole[str->tp.indice].parola); g_print("Selection 3\n"); // If there are no selected items there is nothing more to do than just telling the user so if(!dlist){ g_print("Selection cleared\n"); return; } g_print("Selection 4\n"); // Ok, we got a selection and so we print it for (int kk=0; kk < dim_parola; kk++) { gchar word[dim_parola]; sprintf(word,"%s",str->tp.vetparole[str->tp.indice].parola); gchar *let; let = (gchar*)malloc(sizeof(gchar)); sprintf(let,""); sprintf(let,"%c",word[kk]); //sendKey(str->display,str->win,str->winRoot,XStringToKeysym(let),str->modifier); sendtofocus(str,XStringToKeysym(let)); } printf("\n"); g_print("Selection 5\n"); sendtofocus(str,XK_space); str->tp.vetparole[str->tp.indice].frequenza=str->tp.vetparole[str->tp.indice].frequenza+1; printf("\nNuova frequenza parola selezionata: %d\n",str->tp.vetparole[str->tp.indice].frequenza); char query[200]; bzero (query,200); if (str->tp.vetparole[str->tp.indice].frequenza>1) sprintf (query, "update personale set frequenza =%d where parola =\'%s\';",str->tp.vetparole[str->tp.indice].frequenza,str->tp.vetparole[str->tp.indice].parola); else sprintf (query, "insert into personale (codice,parola,frequenza) values (\'%s\',\'%s\',1);",str->tp.codicet9,str->tp.vetparole[str->tp.indice].parola); printf("\n%s\n",query); int retval = retval = sqlite3_exec(str->tp.db,query,0,0,0); gtk_list_clear_items ((GtkList *) gtklist,0,N); str->tp.luncodicet9 = 0; bzero(str->tp.codicet9,30); //XWarpPointer(display, None, None, 0, 0, 0, 0, -10000,-10000); //XWarpPointer(display, None, None, 0, 0, 0, 0, 90, 1); gdk_window_process_all_updates (); //XCloseDisplay(display); }