Use uid instead of name to identify if an entry already exists

Some apps have the same name, i.e nemo and nautilus are both called 'Files'
Before this fix only one of them would end up in the app launcher
This commit is contained in:
Ofek Itscovits 2023-06-28 21:39:58 +03:00
parent f96d837117
commit b4cb55a525
2 changed files with 14 additions and 13 deletions

View File

@ -302,6 +302,7 @@ function app_launcher:refresh_app_list()
end end
local app = { local app = {
uid = desktop_app_info:get_filename(),
desktop_app_info = desktop_app_info, desktop_app_info = desktop_app_info,
path = desktop_app_info:get_filename(), path = desktop_app_info:get_filename(),
id = id, id = id,

View File

@ -48,9 +48,9 @@ local function has_value(tab, val)
return false return false
end end
local function has_entry(entries, name) local function has_entry(entries, entry)
for _, entry in ipairs(entries) do for _, looped_entry in ipairs(entries) do
if entry.name == name then if looped_entry.uid == entry.uid then
return true return true
end end
end end
@ -109,8 +109,8 @@ local function scroll(self, dir, page_dir)
end end
local function entry_widget(rofi_grid, entry) local function entry_widget(rofi_grid, entry)
if rofi_grid._private.entries_widgets_cache[entry.name] then if rofi_grid._private.entries_widgets_cache[entry.uid] then
return rofi_grid._private.entries_widgets_cache[entry.name] return rofi_grid._private.entries_widgets_cache[entry.uid]
end end
local widget = rofi_grid._private.entry_template(entry, rofi_grid) local widget = rofi_grid._private.entry_template(entry, rofi_grid)
@ -152,8 +152,8 @@ local function entry_widget(rofi_grid, entry)
rofi_grid:emit_signal("entry_widget::add", widget, entry) rofi_grid:emit_signal("entry_widget::add", widget, entry)
rofi_grid._private.entries_widgets_cache[entry.name] = widget rofi_grid._private.entries_widgets_cache[entry.uid] = widget
return rofi_grid._private.entries_widgets_cache[entry.name] return rofi_grid._private.entries_widgets_cache[entry.uid]
end end
local function default_search_sort_fn(text, a, b) local function default_search_sort_fn(text, a, b)
@ -296,23 +296,23 @@ end
function rofi_grid:set_entries(new_entries, sort_fn) function rofi_grid:set_entries(new_entries, sort_fn)
-- Remove old entries that are not in the new entries table -- Remove old entries that are not in the new entries table
for index, entry in pairs(self:get_entries()) do for index, entry in pairs(self:get_entries()) do
if has_entry(new_entries, entry.name) == false then if has_entry(new_entries, entry) == false then
table.remove(self._private.entries, index) table.remove(self._private.entries, index)
if self._private.entries_widgets_cache[entry.name] then if self._private.entries_widgets_cache[entry.uid] then
self._private.entries_widgets_cache[entry.name]:emit_signal("removed") self._private.entries_widgets_cache[entry.uid]:emit_signal("removed")
self._private.entries_widgets_cache[entry.name] = nil self._private.entries_widgets_cache[entry.uid] = nil
end end
end end
end end
-- Add new entries that are not in the old entries table -- Add new entries that are not in the old entries table
for _, entry in ipairs(new_entries) do for _, entry in ipairs(new_entries) do
if has_entry(self:get_entries(), entry.name) == false then if has_entry(self:get_entries(), entry) == false then
table.insert(self._private.entries, entry) table.insert(self._private.entries, entry)
if self:get_lazy_load_widgets() == false then if self:get_lazy_load_widgets() == false then
self._private.entries_widgets_cache[entry.name] = entry_widget(self, entry) self._private.entries_widgets_cache[entry.uid] = entry_widget(self, entry)
end end
end end
end end