[Xfce4-commits] <thunar:master> Add a sencence case rename mode to sbr.

Nick Schermer noreply at xfce.org
Sat Sep 8 19:36:01 CEST 2012


Updating branch refs/heads/master
         to b8cc0567f7c35e10443c511aeed05686137ceb99 (commit)
       from ee26db254c9549fec46859612cdb7296f3e9ab60 (commit)

commit b8cc0567f7c35e10443c511aeed05686137ceb99
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Sep 8 19:33:45 2012 +0200

    Add a sencence case rename mode to sbr.
    
    Only uppercase the first letter in the filename.

 plugins/thunar-sbr/thunar-sbr-case-renamer.c |   13 +++++++++----
 plugins/thunar-sbr/thunar-sbr-enum-types.c   |    9 +++++----
 plugins/thunar-sbr/thunar-sbr-enum-types.h   |    8 +++++---
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/plugins/thunar-sbr/thunar-sbr-case-renamer.c b/plugins/thunar-sbr/thunar-sbr-case-renamer.c
index 9f8f2e8..a2ca8bd 100644
--- a/plugins/thunar-sbr/thunar-sbr-case-renamer.c
+++ b/plugins/thunar-sbr/thunar-sbr-case-renamer.c
@@ -85,7 +85,7 @@ thunar_sbr_case_renamer_class_init (ThunarSbrCaseRenamerClass *klass)
   /**
    * ThunarSbrCaseRenamer:mode:
    *
-   * The #ThunarSbrCaseRenamerMode for this 
+   * The #ThunarSbrCaseRenamerMode for this
    * #ThunarSbrCaseRenamer instance.
    **/
   g_object_class_install_property (gobject_class,
@@ -183,7 +183,8 @@ thunar_sbr_case_renamer_set_property (GObject      *object,
 
 
 static gchar*
-tscr_utf8_strcamel (const gchar *text)
+tscr_utf8_strcase (const gchar *text,
+                   gboolean     camelcase)
 {
   const gchar *t;
   gboolean     upper = TRUE;
@@ -198,7 +199,8 @@ tscr_utf8_strcamel (const gchar *text)
     {
       /* check the next char */
       c = g_utf8_get_char (t);
-      if (g_unichar_isspace (c))
+      if (camelcase
+          && g_unichar_isspace (c))
         {
           upper = TRUE;
         }
@@ -238,7 +240,10 @@ thunar_sbr_case_renamer_process (ThunarxRenamer  *renamer,
       return g_utf8_strup (text, -1);
 
     case THUNAR_SBR_CASE_RENAMER_MODE_CAMEL:
-      return tscr_utf8_strcamel (text);
+      return tscr_utf8_strcase (text, TRUE);
+
+   case THUNAR_SBR_CASE_RENAMER_MODE_SENTENCE:
+      return tscr_utf8_strcase (text, FALSE);
 
     default:
       g_assert_not_reached ();
diff --git a/plugins/thunar-sbr/thunar-sbr-enum-types.c b/plugins/thunar-sbr/thunar-sbr-enum-types.c
index cd02ed0..3260be9 100644
--- a/plugins/thunar-sbr/thunar-sbr-enum-types.c
+++ b/plugins/thunar-sbr/thunar-sbr-enum-types.c
@@ -90,10 +90,11 @@ thunar_sbr_register_enum_types (ThunarxProviderPlugin *plugin)
 {
   static const GEnumValue case_renamer_mode_values[] =
   {
-    { THUNAR_SBR_CASE_RENAMER_MODE_LOWER, "THUNAR_SBR_CASE_RENAMER_MODE_LOWER", N_ ("lowercase"), },
-    { THUNAR_SBR_CASE_RENAMER_MODE_UPPER, "THUNAR_SBR_CASE_RENAMER_MODE_UPPER", N_ ("UPPERCASE"), },
-    { THUNAR_SBR_CASE_RENAMER_MODE_CAMEL, "THUNAR_SBR_CASE_RENAMER_MODE_CAMEL", N_ ("Camelcase"), },
-    { 0,                                  NULL,                                 NULL,             },
+    { THUNAR_SBR_CASE_RENAMER_MODE_LOWER,    "THUNAR_SBR_CASE_RENAMER_MODE_LOWER",    N_ ("lowercase"),     },
+    { THUNAR_SBR_CASE_RENAMER_MODE_UPPER,    "THUNAR_SBR_CASE_RENAMER_MODE_UPPER",    N_ ("UPPERCASE"),     },
+    { THUNAR_SBR_CASE_RENAMER_MODE_CAMEL,    "THUNAR_SBR_CASE_RENAMER_MODE_CAMEL",    N_ ("Camelcase")    , },
+    { THUNAR_SBR_CASE_RENAMER_MODE_SENTENCE, "THUNAR_SBR_CASE_RENAMER_MODE_SENTENCE", N_ ("Sentence case"), },
+    { 0,                                     NULL,                                    NULL,                 },
   };
 
   static const GEnumValue insert_mode_values[] =
diff --git a/plugins/thunar-sbr/thunar-sbr-enum-types.h b/plugins/thunar-sbr/thunar-sbr-enum-types.h
index c57a0fc..c69a3b2 100644
--- a/plugins/thunar-sbr/thunar-sbr-enum-types.h
+++ b/plugins/thunar-sbr/thunar-sbr-enum-types.h
@@ -29,9 +29,10 @@ G_BEGIN_DECLS;
 
 /**
  * ThunarSbrCaseRenamerMode:
- * @THUNAR_SBR_CASE_RENAMER_MODE_LOWER : convert to lower case.
- * @THUNAR_SBR_CASE_RENAMER_MODE_UPPER : convert to upper case.
- * @THUNAR_SBR_CASE_RENAMER_MODE_CAMEL : convert to camel case.
+ * @THUNAR_SBR_CASE_RENAMER_MODE_LOWER    : convert to lower case.
+ * @THUNAR_SBR_CASE_RENAMER_MODE_UPPER    : convert to upper case.
+ * @THUNAR_SBR_CASE_RENAMER_MODE_CAMEL    : convert to camel case.
+ * @THUNAR_SBR_CASE_RENAMER_MODE_SENTENCE : convert to sentence case.
  *
  * The operation mode for the #ThunarSbrCaseRenamer.
  **/
@@ -40,6 +41,7 @@ typedef enum
   THUNAR_SBR_CASE_RENAMER_MODE_LOWER,
   THUNAR_SBR_CASE_RENAMER_MODE_UPPER,
   THUNAR_SBR_CASE_RENAMER_MODE_CAMEL,
+  THUNAR_SBR_CASE_RENAMER_MODE_SENTENCE,
 } ThunarSbrCaseRenamerMode;
 
 GType thunar_sbr_case_renamer_mode_get_type (void) G_GNUC_CONST;


More information about the Xfce4-commits mailing list