summaryrefslogtreecommitdiff
path: root/thunar/thunar-chooser-dialog.c
diff options
context:
space:
mode:
authorAlexander Schwinn <alexxcons@xfce.org>2020-12-07 23:46:56 +0100
committerAlexander Schwinn <alexxcons@xfce.org>2020-12-08 09:53:48 +0100
commit3705fdf36e7bcfc0c2a6fd8ca87fc7afc1167c62 (patch)
treee976e4fe3900936b1fdb046de3568dae84fe5faa /thunar/thunar-chooser-dialog.c
parent7316aabab07444e546ab640f5582ef3e8757ecbc (diff)
downloadthunar-3705fdf36e7bcfc0c2a6fd8ca87fc7afc1167c62.tar.gz
Do not duplicate app_info when added via custom command (Issue #309)
Targets app_info added via "open with"-->"other application"--> "custom command" Introduces a comparison check to dont add the same app_info multiple times. Fixes #309
Diffstat (limited to 'thunar/thunar-chooser-dialog.c')
-rw-r--r--thunar/thunar-chooser-dialog.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/thunar/thunar-chooser-dialog.c b/thunar/thunar-chooser-dialog.c
index 05bdbb8c..65986ecf 100644
--- a/thunar/thunar-chooser-dialog.c
+++ b/thunar/thunar-chooser-dialog.c
@@ -395,6 +395,7 @@ thunar_chooser_dialog_response (GtkDialog *widget,
const gchar *custom_command;
gchar *name;
GList list;
+ GList *all_apps, *lp;
GdkScreen *screen;
/* no special processing for non-accept responses */
@@ -421,6 +422,9 @@ thunar_chooser_dialog_response (GtkDialog *widget,
/* try to add an application for the custom command */
app_info = g_app_info_create_from_commandline (custom_command, name, G_APP_INFO_CREATE_NONE, &error);
+ /* cleanup */
+ g_free (name);
+
/* verify the application */
if (G_UNLIKELY (app_info == NULL))
{
@@ -429,10 +433,23 @@ thunar_chooser_dialog_response (GtkDialog *widget,
/* release the error */
g_error_free (error);
+ return;
}
- /* cleanup */
- g_free (name);
+ /* Check if that application already exists in our list */
+ all_apps = g_app_info_get_all ();
+ for (lp = all_apps; lp != NULL; lp = lp->next)
+ {
+ if( g_strcmp0 (g_app_info_get_name (lp->data), g_app_info_get_name (app_info)) == 0 &&
+ g_strcmp0 (g_app_info_get_commandline (lp->data), g_app_info_get_commandline (app_info)) == 0)
+ {
+ /* Re-use existing app-info instead of adding the same one again */
+ g_object_unref (app_info);
+ app_info = g_object_ref (lp->data);
+ break;
+ }
+ }
+ g_list_free_full (all_apps, g_object_unref);
}
/* verify that we have a valid application */