[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 274/473: Support case sensitive run and search actions.
noreply at xfce.org
noreply at xfce.org
Mon Feb 16 23:57:24 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 a393cc9230c2acf16a43b52081c74df06979ac11
Author: Graeme Gott <graeme at gottcode.org>
Date: Fri Dec 6 05:52:07 2013 -0500
Support case sensitive run and search actions.
---
panel-plugin/query.cpp | 14 +++++++++++---
panel-plugin/query.h | 6 ++++++
panel-plugin/run-action.cpp | 4 ++--
panel-plugin/search-action.cpp | 2 +-
panel-plugin/search-page.cpp | 4 ++--
panel-plugin/window.cpp | 12 ++++--------
6 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/panel-plugin/query.cpp b/panel-plugin/query.cpp
index 4226844..40cc9c6 100644
--- a/panel-plugin/query.cpp
+++ b/panel-plugin/query.cpp
@@ -159,6 +159,7 @@ int Query::match(const std::string& haystack) const
void Query::clear()
{
+ m_raw_query.clear();
m_query.clear();
m_query_words.clear();
}
@@ -167,16 +168,23 @@ void Query::clear()
void Query::set(const std::string& query)
{
+ m_query.clear();
m_query_words.clear();
- m_query = query;
- if (m_query.empty())
+ m_raw_query = query;
+ if (m_raw_query.empty())
{
return;
}
+ gchar* normalized = g_utf8_normalize(m_raw_query.c_str(), -1, G_NORMALIZE_DEFAULT);
+ gchar* utf8 = g_utf8_casefold(normalized, -1);
+ m_query = utf8;
+ g_free(utf8);
+ g_free(normalized);
+
std::string buffer;
- std::stringstream ss(query);
+ std::stringstream ss(m_query);
while (ss >> buffer)
{
m_query_words.push_back(buffer);
diff --git a/panel-plugin/query.h b/panel-plugin/query.h
index 57833c0..8d03e06 100644
--- a/panel-plugin/query.h
+++ b/panel-plugin/query.h
@@ -43,10 +43,16 @@ public:
return m_query;
}
+ std::string raw_query() const
+ {
+ return m_raw_query;
+ }
+
void clear();
void set(const std::string& query);
private:
+ std::string m_raw_query;
std::string m_query;
std::vector<std::string> m_query_words;
};
diff --git a/panel-plugin/run-action.cpp b/panel-plugin/run-action.cpp
index 5dc86a6..0ddcfb9 100644
--- a/panel-plugin/run-action.cpp
+++ b/panel-plugin/run-action.cpp
@@ -51,7 +51,7 @@ int RunAction::search(const Query& query)
bool valid = false;
gchar** argv;
- if (g_shell_parse_argv(query.query().c_str(), NULL, &argv, NULL))
+ if (g_shell_parse_argv(query.raw_query().c_str(), NULL, &argv, NULL))
{
gchar* path = g_find_program_in_path(argv[0]);
valid = path != NULL;
@@ -64,7 +64,7 @@ int RunAction::search(const Query& query)
return G_MAXINT;
}
- m_command_line = query.query();
+ m_command_line = query.raw_query();
// Set item text
const gchar* direction = (gtk_widget_get_default_direction() != GTK_TEXT_DIR_RTL) ? "\342\200\216" : "\342\200\217";
diff --git a/panel-plugin/search-action.cpp b/panel-plugin/search-action.cpp
index 59fd364..4ba5510 100644
--- a/panel-plugin/search-action.cpp
+++ b/panel-plugin/search-action.cpp
@@ -70,7 +70,7 @@ int SearchAction::search(const Query& query)
m_expanded_command.clear();
- const gchar* haystack = query.query().c_str();
+ const gchar* haystack = query.raw_query().c_str();
bool found = !m_is_regex ? match_prefix(haystack) : match_regex(haystack);
if (found && (m_show_description != wm_settings->launcher_show_description))
diff --git a/panel-plugin/search-page.cpp b/panel-plugin/search-page.cpp
index 65e8c87..5c6271f 100644
--- a/panel-plugin/search-page.cpp
+++ b/panel-plugin/search-page.cpp
@@ -62,13 +62,13 @@ void SearchPage::set_filter(const gchar* filter)
// Make sure this is a new search
std::string query(filter);
- if (m_query.query() == query)
+ if (m_query.raw_query() == query)
{
return;
}
// Reset search results if new search does not start with previous search
- if (m_query.query().empty() || !g_str_has_prefix(filter, m_query.query().c_str()))
+ if (m_query.raw_query().empty() || !g_str_has_prefix(filter, m_query.raw_query().c_str()))
{
m_matches.clear();
m_matches.push_back(&m_run_action);
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index 937d45f..6632c65 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -840,17 +840,14 @@ void Window::show_default_page()
void Window::search()
{
// Fetch search string
- gchar* filter_string = NULL;
const gchar* text = gtk_entry_get_text(m_search_entry);
- if (!exo_str_is_empty(text))
+ if (exo_str_is_empty(text))
{
- gchar* normalized = g_utf8_normalize(text, -1, G_NORMALIZE_DEFAULT);
- filter_string = g_utf8_casefold(normalized, -1);
- g_free(normalized);
+ text = NULL;
}
// Update search entry icon
- bool visible = filter_string != NULL;
+ bool visible = text != NULL;
gtk_entry_set_icon_from_stock(m_search_entry, GTK_ENTRY_ICON_SECONDARY, !visible ? GTK_STOCK_FIND : GTK_STOCK_CLEAR);
gtk_entry_set_icon_activatable(m_search_entry, GTK_ENTRY_ICON_SECONDARY, visible);
@@ -870,8 +867,7 @@ void Window::search()
}
// Apply filter
- m_search_results->set_filter(visible ? filter_string : NULL);
- g_free(filter_string);
+ m_search_results->set_filter(text);
}
//-----------------------------------------------------------------------------
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list