From eb8426247302eb4d7cbd9c6d8d9be41f2fe5ac77 Mon Sep 17 00:00:00 2001 From: Thaddaeus Tintenfisch Date: Sat, 21 Feb 2015 10:07:03 +0100 Subject: [PATCH] Hide template file extensions in context menu (bug #11571) --- thunar/thunar-templates-action.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/thunar/thunar-templates-action.c b/thunar/thunar-templates-action.c index eb5081d..945ee51 100644 --- a/thunar/thunar-templates-action.c +++ b/thunar/thunar-templates-action.c @@ -321,6 +321,8 @@ thunar_templates_action_files_ready (ThunarJob *job, GList *items = NULL; GList *parent_menus = NULL; GList *pp; + gchar *label; + gchar *dot; /* determine the menu to add the items and submenus to */ menu = g_object_get_data (G_OBJECT (job), "menu"); @@ -363,14 +365,22 @@ thunar_templates_action_files_ready (ThunarJob *job, } else { + /* generate a label by stripping off the extension */ + label = g_strdup (thunar_file_get_display_name (file)); + dot = g_utf8_strrchr (label, -1, '.'); + if (dot) + *dot = '\0'; + /* allocate a new menu item */ - item = gtk_image_menu_item_new_with_label (thunar_file_get_display_name (file)); + item = gtk_image_menu_item_new_with_label (label); g_object_set_data_full (G_OBJECT (item), I_("thunar-file"), g_object_ref (file), g_object_unref); g_signal_connect (item, "activate", G_CALLBACK (item_activated), templates_action); gtk_menu_shell_append (GTK_MENU_SHELL (parent_menu), item); gtk_widget_show (item); + + g_free(label); } /* determine the icon for this file/directory */ -- 2.1.4