Commit d1d23c4f authored by Graeme Gott's avatar Graeme Gott

Use shared empty string check.

parent 8c645266
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
#include "category-button.h" #include "category-button.h"
#include "launcher-view.h" #include "launcher-view.h"
#include "util.h"
#include <algorithm> #include <algorithm>
#include <exo/exo.h>
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
using namespace WhiskerMenu; using namespace WhiskerMenu;
...@@ -49,7 +49,7 @@ Category::Category(GarconMenu* menu) : ...@@ -49,7 +49,7 @@ Category::Category(GarconMenu* menu) :
{ {
text = _("All Applications"); text = _("All Applications");
} }
set_icon(!exo_str_is_empty(icon) ? icon : "applications-other", true); set_icon(!xfce_str_is_empty(icon) ? icon : "applications-other", true);
set_text(text ? text : ""); set_text(text ? text : "");
set_tooltip(tooltip ? tooltip : ""); set_tooltip(tooltip ? tooltip : "");
} }
......
...@@ -18,9 +18,10 @@ ...@@ -18,9 +18,10 @@
#ifndef WHISKERMENU_ELEMENT_H #ifndef WHISKERMENU_ELEMENT_H
#define WHISKERMENU_ELEMENT_H #define WHISKERMENU_ELEMENT_H
#include "util.h"
#include <climits> #include <climits>
#include <exo/exo.h>
#include <gdk/gdk.h> #include <gdk/gdk.h>
namespace WhiskerMenu namespace WhiskerMenu
...@@ -100,7 +101,7 @@ protected: ...@@ -100,7 +101,7 @@ protected:
void set_tooltip(const gchar* tooltip) void set_tooltip(const gchar* tooltip)
{ {
g_free(m_tooltip); g_free(m_tooltip);
m_tooltip = !exo_str_is_empty(tooltip) ? g_markup_escape_text(tooltip, -1) : nullptr; m_tooltip = !xfce_str_is_empty(tooltip) ? g_markup_escape_text(tooltip, -1) : nullptr;
} }
private: private:
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#include "icon-renderer.h" #include "icon-renderer.h"
#include "settings.h" #include "settings.h"
#include "slot.h" #include "slot.h"
#include "util.h"
#include <exo/exo.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
using namespace WhiskerMenu; using namespace WhiskerMenu;
...@@ -33,7 +33,7 @@ static gboolean is_separator(GtkTreeModel* model, GtkTreeIter* iter, gpointer) ...@@ -33,7 +33,7 @@ static gboolean is_separator(GtkTreeModel* model, GtkTreeIter* iter, gpointer)
{ {
const gchar* text; const gchar* text;
gtk_tree_model_get(model, iter, LauncherView::COLUMN_TEXT, &text, -1); gtk_tree_model_get(model, iter, LauncherView::COLUMN_TEXT, &text, -1);
return exo_str_is_empty(text); return xfce_str_is_empty(text);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
#include "query.h" #include "query.h"
#include "settings.h" #include "settings.h"
#include "util.h"
#include <exo/exo.h>
#include <libxfce4ui/libxfce4ui.h> #include <libxfce4ui/libxfce4ui.h>
using namespace WhiskerMenu; using namespace WhiskerMenu;
...@@ -57,7 +57,7 @@ static std::string normalize(const gchar* string) ...@@ -57,7 +57,7 @@ static std::string normalize(const gchar* string)
#if !LIBXFCE4UTIL_CHECK_VERSION(4,15,1) #if !LIBXFCE4UTIL_CHECK_VERSION(4,15,1)
static void replace_with_quoted_string(std::string& command, std::string::size_type& index, const gchar* unquoted) static void replace_with_quoted_string(std::string& command, std::string::size_type& index, const gchar* unquoted)
{ {
if (!exo_str_is_empty(unquoted)) if (!xfce_str_is_empty(unquoted))
{ {
gchar* quoted = g_shell_quote(unquoted); gchar* quoted = g_shell_quote(unquoted);
command.replace(index, 2, quoted); command.replace(index, 2, quoted);
...@@ -74,7 +74,7 @@ static void replace_with_quoted_string(std::string& command, std::string::size_t ...@@ -74,7 +74,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 gchar* 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)) if (!xfce_str_is_empty(unquoted))
{ {
command.replace(index, 2, prefix); command.replace(index, 2, prefix);
index += strlen(prefix); index += strlen(prefix);
...@@ -167,7 +167,7 @@ Launcher::Launcher(GarconMenuItem* item) : ...@@ -167,7 +167,7 @@ Launcher::Launcher(GarconMenuItem* item) :
generic_name = ""; generic_name = "";
} }
if (!wm_settings->launcher_show_name && !exo_str_is_empty(generic_name)) if (!wm_settings->launcher_show_name && !xfce_str_is_empty(generic_name))
{ {
std::swap(name, generic_name); std::swap(name, generic_name);
} }
...@@ -202,7 +202,7 @@ Launcher::Launcher(GarconMenuItem* item) : ...@@ -202,7 +202,7 @@ Launcher::Launcher(GarconMenuItem* item) :
for (GList* i = keywords; i; i = i->next) for (GList* i = keywords; i; i = i->next)
{ {
const gchar* keyword = static_cast<gchar*>(i->data); const gchar* keyword = static_cast<gchar*>(i->data);
if (!exo_str_is_empty(keyword) && g_utf8_validate(keyword, -1, nullptr)) if (!xfce_str_is_empty(keyword) && g_utf8_validate(keyword, -1, nullptr))
{ {
m_search_keywords.push_back(normalize(keyword)); m_search_keywords.push_back(normalize(keyword));
} }
...@@ -211,7 +211,7 @@ Launcher::Launcher(GarconMenuItem* item) : ...@@ -211,7 +211,7 @@ Launcher::Launcher(GarconMenuItem* item) :
// Create search text for command // Create search text for command
const gchar* command = garcon_menu_item_get_command(m_item); const gchar* command = garcon_menu_item_get_command(m_item);
if (!exo_str_is_empty(command) && g_utf8_validate(command, -1, nullptr)) if (!xfce_str_is_empty(command) && g_utf8_validate(command, -1, nullptr))
{ {
m_search_command = normalize(command); m_search_command = normalize(command);
} }
...@@ -294,7 +294,7 @@ void Launcher::run(GdkScreen* screen) const ...@@ -294,7 +294,7 @@ void Launcher::run(GdkScreen* screen) const
{ {
// Expand the field codes // Expand the field codes
const gchar* string = garcon_menu_item_get_command(m_item); const gchar* string = garcon_menu_item_get_command(m_item);
if (exo_str_is_empty(string)) if (xfce_str_is_empty(string))
{ {
return; return;
} }
...@@ -339,7 +339,7 @@ void Launcher::run(GdkScreen* screen, DesktopAction* action) const ...@@ -339,7 +339,7 @@ void Launcher::run(GdkScreen* screen, DesktopAction* action) const
{ {
// Expand the field codes // Expand the field codes
const gchar* string = action->get_command(); const gchar* string = action->get_command();
if (exo_str_is_empty(string)) if (xfce_str_is_empty(string))
{ {
return; return;
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "search-action.h" #include "search-action.h"
#include "settings.h" #include "settings.h"
#include "slot.h" #include "slot.h"
#include "util.h"
#include "window.h" #include "window.h"
#include <algorithm> #include <algorithm>
...@@ -192,7 +193,7 @@ void SearchPage::activate_search(GtkEntry* entry) ...@@ -192,7 +193,7 @@ void SearchPage::activate_search(GtkEntry* entry)
void SearchPage::cancel_search(GtkSearchEntry* entry) void SearchPage::cancel_search(GtkSearchEntry* entry)
{ {
const gchar* text = gtk_entry_get_text(GTK_ENTRY(entry)); const gchar* text = gtk_entry_get_text(GTK_ENTRY(entry));
if (!exo_str_is_empty(text)) if (!xfce_str_is_empty(text))
{ {
gtk_entry_set_text(GTK_ENTRY(entry), ""); gtk_entry_set_text(GTK_ENTRY(entry), "");
} }
......
/*
* Copyright (C) 2020 Graeme Gott <graeme@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
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WHISKERMENU_UTIL_H
#define WHISKERMENU_UTIL_H
#include <libxfce4ui/libxfce4ui.h>
#if !LIBXFCE4UTIL_CHECK_VERSION(4,15,1)
#include <exo/exo.h>
#define xfce_str_is_empty exo_str_is_empty
#endif
#endif
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
#include "search-page.h" #include "search-page.h"
#include "settings.h" #include "settings.h"
#include "slot.h" #include "slot.h"
#include "util.h"
#include <exo/exo.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include <libxfce4ui/libxfce4ui.h> #include <libxfce4ui/libxfce4ui.h>
...@@ -671,7 +671,7 @@ gboolean WhiskerMenu::Window::on_key_press_event(GtkWidget* widget, GdkEvent* ev ...@@ -671,7 +671,7 @@ gboolean WhiskerMenu::Window::on_key_press_event(GtkWidget* widget, GdkEvent* ev
GdkEventKey* key_event = reinterpret_cast<GdkEventKey*>(event); GdkEventKey* key_event = reinterpret_cast<GdkEventKey*>(event);
// Hide if escape is pressed and there is no text in search entry // Hide if escape is pressed and there is no text in search entry
if ( (key_event->keyval == GDK_KEY_Escape) && exo_str_is_empty(gtk_entry_get_text(m_search_entry)) ) if ( (key_event->keyval == GDK_KEY_Escape) && xfce_str_is_empty(gtk_entry_get_text(m_search_entry)) )
{ {
hide(); hide();
return true; return true;
...@@ -923,7 +923,7 @@ void WhiskerMenu::Window::search() ...@@ -923,7 +923,7 @@ void WhiskerMenu::Window::search()
{ {
// Fetch search string // Fetch search string
const gchar* text = gtk_entry_get_text(m_search_entry); const gchar* text = gtk_entry_get_text(m_search_entry);
if (exo_str_is_empty(text)) if (xfce_str_is_empty(text))
{ {
text = nullptr; text = nullptr;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment