static void listprop_select_child_signal(GtkList *list, GtkWidget *child, ListProperty *prop) { prop->w_selected = gtk_list_child_position(list,child); }
static void layer_dialog_delete_callback(GtkWidget *widget, gpointer gdata) { Diagram *dia; GtkWidget *selected; Layer *layer; int pos; dia = layer_dialog->diagram; if ((dia != NULL) && (dia->data->layers->len>1)) { assert(GTK_LIST(layer_dialog->layer_list)->selection != NULL); selected = GTK_LIST(layer_dialog->layer_list)->selection->data; layer = dia->data->active_layer; data_remove_layer(dia->data, layer); diagram_add_update_all(dia); diagram_flush(dia); pos = gtk_list_child_position(GTK_LIST(layer_dialog->layer_list), selected); gtk_container_remove(GTK_CONTAINER(layer_dialog->layer_list), selected); undo_layer(dia, layer, TYPE_DELETE_LAYER, dia->data->layers->len - pos); undo_set_transactionpoint(dia->undo); if (--pos<0) pos = 0; gtk_list_select_item(GTK_LIST(layer_dialog->layer_list), pos); } }
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 void list_select_child(GtkList *list, GtkWidget *child, gpointer user_data) { Combo *combo = COMBO(user_data); int idx; if (updating_flag) return; idx = gtk_list_child_position(list,child); if (GTK_WIDGET_VISIBLE(GTK_COMBO(combo)->popwin)) { combo->next_chosen_index = idx; return; } combo->chosen_index = idx; gtk_signal_emit(GTK_OBJECT(combo),combo_signals[CHANGED_SIGNAL]); }
/* Searches the children of list for the index of child. */ int clip_GTK_LISTCHILDPOSITION(ClipMachine * ClipMachineMemory) { C_widget *clst = _fetch_cw_arg(ClipMachineMemory); C_widget *cchild = CWIDGET_ARG(ClipMachineMemory, 2); CHECKCWID(clst, GTK_IS_LIST); CHECKARG2(2, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType); CHECKCWID(cchild, GTK_IS_LIST_ITEM); _clip_retni(ClipMachineMemory, gtk_list_child_position(GTK_LIST(clst->widget), cchild->widget)); return 0; err: return 1; }
static void layer_dialog_lower_callback(GtkWidget *widget, gpointer gdata) { Layer *layer; Diagram *dia; GtkWidget *selected; GList *list = NULL; int pos; dia = layer_dialog->diagram; if ((dia != NULL) && (dia->data->layers->len>1)) { assert(GTK_LIST(layer_dialog->layer_list)->selection != NULL); selected = GTK_LIST(layer_dialog->layer_list)->selection->data; pos = gtk_list_child_position(GTK_LIST(layer_dialog->layer_list), selected); if (pos < dia->data->layers->len-1) { layer = DIA_LAYER_WIDGET(selected)->layer; data_lower_layer(dia->data, layer); list = g_list_prepend(list, selected); g_object_ref(selected); gtk_list_remove_items(GTK_LIST(layer_dialog->layer_list), list); gtk_list_insert_items(GTK_LIST(layer_dialog->layer_list), list, pos + 1); g_object_unref(selected); gtk_list_select_item(GTK_LIST(layer_dialog->layer_list), pos+1); diagram_add_update_all(dia); diagram_flush(dia); undo_layer(dia, layer, TYPE_LOWER_LAYER, 0); undo_set_transactionpoint(dia->undo); } } }
static void layer_dialog_new_callback(GtkWidget *widget, gpointer gdata) { Layer *layer; Diagram *dia; GtkWidget *selected; GList *list = NULL; GtkWidget *layer_widget; int pos; static int next_layer_num = 1; dia = layer_dialog->diagram; if (dia != NULL) { gchar* new_layer_name = g_strdup_printf(_("New layer %d"), next_layer_num++); layer = new_layer(new_layer_name, dia->data); assert(GTK_LIST(layer_dialog->layer_list)->selection != NULL); selected = GTK_LIST(layer_dialog->layer_list)->selection->data; pos = gtk_list_child_position(GTK_LIST(layer_dialog->layer_list), selected); data_add_layer_at(dia->data, layer, dia->data->layers->len - pos); diagram_add_update_all(dia); diagram_flush(dia); layer_widget = dia_layer_widget_new(dia, layer); gtk_widget_show(layer_widget); list = g_list_prepend(list, layer_widget); gtk_list_insert_items(GTK_LIST(layer_dialog->layer_list), list, pos); gtk_list_select_item(GTK_LIST(layer_dialog->layer_list), pos); undo_layer(dia, layer, TYPE_ADD_LAYER, dia->data->layers->len - pos); undo_set_transactionpoint(dia->undo); } }
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); }