This is an automated email from the git hooks/post-receive script. g o t t c o d e p u s h e d a c o m m i t t o b r a n c h m a s t e r in repository panel-plugins/xfce4-whiskermenu-plugin.
commit 31520361e35846b6a25f1fb99155b44a2fac80d7 Author: Graeme Gott <[email protected]> Date: Fri Jan 18 05:53:15 2019 -0500 Add searching keywords of menu items. (bug #15047) --- panel-plugin/launcher.cpp | 27 +++++++++++++++++++++++++-- panel-plugin/launcher.h | 3 ++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/panel-plugin/launcher.cpp b/panel-plugin/launcher.cpp index 7d164a5..07fe961 100644 --- a/panel-plugin/launcher.cpp +++ b/panel-plugin/launcher.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2014, 2015, 2016 Graeme Gott <[email protected]> + * Copyright (C) 2013, 2014, 2015, 2016, 2019 Graeme Gott <[email protected]> * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -179,6 +179,19 @@ Launcher::Launcher(GarconMenuItem* item) : m_search_generic_name = normalize(generic_name); m_search_comment = normalize(details); + // Create search text for keywords +#if GARCON_CHECK_VERSION(0,6,2) + GList* keywords = garcon_menu_item_get_keywords(m_item); + for (GList* i = keywords; i != NULL; i = i->next) + { + const gchar* keyword = reinterpret_cast<gchar*>(i->data); + if (!exo_str_is_empty(keyword) && g_utf8_validate(keyword, -1, NULL)) + { + m_search_keywords.push_back(normalize(keyword)); + } + } +#endif + // Create search text for command const gchar* command = garcon_menu_item_get_command(m_item); if (!exo_str_is_empty(command) && g_utf8_validate(command, -1, NULL)) @@ -391,11 +404,21 @@ guint Launcher::search(const Query& query) return match | flags | 0x1000; } + // Sort matches in keywords next + for (std::vector<std::string>::size_type i = 0, end = m_search_keywords.size(); i < end; ++i) + { + match = query.match(m_search_keywords[i]); + if (match != G_MAXUINT) + { + return match | flags | 0x2000; + } + } + // Sort matches in executables last match = query.match(m_search_command); if (match != G_MAXUINT) { - return match | flags | 0x2000; + return match | flags | 0x4000; } return G_MAXUINT; diff --git a/panel-plugin/launcher.h b/panel-plugin/launcher.h index d94218e..09e171f 100644 --- a/panel-plugin/launcher.h +++ b/panel-plugin/launcher.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2015, 2016 Graeme Gott <[email protected]> + * Copyright (C) 2013, 2015, 2016, 2019 Graeme Gott <[email protected]> * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -137,6 +137,7 @@ private: std::string m_search_generic_name; std::string m_search_comment; std::string m_search_command; + std::vector<std::string> m_search_keywords; guint m_search_flags; std::vector<DesktopAction*> m_actions; }; -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list [email protected] https://mail.xfce.org/mailman/listinfo/xfce4-commits
