[nautilus/wip/alexpandelea/batchRename] Use a single action



commit ec4fffd9f5f5ee107f87f2809871c95a30caef39
Author: Alexandru Pandelea <alexandru pandelea gmail com>
Date:   Thu Jun 30 11:34:36 2016 +0300

    Use a single action
    
    Instead of using a separate action for each sort mode, use a single one.

 src/nautilus-batch-rename.c                      |   29 +++++++++++----------
 src/nautilus-batch-rename.h                      |    6 +---
 src/resources/ui/nautilus-batch-rename-dialog.ui |   12 ++++++---
 3 files changed, 25 insertions(+), 22 deletions(-)
---
diff --git a/src/nautilus-batch-rename.c b/src/nautilus-batch-rename.c
index 50cd0db..a5c2ae0 100644
--- a/src/nautilus-batch-rename.c
+++ b/src/nautilus-batch-rename.c
@@ -72,6 +72,7 @@ static void     file_names_widget_entry_on_changed      (NautilusBatchRename
 
 G_DEFINE_TYPE (NautilusBatchRename, nautilus_batch_rename, GTK_TYPE_DIALOG);
 
+/*
 static void
 numbering_order_changed_descending (GSimpleAction       *action,
                                     GVariant            *state,
@@ -86,7 +87,7 @@ numbering_order_changed_descending (GSimpleAction       *action,
         gtk_label_set_label (GTK_LABEL (dialog->numbering_order_label),
                              "Original name (Descending)");
 
-        /* update display text */
+
         file_names_widget_entry_on_changed (dialog);
 }
 
@@ -104,7 +105,7 @@ numbering_order_changed_ascending (GSimpleAction       *action,
         gtk_label_set_label (GTK_LABEL (dialog->numbering_order_label),
                              "Original name (Ascending)  ");
 
-        /* update display text */
+
         file_names_widget_entry_on_changed (dialog);
 }
 
@@ -122,33 +123,35 @@ numbering_order_changed_first_modified (GSimpleAction       *action,
         gtk_label_set_label (GTK_LABEL (dialog->numbering_order_label),
                              "First Modified                       ");
 
-        /* update display text */
+
         file_names_widget_entry_on_changed (dialog);
-}
+}*/
 
 static void
-numbering_order_changed_last_modified (GSimpleAction       *action,
-                                       GVariant            *state,
-                                       gpointer            user_data)
+numbering_order_changed (GSimpleAction       *action,
+                         GVariant            *value,
+                         gpointer            user_data)
 {
         NautilusBatchRename *dialog;
+        const gchar *target_name;
 
         dialog = NAUTILUS_BATCH_RENAME (user_data);
-
         dialog->selection = nautilus_batch_rename_sort (dialog->selection, LAST_MODIFIED);
 
+        target_name = g_variant_get_string (value, NULL);
+        g_message("%s",target_name);
+
         gtk_label_set_label (GTK_LABEL (dialog->numbering_order_label),
                              "Last Modified                       ");
 
+        //g_simple_action_set_state (action, state);
+
         /* update display text */
         file_names_widget_entry_on_changed (dialog);
 }
 
 const GActionEntry dialog_entries[] = {
-        { "numbering-order-changed-descending",  numbering_order_changed_descending },
-        { "numbering-order-changed-ascending",  numbering_order_changed_ascending },
-        { "numbering-order-changed-first-modified",  numbering_order_changed_first_modified },
-        { "numbering-order-changed-last-modified",  numbering_order_changed_last_modified },
+        { "numbering-order-changed",  numbering_order_changed },
 };
 
 static GList*
@@ -470,8 +473,6 @@ numbering_order_popover_closed (NautilusBatchRename *dialog)
 static void
 nautilus_batch_rename_initialize_actions (NautilusBatchRename *dialog)
 {
-        GAction *action;
-
         dialog->action_group = G_ACTION_GROUP (g_simple_action_group_new ());
 
         g_action_map_add_action_entries (G_ACTION_MAP (dialog->action_group),
diff --git a/src/nautilus-batch-rename.h b/src/nautilus-batch-rename.h
index b48423f..c5f0197 100644
--- a/src/nautilus-batch-rename.h
+++ b/src/nautilus-batch-rename.h
@@ -18,10 +18,8 @@ typedef enum {
 typedef enum {
         ORIGINAL_ASCENDING = 0,
         ORIGINAL_DESCENDING = 1,
-        FIRST_CREATED = 2,
-        LAST_CREATED = 3,
-        FIRST_MODIFIED = 4,
-        LAST_MODIFIED = 5,
+        FIRST_MODIFIED = 2,
+        LAST_MODIFIED = 3,
 } SortingMode;
 
 #define NAUTILUS_TYPE_BATCH_RENAME (nautilus_batch_rename_get_type())
diff --git a/src/resources/ui/nautilus-batch-rename-dialog.ui 
b/src/resources/ui/nautilus-batch-rename-dialog.ui
index 6c1f529..6c5f7e5 100644
--- a/src/resources/ui/nautilus-batch-rename-dialog.ui
+++ b/src/resources/ui/nautilus-batch-rename-dialog.ui
@@ -335,7 +335,8 @@
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="text" translatable="yes">Original name (Ascending) </property>
-            <property name="action-name">dialog.numbering-order-changed-ascending</property>
+            <property name="action-name">dialog.numbering-order-changed</property>
+            <property name="action-target">'name-ascending'</property>
           </object>
         </child>
         <child>
@@ -343,7 +344,8 @@
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="text" translatable="yes">Original name (Descending) </property>
-            <property name="action-name">dialog.numbering-order-changed-descending</property>
+            <property name="action-name">dialog.numbering-order-changed</property>
+            <property name="action-target">'name-descending'</property>
           </object>
         </child>
         <child>
@@ -351,7 +353,8 @@
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="text" translatable="yes">First Modified</property>
-            <property name="action-name">dialog.numbering-order-changed-first-modified</property>
+            <property name="action-name">dialog.numbering-order-changed</property>
+            <property name="action-target">'first-modified'</property>
           </object>
         </child>
         <child>
@@ -359,7 +362,8 @@
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="text" translatable="yes">Last Modified</property>
-            <property name="action-name">dialog.numbering-order-changed-last-modified</property>
+            <property name="action-name">dialog.numbering-order-changed</property>
+            <property name="action-target">'last-modified'</property>
           </object>
         </child>
       </object>


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