filechooser: search, location and mount fixes from GTK 3

Backported from GTK 3:

- search results
- the location entry in local-only mode
- folder activation
- long bookmark names
- recent filters by MIME type
- the process list of mount operations
- icon caches

Upstream commits:

- 8a53ed9e55 (Christoph Reiter)
- d254089308 (Cosimo Cecchi)
- abef21776d (Philip Withnall)
- 3923ba1605 (Matthias Clasen)
This commit is contained in:
Daemonratte 2026-10-18 13:31:17 +02:00
commit 6d3cf209af
8 changed files with 30 additions and 15 deletions

View file

@ -625,10 +625,9 @@ unselect_current_file (GtkFileChooserButton *button)
{
g_object_unref (priv->selection_while_inactive);
priv->selection_while_inactive = NULL;
priv->is_changing_selection = TRUE;
}
priv->is_changing_selection = TRUE;
update_label_and_image (button);
update_combo_box (button);
}
@ -2347,6 +2346,8 @@ name_cell_data_func (GtkCellLayout *layout,
if (type == ROW_TYPE_CURRENT_FOLDER)
g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
else if (type == ROW_TYPE_BOOKMARK || type == ROW_TYPE_SHORTCUT)
g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_MIDDLE, NULL);
else
g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_NONE, NULL);
}

View file

@ -7000,6 +7000,7 @@ location_switch_to_filename_entry (GtkFileChooserDefault *impl)
/* Configure the entry */
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (impl->location_entry), impl->current_folder);
_gtk_file_chooser_entry_set_local_only (GTK_FILE_CHOOSER_ENTRY (impl->location_entry), impl->local_only);
/* Done */
@ -12573,7 +12574,7 @@ search_selected_foreach_get_file_cb (GtkTreeModel *model,
list = data;
gtk_tree_model_get (model, iter, MODEL_COL_FILE, &file, -1);
*list = g_slist_prepend (*list, g_object_ref (file));
*list = g_slist_prepend (*list, file); /* The file already has a new ref courtesy of gtk_tree_model_get(); this will be unreffed by the caller */
}
/* Constructs a list of the selected paths in search mode */
@ -13680,13 +13681,15 @@ item_activated (GtkTreeModel *model,
if (is_sensitive && is_folder && file)
{
change_folder_and_display_error (impl, file, FALSE);
return;
goto out;
}
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
g_signal_emit_by_name (impl, "file-activated");
out:
if (file)
g_object_unref (file);
}

View file

@ -233,6 +233,9 @@ find_image_offset (GtkIconCache *cache,
guint32 image_list_offset, n_images;
int i;
if (!icon_name)
return 0;
chain_offset = cache->last_chain_offset;
if (chain_offset)
{

View file

@ -658,7 +658,7 @@ pid_get_env (GPid pid,
n = 0;
while (TRUE)
{
if (env[n] == '\0' || n >= env_len)
if (n >= env_len || env[n] == '\0')
break;
if (g_str_has_prefix (env + n, key) && (*(env + n + key_len) == '='))
@ -671,7 +671,7 @@ pid_get_env (GPid pid,
break;
}
for (; env[n] != '\0' && n < env_len; n++)
for (; n < env_len && env[n] != '\0'; n++)
;
n++;
}

View file

@ -1180,7 +1180,7 @@ on_button_press_event_for_process_tree_view (GtkWidget *widget,
return ret;
}
static void
static GtkWidget *
create_show_processes_dialog (GMountOperation *op,
const char *message,
const char *choices[])
@ -1308,9 +1308,9 @@ create_show_processes_dialog (GMountOperation *op,
g_object_add_weak_pointer (G_OBJECT (tree_view), (gpointer *) &priv->process_tree_view);
g_object_unref (list_store);
gtk_widget_show_all (dialog);
g_object_ref (op);
return dialog;
}
static void
@ -1320,6 +1320,7 @@ gtk_mount_operation_show_processes (GMountOperation *op,
const char *choices[])
{
GtkMountOperationPrivate *priv;
GtkWidget *dialog = NULL;
g_return_if_fail (GTK_IS_MOUNT_OPERATION (op));
g_return_if_fail (message != NULL);
@ -1331,7 +1332,7 @@ gtk_mount_operation_show_processes (GMountOperation *op,
if (priv->process_list_store == NULL)
{
/* need to create the dialog */
create_show_processes_dialog (op, message, choices);
dialog = create_show_processes_dialog (op, message, choices);
}
/* otherwise, we're showing the dialog, assume messages+choices hasn't changed */
@ -1339,6 +1340,11 @@ gtk_mount_operation_show_processes (GMountOperation *op,
update_process_list_store (GTK_MOUNT_OPERATION (op),
priv->process_list_store,
processes);
if (dialog != NULL)
{
gtk_widget_show_all (dialog);
}
}
static void

View file

@ -1183,6 +1183,9 @@ static void
gtk_recent_chooser_sync_action_properties (GtkActivatable *activatable,
GtkAction *action)
{
if (!action)
return;
gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
_gtk_recent_chooser_sync_action_properties (activatable, action);

View file

@ -488,11 +488,12 @@ gtk_recent_filter_filter (GtkRecentFilter *filter,
if (filter_info->mime_type != NULL)
{
gchar *filter_content_type, *rule_content_type;
gboolean match;
gboolean match = FALSE;
filter_content_type = g_content_type_from_mime_type (filter_info->mime_type);
rule_content_type = g_content_type_from_mime_type (rule->u.mime_type);
match = g_content_type_is_a (filter_content_type, rule_content_type);
if (filter_content_type != NULL && rule_content_type != NULL)
match = g_content_type_is_a (filter_content_type, rule_content_type);
g_free (filter_content_type);
g_free (rule_content_type);

View file

@ -314,8 +314,7 @@ load_icon_data (const char *path)
data->n_attach_points = g_strv_length (split);
data->attach_points = g_new (int, 2 * data->n_attach_points);
i = 0;
while (split[i] != NULL && i < data->n_attach_points)
for (i = 0; i < data->n_attach_points; ++i)
{
split_point = strchr (split[i], ',');
if (split_point)
@ -325,7 +324,6 @@ load_icon_data (const char *path)
data->attach_points[2 * i] = atoi (split[i]);
data->attach_points[2 * i + 1] = atoi (split_point);
}
i++;
}
g_strfreev (split);