[maemo-commits] [maemo-commits] r12007 - projects/haf/trunk/hildon-fm/hildon-fm

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu May 31 17:45:09 EEST 2007
Author: marivoll
Date: 2007-05-31 17:44:57 +0300 (Thu, 31 May 2007)
New Revision: 12007

Modified:
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.c
Log:
	* hildon-fm/hildon-file-system-voldev.c
	(capitalize_and_remove_trailing_spaces, beautify_mmc_name): New.
	(hildon_file_system_voldev_volumes_changed): Use them to hack the
	display name of memory cards (N33701).


Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.c	2007-05-31 13:48:31 UTC (rev 12006)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.c	2007-05-31 14:44:57 UTC (rev 12007)
@@ -23,6 +23,7 @@
 
 #include <glib.h>
 #include <string.h>
+#include <ctype.h>
 
 #include "hildon-file-system-voldev.h"
 #include "hildon-file-system-settings.h"
@@ -164,17 +165,26 @@
 }
 
 static void
-capitalize_ascii_string (gchar *str)
+capitalize_and_remove_trailing_spaces (gchar *str)
 {
+  /* STR must not consist of only whitespace.
+   */
+
+  gchar *last_non_space;
+
   if (*str)
     {
+      last_non_space = str;
       *str = g_ascii_toupper (*str);
       str++;
       while (*str)
         {
           *str = g_ascii_tolower (*str);
+	  if (!isspace (*str))
+	    last_non_space = str;
           str++;
         }
+      *(last_non_space+1) = '\0';
     }
 }
 
@@ -196,7 +206,7 @@
       name = g_strdup (name);
     }
   else
-    capitalize_ascii_string (name);
+    capitalize_and_remove_trailing_spaces (name);
 
   return name;
 }


More information about the maemo-commits mailing list