[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 58/473: Make fetching search results constant again.
noreply at xfce.org
noreply at xfce.org
Mon Feb 16 23:53:48 CET 2015
This is an automated email from the git hooks/post-receive script.
gottcode pushed a commit to branch master
in repository panel-plugins/xfce4-whiskermenu-plugin.
commit d585e1a7adb3602f1d8186b501ff7903405cd070
Author: Graeme Gott <graeme at gottcode.org>
Date: Wed Jul 3 07:05:46 2013 -0400
Make fetching search results constant again.
Remove accidental commit of test code.
---
src/launcher.cpp | 22 +++++++++++++---------
src/launcher.hpp | 4 +++-
src/search_page.cpp | 4 ++--
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/launcher.cpp b/src/launcher.cpp
index d5a2768..0483a04 100644
--- a/src/launcher.cpp
+++ b/src/launcher.cpp
@@ -174,6 +174,14 @@ Launcher::~Launcher()
//-----------------------------------------------------------------------------
+unsigned int Launcher::get_search_results(const Query &query) const
+{
+ std::map<std::string, unsigned int>::const_iterator i = m_searches.find(query.query());
+ return (i != m_searches.end()) ? i->second : UINT_MAX;
+}
+
+//-----------------------------------------------------------------------------
+
void Launcher::run(GdkScreen* screen) const
{
const gchar* string = garcon_menu_item_get_command(m_item);
@@ -257,23 +265,20 @@ void Launcher::run(GdkScreen* screen) const
//-----------------------------------------------------------------------------
-unsigned int Launcher::search(const Query& query)
+void Launcher::search(const Query& query)
{
if (query.empty())
{
- return UINT_MAX;
+ return;
}
// Check if search has been done or if a shorter version has failed before
for (std::map<std::string, unsigned int>::const_iterator i = m_searches.begin(), end = m_searches.end(); i != end; ++i)
{
- if (i->first == query.query())
- {
- return i->second;
- }
- else if ((i->second == UINT_MAX) && (query.query().find(i->first) == 0))
+ if ( ((i->second == UINT_MAX) && (query.query().find(i->first) == 0))
+ || (i->first == query.query()) )
{
- return UINT_MAX;
+ return;
}
}
@@ -288,7 +293,6 @@ unsigned int Launcher::search(const Query& query)
}
}
m_searches.insert(std::make_pair(query.query(), match));
- return match;
}
//-----------------------------------------------------------------------------
diff --git a/src/launcher.hpp b/src/launcher.hpp
index df5c354..39fb921 100644
--- a/src/launcher.hpp
+++ b/src/launcher.hpp
@@ -52,9 +52,11 @@ public:
return m_item;
}
+ unsigned int get_search_results(const Query& query) const;
+
void run(GdkScreen* screen) const;
- unsigned int search(const Query& query);
+ void search(const Query& query);
static bool get_show_name();
static bool get_show_description();
diff --git a/src/search_page.cpp b/src/search_page.cpp
index a25000c..58f646d 100644
--- a/src/search_page.cpp
+++ b/src/search_page.cpp
@@ -129,7 +129,7 @@ bool SearchPage::on_filter(GtkTreeModel* model, GtkTreeIter* iter)
// Check if launcher search string contains text
Launcher* launcher = NULL;
gtk_tree_model_get(model, iter, LauncherModel::COLUMN_LAUNCHER, &launcher, -1);
- return launcher->search(m_query) != UINT_MAX;
+ return launcher->get_search_results(m_query) != UINT_MAX;
}
//-----------------------------------------------------------------------------
@@ -142,7 +142,7 @@ gint SearchPage::on_sort(GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, Se
Launcher* launcher_b = NULL;
gtk_tree_model_get(model, b, LauncherModel::COLUMN_LAUNCHER, &launcher_b, -1);
- return launcher_a->search(page->m_query) - launcher_b->search(page->m_query);
+ return launcher_a->get_search_results(page->m_query) - launcher_b->get_search_results(page->m_query);
}
//-----------------------------------------------------------------------------
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list