From 10ed9841f4877002a403f26c8ea289a34e4ead52 Mon Sep 17 00:00:00 2001 From: Graeme Gott Date: Thu, 2 Nov 2023 11:26:22 -0400 Subject: [PATCH] Remove search flags Tracking the exact order of launchers in the recent and favorites makes having a search flag redundant. --- panel-plugin/favorites-page.cpp | 16 ---------------- panel-plugin/launcher.cpp | 29 ++++++----------------------- panel-plugin/launcher.h | 7 ------- panel-plugin/recent-page.cpp | 24 ------------------------ panel-plugin/recent-page.h | 1 - 5 files changed, 6 insertions(+), 71 deletions(-) diff --git a/panel-plugin/favorites-page.cpp b/panel-plugin/favorites-page.cpp index 2b9f4554..21f5dfc7 100644 --- a/panel-plugin/favorites-page.cpp +++ b/panel-plugin/favorites-page.cpp @@ -68,8 +68,6 @@ void FavoritesPage::add(Launcher* launcher) return; } - launcher->set_flag(Launcher::FavoriteFlag, true); - // Append to list of items GtkListStore* store = GTK_LIST_STORE(get_view()->get_model()); gtk_list_store_insert_with_values( @@ -85,11 +83,6 @@ void FavoritesPage::add(Launcher* launcher) void FavoritesPage::remove(Launcher* launcher) { - if (launcher) - { - launcher->set_flag(Launcher::FavoriteFlag, false); - } - GtkTreeModel* model = GTK_TREE_MODEL(get_view()->get_model()); GtkListStore* store = GTK_LIST_STORE(model); GtkTreeIter iter; @@ -134,15 +127,6 @@ void FavoritesPage::set_menu_items() }); g_object_unref(model); - - for (const auto& favorite : wm_settings->favorites) - { - Launcher* launcher = get_window()->get_applications()->find(favorite); - if (launcher) - { - launcher->set_flag(Launcher::FavoriteFlag, true); - } - } } //----------------------------------------------------------------------------- diff --git a/panel-plugin/launcher.cpp b/panel-plugin/launcher.cpp index 1f887243..85421cc5 100644 --- a/panel-plugin/launcher.cpp +++ b/panel-plugin/launcher.cpp @@ -353,33 +353,30 @@ void Launcher::run(GdkScreen* screen, DesktopAction* action) const unsigned int Launcher::search(const Query& query) { - // Prioritize matches in favorites and recent, then favories, and then recent - const unsigned int flags = 3 - m_search_flags; - // Sort matches in names first unsigned int match = query.match(m_search_name); if (match != UINT_MAX) { - return match | flags | 0x400; + return match | 0x400; } match = query.match_as_characters(m_search_name); if (match != UINT_MAX) { - return match | flags | 0x400; + return match | 0x400; } match = query.match(m_search_generic_name); if (match != UINT_MAX) { - return match | flags | 0x800; + return match | 0x800; } // Sort matches in comments next match = query.match(m_search_comment); if (match != UINT_MAX) { - return match | flags | 0x1000; + return match | 0x1000; } // Sort matches in keywords next @@ -388,7 +385,7 @@ unsigned int Launcher::search(const Query& query) match = query.match(keyword); if (match != UINT_MAX) { - return match | flags | 0x2000; + return match | 0x2000; } } @@ -396,24 +393,10 @@ unsigned int Launcher::search(const Query& query) match = query.match(m_search_command); if (match != UINT_MAX) { - return match | flags | 0x4000; + return match | 0x4000; } return UINT_MAX; } //----------------------------------------------------------------------------- - -void Launcher::set_flag(SearchFlag flag, bool enabled) -{ - if (enabled) - { - m_search_flags |= flag; - } - else - { - m_search_flags &= ~flag; - } -} - -//----------------------------------------------------------------------------- diff --git a/panel-plugin/launcher.h b/panel-plugin/launcher.h index b61245f6..2e00b335 100644 --- a/panel-plugin/launcher.h +++ b/panel-plugin/launcher.h @@ -94,13 +94,6 @@ class Launcher : public Element unsigned int search(const Query& query) override; - enum SearchFlag - { - RecentFlag = 0x1, - FavoriteFlag = 0x2 - }; - void set_flag(SearchFlag flag, bool enabled); - private: GarconMenuItem* m_item; const gchar* m_display_name; diff --git a/panel-plugin/recent-page.cpp b/panel-plugin/recent-page.cpp index ce32245e..6b255c31 100644 --- a/panel-plugin/recent-page.cpp +++ b/panel-plugin/recent-page.cpp @@ -58,7 +58,6 @@ void RecentPage::add(Launcher* launcher) { return; } - launcher->set_flag(Launcher::RecentFlag, true); std::string desktop_id = launcher->get_desktop_id(); if (!wm_settings->recent.empty()) @@ -111,12 +110,6 @@ void RecentPage::enforce_item_count() GtkListStore* store = GTK_LIST_STORE(get_view()->get_model()); for (int i = wm_settings->recent.size() - 1, end = wm_settings->recent_items_max; i >= end; --i) { - Launcher* launcher = get_window()->get_applications()->find(wm_settings->recent[i]); - if (launcher) - { - launcher->set_flag(Launcher::RecentFlag, false); - } - GtkTreeIter iter; if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, nullptr, i)) { @@ -129,27 +122,11 @@ void RecentPage::enforce_item_count() //----------------------------------------------------------------------------- -void RecentPage::flag_items(bool enabled) -{ - for (const auto& recent : wm_settings->recent) - { - Launcher* launcher = get_window()->get_applications()->find(recent); - if (launcher) - { - launcher->set_flag(Launcher::RecentFlag, enabled); - } - } -} - -//----------------------------------------------------------------------------- - void RecentPage::set_menu_items() { GtkTreeModel* model = get_window()->get_applications()->create_launcher_model(wm_settings->recent); get_view()->set_model(model); g_object_unref(model); - - flag_items(true); } //----------------------------------------------------------------------------- @@ -171,7 +148,6 @@ void RecentPage::extend_context_menu(GtkWidget* menu) connect(menuitem, "activate", [this](GtkMenuItem*) { - flag_items(false); gtk_list_store_clear(GTK_LIST_STORE(get_view()->get_model())); wm_settings->recent.clear(); }); diff --git a/panel-plugin/recent-page.h b/panel-plugin/recent-page.h index 1529da39..a3cf97d8 100644 --- a/panel-plugin/recent-page.h +++ b/panel-plugin/recent-page.h @@ -31,7 +31,6 @@ class RecentPage : public Page void add(Launcher* launcher); void enforce_item_count(); - void flag_items(bool enabled); void set_menu_items(); void unset_menu_items();