[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 15/20: Be more consistent with use of glib types.

noreply at xfce.org noreply at xfce.org
Thu Feb 6 12:03:32 CET 2020


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 7892d2945060f120104c8107f2d516fbcf802ba5
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sun Feb 2 07:05:15 2020 -0500

    Be more consistent with use of glib types.
---
 panel-plugin/category.cpp      | 10 +++++-----
 panel-plugin/element.h         |  6 ++++--
 panel-plugin/image-menu-item.h |  4 ++--
 panel-plugin/launcher.cpp      | 24 ++++++++++++------------
 panel-plugin/launcher.h        |  4 ++--
 panel-plugin/page.cpp          |  2 +-
 panel-plugin/plugin.cpp        |  2 +-
 panel-plugin/query.cpp         |  1 -
 panel-plugin/run-action.cpp    |  4 ++--
 panel-plugin/run-action.h      |  2 +-
 panel-plugin/search-action.cpp | 16 ++++++++--------
 panel-plugin/search-action.h   |  6 +++---
 panel-plugin/search-page.h     |  6 +++---
 panel-plugin/settings.cpp      | 10 +++++-----
 panel-plugin/settings.h        |  6 ++++--
 15 files changed, 53 insertions(+), 50 deletions(-)

diff --git a/panel-plugin/category.cpp b/panel-plugin/category.cpp
index 6cf8ae6..6f3b72e 100644
--- a/panel-plugin/category.cpp
+++ b/panel-plugin/category.cpp
@@ -185,7 +185,7 @@ void Category::insert_items(GtkTreeStore* model, GtkTreeIter* parent)
 
 			GtkTreeIter iter;
 			gtk_tree_store_insert_with_values(model,
-					&iter, parent, INT_MAX,
+					&iter, parent, G_MAXINT,
 					LauncherView::COLUMN_ICON, category->get_icon(),
 					LauncherView::COLUMN_TEXT, text,
 					LauncherView::COLUMN_TOOLTIP, tooltip,
@@ -197,7 +197,7 @@ void Category::insert_items(GtkTreeStore* model, GtkTreeIter* parent)
 		else if (Launcher* launcher = dynamic_cast<Launcher*>(element))
 		{
 			gtk_tree_store_insert_with_values(model,
-					nullptr, parent, INT_MAX,
+					nullptr, parent, G_MAXINT,
 					LauncherView::COLUMN_ICON, launcher->get_icon(),
 					LauncherView::COLUMN_TEXT, launcher->get_text(),
 					LauncherView::COLUMN_TOOLTIP, launcher->get_tooltip(),
@@ -207,7 +207,7 @@ void Category::insert_items(GtkTreeStore* model, GtkTreeIter* parent)
 		else
 		{
 			gtk_tree_store_insert_with_values(model,
-					nullptr, parent, INT_MAX,
+					nullptr, parent, G_MAXINT,
 					LauncherView::COLUMN_ICON, nullptr,
 					LauncherView::COLUMN_TEXT, nullptr,
 					LauncherView::COLUMN_TOOLTIP, nullptr,
@@ -231,7 +231,7 @@ void Category::insert_items(GtkListStore* model)
 		if (Launcher* launcher = dynamic_cast<Launcher*>(element))
 		{
 			gtk_list_store_insert_with_values(model,
-					nullptr, INT_MAX,
+					nullptr, G_MAXINT,
 					LauncherView::COLUMN_ICON, launcher->get_icon(),
 					LauncherView::COLUMN_TEXT, launcher->get_text(),
 					LauncherView::COLUMN_TOOLTIP, launcher->get_tooltip(),
@@ -241,7 +241,7 @@ void Category::insert_items(GtkListStore* model)
 		else
 		{
 			gtk_list_store_insert_with_values(model,
-					nullptr, INT_MAX,
+					nullptr, G_MAXINT,
 					LauncherView::COLUMN_ICON, nullptr,
 					LauncherView::COLUMN_TEXT, nullptr,
 					LauncherView::COLUMN_TOOLTIP, nullptr,
diff --git a/panel-plugin/element.h b/panel-plugin/element.h
index 47f6060..44ed537 100644
--- a/panel-plugin/element.h
+++ b/panel-plugin/element.h
@@ -18,6 +18,8 @@
 #ifndef WHISKERMENU_ELEMENT_H
 #define WHISKERMENU_ELEMENT_H
 
+#include <climits>
+
 #include <exo/exo.h>
 #include <gdk/gdk.h>
 
@@ -64,9 +66,9 @@ public:
 	{
 	}
 
-	virtual guint search(const Query&)
+	virtual unsigned int search(const Query&)
 	{
-		return G_MAXUINT;
+		return UINT_MAX;
 	}
 
 	static bool less_than(const Element* lhs, const Element* rhs)
diff --git a/panel-plugin/image-menu-item.h b/panel-plugin/image-menu-item.h
index 8634e34..6b899d8 100644
--- a/panel-plugin/image-menu-item.h
+++ b/panel-plugin/image-menu-item.h
@@ -20,7 +20,7 @@
 
 #include <gtk/gtk.h>
 
-inline GtkWidget* whiskermenu_image_menu_item_new(const char* icon, const char* text)
+inline GtkWidget* whiskermenu_image_menu_item_new(const gchar* icon, const gchar* text)
 {
 	GtkWidget* image = gtk_image_new_from_icon_name(icon, GTK_ICON_SIZE_MENU);
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
@@ -30,7 +30,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 	return menuitem;
 }
 
-inline GtkWidget* whiskermenu_image_menu_item_new_with_mnemonic(const char* icon, const char* text)
+inline GtkWidget* whiskermenu_image_menu_item_new_with_mnemonic(const gchar* icon, const gchar* text)
 {
 	GtkWidget* image = gtk_image_new_from_icon_name(icon, GTK_ICON_SIZE_MENU);
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
diff --git a/panel-plugin/launcher.cpp b/panel-plugin/launcher.cpp
index c54462b..0ac8225 100644
--- a/panel-plugin/launcher.cpp
+++ b/panel-plugin/launcher.cpp
@@ -71,7 +71,7 @@ static void replace_with_quoted_string(std::string& command, std::string::size_t
 
 //-----------------------------------------------------------------------------
 
-static void replace_with_quoted_string(std::string& command, std::string::size_type& index, const char* prefix, const gchar* unquoted)
+static void replace_with_quoted_string(std::string& command, std::string::size_type& index, const gchar* prefix, const gchar* unquoted)
 {
 	if (!exo_str_is_empty(unquoted))
 	{
@@ -299,7 +299,7 @@ void Launcher::run(GdkScreen* screen) const
 
 	// Parse and spawn command
 	gchar** argv;
-	gboolean result = false;
+	bool result = false;
 	GError* error = nullptr;
 	if (g_shell_parse_argv(command.c_str(), nullptr, &argv, &error))
 	{
@@ -373,7 +373,7 @@ void Launcher::run(GdkScreen* screen, DesktopAction* action) const
 
 	// Parse and spawn command
 	gchar** argv;
-	gboolean result = false;
+	bool result = false;
 	GError* error = nullptr;
 	if (g_shell_parse_argv(command.c_str(), nullptr, &argv, &error))
 	{
@@ -396,27 +396,27 @@ void Launcher::run(GdkScreen* screen, DesktopAction* action) const
 
 //-----------------------------------------------------------------------------
 
-guint Launcher::search(const Query& query)
+unsigned int Launcher::search(const Query& query)
 {
 	// Prioritize matches in favorites and recent, then favories, and then recent
-	const guint flags = 3 - m_search_flags;
+	const unsigned int flags = 3 - m_search_flags;
 
 	// Sort matches in names first
-	guint match = query.match(m_search_name);
-	if (match != G_MAXUINT)
+	unsigned int match = query.match(m_search_name);
+	if (match != UINT_MAX)
 	{
 		return match | flags | 0x400;
 	}
 
 	match = query.match(m_search_generic_name);
-	if (match != G_MAXUINT)
+	if (match != UINT_MAX)
 	{
 		return match | flags | 0x800;
 	}
 
 	// Sort matches in comments next
 	match = query.match(m_search_comment);
-	if (match != G_MAXUINT)
+	if (match != UINT_MAX)
 	{
 		return match | flags | 0x1000;
 	}
@@ -425,7 +425,7 @@ guint Launcher::search(const Query& query)
 	for (const auto& keyword : m_search_keywords)
 	{
 		match = query.match(keyword);
-		if (match != G_MAXUINT)
+		if (match != UINT_MAX)
 		{
 			return match | flags | 0x2000;
 		}
@@ -433,12 +433,12 @@ guint Launcher::search(const Query& query)
 
 	// Sort matches in executables last
 	match = query.match(m_search_command);
-	if (match != G_MAXUINT)
+	if (match != UINT_MAX)
 	{
 		return match | flags | 0x4000;
 	}
 
-	return G_MAXUINT;
+	return UINT_MAX;
 }
 
 //-----------------------------------------------------------------------------
diff --git a/panel-plugin/launcher.h b/panel-plugin/launcher.h
index db3a0d0..8cb682a 100644
--- a/panel-plugin/launcher.h
+++ b/panel-plugin/launcher.h
@@ -114,7 +114,7 @@ public:
 
 	void run(GdkScreen* screen, DesktopAction* action) const;
 
-	guint search(const Query& query);
+	unsigned int search(const Query& query);
 
 	enum SearchFlag
 	{
@@ -131,7 +131,7 @@ private:
 	std::string m_search_comment;
 	std::string m_search_command;
 	std::vector<std::string> m_search_keywords;
-	guint m_search_flags;
+	unsigned int m_search_flags;
 	std::vector<DesktopAction*> m_actions;
 };
 
diff --git a/panel-plugin/page.cpp b/panel-plugin/page.cpp
index 1b495f8..ad8ea9e 100644
--- a/panel-plugin/page.cpp
+++ b/panel-plugin/page.cpp
@@ -452,7 +452,7 @@ void Page::add_selected_to_desktop()
 	GFile* source_file = m_selected_launcher->get_file();
 
 	// Fetch launcher destination
-	char* basename = g_file_get_basename(source_file);
+	gchar* basename = g_file_get_basename(source_file);
 	GFile* destination_file = g_file_get_child(desktop_folder, basename);
 	g_free(basename);
 
diff --git a/panel-plugin/plugin.cpp b/panel-plugin/plugin.cpp
index e37784f..51d18f5 100644
--- a/panel-plugin/plugin.cpp
+++ b/panel-plugin/plugin.cpp
@@ -56,7 +56,7 @@ static bool panel_utils_grab_available()
 	GdkSeat* seat = gdk_display_get_default_seat(display);
 
 	// Don't try to get the grab for longer then 1/4 second
-	for (guint i = 0; i < (G_USEC_PER_SEC / 400); ++i)
+	for (int i = 0; i < 2500; ++i)
 	{
 		if (gdk_seat_grab(seat, root, GDK_SEAT_CAPABILITY_ALL, true, nullptr, nullptr, nullptr, nullptr))
 		{
diff --git a/panel-plugin/query.cpp b/panel-plugin/query.cpp
index d78e7b7..770927f 100644
--- a/panel-plugin/query.cpp
+++ b/panel-plugin/query.cpp
@@ -20,7 +20,6 @@
 #include <sstream>
 
 #include <climits>
-#include <cstring>
 
 #include <glib.h>
 
diff --git a/panel-plugin/run-action.cpp b/panel-plugin/run-action.cpp
index 362417d..4f733cc 100644
--- a/panel-plugin/run-action.cpp
+++ b/panel-plugin/run-action.cpp
@@ -45,7 +45,7 @@ void RunAction::run(GdkScreen* screen) const
 
 //-----------------------------------------------------------------------------
 
-guint RunAction::search(const Query& query)
+unsigned int RunAction::search(const Query& query)
 {
 	// Check if in PATH
 	bool valid = false;
@@ -61,7 +61,7 @@ guint RunAction::search(const Query& query)
 
 	if (!valid)
 	{
-		return G_MAXUINT;
+		return UINT_MAX;
 	}
 
 	m_command_line = query.raw_query();
diff --git a/panel-plugin/run-action.h b/panel-plugin/run-action.h
index 6071f18..3a3a9f2 100644
--- a/panel-plugin/run-action.h
+++ b/panel-plugin/run-action.h
@@ -31,7 +31,7 @@ public:
 	RunAction();
 
 	void run(GdkScreen* screen) const;
-	guint search(const Query& query);
+	unsigned int 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 602f81d..3583165 100644
--- a/panel-plugin/search-action.cpp
+++ b/panel-plugin/search-action.cpp
@@ -61,7 +61,7 @@ SearchAction::~SearchAction()
 
 //-----------------------------------------------------------------------------
 
-guint SearchAction::search(const Query& query)
+unsigned int SearchAction::search(const Query& query)
 {
 	if (m_pattern.empty() || m_command.empty())
 	{
@@ -71,10 +71,10 @@ guint SearchAction::search(const Query& query)
 	m_expanded_command.clear();
 
 	const gchar* haystack = query.raw_query().c_str();
-	guint found = !m_is_regex ? match_prefix(haystack) : match_regex(haystack);
+	unsigned int found = !m_is_regex ? match_prefix(haystack) : match_regex(haystack);
 
 	const bool show_description = wm_settings->launcher_show_description && !wm_settings->view_as_icons;
-	if ((found != G_MAXUINT) && (m_show_description != show_description))
+	if ((found != UINT_MAX) && (m_show_description != show_description))
 	{
 		m_show_description = show_description;
 		update_text();
@@ -85,11 +85,11 @@ guint SearchAction::search(const Query& query)
 
 //-----------------------------------------------------------------------------
 
-guint SearchAction::match_prefix(const gchar* haystack)
+unsigned int SearchAction::match_prefix(const gchar* haystack)
 {
 	if (!g_str_has_prefix(haystack, m_pattern.c_str()))
 	{
-		return G_MAXUINT;
+		return UINT_MAX;
 	}
 
 	gchar* trimmed = g_strdup(haystack + m_pattern.length());
@@ -146,9 +146,9 @@ guint SearchAction::match_prefix(const gchar* haystack)
 
 //-----------------------------------------------------------------------------
 
-guint SearchAction::match_regex(const gchar* haystack)
+unsigned int SearchAction::match_regex(const gchar* haystack)
 {
-	guint found = G_MAXUINT;
+	unsigned int found = UINT_MAX;
 
 	if (!m_regex)
 	{
@@ -182,7 +182,7 @@ guint SearchAction::match_regex(const gchar* haystack)
 void SearchAction::run(GdkScreen* screen) const
 {
 	GError* error = nullptr;
-	gboolean result = xfce_spawn_command_line_on_screen(screen, m_expanded_command.c_str(), FALSE, FALSE, &error);
+	bool result = xfce_spawn_command_line_on_screen(screen, m_expanded_command.c_str(), false, false, &error);
 
 	if (G_UNLIKELY(!result))
 	{
diff --git a/panel-plugin/search-action.h b/panel-plugin/search-action.h
index a380781..c7f4fee 100644
--- a/panel-plugin/search-action.h
+++ b/panel-plugin/search-action.h
@@ -53,7 +53,7 @@ public:
 	}
 
 	void run(GdkScreen* screen) const;
-	guint search(const Query& query);
+	unsigned int search(const Query& query);
 
 	void set_name(const gchar* name);
 	void set_pattern(const gchar* pattern);
@@ -61,8 +61,8 @@ public:
 	void set_is_regex(bool is_regex);
 
 private:
-	guint match_prefix(const gchar* haystack);
-	guint match_regex(const gchar* haystack);
+	unsigned int match_prefix(const gchar* haystack);
+	unsigned int match_regex(const gchar* haystack);
 	void update_text();
 
 private:
diff --git a/panel-plugin/search-page.h b/panel-plugin/search-page.h
index 50c1986..bb5aac9 100644
--- a/panel-plugin/search-page.h
+++ b/panel-plugin/search-page.h
@@ -53,7 +53,7 @@ private:
 	public:
 		Match(Element* element = nullptr) :
 			m_element(element),
-			m_relevancy(G_MAXINT)
+			m_relevancy(UINT_MAX)
 		{
 		}
 
@@ -80,12 +80,12 @@ private:
 
 		static bool invalid(const Match& match)
 		{
-			return match.m_relevancy == G_MAXUINT;
+			return match.m_relevancy == UINT_MAX;
 		}
 
 	private:
 		Element* m_element;
-		guint m_relevancy;
+		unsigned int m_relevancy;
 	};
 	std::vector<Match> m_matches;
 };
diff --git a/panel-plugin/settings.cpp b/panel-plugin/settings.cpp
index bfe3776..15468f9 100644
--- a/panel-plugin/settings.cpp
+++ b/panel-plugin/settings.cpp
@@ -33,7 +33,7 @@ using namespace WhiskerMenu;
 
 Settings* WhiskerMenu::wm_settings = nullptr;
 
-static const char* const settings_command[Settings::CountCommands][2] = {
+static const gchar* const settings_command[Settings::CountCommands][2] = {
 	{ "command-settings",   "show-command-settings"   },
 	{ "command-lockscreen", "show-command-lockscreen" },
 	{ "command-switchuser", "show-command-switchuser" },
@@ -49,7 +49,7 @@ static const char* const settings_command[Settings::CountCommands][2] = {
 
 //-----------------------------------------------------------------------------
 
-static void read_vector_entry(XfceRc* rc, const char* key, std::vector<std::string>& desktop_ids)
+static void read_vector_entry(XfceRc* rc, const gchar* key, std::vector<std::string>& desktop_ids)
 {
 	if (!xfce_rc_has_entry(rc, key))
 	{
@@ -72,7 +72,7 @@ static void read_vector_entry(XfceRc* rc, const char* key, std::vector<std::stri
 
 //-----------------------------------------------------------------------------
 
-static void write_vector_entry(XfceRc* rc, const char* key, const std::vector<std::string>& desktop_ids)
+static void write_vector_entry(XfceRc* rc, const gchar* key, const std::vector<std::string>& desktop_ids)
 {
 	const auto size = desktop_ids.size();
 	gchar** values = g_new0(gchar*, size + 1);
@@ -210,7 +210,7 @@ Settings::~Settings()
 
 //-----------------------------------------------------------------------------
 
-void Settings::load(char* file)
+void Settings::load(gchar* file)
 {
 	if (!file)
 	{
@@ -314,7 +314,7 @@ void Settings::load(char* file)
 
 //-----------------------------------------------------------------------------
 
-void Settings::save(char* file)
+void Settings::save(gchar* file)
 {
 	if (!file)
 	{
diff --git a/panel-plugin/settings.h b/panel-plugin/settings.h
index 8f11458..9f3dd7f 100644
--- a/panel-plugin/settings.h
+++ b/panel-plugin/settings.h
@@ -23,6 +23,8 @@
 #include <string>
 #include <vector>
 
+#include <glib.h>
+
 namespace WhiskerMenu
 {
 
@@ -40,8 +42,8 @@ class Settings
 	Settings& operator=(const Settings&) = delete;
 	Settings& operator=(Settings&&) = delete;
 
-	void load(char* file);
-	void save(char* file);
+	void load(gchar* file);
+	void save(gchar* file);
 
 	bool m_modified;
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list