summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Müllner <[email protected]>2016-01-20 18:48:20 +0100
committerVictor Kareh <[email protected]>2026-05-29 12:44:00 -0400
commit6bd8c75111e6a83bf9af0e8631f479f5ebb0d9d4 (patch)
treea5c79d46254366327c9814d6d91026cf0c7a59f5
parent6bff5a7d03a80135be2127c2533dab1f40266c8b (diff)
downloadmate-menus-6bd8c75111e6a83bf9af0e8631f479f5ebb0d9d4.tar.bz2
mate-menus-6bd8c75111e6a83bf9af0e8631f479f5ebb0d9d4.tar.xz
libmenu: Remove support for legacy-dirs
Those directories have been deprecated for over a decade and GIO's GDesktopAppInfo API already ignores them ... It's time to let go, simply ignore any <LegacyKDEDirs> and <LegacyDir> elements in menus. Backported from https://gitlab.gnome.org/GNOME/gnome-menus/-/commit/13c6790a Fixes #108
-rw-r--r--layout/mate-applications.menu5
-rw-r--r--libmenu/desktop-entries.c36
-rw-r--r--libmenu/desktop-entries.h2
-rw-r--r--libmenu/entry-directories.c55
-rw-r--r--libmenu/entry-directories.h1
-rw-r--r--libmenu/matemenu-tree.c247
-rw-r--r--libmenu/menu-layout.c34
7 files changed, 6 insertions, 374 deletions
diff --git a/layout/mate-applications.menu b/layout/mate-applications.menu
index 9037852..839b0b5 100644
--- a/layout/mate-applications.menu
+++ b/layout/mate-applications.menu
@@ -6,11 +6,6 @@
<Name>Applications</Name>
<Directory>mate-menu-applications.directory</Directory>
- <!-- Scan legacy dirs first, as later items take priority -->
- <KDELegacyDirs/>
- <LegacyDir>/etc/X11/applnk</LegacyDir>
- <LegacyDir>/usr/share/mate/apps</LegacyDir>
-
<!-- Read standard .directory and .desktop file locations -->
<DefaultAppDirs/>
<DefaultDirectoryDirs/>
diff --git a/libmenu/desktop-entries.c b/libmenu/desktop-entries.c
index 2cbe385..6b8deaa 100644
--- a/libmenu/desktop-entries.c
+++ b/libmenu/desktop-entries.c
@@ -623,42 +623,6 @@ gboolean desktop_entry_has_category(DesktopEntry* entry, const char* category)
return FALSE;
}
-void desktop_entry_add_legacy_category(DesktopEntry* entry)
-{
- GQuark *categories;
- gsize i;
- DesktopEntryDesktop *desktop_entry;
-
- g_return_if_fail (entry->type == DESKTOP_ENTRY_DESKTOP);
-
- desktop_entry = (DesktopEntryDesktop*) entry;
-
- menu_verbose ("Adding Legacy category to \"%s\"\n",
- entry->basename);
-
- if (desktop_entry->categories != NULL)
- {
- i = 0;
- for (; desktop_entry->categories[i]; i++);
-
- categories = g_new0 (GQuark, i + 2);
-
- i = 0;
- for (; desktop_entry->categories[i]; i++)
- categories[i] = desktop_entry->categories[i];
- }
- else
- {
- categories = g_new0 (GQuark, 2);
- i = 0;
- }
-
- categories[i] = g_quark_from_string ("Legacy");
-
- g_free (desktop_entry->categories);
- desktop_entry->categories = categories;
-}
-
/*
* Entry sets
*/
diff --git a/libmenu/desktop-entries.h b/libmenu/desktop-entries.h
index 75827f1..f6dd894 100644
--- a/libmenu/desktop-entries.h
+++ b/libmenu/desktop-entries.h
@@ -57,8 +57,6 @@ gboolean desktop_entry_has_categories (DesktopEntry *entry);
gboolean desktop_entry_has_category (DesktopEntry *entry,
const char *category);
-void desktop_entry_add_legacy_category(DesktopEntry* src);
-
typedef struct DesktopEntrySet DesktopEntrySet;
DesktopEntrySet* desktop_entry_set_new(void);
diff --git a/libmenu/entry-directories.c b/libmenu/entry-directories.c
index 3970c95..da05173 100644
--- a/libmenu/entry-directories.c
+++ b/libmenu/entry-directories.c
@@ -39,10 +39,8 @@ typedef struct CachedDirMonitor CachedDirMonitor;
struct EntryDirectory {
CachedDir* dir;
- char* legacy_prefix;
guint entry_type: 2;
- guint is_legacy: 1;
guint refcount: 24;
};
@@ -726,14 +724,12 @@ static void cached_dir_remove_reference(CachedDir* dir)
* Entry directories
*/
-static EntryDirectory* entry_directory_new_full(DesktopEntryType entry_type, const char* path, gboolean is_legacy, const char* legacy_prefix)
+EntryDirectory* entry_directory_new(DesktopEntryType entry_type, const char* path)
{
EntryDirectory *ed;
char *canonical;
- menu_verbose ("Loading entry directory \"%s\" (legacy %s)\n",
- path,
- is_legacy ? "<yes>" : "<no>");
+ menu_verbose ("Loading entry directory \"%s\"\n", path);
canonical = realpath (path, NULL);
if (canonical == NULL)
@@ -751,9 +747,7 @@ static EntryDirectory* entry_directory_new_full(DesktopEntryType entry_type, con
cached_dir_add_reference (ed->dir);
cached_dir_load_entries_recursive (ed->dir, canonical);
- ed->legacy_prefix = g_strdup (legacy_prefix);
ed->entry_type = entry_type;
- ed->is_legacy = is_legacy != FALSE;
ed->refcount = 1;
g_free (canonical);
@@ -761,16 +755,6 @@ static EntryDirectory* entry_directory_new_full(DesktopEntryType entry_type, con
return ed;
}
-EntryDirectory* entry_directory_new(DesktopEntryType entry_type, const char* path)
-{
- return entry_directory_new_full (entry_type, path, FALSE, NULL);
-}
-
-EntryDirectory* entry_directory_new_legacy(DesktopEntryType entry_type, const char* path, const char* legacy_prefix)
-{
- return entry_directory_new_full(entry_type, path, TRUE, legacy_prefix);
-}
-
EntryDirectory* entry_directory_ref(EntryDirectory* ed)
{
g_return_val_if_fail(ed != NULL, NULL);
@@ -792,10 +776,6 @@ void entry_directory_unref(EntryDirectory* ed)
ed->dir = NULL;
ed->entry_type = DESKTOP_ENTRY_INVALID;
- ed->is_legacy = FALSE;
-
- g_free (ed->legacy_prefix);
- ed->legacy_prefix = NULL;
g_free (ed);
}
@@ -833,26 +813,7 @@ static char* get_desktop_file_id_from_path(EntryDirectory* ed, DesktopEntryType
if (entry_type == DESKTOP_ENTRY_DESKTOP)
{
- if (!ed->is_legacy)
- {
- retval = g_strdelimit (g_strdup (relative_path), "/", '-');
- }
- else
- {
- char *basename;
-
- basename = g_path_get_basename (relative_path);
-
- if (ed->legacy_prefix)
- {
- retval = g_strjoin ("-", ed->legacy_prefix, basename, NULL);
- g_free (basename);
- }
- else
- {
- retval = basename;
- }
- }
+ retval = g_strdelimit (g_strdup (relative_path), "/", '-');
}
else
{
@@ -1125,15 +1086,7 @@ gboolean _entry_directory_list_compare(const EntryDirectoryList* a, const EntryD
static gboolean get_all_func(EntryDirectory* ed, DesktopEntry* entry, const char* file_id, DesktopEntrySet* set, gpointer user_data)
{
- if (ed->is_legacy && !desktop_entry_has_categories (entry))
- {
- entry = desktop_entry_copy (entry);
- desktop_entry_add_legacy_category (entry);
- }
- else
- {
- entry = desktop_entry_ref (entry);
- }
+ entry = desktop_entry_ref (entry);
desktop_entry_set_add_entry (set, entry, file_id);
desktop_entry_unref (entry);
diff --git a/libmenu/entry-directories.h b/libmenu/entry-directories.h
index 0bf8215..462bd74 100644
--- a/libmenu/entry-directories.h
+++ b/libmenu/entry-directories.h
@@ -31,7 +31,6 @@ typedef struct EntryDirectory EntryDirectory;
typedef void (*EntryDirectoryChangedFunc) (EntryDirectory* ed, gpointer user_data);
EntryDirectory* entry_directory_new(DesktopEntryType entry_type, const char* path);
-EntryDirectory* entry_directory_new_legacy(DesktopEntryType entry_type, const char* path, const char* legacy_prefix);
EntryDirectory* entry_directory_ref(EntryDirectory* ed);
void entry_directory_unref(EntryDirectory* ed);
diff --git a/libmenu/matemenu-tree.c b/libmenu/matemenu-tree.c
index 0260a6d..f1ffa9d 100644
--- a/libmenu/matemenu-tree.c
+++ b/libmenu/matemenu-tree.c
@@ -2485,249 +2485,6 @@ resolve_default_merge_dirs (MateMenuTree *tree,
}
static void
-add_filename_include (const char *desktop_file_id,
- DesktopEntry *entry,
- MenuLayoutNode *include)
-{
- if (!desktop_entry_has_categories (entry))
- {
- MenuLayoutNode *node;
-
- node = menu_layout_node_new (MENU_LAYOUT_NODE_FILENAME);
- menu_layout_node_set_content (node, desktop_file_id);
-
- menu_layout_node_append_child (include, node);
- menu_layout_node_unref (node);
- }
-}
-
-static void
-is_dot_directory (const char *basename,
- DesktopEntry *entry,
- gboolean *has_dot_directory)
-{
- if (!strcmp (basename, ".directory"))
- *has_dot_directory = TRUE;
-}
-
-static gboolean
-add_menu_for_legacy_dir (MenuLayoutNode *parent,
- const char *legacy_dir,
- const char *relative_path,
- const char *legacy_prefix,
- const char *menu_name)
-{
- EntryDirectory *ed;
- DesktopEntrySet *desktop_entries;
- DesktopEntrySet *directory_entries;
- GSList *subdirs;
- gboolean menu_added;
- gboolean has_dot_directory;
-
- ed = entry_directory_new_legacy (DESKTOP_ENTRY_INVALID, legacy_dir, legacy_prefix);
- if (!ed)
- return FALSE;
-
- subdirs = NULL;
- desktop_entries = desktop_entry_set_new ();
- directory_entries = desktop_entry_set_new ();
-
- entry_directory_get_flat_contents (ed,
- desktop_entries,
- directory_entries,
- &subdirs);
- entry_directory_unref (ed);
-
- has_dot_directory = FALSE;
- desktop_entry_set_foreach (directory_entries,
- (DesktopEntrySetForeachFunc) is_dot_directory,
- &has_dot_directory);
- desktop_entry_set_unref (directory_entries);
-
- menu_added = FALSE;
- if (desktop_entry_set_get_count (desktop_entries) > 0 || subdirs)
- {
- MenuLayoutNode *menu;
- MenuLayoutNode *node;
- GString *subdir_path;
- GString *subdir_relative;
- GSList *tmp;
- size_t legacy_dir_len;
- size_t relative_path_len;
-
- menu = menu_layout_node_new (MENU_LAYOUT_NODE_MENU);
- menu_layout_node_append_child (parent, menu);
-
- menu_added = TRUE;
-
- g_assert (menu_name != NULL);
-
- node = menu_layout_node_new (MENU_LAYOUT_NODE_NAME);
- menu_layout_node_set_content (node, menu_name);
- menu_layout_node_append_child (menu, node);
- menu_layout_node_unref (node);
-
- if (has_dot_directory)
- {
- node = menu_layout_node_new (MENU_LAYOUT_NODE_DIRECTORY);
- if (relative_path != NULL)
- {
- char *directory_entry_path;
-
- directory_entry_path = g_strdup_printf ("%s/.directory", relative_path);
- menu_layout_node_set_content (node, directory_entry_path);
- g_free (directory_entry_path);
- }
- else
- {
- menu_layout_node_set_content (node, ".directory");
- }
- menu_layout_node_append_child (menu, node);
- menu_layout_node_unref (node);
- }
-
- if (desktop_entry_set_get_count (desktop_entries) > 0)
- {
- MenuLayoutNode *include;
-
- include = menu_layout_node_new (MENU_LAYOUT_NODE_INCLUDE);
- menu_layout_node_append_child (menu, include);
-
- desktop_entry_set_foreach (desktop_entries,
- (DesktopEntrySetForeachFunc) add_filename_include,
- include);
-
- menu_layout_node_unref (include);
- }
-
- subdir_path = g_string_new (legacy_dir);
- legacy_dir_len = strlen (legacy_dir);
-
- subdir_relative = g_string_new (relative_path);
- relative_path_len = relative_path ? strlen (relative_path) : 0;
-
- tmp = subdirs;
- while (tmp != NULL)
- {
- const char *subdir = tmp->data;
-
- g_string_append_c (subdir_path, G_DIR_SEPARATOR);
- g_string_append (subdir_path, subdir);
-
- if (relative_path_len)
- {
- g_string_append_c (subdir_relative, G_DIR_SEPARATOR);
- }
- g_string_append (subdir_relative, subdir);
-
- add_menu_for_legacy_dir (menu,
- subdir_path->str,
- subdir_relative->str,
- legacy_prefix,
- subdir);
-
- g_string_truncate (subdir_relative, relative_path_len);
- g_string_truncate (subdir_path, legacy_dir_len);
-
- tmp = tmp->next;
- }
-
- g_string_free (subdir_path, TRUE);
- g_string_free (subdir_relative, TRUE);
-
- menu_layout_node_unref (menu);
- }
-
- desktop_entry_set_unref (desktop_entries);
-
- g_slist_free_full (subdirs, (GDestroyNotify) g_free);
-
- return menu_added;
-}
-
-static void
-resolve_legacy_dir (MateMenuTree *tree,
- GHashTable *loaded_menu_files,
- MenuLayoutNode *legacy)
-{
- MenuLayoutNode *to_merge;
- MenuLayoutNode *menu;
-
- to_merge = menu_layout_node_new (MENU_LAYOUT_NODE_ROOT);
-
- menu = menu_layout_node_get_parent (legacy);
- g_assert (menu_layout_node_get_type (menu) == MENU_LAYOUT_NODE_MENU);
-
- if (add_menu_for_legacy_dir (to_merge,
- menu_layout_node_get_content (legacy),
- NULL,
- menu_layout_node_legacy_dir_get_prefix (legacy),
- menu_layout_node_menu_get_name (menu)))
- {
- merge_resolved_children (tree, loaded_menu_files, legacy, to_merge);
- }
-
- menu_layout_node_unref (to_merge);
-}
-
-static MenuLayoutNode *
-add_legacy_dir (MateMenuTree *tree,
- GHashTable *loaded_menu_files,
- MenuLayoutNode *before,
- const char *data_dir)
-{
- MenuLayoutNode *legacy;
- char *dirname;
-
- dirname = g_build_filename (data_dir, "applnk", NULL);
-
- legacy = menu_layout_node_new (MENU_LAYOUT_NODE_LEGACY_DIR);
- menu_layout_node_set_content (legacy, dirname);
- menu_layout_node_legacy_dir_set_prefix (legacy, "kde");
- menu_layout_node_insert_before (before, legacy);
- menu_layout_node_unref (before);
-
- menu_verbose ("Adding <LegacyDir>%s</LegacyDir> in <KDELegacyDirs/>\n",
- dirname);
-
- resolve_legacy_dir (tree, loaded_menu_files, legacy);
-
- g_free (dirname);
-
- return legacy;
-}
-
-static void
-resolve_kde_legacy_dirs (MateMenuTree *tree,
- GHashTable *loaded_menu_files,
- MenuLayoutNode *layout)
-{
- MenuLayoutNode *before;
- const char * const *system_data_dirs;
- int i;
-
- system_data_dirs = g_get_system_data_dirs ();
-
- before = add_legacy_dir (tree,
- loaded_menu_files,
- menu_layout_node_ref (layout),
- g_get_user_data_dir ());
-
- i = 0;
- while (system_data_dirs[i] != NULL)
- {
- before = add_legacy_dir (tree, loaded_menu_files, before, system_data_dirs[i]);
-
- ++i;
- }
-
- menu_layout_node_unref (before);
-
- /* remove the now-replaced node */
- menu_layout_node_unlink (layout);
-}
-
-static void
matemenu_tree_resolve_files (MateMenuTree *tree,
GHashTable *loaded_menu_files,
MenuLayoutNode *layout)
@@ -2760,11 +2517,11 @@ matemenu_tree_resolve_files (MateMenuTree *tree,
break;
case MENU_LAYOUT_NODE_LEGACY_DIR:
- resolve_legacy_dir (tree, loaded_menu_files, layout);
+ menu_verbose ("Ignoring obsolete legacy dir");
break;
case MENU_LAYOUT_NODE_KDE_LEGACY_DIRS:
- resolve_kde_legacy_dirs (tree, loaded_menu_files, layout);
+ menu_verbose ("Ignoring obsolete KDE legacy dirs");
break;
case MENU_LAYOUT_NODE_PASSTHROUGH:
diff --git a/libmenu/menu-layout.c b/libmenu/menu-layout.c
index f51ef24..889f3f7 100644
--- a/libmenu/menu-layout.c
+++ b/libmenu/menu-layout.c
@@ -731,40 +731,6 @@ ensure_dir_lists (MenuLayoutNodeMenu *nm)
g_free (path);
}
- if (iter->type == MENU_LAYOUT_NODE_LEGACY_DIR)
- {
- MenuLayoutNodeLegacyDir *legacy = (MenuLayoutNodeLegacyDir *) iter;
- char *path;
-
- path = menu_layout_node_get_content_as_path (iter);
-
- if (app_dirs != NULL) /* we're loading app dirs */
- {
- ed = entry_directory_new_legacy (DESKTOP_ENTRY_DESKTOP,
- path,
- legacy->prefix);
- if (ed != NULL)
- {
- entry_directory_list_prepend (app_dirs, ed);
- entry_directory_unref (ed);
- }
- }
-
- if (dir_dirs != NULL) /* we're loading dir dirs */
- {
- ed = entry_directory_new_legacy (DESKTOP_ENTRY_DIRECTORY,
- path,
- legacy->prefix);
- if (ed != NULL)
- {
- entry_directory_list_prepend (dir_dirs, ed);
- entry_directory_unref (ed);
- }
- }
-
- g_free (path);
- }
-
iter = node_next (iter);
}