[gnome-packagekit] trivial: Inline a simple string test



commit 2d9ab587b599d88edd4a2bfa601611042b708746
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jul 18 14:23:16 2016 +0100

    trivial: Inline a simple string test

 src/Makefile.am         |    4 ---
 src/egg-string.c        |   66 -----------------------------------------------
 src/egg-string.h        |   34 ------------------------
 src/gpk-application.c   |   20 ++++++++++----
 src/gpk-common.c        |    2 -
 src/gpk-dialog.c        |    5 +---
 src/gpk-enum.c          |    2 -
 src/gpk-update-viewer.c |   25 ++++++++++++-----
 8 files changed, 32 insertions(+), 126 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index cef6484..87fc25d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,8 +36,6 @@ bin_PROGRAMS =                                                \
 
 noinst_LIBRARIES = libgpkshared.a
 libgpkshared_a_SOURCES =                               \
-       egg-string.c                                    \
-       egg-string.h                                    \
        gpk-debug.c                                     \
        gpk-debug.h                                     \
        gpk-enum.c                                      \
@@ -130,8 +128,6 @@ noinst_PROGRAMS =                                   \
 
 gpk_self_test_SOURCES =                                        \
        gpk-self-test.c                                 \
-       egg-string.c                                    \
-       egg-string.h                                    \
        gpk-debug.c                                     \
        gpk-debug.h                                     \
        gpk-enum.c                                      \
diff --git a/src/gpk-application.c b/src/gpk-application.c
index b4e00ad..0da75c7 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -34,8 +34,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "egg-string.h"
-
 #include "gpk-common.h"
 #include "gpk-common.h"
 #include "gpk-dialog.h"
@@ -130,6 +128,16 @@ static void gpk_application_perform_search (GpkApplicationPrivate *priv);
 static void gpk_application_get_requires_cb (PkClient *client, GAsyncResult *res, GpkApplicationPrivate 
*priv);
 static void gpk_application_get_depends_cb (PkClient *client, GAsyncResult *res, GpkApplicationPrivate 
*priv);
 
+static gboolean
+_g_strzero (const gchar *text)
+{
+       if (text == NULL)
+               return TRUE;
+       if (text[0] == '\0')
+               return TRUE;
+       return FALSE;
+}
+
 /**
  * gpk_application_state_get_icon:
  **/
@@ -191,7 +199,7 @@ gpk_application_set_text_buffer (GtkWidget *widget, const gchar *text)
        GtkTextBuffer *buffer;
        buffer = gtk_text_buffer_new (NULL);
        /* ITS4: ignore, not used for allocation */
