diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index 2bf47a067ec7630e8be7d2f8c0ebfb669e90e82c..a75f1d9c13e3ed819a0a87296fc90c460d121e3c 100644 --- a/gtk/gtkfilechooserentry.c +++ b/gtk/gtkfilechooserentry.c @@ -103,11 +103,6 @@ static void delete_text_callback (GtkFileChooserEntry *widget, gpointer user_data); #endif -static gboolean match_selected_callback (GtkEntryCompletion *completion, - GtkTreeModel *model, - GtkTreeIter *iter, - GtkFileChooserEntry *chooser_entry); - static void set_complete_on_load (GtkFileChooserEntry *chooser_entry, gboolean complete_on_load); static void refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry); @@ -182,40 +177,6 @@ _gtk_file_chooser_entry_class_init (GtkFileChooserEntryClass *class) G_TYPE_NONE, 0); } -static gboolean -match_func (GtkEntryCompletion *compl, - const char *key, - GtkTreeIter *iter, - gpointer user_data) -{ - GtkFileChooserEntry *chooser_entry = user_data; - - /* If we arrive here, the GtkFileSystemModel's GtkFileFilter already filtered out all - * files that don't start with the current prefix, so we manually apply the GtkFileChooser's - * current file filter (e.g. just jpg files) here. */ - if (chooser_entry->current_filter != NULL) - { - GFile *file; - GFileInfo *info; - - file = _gtk_file_system_model_get_file (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store), - iter); - info = _gtk_file_system_model_get_info (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store), - iter); - - /* We always allow navigating into subfolders, so don't ever filter directories */ - if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR) - return TRUE; - - if (!g_file_info_has_attribute (info, "standard::file")) - g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file)); - - return gtk_filter_match (GTK_FILTER (chooser_entry->current_filter), info); - } - - return TRUE; -} - static void chooser_entry_focus_out (GtkEventController *controller, GtkFileChooserEntry *chooser_entry) @@ -227,37 +188,9 @@ static void _gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry) { GtkEventController *controller; - GtkEntryCompletion *comp; - GtkCellRenderer *cell; g_object_set (chooser_entry, "truncate-multiline", TRUE, NULL); - comp = gtk_entry_completion_new (); - gtk_entry_completion_set_popup_single_match (comp, FALSE); - gtk_entry_completion_set_minimum_key_length (comp, 0); - /* see docs for gtk_entry_completion_set_text_column() */ - g_object_set (comp, "text-column", FULL_PATH_COLUMN, NULL); - - /* Need a match func here or entry completion uses a wrong one. - * We do our own filtering after all. */ - gtk_entry_completion_set_match_func (comp, - match_func, - chooser_entry, - NULL); - - cell = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (comp), - cell, TRUE); - gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (comp), - cell, - "text", DISPLAY_NAME_COLUMN); - - g_signal_connect (comp, "match-selected", - G_CALLBACK (match_selected_callback), chooser_entry); - - gtk_entry_set_completion (GTK_ENTRY (chooser_entry), comp); - g_object_unref (comp); - /* NB: This needs to happen after the completion is set, so this controller * runs before the one installed by entrycompletion */ controller = gtk_event_controller_key_new (); @@ -307,36 +240,6 @@ gtk_file_chooser_entry_dispose (GObject *object) G_OBJECT_CLASS (_gtk_file_chooser_entry_parent_class)->dispose (object); } -/* Match functions for the GtkEntryCompletion */ -static gboolean -match_selected_callback (GtkEntryCompletion *completion, - GtkTreeModel *model, - GtkTreeIter *iter, - GtkFileChooserEntry *chooser_entry) -{ - char *path; - int pos; - - gtk_tree_model_get (model, iter, - FULL_PATH_COLUMN, &path, - -1); - - gtk_editable_delete_text (GTK_EDITABLE (chooser_entry), - 0, - gtk_editable_get_position (GTK_EDITABLE (chooser_entry))); - pos = 0; - gtk_editable_insert_text (GTK_EDITABLE (chooser_entry), - path, - -1, - &pos); - - gtk_editable_set_position (GTK_EDITABLE (chooser_entry), pos); - - g_free (path); - - return TRUE; -} - static void set_complete_on_load (GtkFileChooserEntry *chooser_entry, gboolean complete_on_load) @@ -664,7 +567,7 @@ set_completion_folder (GtkFileChooserEntry *chooser_entry, g_free (chooser_entry->dir_part); chooser_entry->dir_part = g_strdup (dir_part); - + chooser_entry->current_folder_loaded = FALSE; discard_completion_store (chooser_entry); @@ -833,7 +736,7 @@ _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry, g_return_if_fail (file == NULL || G_IS_FILE (file)); if (chooser_entry->base_folder == file || - (file != NULL && chooser_entry->base_folder != NULL + (file != NULL && chooser_entry->base_folder != NULL && g_file_equal (chooser_entry->base_folder, file))) return; @@ -915,7 +818,7 @@ _gtk_file_chooser_entry_set_action (GtkFileChooserEntry *chooser_entry, GtkFileChooserAction action) { g_return_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry)); - + if (chooser_entry->action != action) { GtkEntryCompletion *comp; @@ -952,7 +855,7 @@ _gtk_file_chooser_entry_set_action (GtkFileChooserEntry *chooser_entry, * _gtk_file_chooser_entry_get_action: * @chooser_entry: a `GtkFileChooserEntry` * - * Gets the action for this entry. + * Gets the action for this entry. * * Returns: the action **/ @@ -961,7 +864,7 @@ _gtk_file_chooser_entry_get_action (GtkFileChooserEntry *chooser_entry) { g_return_val_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry), GTK_FILE_CHOOSER_ACTION_OPEN); - + return chooser_entry->action; }