[nautilus/wip/alexpandelea/batchRename: 5/17] Move buttons to header-bar



commit 03876fd9ce83e5530b13fe6421a73c2b02d5fe12
Author: Alexandru Pandelea <alexandru pandelea gmail com>
Date:   Fri Jun 17 11:18:15 2016 +0300

    Move buttons to header-bar
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768311

 src/nautilus-batch-rename.c                      |   55 +++++++++------
 src/resources/ui/nautilus-batch-rename-dialog.ui |   77 +++++++++++-----------
 2 files changed, 72 insertions(+), 60 deletions(-)
---
diff --git a/src/nautilus-batch-rename.c b/src/nautilus-batch-rename.c
index 01912fc..44daf7c 100644
--- a/src/nautilus-batch-rename.c
+++ b/src/nautilus-batch-rename.c
@@ -27,7 +27,7 @@
 
 #define ADD_TEXT_ENTRY_SIZE 550
 #define REPLACE_ENTRY_SIZE  275
-#define MAX_DISPLAY_LEN 40
+#define MAX_DISPLAY_LEN 50
 
 struct _NautilusBatchRename
 {
@@ -197,19 +197,19 @@ static void
 activate_expander (GtkExpander *expander,
                    NautilusBatchRename *dialog)
 {
-        GValue width = G_VALUE_INIT;
+        //GValue width = G_VALUE_INIT;
 
-        g_value_init (&width, G_TYPE_INT);
+        //g_value_init (&width, G_TYPE_INT);
 
-        if (gtk_expander_get_expanded (GTK_EXPANDER (expander))) {
+        //if (gtk_expander_get_expanded (GTK_EXPANDER (expander))) {
 
-                g_value_set_int (&width, 8);
-                gtk_container_child_set_property (GTK_CONTAINER (dialog->grid), dialog->label_stack, 
"width",&width);
-        } else {
+                //g_value_set_int (&width, 8);
+                //gtk_container_child_set_property (GTK_CONTAINER (dialog->grid), dialog->label_stack, 
"width",&width);
+        //} else {
 
-                g_value_set_int (&width, 5);
-                gtk_container_child_set_property (GTK_CONTAINER (dialog->grid), dialog->label_stack, 
"width",&width);
-        }
+                //g_value_set_int (&width, 5);
+                //gtk_container_child_set_property (GTK_CONTAINER (dialog->grid), dialog->label_stack, 
"width",&width);
+        //}
 }
 
 static void
@@ -305,7 +305,8 @@ file_names_widget_entry_on_changed (NautilusBatchRename *dialog)
         GList *duplicates;
         gchar *display_text = NULL;
         NautilusFile *file;
-        GValue width = G_VALUE_INIT;
+        gboolean singe_conflict;
+        //GValue width = G_VALUE_INIT;
 
         if(dialog->selection == NULL)
                 return;
@@ -313,33 +314,45 @@ file_names_widget_entry_on_changed (NautilusBatchRename *dialog)
         new_names = batch_rename_get_new_names(dialog);
         duplicates = list_has_duplicates (dialog->view, new_names, dialog->selection);
 
+        if (duplicates != NULL)
+                singe_conflict = (duplicates->next == NULL) ? TRUE:FALSE;
+
+        file_name = NULL;
+
         /* check if there are name conflicts and display them if they exist */
