Skip to content

Commit

Permalink
uncrustify
Browse files Browse the repository at this point in the history
  • Loading branch information
trigg committed Apr 15, 2024
1 parent f576fab commit 58281d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions src/panel/widgets/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ uint32_t WfMenuMenuItem::fuzzy_match(Glib::ustring pattern)
Glib::ustring long_name = m_app_info->get_display_name();
Glib::ustring progr = m_app_info->get_executable();

auto name_lower = name.lowercase();
auto name_lower = name.lowercase();
auto long_name_lower = long_name.lowercase();
auto progr_lower = progr.lowercase();
auto pattern_lower = pattern.lowercase();
Expand All @@ -217,10 +217,12 @@ uint32_t WfMenuMenuItem::fuzzy_match(Glib::ustring pattern)
{
match_score += 100;
}

if (::fuzzy_match(name_lower, pattern_lower))
{
match_score += 100;
}

if (::fuzzy_match(long_name_lower, pattern_lower))
{
match_score += 10;
Expand All @@ -231,38 +233,42 @@ uint32_t WfMenuMenuItem::fuzzy_match(Glib::ustring pattern)

uint32_t WfMenuMenuItem::matches(Glib::ustring pattern)
{
uint32_t match_score = 0;
uint32_t match_score = 0;
Glib::ustring long_name = m_app_info->get_display_name();
Glib::ustring name = m_app_info->get_name();
Glib::ustring progr = m_app_info->get_executable();
Glib::ustring descr = m_app_info->get_description();
Glib::ustring name = m_app_info->get_name();
Glib::ustring progr = m_app_info->get_executable();
Glib::ustring descr = m_app_info->get_description();

auto name_lower = name.lowercase();
auto long_name_lower = long_name.lowercase();
auto progr_lower = progr.lowercase();
auto descr_lower = descr.lowercase();
auto pattern_lower = pattern.lowercase();
auto progr_lower = progr.lowercase();
auto descr_lower = descr.lowercase();
auto pattern_lower = pattern.lowercase();

auto pos = name_lower.find(pattern_lower);
if (pos != name_lower.npos)
{
match_score += 1000 - pos;
}

pos = progr_lower.find(pattern_lower);
if (pos != progr_lower.npos)
{
match_score += 1000 - pos;
}

pos = long_name_lower.find(pattern_lower);
if (pos != long_name_lower.npos)
{
match_score += 500 - pos;
}

pos = descr_lower.find(pattern_lower);
if (pos != descr_lower.npos)
{
match_score += 300 - pos;
}

return match_score;
}

Expand Down
2 changes: 1 addition & 1 deletion src/panel/widgets/menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class WfMenuMenuItem : public Gtk::FlowBoxChild
Gtk::Label m_label;
Gtk::Menu m_action_menu;

bool m_has_actions = false;
bool m_has_actions = false;
uint32_t m_search_value = 0;

Glib::RefPtr<Gio::DesktopAppInfo> m_app_info;
Expand Down

0 comments on commit 58281d5

Please sign in to comment.