From 21f910b8de281b999f7985f44c80f8a327a0e6f3 Mon Sep 17 00:00:00 2001 From: Dennis Gert Date: Wed, 18 May 2022 17:43:31 +0000 Subject: [PATCH 1/3] Update gtk/gtkfilechooserentry.c --- gtk/gtkfilechooserentry.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index 2bf47a067e..2ce1e3cc8c 100644 --- a/gtk/gtkfilechooserentry.c +++ b/gtk/gtkfilechooserentry.c @@ -182,6 +182,7 @@ _gtk_file_chooser_entry_class_init (GtkFileChooserEntryClass *class) G_TYPE_NONE, 0); } +/* static gboolean match_func (GtkEntryCompletion *compl, const char *key, @@ -190,9 +191,9 @@ match_func (GtkEntryCompletion *compl, { 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 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; @@ -203,7 +204,7 @@ match_func (GtkEntryCompletion *compl, 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 */ + // 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; @@ -215,6 +216,7 @@ match_func (GtkEntryCompletion *compl, return TRUE; } +*/ static void chooser_entry_focus_out (GtkEventController *controller, @@ -227,19 +229,20 @@ static void _gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry) { GtkEventController *controller; - GtkEntryCompletion *comp; - GtkCellRenderer *cell; + //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() */ + // 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. */ + // 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, @@ -257,6 +260,7 @@ _gtk_file_chooser_entry_init (GtkFileChooserEntry *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 */ @@ -308,6 +312,8 @@ gtk_file_chooser_entry_dispose (GObject *object) } /* Match functions for the GtkEntryCompletion */ + +/* static gboolean match_selected_callback (GtkEntryCompletion *completion, GtkTreeModel *model, @@ -336,6 +342,7 @@ match_selected_callback (GtkEntryCompletion *completion, return TRUE; } +*/ static void set_complete_on_load (GtkFileChooserEntry *chooser_entry, @@ -664,7 +671,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 +840,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 +922,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 +959,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 +968,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; } -- GitLab From ef3bdd92d20b4567d2e7b39bd0a2e605f25f0cfe Mon Sep 17 00:00:00 2001 From: Dennis Gert Date: Wed, 18 May 2022 18:17:46 +0000 Subject: [PATCH 2/3] Update gtk/gtkfilechooserentry.c --- gtk/gtkfilechooserentry.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index 2ce1e3cc8c..a675896966 100644 --- a/gtk/gtkfilechooserentry.c +++ b/gtk/gtkfilechooserentry.c @@ -103,11 +103,11 @@ static void delete_text_callback (GtkFileChooserEntry *widget, gpointer user_data); #endif -static gboolean match_selected_callback (GtkEntryCompletion *completion, +/*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); -- GitLab From c0406b808be067ccc6ee81cf11e36868a383ac72 Mon Sep 17 00:00:00 2001 From: Dennis Gert Date: Wed, 18 May 2022 19:12:19 +0000 Subject: [PATCH 3/3] Update gtk/gtkfilechooserentry.c --- gtk/gtkfilechooserentry.c | 104 -------------------------------------- 1 file changed, 104 deletions(-) diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index a675896966..a75f1d9c13 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,42 +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) @@ -229,39 +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 (); @@ -311,39 +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) -- GitLab