[Gnucash-changes] r14349 - gnucash/branches/deprecated-cleanup/src/core-utils - Allow completion without requiring that the entered text be present in

David Hampton hampton at cvs.gnucash.org
Fri Jun 9 00:35:00 EDT 2006


Author: hampton
Date: 2006-06-09 00:34:59 -0400 (Fri, 09 Jun 2006)
New Revision: 14349
Trac: http://svn.gnucash.org/trac/changeset/14349

Modified:
   gnucash/branches/deprecated-cleanup/src/core-utils/gnc-gtk-utils.c
   gnucash/branches/deprecated-cleanup/src/core-utils/gnc-gtk-utils.h
Log:
Allow completion without requiring that the entered text be present in
the model.  Used for new entry of new namespaces.


Modified: gnucash/branches/deprecated-cleanup/src/core-utils/gnc-gtk-utils.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/core-utils/gnc-gtk-utils.c	2006-06-08 11:52:46 UTC (rev 14348)
+++ gnucash/branches/deprecated-cleanup/src/core-utils/gnc-gtk-utils.c	2006-06-09 04:34:59 UTC (rev 14349)
@@ -155,29 +155,43 @@
 }
 
 void
-gnc_cbe_require_list_item (GtkComboBoxEntry *cbe)
+gnc_cbe_add_completion (GtkComboBoxEntry *cbe)
 {
   GtkEntry *entry;
   GtkEntryCompletion *completion;
   GtkTreeModel *model;
-  GtkTreeIter iter;
-  gint index, id;
 
   entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(cbe)));
   completion = gtk_entry_get_completion(entry);
+  if (completion)
+    return;
 
   /* No completion yet? Set one up. */
-  if (!completion) {
-    completion = gtk_entry_completion_new();
-    model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbe));
-    gtk_entry_completion_set_model(completion, model);
-    gtk_entry_completion_set_text_column(completion, 0);
-    gtk_entry_set_completion(entry, completion);
-  }
+  completion = gtk_entry_completion_new();
+  model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbe));
+  gtk_entry_completion_set_model(completion, model);
+  gtk_entry_completion_set_text_column(completion, 0);
+  gtk_entry_completion_set_inline_completion(completion, TRUE);
+  gtk_entry_set_completion(entry, completion);
+}
 
+void
+gnc_cbe_require_list_item (GtkComboBoxEntry *cbe)
+{
+  GtkEntry *entry;
+  GtkEntryCompletion *completion;
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  gint index, id;
+
+  /* Ensure completion is set up. */
+  gnc_cbe_add_completion(cbe);
+
   /* If an item in the combo box isn't already selected, then force
    * select the first item. Take care, the combo box may not have been
    * filled yet.  */
+  entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(cbe)));
+  completion = gtk_entry_get_completion(entry);
   index = gtk_combo_box_get_active(GTK_COMBO_BOX(cbe));
   if (index == -1) {
     model = gtk_entry_completion_get_model(completion);

Modified: gnucash/branches/deprecated-cleanup/src/core-utils/gnc-gtk-utils.h
===================================================================
--- gnucash/branches/deprecated-cleanup/src/core-utils/gnc-gtk-utils.h	2006-06-08 11:52:46 UTC (rev 14348)
+++ gnucash/branches/deprecated-cleanup/src/core-utils/gnc-gtk-utils.h	2006-06-09 04:34:59 UTC (rev 14349)
@@ -44,6 +44,7 @@
 */
 
 void gnc_cbe_set_by_string(GtkComboBoxEntry *cbe, const gchar *text);
+void gnc_cbe_add_completion (GtkComboBoxEntry *cbe);
 void gnc_cbe_require_list_item (GtkComboBoxEntry *cbe);
 
 



More information about the gnucash-changes mailing list