void combo_remove_item(Combo *combo, int item_index) { g_assert(item_index != combo->chosen_index); gtk_list_clear_items(GTK_LIST(GTK_COMBO(combo)->list),item_index, item_index+1); if (item_index < combo->chosen_index) combo->chosen_index--; }
void wxListBox::Clear() { wxCHECK_RET( m_list != NULL, wxT("invalid listbox") ); gtk_list_clear_items( m_list, 0, (int)GetCount() ); if ( GTK_LIST(m_list)->last_focus_child != NULL ) { // This should be NULL, I think. GTK_LIST(m_list)->last_focus_child = NULL; } if ( HasClientObjectData() ) { // destroy the data (due to Robert's idea of using wxList<wxObject> // and not wxList<wxClientData> we can't just say // m_clientList.DeleteContents(true) - this would crash! wxList::compatibility_iterator node = m_clientList.GetFirst(); while ( node ) { delete (wxClientData *)node->GetData(); node = node->GetNext(); } } m_clientList.Clear(); if ( m_strings ) m_strings->Clear(); }
static void populate_user_list(login_dlg *ldlg) { GSList *l; GList *strings = NULL; JamHost *host = ldlg->curhost; JamAccount *acc; gtk_widget_set_sensitive(ldlg->bupdate, JAM_HOST_IS_LJ(ldlg->curhost)); for (l = host->accounts; l != NULL; l = l->next) { strings = g_list_append(strings, (char*)jam_account_get_username(l->data)); } if (strings) gtk_combo_set_popdown_strings(GTK_COMBO(ldlg->cusername), strings); else gtk_list_clear_items(GTK_LIST(GTK_COMBO(ldlg->cusername)->list), 0, -1); if (host->lastaccount) { acc = host->lastaccount; } else if (host->accounts) { acc = host->accounts->data; } else { acc = NULL; } gtk_entry_set_text(GTK_ENTRY(ldlg->eusername), acc ? jam_account_get_username(acc) : ""); load_account(ldlg, acc); }
void combo_set_vals (GtkWidget *combo, GList *strlist, const char *str) { g_return_if_fail(GTK_IS_COMBO(combo)); if (!strlist) { gtk_list_clear_items (GTK_LIST (GTK_COMBO (combo)->list), 0, -1); } else { /* * gtk_combo_set_popdown_strings (actually gtk_list_insert_items) * automatically selects the first one and puts it into entry. * That should not happen. Drop selection mode for a moment * to prevent that. */ gtk_list_set_selection_mode (GTK_LIST (GTK_COMBO (combo)->list), GTK_SELECTION_SINGLE); gtk_combo_set_popdown_strings (GTK_COMBO (combo), strlist); gtk_list_set_selection_mode (GTK_LIST (GTK_COMBO (combo)->list), GTK_SELECTION_BROWSE); } if (str) { gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry), str); gtk_entry_set_position (GTK_ENTRY (GTK_COMBO (combo)->entry), 0); } else { gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry), ""); } }
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); }
/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_combo_set_properties (GtkWidget * widget, GbWidgetSetArgData * data) { gboolean value_in_list, ok_if_empty, case_sensitive, arrows, arrows_always; gchar *items; GList *item_list = NULL; value_in_list = gb_widget_input_bool (data, ValueInList); if (data->apply) { gtk_object_set_data (GTK_OBJECT (widget), ValueInList, value_in_list ? "TRUE" : NULL); } ok_if_empty = gb_widget_input_bool (data, OKIfEmpty); if (data->apply) { gtk_object_set_data (GTK_OBJECT (widget), OKIfEmpty, ok_if_empty ? "TRUE" : NULL); } case_sensitive = gb_widget_input_bool (data, Case); if (data->apply) gtk_combo_set_case_sensitive (GTK_COMBO (widget), case_sensitive); arrows = gb_widget_input_bool (data, Arrows); if (data->apply) gtk_combo_set_use_arrows (GTK_COMBO (widget), arrows); arrows_always = gb_widget_input_bool (data, Always); if (data->apply) gtk_combo_set_use_arrows_always (GTK_COMBO (widget), arrows_always); items = gb_widget_input_text (data, Items); if (data->apply) { gchar *pos = items; gchar *items_end = &items[strlen (items)]; while (pos < items_end) { gchar *item_end = strchr (pos, '\n'); if (item_end == NULL) item_end = items_end; *item_end = '\0'; item_list = g_list_append (item_list, pos); pos = item_end + 1; } if (item_list) gtk_combo_set_popdown_strings (GTK_COMBO (widget), item_list); else gtk_list_clear_items (GTK_LIST (GTK_COMBO (widget)->list), 0, -1); g_list_free (item_list); } if (data->action == GB_APPLYING) g_free (items); }
int clip_GTK_COMBOSETPOPDOWNSTRINGS(ClipMachine * ClipMachineMemory) { C_widget *ccmb = _fetch_cw_arg(ClipMachineMemory); ClipArrVar *astr = (ClipArrVar *) _clip_vptr(_clip_spar(ClipMachineMemory, 2)); GList *str_list = NULL; gchar *text_utf; ClipStrVar *s; int i; CHECKCWID(ccmb, GTK_IS_COMBO); CHECKOPT(2, ARRAY_type_of_ClipVarType); for (i = 0; i < astr->count; i++) { if (astr->items[i].t.ClipVartype_type_of_ClipType != CHARACTER_type_of_ClipVarType) continue; s = (ClipStrVar *) _clip_vptr(&astr->items[i]); text_utf = _clip_locale_to_utf8(s->str.buf); if (ccmb->objtype == GTK_WIDGET_COMBO_SIMPLE) { str_list = g_list_append(str_list, gtk_list_item_new_with_label(text_utf)); g_free(text_utf); } else str_list = g_list_append(str_list, text_utf); } if (ccmb->objtype == GTK_WIDGET_COMBO_SIMPLE) { gtk_list_clear_items(GTK_LIST(GTK_COMBO(ccmb->widget)->list), 0, -1); gtk_list_append_items(GTK_LIST(GTK_COMBO(ccmb->widget)->list), str_list); } else gtk_combo_set_popdown_strings(GTK_COMBO(ccmb->widget), str_list); /* while (str_list) { g_free(str_list->data); str_list = g_list_next(str_list); } */ return 0; err: return 1; }
static void listprop_reset_widget(ListProperty *prop, WIDGET *widget) { guint i; GList *items = NULL; gtk_list_clear_items(GTK_LIST(widget),0,-1); for (i = 0; i < prop->lines->len; i++) { items = g_list_append(items, make_item(g_ptr_array_index(prop->lines,i))); } gtk_list_append_items(GTK_LIST(widget),items); prop->w_selected = prop->selected; gtk_list_select_item(GTK_LIST(widget),prop->selected); }
void wxComboBox::DoClear() { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); DisableEvents(); GtkWidget *list = GTK_COMBO(m_widget)->list; gtk_list_clear_items( GTK_LIST(list), 0, (int)GetCount() ); m_clientObjectList.Clear(); m_clientDataList.Clear(); EnableEvents(); InvalidateBestSize(); }
void wxListBox::DoClear() { wxCHECK_RET( m_list != NULL, wxT("invalid listbox") ); gtk_list_clear_items( m_list, 0, (int)GetCount() ); if ( GTK_LIST(m_list)->last_focus_child != NULL ) { // This should be NULL, I think. GTK_LIST(m_list)->last_focus_child = NULL; } m_clientList.Clear(); if ( m_strings ) m_strings->Clear(); }
//__________________________________________________________________ void _HYPlatformPullDown::_DeleteMenuItem (long index) { if (theMenu) { /*printf ("\nDeleting menu item at %d\n", index); for (long k = 0; k<widgetList.lLength; k+=2) printf ("%d %s\n", k, GTK_OBJECT_TYPE_NAME (GTK_WIDGET (widgetList(k))));*/ widgetList.Delete (2*index); widgetList.Delete (2*index); gtk_list_clear_items(GTK_LIST (GTK_COMBO (theMenu)->list),index,index+1); if (selection == index) { cbSelection = -1; //if (selection) // selection--; _RefreshComboBox (); } } }
/* Removes the items between index start (included) and end (excluded) * from the list. If end is negative, or greater than the number of * children of list, it's assumed to be exactly the number of elements. * If start is greater than or equal to end, nothing is done. */ int clip_GTK_LISTCLEARITEMS(ClipMachine * ClipMachineMemory) { C_widget *clst = _fetch_cw_arg(ClipMachineMemory); gint start = INT_OPTION(ClipMachineMemory, 2, 1); gint end = INT_OPTION(ClipMachineMemory, 3, 1); CHECKCWID(clst, GTK_IS_LIST); CHECKOPT(2, NUMERIC_type_of_ClipVarType); CHECKOPT(3, NUMERIC_type_of_ClipVarType); gtk_list_clear_items(GTK_LIST(clst->widget), start - 1, end - 1); return 0; err: return 1; }
/********************************************************* *NAME: dialogGameFinderClear *AUTHOR: John Morrison *Creation Date: 18/1/00 *Last Modified: 18/1/00 *PURPOSE: * Clears the dialog of game information and empties the * list box. * *ARGUMENTS: * *********************************************************/ void dialogGameFinderClear() { gtk_label_set_text(GTK_LABEL(idc_address), EMPTY_STRING); gtk_label_set_text(GTK_LABEL(idc_gamefindversion), EMPTY_STRING); gtk_label_set_text(GTK_LABEL(idc_gamefindport), EMPTY_STRING); gtk_label_set_text(GTK_LABEL(idc_gamefindnumplayers), EMPTY_STRING); gtk_label_set_text(GTK_LABEL(idc_gamefindtype), EMPTY_STRING); gtk_label_set_text(GTK_LABEL(idc_gamefindbases), EMPTY_STRING); gtk_label_set_text(GTK_LABEL(idc_gamefindpills), EMPTY_STRING); gtk_label_set_text(GTK_LABEL(idc_gamefindmines), EMPTY_STRING); gtk_label_set_text(GTK_LABEL(idc_gamefindpass), EMPTY_STRING); gtk_label_set_text(GTK_LABEL(idc_gamefindbrains), EMPTY_STRING); gtk_label_set_text(GTK_LABEL(idc_gamefindmapname), EMPTY_STRING); gtk_widget_set_sensitive (idc_gamefindjoin, FALSE); gtk_widget_set_sensitive (idc_gamefindrejoin, FALSE); gtk_list_clear_items(GTK_LIST(list1), 0, -1); }
static void limited_int_build(node_gui_t *ng, gboolean ishex) { unsigned long i; GtkWidget *listw; const GList *list; ng->combo = gtk_combo_new(); gtk_combo_set_value_in_list(GTK_COMBO(ng->combo), TRUE, FALSE); gtk_combo_set_use_arrows(GTK_COMBO(ng->combo), FALSE); ng->entry = GTK_COMBO(ng->combo)->entry; gtk_entry_set_editable(GTK_ENTRY(ng->entry), FALSE); gtk_signal_connect(GTK_OBJECT(ng->entry), "changed", GTK_SIGNAL_FUNC(on_limited_int_combo_changed), ng); listw = GTK_COMBO(ng->combo)->list; gtk_list_clear_items(GTK_LIST(listw), 0, -1); list = cml_node_get_enumdefs(ng->node); if (list != 0) { for ( ; list != 0 ; list = list->next) { cml_enumdef *ed = (cml_enumdef *)list->data; add_list_entry(listw, cml_node_get_banner(ed->symbol), ed->value); } } else { for (list = cml_node_get_range(ng->node) ; list != 0 ; list = list->next) { cml_subrange *sr = (cml_subrange *)list->data; for (i = sr->begin ; i <= sr->end ; i++) { char valuebuf[32]; sprintf(valuebuf, (ishex ? "0x%lX" : "%ld"), i); add_list_entry(listw, valuebuf, i); } } } node_gui_attach_widget(ng, ng->combo, VALUE); }
void layer_dialog_set_diagram(Diagram *dia) { DiagramData *data; GtkWidget *layer_widget; Layer *layer; Layer *active_layer = NULL; int sel_pos; int i,j; if (dia!=NULL) active_layer = dia->data->active_layer; if (layer_dialog == NULL || layer_dialog->dialog == NULL) layer_dialog_create(); /* May have been destroyed */ g_assert(layer_dialog != NULL); /* must be valid now */ gtk_container_foreach (GTK_CONTAINER(layer_dialog->layer_list), _layer_widget_clear_layer, NULL); gtk_list_clear_items(GTK_LIST(layer_dialog->layer_list), 0, -1); layer_dialog->diagram = dia; if (dia != NULL) { i = g_list_index(dia_open_diagrams(), dia); if (i >= 0 && layer_dialog->diagram_omenu != NULL) gtk_option_menu_set_history(GTK_OPTION_MENU(layer_dialog->diagram_omenu), i); } if (dia != NULL) { data = dia->data; sel_pos = 0; for (i=data->layers->len-1,j=0;i>=0;i--,j++) { layer = (Layer *) g_ptr_array_index(data->layers, i); layer_widget = dia_layer_widget_new(dia, layer); gtk_widget_show(layer_widget); gtk_container_add(GTK_CONTAINER(layer_dialog->layer_list), layer_widget); if (layer==active_layer) sel_pos = j; } gtk_list_select_item(GTK_LIST(layer_dialog->layer_list), sel_pos); } }
void fButtonTP(struttura *str) /*Funzione associata al tasto TP */ { if (str->tp.statot9==0) { str->tp.statot9=1; str->tp.indice=0; str->tp.luncodicet9=0; str->tp.codicet9[0]=0; gtk_label_set_text (GTK_LABEL (str->mylabel2),"PT on"); } else { ins(str); str->tp.statot9=0; gtk_list_clear_items ((GtkList *) str->tp.gtklist,0,N); gtk_widget_set_usize(str->tp.scrolled_window, 0,S_W_MAIN); gtk_label_set_text (GTK_LABEL (str->mylabel2),"PT off"); } }
void gtk_combo_set_popdown_strings (GtkCombo * combo, GList * strings) { GList *list; GtkWidget *li; g_return_if_fail (combo != NULL); g_return_if_fail (GTK_IS_COMBO (combo)); g_return_if_fail (strings != NULL); gtk_list_clear_items (GTK_LIST (combo->list), 0, -1); list = strings; while (list) { li = gtk_list_item_new_with_label ((gchar *) list->data); gtk_widget_show (li); gtk_container_add (GTK_CONTAINER (combo->list), li); list = list->next; } }
void SetPopdownStringsToCombo(GtkWidget *combo, GList *glist, int focus_index) { GList *p = glist; GtkWidget *label; int index = 0; gtk_list_clear_items(GTK_LIST(GTK_COMBO(combo)->list), 0, -1); while( p != NULL ) { label = gtk_list_item_new_with_label((gchar*)p->data); gtk_container_add(GTK_CONTAINER(GTK_COMBO(combo)->list), label); gtk_widget_show(label); if( index == focus_index ) gtk_widget_grab_focus(label); p = p->next; index++; } }
int clip_GTK_COMBOSETPOPDOWNSTRINGS(ClipMachine * ClipMachineMemory) { C_widget *ccmb = _fetch_cw_arg(ClipMachineMemory); ClipArrVar *astr = (ClipArrVar *) _clip_vptr(_clip_spar(ClipMachineMemory, 2)); GList *str_list = NULL; ClipStrVar *s; int i; CHECKCWID(ccmb, GTK_IS_COMBO); CHECKOPT(2, ARRAY_type_of_ClipVarType); for (i = 0; i < astr->count_of_ClipArrVar; i++) { if (astr->ClipVar_items_of_ClipArrVar[i].ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType != CHARACTER_type_of_ClipVarType) continue; s = (ClipStrVar *) _clip_vptr(&astr->ClipVar_items_of_ClipArrVar[i]); if (ccmb->objtype == GTK_WIDGET_COMBO_SIMPLE) str_list = g_list_append(str_list, gtk_list_item_new_with_label(s->ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf)); else str_list = g_list_append(str_list, s->ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf); } if (ccmb->objtype == GTK_WIDGET_COMBO_SIMPLE) { gtk_list_clear_items(GTK_LIST(GTK_COMBO(ccmb->widget)->list), 0, -1); gtk_list_append_items(GTK_LIST(GTK_COMBO(ccmb->widget)->list), str_list); } else gtk_combo_set_popdown_strings(GTK_COMBO(ccmb->widget), str_list); return 0; err: return 1; }
void wxComboBox::Clear() { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); DisableEvents(); GtkWidget *list = GTK_COMBO(m_widget)->list; gtk_list_clear_items( GTK_LIST(list), 0, (int)GetCount() ); wxList::compatibility_iterator node = m_clientObjectList.GetFirst(); while (node) { wxClientData *cd = (wxClientData*)node->GetData(); if (cd) delete cd; node = node->GetNext(); } m_clientObjectList.Clear(); m_clientDataList.Clear(); EnableEvents(); InvalidateBestSize(); }
void wxComboBox::Clear() { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); DisableEvents(); #ifdef __WXGTK24__ if (!gtk_check_version(2,4,0)) { GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); const unsigned int count = GetCount(); for (unsigned int i = 0; i < count; i++) gtk_combo_box_remove_text( combobox, 0 ); } else // GTK+ < 2.4.0 #endif // __WXGTK24__ { GtkWidget *list = GTK_COMBO(m_widget)->list; gtk_list_clear_items( GTK_LIST(list), 0, GetCount() ); } wxList::compatibility_iterator node = m_clientObjectList.GetFirst(); while (node) { wxClientData *cd = (wxClientData*)node->GetData(); delete cd; node = node->GetNext(); } m_clientObjectList.Clear(); m_clientDataList.Clear(); EnableEvents(); InvalidateBestSize(); }
void group_friend_list_clear(GtkWidget* list){ // gtk_list_clear_items(GTK_LIST(list),0,-1); }
static void clear_wifi_list(GtkWidget *gtk_list) { gtk_list_clear_items(GTK_LIST(gtk_list), 0, -1); }
gboolean on_key_treeview_selection ( GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer userdata ) /* Global input: key_list - The list containing the settings for every key Global output: selected_key - Will point to the KTKeySettings in 'key_list' that corresponds to the selected key (if a key is selected) Description: This function sets all the settings of the selected key (if one selected) to the GUI and sets 'selected_key' to the address of the selected key settings. The key settings will be found in 'key_list'. */ { GtkEntry *program_entry = NULL, *default_entry, *plugin_combo_entry, *plugin_function_combo_entry; GtkRadioButton *radiobutton, *default_radiobutton, *program_radiobutton, *special_action_radiobutton; GtkList *plugin_combo_list, *plugin_function_combo_list; GtkTreeView *key_treeview; GtkTreeIter iter; char *key_name, *program_user = "", *default_action; KTPluginInfoEntry *plugin; /* If a row was selected instead of deselected */ if (gtk_tree_model_get_iter(model, &iter, path)) { /* Get the name of the selected key */ gtk_tree_model_get (model, &iter, FIRST_COLUMN, &key_name, -1); if (key_name != NULL) /* If a listitem was selected instead of deselected */ { key_treeview = gtk_tree_selection_get_tree_view(selection); program_entry = KTGUI_program_entry(); default_entry = KTGUI_default_entry(); plugin_combo_entry = KTGUI_plugin_combo_entry(); plugin_function_combo_entry = KTGUI_plugin_function_combo_entry(); default_radiobutton = KTGUI_default_radiobutton(); program_radiobutton = KTGUI_program_radiobutton(); special_action_radiobutton = KTGUI_special_action_radiobutton(); plugin_combo_list = KTGUI_plugin_combo_list(); plugin_function_combo_list = KTGUI_plugin_function_combo_list(); /* Block the signal handlers of the entries and the radiobuttons */ g_signal_handlers_block_by_func (GTK_OBJECT(program_entry), (void *)on_program_entry_changed, NULL); g_signal_handlers_block_by_func (GTK_OBJECT(default_radiobutton), (void *)on_default_radiobutton_toggled, NULL); g_signal_handlers_block_by_func (GTK_OBJECT(program_radiobutton), (void *)on_program_radiobutton_toggled, NULL); g_signal_handlers_block_by_func (GTK_OBJECT(special_action_radiobutton), (void *)on_special_action_radiobutton_toggled, NULL); g_signal_handlers_block_by_func (GTK_OBJECT(plugin_combo_entry), (void *)on_plugin_combo_entry_changed, NULL); g_signal_handlers_block_by_func (GTK_OBJECT(plugin_function_combo_entry), (void *)on_plugin_function_combo_entry_changed, NULL); gtk_entry_set_text (plugin_combo_entry, ""); gtk_entry_set_text (plugin_function_combo_entry, ""); /* Clear the plugin function list */ gtk_list_clear_items (plugin_function_combo_list, 0, -1); /* Clear the whole list */ /* Select the key in the linked list */ selected_key = find_key_settings(key_name, &key_list); /* Read the settings of the key */ if (!memcmp(&selected_key->action, &selected_key->default_action, sizeof(KTAction))) { radiobutton = default_radiobutton; } else if (selected_key->action.type == KTActionTypeProgram) { program_user = selected_key->action.program.command; radiobutton = GTK_RADIO_BUTTON( lookup_widget(GTK_WIDGET(key_treeview), "program_radiobutton") ); } else if (selected_key->action.type == KTActionTypePlugin) { plugin = find_plugin (selected_key->action.plugin.plugin_name, &plugin_list); if (plugin_function_exists (selected_key->action.plugin.plugin_name, selected_key->action.plugin.function_name, &plugin_list)) { reload_plugin_function_list (KTGUI_plugin_function_combo_list(), GTK_OBJECT( KTGUI_plugin_function_combo_entry() ), on_plugin_function_combo_entry_changed, plugin); gtk_entry_set_text (plugin_combo_entry, selected_key->action.plugin.plugin_name); gtk_entry_set_text (plugin_function_combo_entry, selected_key->action.plugin.function_name); radiobutton = special_action_radiobutton; } else { radiobutton = default_radiobutton; } } /* Show the settings of the key */ gtk_label_set_text (KTGUI_key_name_label(), key_name); gtk_entry_set_text (GTK_ENTRY(program_entry), program_user); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(radiobutton), TRUE); if (selected_key->default_action.type == KTActionTypePlugin) { /* If the plugin is not available on this system */ if (selected_key->default_action.plugin.plugin_name == NULL) { default_action = ""; } else { default_action = (char *)g_strdup_printf ("%s - %s", selected_key->default_action.plugin.plugin_name, selected_key->default_action.plugin.function_name); } } else if (selected_key->default_action.type == KTActionTypeProgram) { default_action = (char *)g_strdup_printf( selected_key->default_action.program.command); } /* Show the default action */ gtk_entry_set_text (GTK_ENTRY(default_entry), default_action); if (default_action[0] != '\0') { g_free (default_action); } /* Unblock the signal handlers of the entries and the radiobuttons */ g_signal_handlers_unblock_by_func (GTK_OBJECT(program_entry), (void *)on_program_entry_changed, NULL); g_signal_handlers_unblock_by_func (GTK_OBJECT(default_radiobutton), (void *)on_default_radiobutton_toggled, NULL); g_signal_handlers_unblock_by_func (GTK_OBJECT(program_radiobutton), (void *)on_program_radiobutton_toggled, NULL); g_signal_handlers_unblock_by_func (GTK_OBJECT(special_action_radiobutton), (void *)on_special_action_radiobutton_toggled, NULL); g_signal_handlers_unblock_by_func (GTK_OBJECT(plugin_combo_entry), (void *)on_plugin_combo_entry_changed, NULL); g_signal_handlers_unblock_by_func (GTK_OBJECT(plugin_function_combo_entry), (void *)on_plugin_function_combo_entry_changed, NULL); g_free (key_name); } } return (TRUE); }
//Algoritmo T9 di predizione del testo basato su liste void gestionet9 (struttura *str) { gtk_list_clear_items ((GtkList *) str->tp.gtklist,0,N); if (str->tp.luncodicet9==-1) /*possibile solo se provenienti da un delete*/ { gtk_widget_set_usize(str->tp.scrolled_window, 0,S_W_MAIN); str->tp.luncodicet9=0; return; } //fase inizializzazione str->tp.numparoletrovate=0; int i=0; for (i=0; i<N;i++) { bzero(str->tp.vetparole[i].parola,LEN_WORD_DB+1); } //aggiornamento str->tp.luncodicet9++; str->tp.codicet9[str->tp.luncodicet9]=0; //printf("\nTasti premuti: %s\tlunghezza:%d\n",str->tp.codicet9,str->tp.luncodicet9); char query[200]; bzero (query,200); //se freq0 globale, se 1 pers sprintf (query, " select parola,codice,frequenza from globale where codice like \'%s%%\' order by codice,frequenza desc limit 0,%d;",str->tp.codicet9,N); //GtkWidget *list_item; GList *dlist=NULL; gchar *s; s = (gchar*)malloc(sizeof(gchar)); *s=0;//equals sprintf(s,""); //printf("\n%s\n",query); int retval = sqlite3_prepare_v2(str->tp.db,query,-1,&str->tp.stmt,0); if(retval) { return; } // Read the number of rows fetched int cols = sqlite3_column_count(str->tp.stmt); while(1) { // fetch a row's status retval = sqlite3_step(str->tp.stmt); if(retval == SQLITE_DONE) break; else if(retval == SQLITE_ROW) { // SQLITE_ROW means fetched a row str->tp.numparoletrovate=str->tp.numparoletrovate+1; //printf ("\n"); // sqlite3_column_text returns a const void* , typecast it to const char* for(int col=0 ; col<cols;col++) { char *val = (char *)sqlite3_column_text(str->tp.stmt,col); //printf("%s = %s\t",sqlite3_column_name(str->tp.stmt,col),val); if (col==0) { sprintf(str->tp.vetparole[str->tp.numparoletrovate-1].parola,"%s",val); str->tp.list_item=gtk_list_item_new_with_label(val); dlist=g_list_append(dlist, str->tp.list_item); gtk_widget_set_usize(str->tp.list_item,0,25); gtk_widget_show(str->tp.list_item); gtk_object_set_data(GTK_OBJECT(str->tp.list_item), list_item_data_key,s); } else strcpy(str->tp.vetparole[str->tp.numparoletrovate-1].keyparola,val); } } else { // Some error encountered return; } } str->tp.indice=0; if(str->tp.numparoletrovate> 0) gtk_list_append_items((GtkList*)(str->tp.gtklist), dlist); else{ ins(str); fButtonTP(str); } gdk_window_process_all_updates (); //printf ("\n"); }
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); }
//Algoritmo T9 di predizione del testo basato su liste void gestionet9 (struttura *str,int tasto) { //fase inizializzazione str->tp.numparoletrovate=0; int i=0; for (i=0; i<N;i++) { str->tp.vetparole[i].frequenza=0; bzero(str->tp.vetparole[i].parola,30); } gtk_list_clear_items ((GtkList *) str->tp.gtklist,0,N); //aggiornamento str->tp.luncodicet9=str->tp.luncodicet9+1; sprintf(str->tp.codicet9,"%s%d",str->tp.codicet9,tasto); //printf("\nTasti premuti: %s\tlunghezza:%d\n",str->tp.codicet9,str->tp.luncodicet9); char query[200]; bzero (query,200); //se freq0 globale, se 1 pers sprintf (query, " select parola dist,frequenza from personale where codice like \'%s%%\' union select parola dist,frequenza from globale where codice like \'%s%%\' order by 2 desc, 1 asc limit 0,5;",str->tp.codicet9,str->tp.codicet9); //GtkWidget *list_item; GList *dlist=NULL; gchar *s; s = (gchar*)malloc(sizeof(gchar)); sprintf(s,""); printf("\n%s\n",query); int retval = sqlite3_prepare_v2(str->tp.db,query,-1,&str->tp.stmt,0); if(retval) { printf("\nerrore database\n"); return; } // Read the number of rows fetched int cols = sqlite3_column_count(str->tp.stmt); while(1) { // fetch a row's status retval = sqlite3_step(str->tp.stmt); if(retval == SQLITE_DONE) break; else if(retval == SQLITE_ROW) { // SQLITE_ROW means fetched a row str->tp.numparoletrovate=str->tp.numparoletrovate+1; printf ("\n"); // sqlite3_column_text returns a const void* , typecast it to const char* for(int col=0 ; col<cols;col++) { const char *val = (const char*)sqlite3_column_text(str->tp.stmt,col); //printf("%s = %s\t",sqlite3_column_name(str->tp.stmt,col),val); if (col==0) { printf ("%s",val); sprintf(str->tp.vetparole[str->tp.numparoletrovate-1].parola,"%s",val); str->tp.list_item=gtk_list_item_new_with_label(val); dlist=g_list_append(dlist, str->tp.list_item); gtk_widget_show(str->tp.list_item); gtk_object_set_data(GTK_OBJECT(str->tp.list_item), list_item_data_key,s); } else { printf ("\tfr=%s",val); str->tp.vetparole[str->tp.numparoletrovate-1].frequenza=atoi(val); } } } else { // Some error encountered printf("errori query\n"); return; } } str->tp.indice=0; Display *display = XOpenDisplay(0); if(str->tp.numparoletrovate> 0) { gtk_list_append_items((GtkList*)(str->tp.gtklist), dlist); } gdk_window_process_all_updates (); XCloseDisplay(display); printf ("\n"); }