[Xfce4-commits] <xfce4-panel:devel> Get rid of custom IS_STRING macro.

Nick Schermer noreply at xfce.org
Tue Jan 26 19:40:01 CET 2010


Updating branch refs/heads/devel
         to 0e40ea5f463f508e08c34e95968fdcf9db3f0b69 (commit)
       from 9e6747e0d562d3b699acd6ebbf251da6832e76f3 (commit)

commit 0e40ea5f463f508e08c34e95968fdcf9db3f0b69
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Jan 26 19:20:29 2010 +0100

    Get rid of custom IS_STRING macro.

 common/panel-private.h           |    3 ---
 libxfce4panel/xfce-panel-image.c |    4 ++--
 panel/panel-application.c        |    2 +-
 panel/panel-dbus-client.c        |    5 +++--
 panel/panel-item-dialog.c        |    2 +-
 panel/panel-module.c             |    4 ++--
 plugins/clock/clock.c            |    6 +++---
 plugins/systray/systray-box.c    |   11 ++++++-----
 plugins/systray/systray.c        |    6 +++---
 plugins/windowmenu/windowmenu.c  |    6 +++---
 10 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/common/panel-private.h b/common/panel-private.h
index d694c29..a0830f0 100644
--- a/common/panel-private.h
+++ b/common/panel-private.h
@@ -51,9 +51,6 @@
 #define PANEL_UNSET_FLAG(flags,flag) G_STMT_START{ ((flags) &= ~(flag)); }G_STMT_END
 #define PANEL_HAS_FLAG(flags,flag) (((flags) & (flag)) != 0)
 
-/* check if the string is not empty */
-#define IS_STRING(string) ((string) != NULL && *(string) != '\0')
-
 /* relative path to the plugin directory */
 #define PANEL_PLUGIN_RELATIVE_PATH "xfce4" G_DIR_SEPARATOR_S "panel"
 
