gnome-commander r2234 - in trunk: . doc/C src



Author: epiotr
Date: Thu Oct 23 22:28:56 2008
New Revision: 2234
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2234&view=rev

Log:
Advanced file rename tool - trim blanks

Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/doc/C/gnome-commander.xml
   trunk/src/Makefile.am
   trunk/src/gnome-cmd-advrename-dialog.cc

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Thu Oct 23 22:28:56 2008
@@ -14,6 +14,7 @@
 New features:
  * Support for PDF metatags in advanced file rename templates
  * Support for metadata tags in internal viewer
+ * Advanced file rename tool - trim blanks
  * New colour theme: cafezinho
  * New or updated docs: de, en, es
  * New or updated translations: ar, de, es, eu, pl

Modified: trunk/doc/C/gnome-commander.xml
==============================================================================
--- trunk/doc/C/gnome-commander.xml	(original)
+++ trunk/doc/C/gnome-commander.xml	Thu Oct 23 22:28:56 2008
@@ -5965,6 +5965,9 @@
                             <para>Support for metadata tags in internal viewer</para>
                         </listitem>
                         <listitem>
+                            <para>Advanced file rename tool - trim blanks</para>
+                        </listitem>
+                        <listitem>
                             <para>New colour theme: cafezinho</para>
                         </listitem>
                         <listitem>

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Thu Oct 23 22:28:56 2008
@@ -38,6 +38,7 @@
 	gnome-cmd-con-list.h gnome-cmd-con-list.cc \
 	gnome-cmd-con-smb.h gnome-cmd-con-smb.cc \
 	gnome-cmd-con.h gnome-cmd-con.cc \
+	gnome-cmd-convert.h gnome-cmd-convert.cc \
 	gnome-cmd-data.h gnome-cmd-data.cc \
 	gnome-cmd-delete-dialog.h gnome-cmd-delete-dialog.cc \
 	gnome-cmd-dir-indicator.h gnome-cmd-dir-indicator.cc \

Modified: trunk/src/gnome-cmd-advrename-dialog.cc
==============================================================================
--- trunk/src/gnome-cmd-advrename-dialog.cc	(original)
+++ trunk/src/gnome-cmd-advrename-dialog.cc	Thu Oct 23 22:28:56 2008
@@ -24,6 +24,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include "gnome-cmd-includes.h"
+#include "gnome-cmd-convert.h"
 #include "gnome-cmd-advrename-dialog.h"
 #include "gnome-cmd-advrename-lexer.h"
 #include "gnome-cmd-file.h"
@@ -55,6 +56,7 @@
     GList *entries;
     PatternEntry *sel_entry;
     GnomeCmdData::AdvrenameDefaults *defaults;
+    GnomeCmdConvertFunc trim_blanks;
 
     GtkWidget *pat_list;
     GtkWidget *res_list;
@@ -66,6 +68,7 @@
     GtkWidget *remove_all_btn;
     GtkWidget *templ_combo;
     GtkWidget *templ_entry;
+    GtkWidget *trim_combo;
 
     GtkWidget *menu[NUM_MENUS];
 };
@@ -746,12 +749,12 @@
 
         gnome_cmd_advrename_gen_fname (fname, sizeof (fname), entry->finfo);
 
-        entry->new_name = create_new_name (fname, patterns);
+        entry->new_name = dialog->priv->trim_blanks (create_new_name (fname, patterns));
     }
 }
 
 
-static void redisplay_new_names (GnomeCmdAdvrenameDialog *dialog)
+inline void redisplay_new_names (GnomeCmdAdvrenameDialog *dialog)
 {
     for (GList *tmp = dialog->priv->entries; tmp; tmp = tmp->next)
     {
@@ -918,6 +921,7 @@
     dialog->priv->defaults->counter_start = 1;
     dialog->priv->defaults->counter_precision = 1;
     dialog->priv->defaults->counter_increment = 1;
+    gtk_option_menu_set_history (GTK_OPTION_MENU (dialog->priv->trim_combo), 3);
 }
 
 
@@ -965,6 +969,22 @@
 }
 
 
+static void on_trim_combo_changed (GtkOptionMenu *optmenu, GnomeCmdAdvrenameDialog *dialog)
+{
+    TRACE(gtk_option_menu_get_history (optmenu));
+
+    switch (gtk_option_menu_get_history (optmenu))
+    {
+        case 0: dialog->priv->trim_blanks = gcmd_convert_unchanged; break;
+        case 1: dialog->priv->trim_blanks = gcmd_convert_ltrim; break;
+        case 2: dialog->priv->trim_blanks = gcmd_convert_rtrim; break;
+        case 3: dialog->priv->trim_blanks = gcmd_convert_strip; break;
+    }
+
+    do_test (dialog);
+}
+
+
 static gboolean on_template_options_ok (GnomeCmdStringDialog *string_dialog, const gchar **values, GnomeCmdAdvrenameDialog *dialog)
 {
     guint start, precision, inc;
@@ -1075,12 +1095,22 @@
 
 static void init (GnomeCmdAdvrenameDialog *in_dialog)
 {
-    GtkWidget *vbox;
+    GtkWidget *hbox, *vbox;
     GtkWidget *sw;
     GtkWidget *bbox;
     GtkWidget *btn;
     GtkWidget *cat;
     GtkWidget *table;
+    GtkWidget *optmenu;
+    GtkWidget *label;
+
+    gchar *trim_modes[] = {
+                              _("<none>"),
+                              _("leading"),
+                              _("trailing"),
+                              _("leading and trailing"),
+                              NULL
+                          };
 
     in_dialog->priv = g_new0 (GnomeCmdAdvrenameDialogPrivate, 1);
 
@@ -1198,6 +1228,26 @@
     gtk_widget_set_sensitive (GTK_WIDGET (in_dialog->priv->move_down_btn), FALSE);
 
 
+    // Trim blanks stuff
+    hbox = create_hbox (dialog, FALSE, 12);
+    gnome_cmd_dialog_add_category (GNOME_CMD_DIALOG (dialog), hbox);
+
+    gchar *str = g_strdup_printf ("<b>%s</b>", _("Trim blanks"));
+    label = gtk_label_new_with_mnemonic (str);
+    g_free (str);
+
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+    gtk_widget_show (label);
+    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+    in_dialog->priv->trim_combo = optmenu = create_option_menu (dialog, trim_modes);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), optmenu);
+    gtk_box_pack_start (GTK_BOX (hbox), optmenu, FALSE, FALSE, 0);
+    gtk_signal_connect (GTK_OBJECT (optmenu), "changed", GTK_SIGNAL_FUNC (on_trim_combo_changed), dialog);
+    gtk_option_menu_set_history (GTK_OPTION_MENU (in_dialog->priv->trim_combo), 3);
+
+
     // Result list stuff
     vbox = create_vbox (dialog, FALSE, 0);
     cat = create_category (dialog, vbox, _("Result"));



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