-       if (egg_strzero (text) == FALSE) {
+       if (_g_strzero (text) == FALSE) {
                gtk_text_buffer_set_text (buffer, text, -1);
        } else {
                /* no information */
@@ -1099,7 +1107,7 @@ gpk_application_get_full_repo_name (GpkApplicationPrivate *priv, const gchar *da
        const gchar *repo_name;
 
        /* if no data, we can't look up in the hash table */
-       if (egg_strzero (data)) {
+       if (_g_strzero (data)) {
                g_warning ("no ident data");
                /* TRANSLATORS: the repo name is invalid or not found, fall back to this */
                return _("Invalid");
@@ -1464,12 +1472,12 @@ gpk_application_perform_search_name_details_file (GpkApplicationPrivate *priv)
        priv->search_text = g_strdup (gtk_entry_get_text (entry));
 
        /* have we got input? */
-       if (egg_strzero (priv->search_text)) {
+       if (_g_strzero (priv->search_text)) {
                g_debug ("no input");
                goto out;
        }
 
-       ret = !egg_strzero (priv->search_text);
+       ret = !_g_strzero (priv->search_text);
        if (!ret) {
                g_debug ("invalid input text, will fail");
                /* TODO - make the dialog turn red... */
diff --git a/src/gpk-common.c b/src/gpk-common.c
index 0d24798..7061904 100644
--- a/src/gpk-common.c
+++ b/src/gpk-common.c
@@ -33,8 +33,6 @@
 #include <packagekit-glib2/packagekit.h>
 #include <locale.h>
 
-#include "egg-string.h"
-
 #include "gpk-enum.h"
 #include "gpk-common.h"
 #include "gpk-error.h"
diff --git a/src/gpk-dialog.c b/src/gpk-dialog.c
index 2a27cde..97fa1ec 100644
--- a/src/gpk-dialog.c
+++ b/src/gpk-dialog.c
@@ -26,8 +26,6 @@
 #include <gtk/gtk.h>
 #include <packagekit-glib2/packagekit.h>
 
-#include "egg-string.h"
-
 #include "gpk-common.h"
 #include "gpk-dialog.h"
 #include "gpk-enum.h"
@@ -229,8 +227,7 @@ gpk_dialog_embed_file_list_widget (GtkDialog *dialog, GPtrArray *files)
        /* split and show */
        array = pk_ptr_array_to_strv (files);
        text = g_strjoinv ("\n", array);
-
-       if (egg_strzero (text)) {
+       if (text[0] == '\0') {
                g_free (text);
                text = g_strdup (_("No files"));
        }
diff --git a/src/gpk-enum.c b/src/gpk-enum.c
index 7cf08a9..d6b22a5 100644
--- a/src/gpk-enum.c
+++ b/src/gpk-enum.c
@@ -25,8 +25,6 @@
 #include <glib/gi18n.h>
 #include <packagekit-glib2/packagekit.h>
 
-#include "egg-string.h"
-
 #include "gpk-enum.h"
 #include "gpk-common.h"
 
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index ed26c7f..3d3b094 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -29,7 +29,6 @@
 #include <locale.h>
 #include <packagekit-glib2/packagekit.h>
 
-#include "egg-string.h"
 #ifdef HAVE_SYSTEMD
 #include "systemd-proxy.h"
 #endif
@@ -94,6 +93,16 @@ enum {
 
 static gboolean gpk_update_viewer_get_new_update_array (void);
 
+static gboolean
+_g_strzero (const gchar *text)
+{
+       if (text == NULL)
+               return TRUE;
+       if (text[0] == '\0')
+               return TRUE;
+       return FALSE;
+}
+
 /**
  * gpk_update_viewer_quit:
  **/
@@ -1998,8 +2007,8 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
        }
 
        /* update text */
-       if (!egg_strzero (update_text)) {
-               if (!egg_strzero (line)) {
+       if (!_g_strzero (update_text)) {
+               if (!_g_strzero (line)) {
                        gtk_text_buffer_insert (text_buffer, &iter, update_text, -1);
                        gtk_text_buffer_insert (text_buffer, &iter, "\n\n", -1);
                        has_update_text = TRUE;
@@ -2031,7 +2040,7 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
        }
 #else
        /* add all the links */
-       if (!egg_strzero (vendor_url)) {
+       if (!_g_strzero (vendor_url)) {
                array = gpk_update_viewer_get_uris (vendor_url);
                /* TRANSLATORS: this is a array of vendor URLs */
                title = ngettext ("For more information about this update please visit this website:",
@@ -2039,7 +2048,7 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
                gpk_update_viewer_add_description_link_item (text_buffer, &iter, title, array);
                g_ptr_array_unref (array);
        }
-       if (!egg_strzero (bugzilla_url)) {
+       if (!_g_strzero (bugzilla_url)) {
                array = gpk_update_viewer_get_uris (bugzilla_url);
                /* TRANSLATORS: this is a array of bugzilla URLs */
                title = ngettext ("For more information about bugs fixed by this update please visit this 
website:",
@@ -2047,7 +2056,7 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
                gpk_update_viewer_add_description_link_item (text_buffer, &iter, title, array);
                g_ptr_array_unref (array);
        }
-       if (!egg_strzero (cve_url)) {
+       if (!_g_strzero (cve_url)) {
                array = gpk_update_viewer_get_uris (cve_url);
                /* TRANSLATORS: this is a array of CVE (security) URLs */
                title = ngettext ("For more information about this security update please visit this 
website:",
@@ -2079,8 +2088,8 @@ gpk_update_viewer_populate_details (PkUpdateDetail *item)
        }
 
        /* only show changelog if we didn't have any update text */
-       if (!has_update_text && !egg_strzero (changelog)) {
-               if (!egg_strzero (changelog)) {
+       if (!has_update_text && !_g_strzero (changelog)) {
+               if (!_g_strzero (changelog)) {
                        /* TRANSLATORS: this is a ChangeLog */
                        line2 = g_strdup_printf ("%s\n%s\n", _("The developer logs will be shown as no 
description is available for this update:"), changelog);
                        gtk_text_buffer_insert_markup (text_buffer, &iter, line2, -1);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]