diff --git a/libxfce4panel/xfce-panel-image.c b/libxfce4panel/xfce-panel-image.c
index a772ddc..2b88450 100644
--- a/libxfce4panel/xfce-panel-image.c
+++ b/libxfce4panel/xfce-panel-image.c
@@ -496,7 +496,7 @@ xfce_panel_image_new_from_pixbuf (GdkPixbuf *pixbuf)
 GtkWidget *
 xfce_panel_image_new_from_source (const gchar *source)
 {
-  g_return_val_if_fail (IS_STRING (source), NULL);
+  g_return_val_if_fail (source != NULL && *source != '\0', NULL);
 
   return g_object_new (XFCE_TYPE_PANEL_IMAGE,
                        "source", source, NULL);
@@ -527,7 +527,7 @@ xfce_panel_image_set_from_source (XfcePanelImage *image,
                                   const gchar    *source)
 {
   g_return_if_fail (XFCE_IS_PANEL_IMAGE (image));
-  g_return_if_fail (IS_STRING (source));
+  g_return_if_fail (source != NULL && *source != '\0');
 
   xfce_panel_image_clear (image);
 
diff --git a/panel/panel-application.c b/panel/panel-application.c
index 2e010c6..17dcf69 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -411,7 +411,7 @@ panel_application_plugin_delete_config (PanelApplication *application,
   gchar *filename, *path;
 
   panel_return_if_fail (PANEL_IS_APPLICATION (application));
-  panel_return_if_fail (IS_STRING (name));
+  panel_return_if_fail (!exo_str_is_empty (name));
   panel_return_if_fail (unique_id != -1);
 
   /* remove the xfconf property */
diff --git a/panel/panel-dbus-client.c b/panel/panel-dbus-client.c
index ac55dea..176119c 100644
--- a/panel/panel-dbus-client.c
+++ b/panel/panel-dbus-client.c
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #endif
 
+#include <exo/exo.h>
 #include <dbus/dbus-glib.h>
 #include <libxfce4util/libxfce4util.h>
 #include <common/panel-private.h>
@@ -218,8 +219,8 @@ panel_dbus_client_plugin_event (const gchar  *plugin_event,
   n_tokens = g_strv_length (tokens);
 
   if (!(n_tokens == 2 || n_tokens == N_TOKENS)
-      || !IS_STRING (tokens[PLUGIN_NAME])
-      || !IS_STRING (tokens[NAME])
+      || exo_str_is_empty (tokens[PLUGIN_NAME])
+      || exo_str_is_empty (tokens[NAME])
       || *tokens[NAME] == SIGNAL_PREFIX)
     {
       g_set_error_literal (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
diff --git a/panel/panel-item-dialog.c b/panel/panel-item-dialog.c
index 8315be4..fc5063c 100644
--- a/panel/panel-item-dialog.c
+++ b/panel/panel-item-dialog.c
@@ -610,7 +610,7 @@ panel_item_dialog_visible_func (GtkTreeModel *model,
 
   /* search string from dialog */
   text = gtk_entry_get_text (entry);
-  if (G_UNLIKELY (!IS_STRING (text)))
+  if (G_UNLIKELY (exo_str_is_empty (text)))
     return TRUE;
 
   gtk_tree_model_get (model, iter, COLUMN_MODULE, &module, -1);
diff --git a/panel/panel-module.c b/panel/panel-module.c
index fc38b50..fdf849e 100644
--- a/panel/panel-module.c
+++ b/panel/panel-module.c
@@ -289,8 +289,8 @@ panel_module_new_from_desktop_file (const gchar *filename,
   gchar       *path;
   const gchar *module_exec;
 
-  panel_return_val_if_fail (IS_STRING (filename), NULL);
-  panel_return_val_if_fail (IS_STRING (name), NULL);
+  panel_return_val_if_fail (!exo_str_is_empty (filename), NULL);
+  panel_return_val_if_fail (!exo_str_is_empty (name), NULL);
 
   rc = xfce_rc_simple_open (filename, TRUE);
   if (G_UNLIKELY (rc == NULL))
diff --git a/plugins/clock/clock.c b/plugins/clock/clock.c
index 2380538..98ef10c 100644
--- a/plugins/clock/clock.c
+++ b/plugins/clock/clock.c
@@ -587,7 +587,7 @@ clock_plugin_configure_plugin_chooser_fill (GtkComboBox *combo,
       g_free (preview);
 
       if (has_active == FALSE
-          && IS_STRING (active_format)
+          && !exo_str_is_empty (active_format)
           && strcmp (active_format, formats[i]) == 0)
         {
           gtk_combo_box_set_active_iter (combo, &iter);
@@ -937,7 +937,7 @@ clock_plugin_strdup_strftime (const gchar     *format,
   gchar  buffer[1024];
 
   /* leave when format is null */
-  if (G_UNLIKELY (!IS_STRING (format)))
+  if (G_UNLIKELY (exo_str_is_empty (format)))
     return NULL;
 
   /* convert to locale, because that's what strftime uses */
@@ -966,7 +966,7 @@ clock_plugin_interval_from_format (const gchar *format)
 {
   const gchar *p;
 
-  if (G_UNLIKELY (!IS_STRING (format)))
+  if (G_UNLIKELY (exo_str_is_empty (format)))
       return CLOCK_INTERVAL_MINUTE;
 
   for (p = format; *p != '\0'; ++p)
diff --git a/plugins/systray/systray-box.c b/plugins/systray/systray-box.c
index b7481cd..5807df0 100644
--- a/plugins/systray/systray-box.c
+++ b/plugins/systray/systray-box.c
@@ -24,6 +24,7 @@
 #include <string.h>
 #endif
 
+#include <exo/exo.h>
 #include <gtk/gtk.h>
 #include <libxfce4panel/libxfce4panel.h>
 #include <common/panel-private.h>
@@ -640,12 +641,12 @@ systray_box_compare_function (gconstpointer a,
     return (child_a->auto_hide ? -1 : 1);
 
   /* put icons without name after the hidden icons */
-  if (!IS_STRING (child_a->name) || !IS_STRING (child_b->name))
+  if (exo_str_is_empty (child_a->name) || exo_str_is_empty (child_b->name))
     {
-      if (IS_STRING (child_a->name) == IS_STRING (child_b->name))
+      if (!exo_str_is_empty (child_a->name) == !exo_str_is_empty (child_b->name))
         return 0;
       else
-        return !IS_STRING (child_a->name) ? -1 : 1;
+        return exo_str_is_empty (child_a->name) ? -1 : 1;
     }
 
   /* sort by name */
@@ -764,7 +765,7 @@ systray_box_name_add (SystrayBox  *box,
                       gboolean     hidden)
 {
   panel_return_if_fail (XFCE_IS_SYSTRAY_BOX (box));
-  panel_return_if_fail (IS_STRING (name));
+  panel_return_if_fail (!exo_str_is_empty (name));
 
   /* insert the application */
   g_hash_table_insert (box->names, g_strdup (name),
@@ -783,7 +784,7 @@ systray_box_name_set_hidden (SystrayBox  *box,
   gint             n_hidden_childeren;
 
   panel_return_if_fail (XFCE_IS_SYSTRAY_BOX (box));
-  panel_return_if_fail (IS_STRING (name));
+  panel_return_if_fail (!exo_str_is_empty (name));
 
   /* replace the old name */
   g_hash_table_replace (box->names, g_strdup (name),
diff --git a/plugins/systray/systray.c b/plugins/systray/systray.c
index ae2a573..f06a96e 100644
--- a/plugins/systray/systray.c
+++ b/plugins/systray/systray.c
@@ -541,7 +541,7 @@ systray_plugin_dialog_camel_case (const gchar *text)
   gunichar     c;
   GString     *result;
 
-  panel_return_val_if_fail (IS_STRING (text), NULL);
+  panel_return_val_if_fail (!exo_str_is_empty (text), NULL);
 
   /* allocate a new string for the result */
   result = g_string_sized_new (32);
@@ -582,7 +582,7 @@ systray_plugin_dialog_icon (GtkIconTheme *icon_theme,
   gchar       *first_occ;
   const gchar *p;
 
-  panel_return_val_if_fail (IS_STRING (icon_name), NULL);
+  panel_return_val_if_fail (!exo_str_is_empty (icon_name), NULL);
   panel_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), NULL);
 
   /* try to load the icon from the theme */
@@ -637,7 +637,7 @@ systray_plugin_dialog_add_application_names (SystrayPlugin *plugin,
       name = li->data;
 
       /* skip invalid names */
-      if (!IS_STRING (name))
+      if (exo_str_is_empty (name))
         continue;
 
       /* init */
diff --git a/plugins/windowmenu/windowmenu.c b/plugins/windowmenu/windowmenu.c
index 13357d5..bc44237 100644
--- a/plugins/windowmenu/windowmenu.c
+++ b/plugins/windowmenu/windowmenu.c
@@ -975,7 +975,7 @@ window_menu_plugin_menu_window_item_new (WnckWindow           *window,
 
   /* try to get an utf-8 valid name */
   name = wnck_window_get_name (window);
-  if (IS_STRING (name) && !g_utf8_validate (name, -1, NULL))
+  if (!exo_str_is_empty (name) && !g_utf8_validate (name, -1, NULL))
     name = utf8 = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
 
   if (exo_str_is_empty (name))
@@ -1307,12 +1307,12 @@ window_menu_plugin_menu_new (WindowMenuPlugin *plugin)
         {
           /* try to get an utf-8 valid name */
           name = wnck_workspace_get_name (workspace);
-          if (IS_STRING (name) && !g_utf8_validate (name, -1, NULL))
+          if (!exo_str_is_empty (name) && !g_utf8_validate (name, -1, NULL))
             name = utf8 = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
         }
 
       /* create label */
-      if (IS_STRING (name))
+      if (!exo_str_is_empty (name))
         label = g_strdup_printf (_("Remove Workspace \"%s\""), name);
       else
         label = g_strdup_printf (_("Remove Workspace %d"), n_workspaces);



More information about the Xfce4-commits mailing list