[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 02/05: Use unsigned integers for search result relevancy.
noreply at xfce.org
noreply at xfce.org
Mon Sep 21 17:42:36 CEST 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 68b227d18a8987889e1485ec54493c01d5727619
Author: Graeme Gott <graeme at gottcode.org>
Date: Mon Sep 21 10:23:24 2015 -0400
Use unsigned integers for search result relevancy.
---
panel-plugin/element.h | 6 +++---
panel-plugin/launcher.cpp | 14 +++++++-------
panel-plugin/launcher.h | 4 ++--
panel-plugin/query.cpp | 8 ++++----
panel-plugin/query.h | 4 ++--
panel-plugin/run-action.cpp | 6 +++---
panel-plugin/run-action.h | 4 ++--
panel-plugin/search-action.cpp | 16 ++++++++--------
panel-plugin/search-action.h | 8 ++++----
panel-plugin/search-page.h | 6 +++---
10 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/panel-plugin/element.h b/panel-plugin/element.h
index 8749817..4230e70 100644
--- a/panel-plugin/element.h
+++ b/panel-plugin/element.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2015 Graeme Gott <graeme at gottcode.org>
*
* 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
@@ -58,9 +58,9 @@ public:
{
}
- virtual int search(const Query&)
+ virtual guint search(const Query&)
{
- return G_MAXINT;
+ return G_MAXUINT;
}
static bool less_than(const Element* lhs, const Element* rhs)
diff --git a/panel-plugin/launcher.cpp b/panel-plugin/launcher.cpp
index 06cab2d..d046223 100644
--- a/panel-plugin/launcher.cpp
+++ b/panel-plugin/launcher.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013, 2014 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2014, 2015 Graeme Gott <graeme at gottcode.org>
*
* 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
@@ -276,10 +276,10 @@ void Launcher::run(GdkScreen* screen) const
//-----------------------------------------------------------------------------
-int Launcher::search(const Query& query)
+guint Launcher::search(const Query& query)
{
- int match = query.match(m_search_name);
- if (match != G_MAXINT)
+ guint match = query.match(m_search_name);
+ if (match != G_MAXUINT)
{
if (match > 5)
{
@@ -289,7 +289,7 @@ int Launcher::search(const Query& query)
}
match = query.match(m_search_generic_name);
- if (match != G_MAXINT)
+ if (match != G_MAXUINT)
{
match += 10;
return match;
@@ -297,7 +297,7 @@ int Launcher::search(const Query& query)
// Sort matches in executables after matches in names
match = query.match(m_search_command);
- if (match != G_MAXINT)
+ if (match != G_MAXUINT)
{
match += 20;
return match;
@@ -305,7 +305,7 @@ int Launcher::search(const Query& query)
// Sort matches in comments after matches in names
match = query.match(m_search_comment);
- if (match != G_MAXINT)
+ if (match != G_MAXUINT)
{
match += 30;
}
diff --git a/panel-plugin/launcher.h b/panel-plugin/launcher.h
index e3fd43a..75f6b67 100644
--- a/panel-plugin/launcher.h
+++ b/panel-plugin/launcher.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2015 Graeme Gott <graeme at gottcode.org>
*
* 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
@@ -64,7 +64,7 @@ public:
void run(GdkScreen* screen) const;
- int search(const Query& query);
+ guint search(const Query& query);
private:
GarconMenuItem* m_item;
diff --git a/panel-plugin/query.cpp b/panel-plugin/query.cpp
index 3bcbfa0..cd39346 100644
--- a/panel-plugin/query.cpp
+++ b/panel-plugin/query.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2015 Graeme Gott <graeme at gottcode.org>
*
* 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
@@ -55,12 +55,12 @@ Query::~Query()
//-----------------------------------------------------------------------------
-int Query::match(const std::string& haystack) const
+unsigned int Query::match(const std::string& haystack) const
{
// Make sure haystack is longer than query
if (m_query.empty() || (m_query.length() > haystack.length()))
{
- return INT_MAX;
+ return UINT_MAX;
}
// Check if haystack begins with or is query
@@ -146,7 +146,7 @@ int Query::match(const std::string& haystack) const
start_word = false;
}
}
- int result = INT_MAX;
+ unsigned int result = UINT_MAX;
if (*query_string == 0)
{
result = characters_start_words ? 6 : 7;
diff --git a/panel-plugin/query.h b/panel-plugin/query.h
index 8d03e06..9970e64 100644
--- a/panel-plugin/query.h
+++ b/panel-plugin/query.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2015 Graeme Gott <graeme at gottcode.org>
*
* 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
@@ -36,7 +36,7 @@ public:
return m_query.empty();
}
- int match(const std::string& haystack) const;
+ unsigned int match(const std::string& haystack) const;
std::string query() const
{
diff --git a/panel-plugin/run-action.cpp b/panel-plugin/run-action.cpp
index 0ddcfb9..3bdbf83 100644
--- a/panel-plugin/run-action.cpp
+++ b/panel-plugin/run-action.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2015 Graeme Gott <graeme at gottcode.org>
*
* 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
@@ -45,7 +45,7 @@ void RunAction::run(GdkScreen* screen) const
//-----------------------------------------------------------------------------
-int RunAction::search(const Query& query)
+guint RunAction::search(const Query& query)
{
// Check if in PATH
bool valid = false;
@@ -61,7 +61,7 @@ int RunAction::search(const Query& query)
if (!valid)
{
- return G_MAXINT;
+ return G_MAXUINT;
}
m_command_line = query.raw_query();
diff --git a/panel-plugin/run-action.h b/panel-plugin/run-action.h
index b08832c..02c7666 100644
--- a/panel-plugin/run-action.h
+++ b/panel-plugin/run-action.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2015 Graeme Gott <graeme at gottcode.org>
*
* 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
@@ -40,7 +40,7 @@ public:
}
void run(GdkScreen* screen) const;
- int search(const Query& query);
+ guint search(const Query& query);
private:
std::string m_command_line;
diff --git a/panel-plugin/search-action.cpp b/panel-plugin/search-action.cpp
index 5f520b6..1d1efb0 100644
--- a/panel-plugin/search-action.cpp
+++ b/panel-plugin/search-action.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2015 Graeme Gott <graeme at gottcode.org>
*
* 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
@@ -61,7 +61,7 @@ SearchAction::~SearchAction()
//-----------------------------------------------------------------------------
-int SearchAction::search(const Query& query)
+guint SearchAction::search(const Query& query)
{
if (m_pattern.empty() || m_command.empty())
{
@@ -71,9 +71,9 @@ int SearchAction::search(const Query& query)
m_expanded_command.clear();
const gchar* haystack = query.raw_query().c_str();
- int found = !m_is_regex ? match_prefix(haystack) : match_regex(haystack);
+ guint found = !m_is_regex ? match_prefix(haystack) : match_regex(haystack);
- if (found && (m_show_description != wm_settings->launcher_show_description))
+ if ((found != G_MAXUINT) && (m_show_description != wm_settings->launcher_show_description))
{
m_show_description = wm_settings->launcher_show_description;
update_text();
@@ -84,11 +84,11 @@ int SearchAction::search(const Query& query)
//-----------------------------------------------------------------------------
-int SearchAction::match_prefix(const gchar* haystack)
+guint SearchAction::match_prefix(const gchar* haystack)
{
if (!g_str_has_prefix(haystack, m_pattern.c_str()))
{
- return G_MAXINT;
+ return G_MAXUINT;
}
gchar* trimmed = g_strdup(haystack + m_pattern.length());
@@ -145,9 +145,9 @@ int SearchAction::match_prefix(const gchar* haystack)
//-----------------------------------------------------------------------------
-int SearchAction::match_regex(const gchar* haystack)
+guint SearchAction::match_regex(const gchar* haystack)
{
- int found = G_MAXINT;
+ guint found = G_MAXUINT;
if (!m_regex)
{
diff --git a/panel-plugin/search-action.h b/panel-plugin/search-action.h
index 3d64a4c..9d045f3 100644
--- a/panel-plugin/search-action.h
+++ b/panel-plugin/search-action.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2015 Graeme Gott <graeme at gottcode.org>
*
* 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
@@ -62,7 +62,7 @@ public:
}
void run(GdkScreen* screen) const;
- int search(const Query& query);
+ guint search(const Query& query);
void set_name(const gchar* name);
void set_pattern(const gchar* pattern);
@@ -70,8 +70,8 @@ public:
void set_is_regex(bool is_regex);
private:
- int match_prefix(const gchar* haystack);
- int match_regex(const gchar* haystack);
+ guint match_prefix(const gchar* haystack);
+ guint match_regex(const gchar* haystack);
void update_text();
private:
diff --git a/panel-plugin/search-page.h b/panel-plugin/search-page.h
index d271841..74a417a 100644
--- a/panel-plugin/search-page.h
+++ b/panel-plugin/search-page.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2015 Graeme Gott <graeme at gottcode.org>
*
* 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
@@ -80,12 +80,12 @@ private:
static bool invalid(const Match& match)
{
- return match.m_relevancy == G_MAXINT;
+ return match.m_relevancy == G_MAXUINT;
}
private:
Element* m_element;
- int m_relevancy;
+ guint m_relevancy;
};
std::vector<Match> m_matches;
};
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list