-        if (duplicates != NULL && gtk_widget_is_sensitive (dialog->rename_button)) {
+        if (duplicates != NULL) {
                 gtk_widget_set_sensitive (dialog->rename_button, FALSE);
 
-                gtk_expander_set_expanded (GTK_EXPANDER (dialog->expander), FALSE);
-                gtk_stack_set_visible_child (GTK_STACK (dialog->label_stack), GTK_WIDGET (dialog->expander));
-
                 /* check if there is more than one conflict */
-                if (duplicates->next != NULL)
+                if (!singe_conflict)
                         gtk_expander_set_label (GTK_EXPANDER (dialog->expander),
                                                 "Multiple file conflicts");
                 else {
                         file_name = concat ("File conflict: ", duplicates->data);
 
+                        if (strlen (file_name) >= MAX_DISPLAY_LEN) {
                         gtk_label_set_label (GTK_LABEL (dialog->expander_label), file_name);
 
                         gtk_expander_set_label_widget (GTK_EXPANDER (dialog->expander),
                                                        dialog->expander_label);
 
                         gtk_widget_show (dialog->expander_label);
+                        } else {
+                               gtk_label_set_label (GTK_LABEL (dialog->error_label), file_name);
+                        }
+                }
 
-                        g_free (file_name);
+                if (!singe_conflict || strlen (file_name) >= MAX_DISPLAY_LEN) {
+                        gtk_expander_set_expanded (GTK_EXPANDER (dialog->expander), FALSE);
+                        gtk_stack_set_visible_child (GTK_STACK (dialog->label_stack),
+                                                     GTK_WIDGET (dialog->expander));
                 }
 
                 /* add name conflicts to the listbox */
                 fill_conflict_listbox (dialog, duplicates);
 
+                g_free (file_name);
+
                 return;
         }
         else
@@ -351,9 +364,9 @@ file_names_widget_entry_on_changed (NautilusBatchRename *dialog)
 
                         gtk_stack_set_visible_child (GTK_STACK (dialog->label_stack), GTK_WIDGET 
(dialog->error_label));
 
-                        g_value_init (&width, G_TYPE_INT);
-                        g_value_set_int (&width, 8);
-                        gtk_container_child_set_property (GTK_CONTAINER (dialog->grid), dialog->label_stack, 
"width",&width);
+                        //g_value_init (&width, G_TYPE_INT);
+                        //g_value_set_int (&width, 8);
+                        //gtk_container_child_set_property (GTK_CONTAINER (dialog->grid), 
dialog->label_stack, "width",&width);
 
 
                 }
@@ -390,8 +403,6 @@ static void
 batch_rename_dialog_on_closed (GtkDialog *dialog)
 {
         gtk_window_close (GTK_WINDOW (dialog));
-        g_message("closed this");
-
 }
 
 static void
diff --git a/src/resources/ui/nautilus-batch-rename-dialog.ui 
b/src/resources/ui/nautilus-batch-rename-dialog.ui
index 8d7704e..ca8290d 100644
--- a/src/resources/ui/nautilus-batch-rename-dialog.ui
+++ b/src/resources/ui/nautilus-batch-rename-dialog.ui
@@ -6,6 +6,34 @@
     <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
     <property name="title">Batch rename</property>
+    <property name="use-header-bar">1</property>
+
+    <child type="action">
+      <object class="GtkButton" id="cancel_button">
+        <property name="label" translatable="yes">_Cancel</property>
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="use_underline">True</property>
+        <signal name="clicked" handler="batch_rename_dialog_on_closed" swapped="yes" />
+      </object>
+    </child>
+
+    <child type="action">
+      <object class="GtkButton" id="rename_button">
+        <property name="label" translatable="yes">_Rename</property>
+        <property name="visible">True</property>
+        <property name="use_underline">True</property>
+        <property name="can_default">True</property>
+        <signal name="clicked" handler="file_names_widget_on_activate" swapped="yes" />
+        <style>
+          <class name="suggested-action"/>
+        </style>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="ok" default="true">rename_button</action-widget>
+      <action-widget response="cancel">cancel_button</action-widget>
+    </action-widgets>
 
     <child internal-child="vbox">
       <object class="GtkBox" id="vbox">
@@ -37,6 +65,17 @@
               </packing>
             </child>
             <child>
+              <object class="GtkStackSwitcher" id="stack_switcher">
+                <property name="stack">label_stack</property>
+                <property name="no-show-all">1</property>
+              </object>
+              <packing>
+                <property name="left-attach">1</property>
+                <property name="top-attach">0</property>
+                <property name="width">1</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkEntry" id="name_entry">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -53,44 +92,6 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="cancel_button">
-                <property name="label" translatable="yes">_Cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="use_underline">True</property>
-                <property name="height_request">10</property>
-                <signal name="clicked" handler="batch_rename_dialog_on_closed" swapped="yes" />
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="left-attach">5</property>
-                <property name="top-attach">2</property>
-                <property name="width">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="rename_button">
-                <property name="label" translatable="yes">_Rename</property>
-                <property name="visible">True</property>
-                <property name="use_underline">True</property>
-                <property name="can_default">True</property>
-                <property name="height_request">10</property>
-                <signal name="clicked" handler="file_names_widget_on_activate" swapped="yes" />
-                <style>
-                  <class name="suggested-action"/>
-                </style>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="left-attach">6</property>
-                <property name="top-attach">2</property>
-                <property name="width">1</property>
-              </packing>
-            </child>
-
-            <child>
               <object class="GtkStack" id="label_stack">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>


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