+2003-12-03 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilechooserentry.c (struct _GtkFileChooserEntry): Removed
+ the in_change flag.
+ (completion_idle_callback): Use a temporary list store and re-set
+ it on the completion rather than modifying the old one. We are
+ re-reading the folder anyway, and this gets rid of non-atomicity
+ problems.
+
2003-12-01 Federico Mena Quintero <federico@ximian.com>
Decouple impl->current_folder from the selection in the folder
GtkListStore *completion_store;
- guint in_change : 1;
guint has_completion : 1;
};
GSList *tmp_list;
gchar *common_prefix = NULL;
GtkFilePath *unique_path = NULL;
+ GtkListStore *new_store;
chooser_entry->completion_idle = NULL;
&child_paths,
NULL); /* NULL-GError */
- chooser_entry->in_change = TRUE;
- gtk_list_store_clear (chooser_entry->completion_store);
+ new_store = gtk_list_store_new (1, G_TYPE_STRING);
for (tmp_list = child_paths; tmp_list; tmp_list = tmp_list->next)
{
const gchar *display_name = gtk_file_info_get_display_name (info);
GtkTreeIter iter;
- gtk_list_store_append (chooser_entry->completion_store, &iter);
- gtk_list_store_set (chooser_entry->completion_store, &iter,
+ gtk_list_store_append (new_store, &iter);
+ gtk_list_store_set (new_store, &iter,
0, display_name,
-1);
gtk_file_info_free (info);
}
}
- chooser_entry->in_change = FALSE;
+
+ g_object_unref (chooser_entry->completion_store);
+ chooser_entry->completion_store = new_store;
+ gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)),
+ GTK_TREE_MODEL (new_store));
if (unique_path)
{
if (common_prefix_len > file_part_len)
{
- chooser_entry->in_change = TRUE;
-
pos = total_len - file_part_len;
gtk_editable_delete_text (editable,
pos, -1);
gtk_editable_select_region (editable,
total_len,
total_len - file_part_len + common_prefix_len);
-
- chooser_entry->in_change = FALSE;
+
chooser_entry->has_completion = TRUE;
}
gint *position)
{
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (editable);
- char *tmp;
parent_editable_iface->do_insert_text (editable, new_text, new_text_length, position);
- if (!chooser_entry->in_change &&
- *position == GTK_ENTRY (editable)->text_length &&
+ if (*position == GTK_ENTRY (editable)->text_length &&
!chooser_entry->completion_idle)
{
chooser_entry->completion_idle = g_idle_source_new ();
{
g_return_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry));
- chooser_entry->in_change = TRUE;
gtk_entry_set_text (GTK_ENTRY (chooser_entry), file_part);
- chooser_entry->in_change = FALSE;
}