Skip to content
Snippets Groups Projects
Commit 5df98970 authored by Harald Judt's avatar Harald Judt
Browse files

Remember the last used application when opening files

Remembering the last used application will move it to the top of the
list of alternatives.
parent 98300e06
No related branches found
No related tags found
No related merge requests found
...@@ -526,9 +526,12 @@ thunar_g_app_info_launch (GAppInfo *info, ...@@ -526,9 +526,12 @@ thunar_g_app_info_launch (GAppInfo *info,
GAppLaunchContext *context, GAppLaunchContext *context,
GError **error) GError **error)
{ {
gboolean result = FALSE; ThunarFile *file;
gchar *new_path = NULL; GList *lp;
gchar *old_path = NULL; const gchar *content_type;
gboolean result = FALSE;
gchar *new_path = NULL;
gchar *old_path = NULL;
_thunar_return_val_if_fail (G_IS_APP_INFO (info), FALSE); _thunar_return_val_if_fail (G_IS_APP_INFO (info), FALSE);
_thunar_return_val_if_fail (working_directory == NULL || G_IS_FILE (working_directory), FALSE); _thunar_return_val_if_fail (working_directory == NULL || G_IS_FILE (working_directory), FALSE);
...@@ -554,6 +557,25 @@ thunar_g_app_info_launch (GAppInfo *info, ...@@ -554,6 +557,25 @@ thunar_g_app_info_launch (GAppInfo *info,
/* launch the paths with the specified app info */ /* launch the paths with the specified app info */
result = g_app_info_launch (info, path_list, context, error); result = g_app_info_launch (info, path_list, context, error);
/* if successful, remember the application as last used for the file types */
if (result == TRUE)
{
for (lp = path_list; lp != NULL; lp = lp->next)
{
file = thunar_file_get (lp->data, NULL);
if (file != NULL)
{
content_type = thunar_file_get_content_type (file);
/* emit "changed" on the file if we successfully changed the last used application */
if (g_app_info_set_as_last_used_for_type (info, content_type, NULL))
thunar_file_changed (file);
g_object_unref (file);
}
}
}
/* check if we need to reset the working directory to the one Thunar was /* check if we need to reset the working directory to the one Thunar was
* opened from */ * opened from */
if (old_path != NULL) if (old_path != NULL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment