static void setup_timezone_dialog (CcDateTimePanel *self) { CcDateTimePanelPrivate *priv = self->priv; GtkEntryCompletion *completion; GtkTreeModel *completion_model; GtkWidget *dialog; GtkWidget *entry; /* set up timezone map */ priv->map = (GtkWidget *) cc_timezone_map_new (); gtk_widget_show (priv->map); gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (priv->builder, "aspectmap")), priv->map); dialog = W ("timezone-dialog"); entry = W ("timezone-searchentry"); g_signal_connect (dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL); /* Create the completion object */ completion = gtk_entry_completion_new (); gtk_entry_set_completion (GTK_ENTRY (entry), completion); g_object_unref (completion); completion_model = GTK_TREE_MODEL (gtk_builder_get_object (priv->builder, "city-modelsort")); gtk_entry_completion_set_model (completion, completion_model); gtk_entry_completion_set_text_column (completion, CITY_COL_CITY_HUMAN_READABLE); }
/* * Create completion in entry */ static void dialog_entry_completion_new(const GtkWidget *container, GtkEntryCompletionMatchFunc completion_func, gpointer completion_data) { GtkListStore *list_store = NULL; GtkEntryCompletion *completion = NULL; /* Create a tree model and use it as the completion model */ list_store = gtk_list_store_new(1, G_TYPE_STRING); /* Create the completion object */ completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(list_store)); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_minimum_key_length(completion, AV_WIDGET_ENTRY_COMPLETION_KEY_LEN_MIN); gtk_entry_completion_set_popup_completion(completion, FALSE); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_completion_set_match_func(completion, completion_func, completion_data, NULL); /* Assign the completion to the entry */ gtk_entry_set_completion(GTK_ENTRY(container), completion); g_object_unref (completion); }
static gboolean on_focus_in( GtkWidget *entry, GdkEventFocus* evt, gpointer user_data ) { GtkEntryCompletion* completion = gtk_entry_completion_new(); GtkListStore* list = gtk_list_store_new( N_COLS, G_TYPE_STRING, G_TYPE_STRING ); GtkCellRenderer* render; gtk_entry_completion_set_minimum_key_length( completion, 1 ); gtk_entry_completion_set_model( completion, GTK_TREE_MODEL(list) ); g_object_unref( list ); /* gtk_entry_completion_set_text_column( completion, COL_PATH ); */ // Following line causes GTK3 to show both columns, so skip this and use // custom match-selected handler to insert COL_PATH //g_object_set( completion, "text-column", COL_PATH, NULL ); render = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start( (GtkCellLayout*)completion, render, TRUE ); gtk_cell_layout_add_attribute( (GtkCellLayout*)completion, render, "text", COL_NAME ); //gtk_entry_completion_set_inline_completion( completion, TRUE ); gtk_entry_completion_set_popup_set_width( completion, TRUE ); gtk_entry_set_completion( GTK_ENTRY(entry), completion ); g_signal_connect( G_OBJECT(entry), "changed", G_CALLBACK(on_changed), NULL ); g_signal_connect( G_OBJECT( completion ), "match-selected", G_CALLBACK( on_match_selected ), entry ); g_signal_connect( G_OBJECT( completion ), "insert-prefix", G_CALLBACK( on_insert_prefix ), entry ); g_object_unref( completion ); return FALSE; }
static GtkEntryCompletion * _new_bin_completion (void) { const gchar *path_env = g_getenv ("PATH"); gchar **pathdirs = g_strsplit (path_env, G_SEARCHPATH_SEPARATOR_S, 0); gchar **pathiter = pathdirs; GList *cmds_p[] = {NULL}; for (; *pathiter != NULL; pathiter++) { gchar *path = *pathiter; ol_traverse_dir (path, FALSE, _prepend_cmd_to_list, cmds_p); } GList *cmds = cmds_p[0]; cmds = g_list_sort (cmds, (GCompareFunc)strcasecmp); GtkListStore *list = gtk_list_store_new (1, G_TYPE_STRING); for (; cmds != NULL; cmds = cmds->next) { GtkTreeIter iter; gtk_list_store_append (list, &iter); gtk_list_store_set (list, &iter, 0, cmds->data, -1); } for (; cmds != NULL; cmds = g_list_delete_link (cmds, cmds)) g_free (cmds->data); GtkEntryCompletion *comp = gtk_entry_completion_new (); gtk_entry_completion_set_model (comp, GTK_TREE_MODEL (list)); gtk_entry_completion_set_text_column (comp, 0); gtk_entry_completion_set_inline_completion (comp, TRUE); gtk_entry_completion_set_inline_selection (comp, TRUE); return comp; }
bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString& choices) { GtkEntry* const entry = (GtkEntry*)GetEditable(); wxCHECK_MSG(GTK_IS_ENTRY(entry), false, "auto completion doesn't work with this control"); GtkListStore * const store = gtk_list_store_new(1, G_TYPE_STRING); GtkTreeIter iter; #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for ( wxArrayString::const_iterator i = choices.begin(); i != choices.end(); ++i ) { gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, (const gchar *)i->utf8_str(), -1); } GtkEntryCompletion * const completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store)); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_set_completion(entry, completion); g_object_unref(completion); return true; }
/* * fill completion model for the entry, using list of * available gajim contacts */ static GtkWidget * get_contacts_widget (NstPlugin *plugin) { GtkWidget *entry; GtkEntryCompletion *completion; GtkListStore *store; GtkCellRenderer *renderer; GtkTreeModel *completion_model; entry = gtk_entry_new (); completion = gtk_entry_completion_new (); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion), renderer, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (completion), renderer, "pixbuf", 0, NULL); store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING); if(!add_gajim_contacts_to_model (store)) { gtk_widget_set_sensitive(entry, FALSE); } completion_model = GTK_TREE_MODEL (store); gtk_entry_completion_set_model (completion, completion_model); gtk_entry_set_completion (GTK_ENTRY (entry), completion); gtk_entry_completion_set_text_column (completion, 1); g_object_unref (completion_model); g_object_unref (completion); return entry; }
void completion_setup(GtkWidget * entry, CompletionType completiontype) // Sets up completion on an entry. { // Create completion. GtkEntryCompletion *completion; completion = gtk_entry_completion_new(); // Assign it to the entry. gtk_entry_set_completion(GTK_ENTRY(entry), completion); // Free memory. g_object_unref(completion); // Create a model / store and fill it with data. extern Settings *settings; GtkListStore *store; store = gtk_list_store_new(1, G_TYPE_STRING); GtkTreeIter iter; vector < ustring > completiontable; switch (completiontype) { case cpSearch: completiontable = settings->session.completion_search; case cpReplace: completiontable = settings->session.completion_replace; case cpGoto: completiontable = settings->session.completion_goto; } for (unsigned int i = 0; i < completiontable.size(); i++) { gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, completiontable[i].c_str(), -1); } gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store)); // Free memory. g_object_unref(store); // Point it to first column to use. gtk_entry_completion_set_text_column(completion, 0); }
void on_input_word_changed (GtkEditable *editable, gpointer user_data) { // g_print("on_input_word_changed called\n"); char *word = NULL, *entry_word = NULL; entry_word = gtk_entry_get_text ( mydata.input_word ); // word = g_strchomp( g_strchug( g_strdown( entry_word ) ) ); // it has caused a Pango: index out of bound bug so use instead word = g_strdown( entry_word ); if( strlen( word ) == 0 ){ //g_print("on_input_word_changed():word is NULL\n"); //avoid some latency by commenting below //remove_all_from_list(); return ; //return as word is NULL and nothing to do } if( strlen( word ) == 1 ){ // // g_print("on_input_word_changed():word= %s\n", word ); load_hashtable_list(); // //list is loaded use it for auto completion GtkEntryCompletion *completion; completion = gtk_entry_completion_new(); gtk_entry_completion_set_text_column(completion, LIST_ITEM ); gtk_entry_set_completion(GTK_ENTRY(mydata.input_word), completion); g_signal_connect(G_OBJECT (completion), "match-selected",G_CALLBACK (on_match_select), NULL); gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(mydata.list_store)); // } }
int clip_GTK_ENTRYCOMPLETIONNEW(ClipMachine * ClipMachineMemory) { ClipVar *cv = _clip_spar(ClipMachineMemory, 1); GtkEntryCompletion *completion; C_object *ccompletion; CHECKOPT(1, MAP_type_of_ClipVarType); completion = gtk_entry_completion_new(); if (completion) { ccompletion = _list_get_cobject(ClipMachineMemory, completion); if (!ccompletion) ccompletion = _register_object(ClipMachineMemory, completion, GTK_TYPE_ENTRY_COMPLETION, cv, NULL); if (ccompletion) _clip_mclone(ClipMachineMemory, RETPTR(ClipMachineMemory), &ccompletion->obj); } return 0; err: return 1; }
EntityPropertyEditor::EntityPropertyEditor (Entity* entity, const std::string& name) { _widget = gtk_vbox_new(FALSE, 6); GtkWidget* editBox = gtk_hbox_new(FALSE, 3); gtk_container_set_border_width(GTK_CONTAINER(editBox), 3); // Set up the combobox TreeModel _comboBox = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(gtk_list_store_new(1, G_TYPE_STRING)), 0); // number of the "text" column populateComboBox(); // Add completion functionality to the combobox entry GtkEntryCompletion* completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX(_comboBox))) ); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_set_completion(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(_comboBox))), completion); std::string caption = name + ": "; gtk_box_pack_start(GTK_BOX(editBox), gtk_label_new(caption.c_str()), FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(editBox), _comboBox, TRUE, TRUE, 0); GtkWidget* vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), editBox, TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX(_widget), vbox, TRUE, TRUE, 0); }
static gboolean on_focus_in( GtkWidget *entry, GdkEventFocus* evt, gpointer user_data ) { GtkEntryCompletion* completion = gtk_entry_completion_new(); GtkListStore* list = gtk_list_store_new( COUNT_COLS, G_TYPE_STRING, G_TYPE_STRING ); GtkCellRenderer* render; gtk_entry_completion_set_minimum_key_length( completion, 1 ); gtk_entry_completion_set_model( completion, GTK_TREE_MODEL(list) ); g_object_unref( list ); // gtk_entry_completion_set_text_column( completion, COL_PATH ); // g_object_set( completion, "text-column", COL_PATH, NULL );VV g_object_set( completion, "text-column", COL_NAME, NULL ); render = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start( (GtkCellLayout*)completion, render, TRUE ); gtk_cell_layout_add_attribute( (GtkCellLayout*)completion, render, "text", COL_NAME ); gtk_entry_completion_set_inline_completion( completion, TRUE ); #if GTK_CHECK_VERSION( 2, 8, 0) // gtk+ prior to 2.8.0 doesn't have this API gtk_entry_completion_set_popup_set_width( completion, TRUE ); #endif gtk_entry_set_completion( GTK_ENTRY(entry), completion ); g_signal_connect( G_OBJECT(entry), "changed", G_CALLBACK(on_changed), NULL ); g_object_unref( completion ); return FALSE; }
static void setup_auto_complete_with_data(ThreadData* data) { GtkListStore* store; GSList *l; GtkEntryCompletion* comp = gtk_entry_completion_new(); gtk_entry_completion_set_minimum_key_length( comp, 2 ); gtk_entry_completion_set_inline_completion( comp, TRUE ); #if GTK_CHECK_VERSION( 2, 8, 0 ) gtk_entry_completion_set_popup_set_width( comp, TRUE ); gtk_entry_completion_set_popup_single_match( comp, FALSE ); #endif store = gtk_list_store_new( 1, G_TYPE_STRING ); for( l = data->files; l; l = l->next ) { const char *name = (const char*)l->data; GtkTreeIter it; gtk_list_store_append( store, &it ); gtk_list_store_set( store, &it, 0, name, -1 ); } gtk_entry_completion_set_model( comp, (GtkTreeModel*)store ); g_object_unref( store ); gtk_entry_completion_set_text_column( comp, 0 ); gtk_entry_set_completion( (GtkEntry*)data->entry, comp ); /* trigger entry completion */ gtk_entry_completion_complete(comp); g_object_unref( comp ); }
/* exported interface documented in completion.h */ GtkEntryCompletion *nsgtk_url_entry_completion_new(struct nsgtk_scaffolding *gs) { GtkEntryCompletion *completion; completion = gtk_entry_completion_new(); gtk_entry_completion_set_match_func(completion, nsgtk_completion_match, NULL, NULL); gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(nsgtk_completion_list)); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_minimum_key_length(completion, 1); /* enable popup for completion */ gtk_entry_completion_set_popup_completion(completion, TRUE); /* when selected callback */ g_signal_connect(G_OBJECT(completion), "match-selected", G_CALLBACK(nsgtk_completion_match_select), gs); g_object_set(G_OBJECT(completion), "popup-set-width", TRUE, "popup-single-match", TRUE, NULL); return completion; }
bool wxTextEntry::DoAutoCompleteStrings(const wxArrayString& choices) { GtkEntry* const entry = (GtkEntry*)GetEditable(); wxCHECK_MSG(GTK_IS_ENTRY(entry), false, "auto completion doesn't work with this control"); GtkListStore * const store = gtk_list_store_new(1, G_TYPE_STRING); GtkTreeIter iter; for ( wxArrayString::const_iterator i = choices.begin(); i != choices.end(); ++i ) { gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, (const gchar *)i->utf8_str(), -1); } GtkEntryCompletion * const completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store)); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_set_completion(entry, completion); g_object_unref(completion); return true; }
static GtkWidget * ekiga_window_uri_entry_new (EkigaWindow *mw) { GtkWidget *entry = NULL; GtkEntryCompletion *completion = NULL; g_return_val_if_fail (EKIGA_IS_WINDOW (mw), NULL); /* URI Entry */ entry = gm_entry_new (BASIC_URI_REGEX); gm_entry_set_activate_icon (GM_ENTRY (entry), "call-start"); mw->priv->completion = gtk_list_store_new (1, G_TYPE_STRING); completion = gtk_entry_completion_new (); gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), GTK_TREE_MODEL (mw->priv->completion)); gtk_entry_completion_set_text_column (GTK_ENTRY_COMPLETION (completion), 0); gtk_entry_set_completion (GTK_ENTRY (entry), completion); gtk_entry_set_text (GTK_ENTRY (entry), "sip:"); gtk_entry_completion_set_inline_completion (GTK_ENTRY_COMPLETION (completion), true); gtk_entry_completion_set_popup_completion (GTK_ENTRY_COMPLETION (completion), true); gtk_widget_add_accelerator (entry, "grab-focus", mw->priv->accel, GDK_KEY_L, (GdkModifierType) GDK_CONTROL_MASK, (GtkAccelFlags) 0); gtk_editable_set_position (GTK_EDITABLE (entry), -1); g_signal_connect (entry, "changed", G_CALLBACK (url_changed_cb), mw); g_signal_connect (entry, "activated", G_CALLBACK (place_call_cb), mw); return entry; }
void dbgromcall_create_window(GladeXML *xml) { GtkTreeModel *model; GtkComboBox *combo; GtkEntry *entry; GtkEntryCompletion* completion; gpointer data; pbar = data = glade_xml_get_widget(xml, "progressbar1"); combo = data = glade_xml_get_widget(xml, "comboboxentry1"); entry = GTK_ENTRY(GTK_BIN(combo)->child); // create storage store = gtk_list_store_new(CLIST_NCOLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, -1 ); model = GTK_TREE_MODEL(store); // and set storage gtk_combo_box_set_model(combo, model); gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(combo), COL_FULL); /* --- */ // set auto-completion completion = gtk_entry_completion_new(); gtk_entry_set_completion(entry, completion); gtk_entry_completion_set_model(completion, model); gtk_entry_completion_set_text_column (completion, COL_FULL); g_signal_connect(G_OBJECT(completion), "match-selected", G_CALLBACK(on_combo_entry1_match_selected), NULL); //gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1); }
GtkWidget * terminal_search_dialog_new (GtkWindow *parent) { GtkWidget *dialog; TerminalSearchDialogPrivate *priv; GtkListStore *store; GtkEntryCompletion *completion; priv = g_new0 (TerminalSearchDialogPrivate, 1); if (!terminal_util_load_builder_file ("find-dialog.ui", "find-dialog", &dialog, "search-label", &priv->search_label, "search-entry", &priv->search_entry, "match-case-checkbutton", &priv->match_case_checkbutton, "entire-word-checkbutton", &priv->entire_word_checkbutton, "regex-checkbutton", &priv->regex_checkbutton, "search-backwards-checkbutton", &priv->backwards_checkbutton, "wrap-around-checkbutton", &priv->wrap_around_checkbutton, NULL)) { g_free (priv); return NULL; } g_object_set_qdata_full (G_OBJECT (dialog), get_quark (), priv, (GDestroyNotify) terminal_search_dialog_private_destroy); priv->search_text_entry = gtk_bin_get_child (GTK_BIN (priv->search_entry)); gtk_widget_set_size_request (priv->search_entry, 300, -1); priv->store = store = gtk_list_store_new (1, G_TYPE_STRING); g_object_set (G_OBJECT (priv->search_entry), "model", store, "text-column", 0, NULL); priv->completion = completion = gtk_entry_completion_new (); gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (store)); gtk_entry_completion_set_text_column (completion, 0); gtk_entry_completion_set_minimum_key_length (completion, HISTORY_MIN_ITEM_LEN); gtk_entry_completion_set_popup_completion (completion, FALSE); gtk_entry_completion_set_inline_completion (completion, TRUE); gtk_entry_set_completion (GTK_ENTRY (priv->search_text_entry), completion); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT, FALSE); gtk_entry_set_activates_default (GTK_ENTRY (priv->search_text_entry), TRUE); g_signal_connect (priv->search_text_entry, "changed", G_CALLBACK (update_sensitivity), dialog); g_signal_connect (priv->regex_checkbutton, "toggled", G_CALLBACK (update_sensitivity), dialog); g_signal_connect (dialog, "response", G_CALLBACK (response_handler), NULL); if (parent) gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); return GTK_WIDGET (dialog); }
static void fm_path_entry_init(FmPathEntry *entry) { FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry); GtkEntryCompletion* completion = gtk_entry_completion_new(); GtkCellRenderer* render; priv->model = NULL; priv->completion_model = NULL; priv->completion_len = 0; priv->in_change = FALSE; priv->completion = completion; priv->highlight_completion_match = TRUE; priv->common_suffix_append_idle_id = -1; priv->common_suffix[0] = 0; gtk_entry_completion_set_minimum_key_length(completion, 1); gtk_entry_completion_set_match_func(completion, fm_path_entry_match_func, NULL, NULL); g_signal_connect(G_OBJECT(completion), "match-selected", G_CALLBACK(fm_path_entry_match_selected), (gpointer)NULL); g_object_set(completion, "text-column", COL_FILE_NAME, NULL); render = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start( (GtkCellLayout*)completion, render, TRUE ); gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(completion), render, fm_path_entry_completion_render_func, entry, NULL); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_completion_set_popup_set_width(completion, TRUE); g_signal_connect(G_OBJECT(entry), "key-press-event", G_CALLBACK(fm_path_entry_key_press), NULL); gtk_entry_set_completion(GTK_ENTRY(entry), completion); }
GtkWidget * do_entry_completion (GtkWidget *do_widget) { GtkWidget *vbox; GtkWidget *label; GtkWidget *entry; GtkEntryCompletion *completion; GtkTreeModel *completion_model; if (!window) { window = gtk_dialog_new_with_buttons ("GtkEntryCompletion", GTK_WINDOW (do_widget), 0, GTK_STOCK_CLOSE, GTK_RESPONSE_NONE, NULL); gtk_window_set_resizable (GTK_WINDOW (window), FALSE); g_signal_connect (window, "response", G_CALLBACK (gtk_widget_destroy), NULL); g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); vbox = gtk_vbox_new (FALSE, 5); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), vbox, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); label = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (label), "Completion demo, try writing <b>total</b> or <b>gnome</b> for example."); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); /* Create our entry */ entry = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); /* Create the completion object */ completion = gtk_entry_completion_new (); /* Assign the completion to the entry */ gtk_entry_set_completion (GTK_ENTRY (entry), completion); g_object_unref (completion); /* Create a tree model and use it as the completion model */ completion_model = create_completion_model (); gtk_entry_completion_set_model (completion, completion_model); g_object_unref (completion_model); /* Use model column 0 as the text column */ gtk_entry_completion_set_text_column (completion, 0); } if (!GTK_WIDGET_VISIBLE (window)) gtk_widget_show_all (window); else gtk_widget_destroy (window); return window; }
void C4PropertyDlg::UpdateInputCtrl(C4Object *pObj) { int cnt; #ifdef WITH_DEVELOPER_MODE GtkEntryCompletion *completion = gtk_entry_get_completion(GTK_ENTRY(entry)); GtkListStore *store; // Uncouple list store from completion so that the completion is not // notified for every row we are going to insert. This enhances // performance significantly. if (!completion) { completion = gtk_entry_completion_new(); store = gtk_list_store_new(1, G_TYPE_STRING); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_set_completion(GTK_ENTRY(entry), completion); g_object_unref(G_OBJECT(completion)); } else { store = GTK_LIST_STORE(gtk_entry_completion_get_model(completion)); g_object_ref(G_OBJECT(store)); gtk_entry_completion_set_model(completion, NULL); } GtkTreeIter iter; gtk_list_store_clear(store); #endif // WITH_DEVELOPER_MODE // add global and standard functions for (C4AulFunc *pFn = Game.ScriptEngine.GetFirstFunc(); pFn; pFn = Game.ScriptEngine.GetNextFunc(pFn)) if (pFn->GetPublic()) { SCopy(pFn->Name, OSTR); #ifdef WITH_DEVELOPER_MODE gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, OSTR, -1); #endif } // Add object script functions C4AulScriptFunc *pRef; // Object script available if (pObj && pObj->Def) // Scan all functions for (cnt = 0; pRef = pObj->Def->Script.GetSFunc(cnt); cnt++) // Public functions only if (pRef->Access = AA_PUBLIC) { // Add function SCopy(pRef->Name, OSTR); #ifdef WITH_DEVELOPER_MODE gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, OSTR, -1); #endif } #if WITH_DEVELOPER_MODE // Reassociate list store with completion gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store)); #endif }
static void make_xpath_completion (XpathExplorer *ttt) { GtkEntryCompletion *completion; completion = gtk_entry_completion_new(); gtk_entry_completion_set_text_column(completion, XML_TREE_MODEL_COL_XPATH); gtk_entry_set_completion(GTK_ENTRY(ttt->entry), completion); //g_signal_connect(G_OBJECT (completion), "match-selected", G_CALLBACK (xpath_match_select), ttt); g_signal_connect(ttt, "xpath-model-changed", G_CALLBACK(xpath_update_completion), ttt->entry); }
int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *vbox; GtkWidget *label; GtkWidget *entry; GtkEntryCompletion *completion; GtkListStore *store; GtkTreeIter iter; int i; // 作為自動完成時的項目提示 gchar *topics[] = { "C", "C++", "Java", "JSP", "JSF", "JUnit", "JavaScript" }; gtk_init (&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "GtkEntryCompletion"); gtk_window_set_default_size(GTK_WINDOW(window), 300, 50); // 使用GtkListStore儲存項目提示 store = gtk_list_store_new(1, G_TYPE_STRING); for(i = 0; i < 7; i++) { gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, topics[i], -1); } // 將GtkListStore設定給GtkEntryCompletion completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store)); gtk_entry_completion_set_text_column (completion, 0); label = gtk_label_new("請輸入技術主題"); // 建立GtkEntry entry = gtk_entry_new(); // 設定GtkEntryCompletion gtk_entry_set_completion(GTK_ENTRY(entry), completion); vbox = gtk_vbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX (vbox), entry, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER (window), vbox); g_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_widget_show_all (window); gtk_main(); return 0; }
/* test that we have a cell area after new() */ static void test_completion_new (void) { GtkEntryCompletion *c; GtkCellArea *area; c = gtk_entry_completion_new (); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (c)); g_assert (GTK_IS_CELL_AREA_BOX (area)); g_object_ref_sink (c); g_object_unref (c); }
explicit wxTextAutoCompleteData(wxTextEntry* entry) : m_entry(entry), m_widgetEntry(entry->GetEntry()) { // This will be really set in ToggleProcessEnterFlag(). m_hadProcessEnterFlag = false; GtkEntryCompletion* const completion = gtk_entry_completion_new(); gtk_entry_completion_set_text_column (completion, 0); gtk_entry_set_completion(m_widgetEntry, completion); g_signal_connect (m_widgetEntry, "grab-notify", G_CALLBACK (wx_gtk_entry_parent_grab_notify), this); }
static void hotssh_tab_init (HotSshTab *self) { HotSshTabPrivate *priv = hotssh_tab_get_instance_private (self); priv->settings = g_settings_new ("org.gnome.hotssh"); gtk_widget_init_template (GTK_WIDGET (self)); gtk_notebook_set_show_tabs ((GtkNotebook*)self, FALSE); g_signal_connect (priv->create_and_connect_button, "clicked", G_CALLBACK (on_create_and_connect), self); g_signal_connect (priv->add_new_connection_button, "clicked", G_CALLBACK (on_add_new_connection), self); g_signal_connect (priv->connect_cancel_button, "clicked", G_CALLBACK (on_connect_cancel), self); g_signal_connect (priv->error_disconnect, "clicked", G_CALLBACK (on_connect_cancel), self); g_signal_connect (priv->auth_cancel_button, "clicked", G_CALLBACK (on_connect_cancel), self); g_signal_connect (priv->approve_hostkey_button, "clicked", G_CALLBACK (on_approve_hostkey_clicked), self); g_signal_connect (priv->disapprove_hostkey_button, "clicked", G_CALLBACK (on_connect_cancel), self); g_signal_connect_swapped (priv->password_entry, "activate", G_CALLBACK (submit_password), self); g_signal_connect_swapped (priv->password_submit, "clicked", G_CALLBACK (submit_password), self); g_signal_connect (priv->connections_treeview, "row-activated", G_CALLBACK (on_connection_row_activated), self); priv->password_interaction = hotssh_password_interaction_new ((GtkEntry*)priv->password_entry); priv->terminal = vte_terminal_new (); g_signal_connect (priv->terminal, "realize", G_CALLBACK (on_vte_realize), self); vte_terminal_set_audible_bell ((VteTerminal*)priv->terminal, FALSE); /* Audible bell is a terrible idea */ g_signal_connect ((GObject*)priv->terminal, "size-allocate", G_CALLBACK (on_terminal_size_allocate), self); g_signal_connect ((GObject*)priv->terminal, "commit", G_CALLBACK (on_terminal_commit), self); gtk_box_pack_start ((GtkBox*)priv->terminal_box, priv->terminal, TRUE, TRUE, 0); gtk_range_set_adjustment ((GtkRange*)priv->terminal_vscrollbar, gtk_scrollable_get_vadjustment ((GtkScrollable*)priv->terminal)); gtk_widget_show_all (priv->terminal_box); g_queue_init (&priv->write_queue); { gs_unref_object HotSshHostDB *hostdb = hotssh_hostdb_get_instance (); gs_unref_object GtkTreeModel *hostdb_model = hotssh_hostdb_get_model (hostdb); priv->host_completion = gtk_entry_completion_new (); gtk_entry_completion_set_match_func (priv->host_completion, host_entry_match, self, NULL); gtk_entry_completion_set_model (priv->host_completion, hostdb_model); gtk_entry_completion_set_text_column (priv->host_completion, 0); gtk_entry_completion_set_inline_completion (priv->host_completion, TRUE); gtk_entry_set_completion ((GtkEntry*)priv->host_entry, priv->host_completion); } }
int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *grid; GtkWidget *label; GtkWidget *entry; GtkWidget *radio1; GtkWidget *radio2; GtkListStore *store; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Completion"); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_container_set_border_width(GTK_CONTAINER(window), 10); grid = gtk_grid_new(); gtk_container_add(GTK_CONTAINER(window), grid); label = gtk_label_new("There are completions for numbers from 'one' to 'ten'"); gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 2, 1); radio1 = gtk_radio_button_new_with_label(NULL, "Popup"); gtk_grid_attach(GTK_GRID(grid), radio1, 0, 1, 1, 1); radio2 = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(radio1), "Inline"); gtk_grid_attach(GTK_GRID(grid), radio2, 1, 1, 1, 1); entry = gtk_entry_new(); gtk_grid_attach(GTK_GRID(grid), entry, 0, 2, 2, 1); store = create_completion_list_store(); g_completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(g_completion, GTK_TREE_MODEL(store)); gtk_entry_completion_set_text_column(g_completion, 0); gtk_entry_set_completion(GTK_ENTRY(entry), g_completion); g_signal_connect(radio1, "toggled", G_CALLBACK(popup_radio_toggled), NULL); g_signal_connect(radio2, "toggled", G_CALLBACK(inline_radio_toggled), NULL); gtk_widget_show_all(window); gtk_main(); return 0; }
/* --------------------------------------------------------------------- * Create the dialog, return the entry * --------------------------------------------------------------------- */ static GtkWidget* create_dialog(GtkWidget **dialog, GtkTreeModel *completion_model) { GtkWidget *entry; GtkWidget *label; GtkWidget *vbox; GtkEntryCompletion *completion; *dialog = gtk_dialog_new_with_buttons("Go to File...", GTK_WINDOW(geany->main_widgets->window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); gtk_dialog_set_default_response(GTK_DIALOG(*dialog), GTK_RESPONSE_ACCEPT); gtk_widget_set_name(*dialog, "GotoFile"); vbox = ui_dialog_vbox_new(GTK_DIALOG(*dialog)); label = gtk_label_new(_("Enter the file you want to open:")); gtk_container_add(GTK_CONTAINER(vbox), label); /* Entry definition */ entry = gtk_entry_new(); gtk_container_add(GTK_CONTAINER(vbox), entry); gtk_entry_set_text(GTK_ENTRY(entry), ""); gtk_entry_set_max_length(GTK_ENTRY(entry), MAX_FILENAME_LENGTH); gtk_entry_set_width_chars(GTK_ENTRY(entry), 40); gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); /* 'enter' key */ /* Completion definition */ completion = gtk_entry_completion_new(); gtk_entry_set_completion(GTK_ENTRY(entry), completion); gtk_entry_completion_set_model (completion, completion_model); /* Completion options */ gtk_entry_completion_set_inline_completion(completion, 1); gtk_entry_completion_set_text_column (completion, 0); /* Signals */ g_signal_connect_after(GTK_ENTRY(entry), "changed", G_CALLBACK(directory_check), completion); gtk_widget_show_all(*dialog); return entry; }
void completion_add(struct tab *t) { /* enable completion for tab */ t->completion = gtk_entry_completion_new(); gtk_entry_completion_set_text_column(t->completion, 0); gtk_entry_set_completion(GTK_ENTRY(t->uri_entry), t->completion); gtk_entry_completion_set_model(t->completion, GTK_TREE_MODEL(completion_model)); gtk_entry_completion_set_match_func(t->completion, completion_match, NULL, NULL); gtk_entry_completion_set_minimum_key_length(t->completion, 1); gtk_entry_completion_set_inline_selection(t->completion, TRUE); g_signal_connect(G_OBJECT (t->completion), "match-selected", G_CALLBACK(completion_select_cb), t); g_signal_connect(G_OBJECT (t->completion), "cursor-on-match", G_CALLBACK(completion_hover_cb), t); }
static void share_nfs_add_hosts_completion (void) { GtkWidget *entry = gst_dialog_get_widget (tool->main_dialog, "share_nfs_hostname"); GtkEntryCompletion *completion; GtkListStore *store; completion = gtk_entry_completion_new (); store = gtk_list_store_new (1, G_TYPE_STRING); gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (store)); g_object_unref (store); gtk_entry_set_completion (GTK_ENTRY (entry), completion); g_object_unref (completion); gtk_entry_completion_set_text_column (completion, 0); populate_hosts_completion (store); }
static void fm_path_entry_init(FmPathEntry *entry) { FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry); GtkEntryCompletion* completion = gtk_entry_completion_new(); GtkCellRenderer* render; priv->model = fm_path_entry_model_new(entry); priv->completion = completion; priv->cancellable = g_cancellable_new(); priv->highlight_completion_match = TRUE; gtk_entry_completion_set_minimum_key_length(completion, 1); gtk_entry_completion_set_match_func(completion, fm_path_entry_match_func, NULL, NULL); g_object_set(completion, "text_column", COL_FULL_PATH, NULL); gtk_entry_completion_set_model(completion, priv->model); render = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start( (GtkCellLayout*)completion, render, TRUE ); gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(completion), render, fm_path_entry_completion_render_func, entry, NULL); /* NOTE: this is to avoid a bug of gtk+. * The inline selection provided by GtkEntry is buggy. * If we change the content of the entry, it still stores * the old prefix sometimes so things don't work as expected. * So, unfortunately, we're not able to use this nice feature. * * Please see gtk_entry_completion_key_press() of gtk/gtkentry.c * and look for completion->priv->completion_prefix. */ gtk_entry_completion_set_inline_selection(completion, FALSE); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_completion_set_popup_set_width(completion, TRUE); /* gtk_entry_completion_set_popup_single_match(completion, FALSE); */ /* connect to these signals rather than overriding default handlers since * we want to invoke our handlers before the default ones provided by Gtk. */ g_signal_connect(entry, "key-press-event", G_CALLBACK(fm_path_entry_key_press), NULL); g_signal_connect(entry, "activate", G_CALLBACK(fm_path_entry_on_activate), NULL); g_signal_connect(entry, "populate-popup", G_CALLBACK(fm_path_entry_populate_popup), NULL); }