[Xfce4-commits] <garcon:master> Follow Jannis' coding style in loops.

Nick Schermer nick at xfce.org
Mon Aug 17 19:08:01 CEST 2009


Updating branch refs/heads/master
         to 53b235e05771f5bd7ac44c4efc987a46b5ffb88a (commit)
       from 7a509d72dd7f8c22b13900ef95fbf38392e431a2 (commit)

commit 53b235e05771f5bd7ac44c4efc987a46b5ffb88a
Author: Nick Schermer <nick at xfce.org>
Date:   Mon Aug 17 19:03:17 2009 +0200

    Follow Jannis' coding style in loops.

 garcon/garcon-menu-directory.c |   18 ++++++------------
 garcon/garcon-menu-item.c      |   26 ++++++++++----------------
 2 files changed, 16 insertions(+), 28 deletions(-)

diff --git a/garcon/garcon-menu-directory.c b/garcon/garcon-menu-directory.c
index ca2853e..c486c83 100644
--- a/garcon/garcon-menu-directory.c
+++ b/garcon/garcon-menu-directory.c
@@ -519,6 +519,7 @@ garcon_menu_directory_get_show_in_environment (GarconMenuDirectory *directory)
 {
   const gchar *env;
   guint        i;
+  gboolean     show = TRUE;
 
   g_return_val_if_fail (GARCON_IS_MENU_DIRECTORY (directory), FALSE);
 
@@ -534,26 +535,19 @@ garcon_menu_directory_get_show_in_environment (GarconMenuDirectory *directory)
   if (G_UNLIKELY (directory->priv->only_show_in != NULL))
     {
       /* Check if your environemnt is in OnlyShowIn list */
-      for (i = 0; directory->priv->only_show_in[i] != NULL; i++)
+      for (i = 0, show = FALSE; !show && directory->priv->only_show_in[i] != NULL; i++)
         if (g_utf8_collate (directory->priv->only_show_in[i], env) == 0)
-          return TRUE;
-
-      /* Not in the list, hide it */
-      return FALSE;
+          show = TRUE;
     }
   else if (G_UNLIKELY (directory->priv->not_show_in != NULL))
     {
       /* Check if your environemnt is in NotShowIn list */
-      for (i = 0; directory->priv->not_show_in[i] != NULL; i++)
+      for (i = 0, show = TRUE; show && directory->priv->not_show_in[i] != NULL; i++)
         if (g_utf8_collate (directory->priv->not_show_in[i], env) == 0)
-          return FALSE;
-
-      /* Not in the list, show it */
-      return TRUE;
+          show = FALSE;
     }
 
-  /* No list, show it */
-  return TRUE;
+  return show;
 }
 
 
diff --git a/garcon/garcon-menu-item.c b/garcon/garcon-menu-item.c
index b7a42b4..f3a1d95 100644
--- a/garcon/garcon-menu-item.c
+++ b/garcon/garcon-menu-item.c
@@ -1106,6 +1106,7 @@ garcon_menu_item_get_show_in_environment (GarconMenuItem *item)
 {
   const gchar *env;
   guint        i;
+  gboolean     show = TRUE;
 
   g_return_val_if_fail (GARCON_IS_MENU_ITEM (item), FALSE);
 
@@ -1121,26 +1122,19 @@ garcon_menu_item_get_show_in_environment (GarconMenuItem *item)
   if (G_UNLIKELY (item->priv->only_show_in != NULL))
     {
       /* Check if your environemnt is in OnlyShowIn list */
-      for (i = 0; item->priv->only_show_in[i] != NULL; i++)
+      for (i = 0, show = FALSE; !show && item->priv->only_show_in[i] != NULL; i++)
         if (g_utf8_collate (item->priv->only_show_in[i], env) == 0)
-          return TRUE;
-
-      /* Not in the list, hide it */
-      return FALSE;
+          show = TRUE;
     }
   else if (G_UNLIKELY (item->priv->not_show_in != NULL))
     {
       /* Check if your environemnt is in NotShowIn list */
-      for (i = 0; item->priv->not_show_in[i] != NULL; i++)
+      for (i = 0, show = TRUE; show && item->priv->not_show_in[i] != NULL; i++)
         if (g_utf8_collate (item->priv->not_show_in[i], env) == 0)
-          return FALSE;
-
-      /* Not in the list, show it */
-      return TRUE;
+          show = FALSE;
     }
 
-  /* No list, show it */
-  return TRUE;
+  return show;
 }
 
 
@@ -1150,6 +1144,7 @@ garcon_menu_item_only_show_in_environment (GarconMenuItem *item)
 {
   const gchar *env;
   guint        i;
+  gboolean     show = FALSE;
 
   g_return_val_if_fail (GARCON_IS_MENU_ITEM (item), FALSE);
 
@@ -1164,13 +1159,12 @@ garcon_menu_item_only_show_in_environment (GarconMenuItem *item)
   if (G_UNLIKELY (item->priv->only_show_in != NULL))
     {
       /* Check if your environemnt is in OnlyShowIn list */
-      for (i = 0; item->priv->only_show_in[i] != NULL; i++)
+      for (i = 0, show = FALSE; !show && item->priv->only_show_in[i] != NULL; i++)
         if (g_utf8_collate (item->priv->only_show_in[i], env) == 0)
-          return TRUE;
+          show = TRUE;
     }
 
-  /* Not in the list or not list, hide it */
-  return FALSE;
+  return show;
 }
 
 



More information about the Xfce4-commits mailing list