[nautilus/wip/alexpandelea/batchRename: 1/17] Add Replace and Add text modes
- From: Alexandru-Ionut Pandelea <alexpandelea src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/alexpandelea/batchRename: 1/17] Add Replace and Add text modes
- Date: Tue, 5 Jul 2016 16:48:35 +0000 (UTC)
commit b340772ef4b46cdf005271c805cfe78937bb2a3f
Author: Alexandru Pandelea <alexandru pandelea gmail com>
Date: Mon Jun 6 12:31:56 2016 +0300
Add Replace and Add text modes
https://bugzilla.gnome.org/show_bug.cgi?id=768311
src/Makefile.am | 4 +
src/nautilus-batch-rename.c | 305 ++++++++++++++++++++++
src/nautilus-batch-rename.h | 26 ++
src/nautilus-file.c | 15 +
src/nautilus-file.h | 1 +
src/nautilus-files-view.c | 14 +-
src/nautilus-rename-utilities.c | 166 ++++++++++++
src/nautilus-rename-utilities.h | 22 ++
src/resources/nautilus.gresource.xml | 1 +
src/resources/ui/nautilus-batch-rename-dialog.ui | 171 ++++++++++++
10 files changed, 723 insertions(+), 2 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 4dc71ca..b6494ea 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -160,6 +160,8 @@ nautilus_no_main_sources = \
gtk/nautilusgtkplacesviewrowprivate.h \
nautilus-application.c \
nautilus-application.h \
+ nautilus-batch-rename.c \
+ nautilus-batch-rename.h \
nautilus-bookmark-list.c \
nautilus-bookmark-list.h \
nautilus-canvas-view.c \
@@ -213,6 +215,8 @@ nautilus_no_main_sources = \
nautilus-properties-window.h \
nautilus-query-editor.c \
nautilus-query-editor.h \
+ nautilus-rename-utilities.c \
+ nautilus-rename-utilities.h \
nautilus-search-popover.c \
nautilus-search-popover.h \
nautilus-self-check-functions.c \
diff --git a/src/nautilus-batch-rename.c b/src/nautilus-batch-rename.c
new file mode 100644
index 0000000..ec137cc
--- /dev/null
+++ b/src/nautilus-batch-rename.c
@@ -0,0 +1,305 @@
+/* nautilus-batch-rename.c
+ *
+ * Copyright (C) 2016 Alexandru Pandelea <alexandru pandelea gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "nautilus-batch-rename.h"
+#include "nautilus-file.h"
+#include "nautilus-files-view.h"
+#include "nautilus-error-reporting.h"
+#include "nautilus-rename-utilities.h"
+
+#include <glib/gprintf.h>
+#include <string.h>
+
+#define ADD_TEXT_ENTRY_SIZE 550
+#define REPLACE_ENTRY_SIZE 275
+
+struct _NautilusBatchRename
+{
+ GtkDialog parent;
+
+ GtkWidget *grid;
+
+ GtkWidget *add_text_options;
+ GtkWidget *cancel_button;
+ GtkWidget *error_label;
+ GtkWidget *name_entry;
+ GtkWidget *rename_button;
+ GtkWidget *rename_modes;
+ GtkWidget *find_label;
+ GtkWidget *left_stack;
+ GtkWidget *right_stack;
+ GtkWidget *replace_entry;
+ GtkWidget *replace_label;
+ GtkWidget *replace_box;
+
+
+ GList *selection;
+ NautilusBatchRenameModes mode;
+ NautilusFilesView *view;
+};
+
+static void batch_rename_dialog_on_closed (GtkDialog *dialog);
+static void file_names_widget_entry_on_changed (NautilusBatchRename *dialog);
+
+G_DEFINE_TYPE (NautilusBatchRename, nautilus_batch_rename, GTK_TYPE_DIALOG);
+
+static GList*
+batch_rename_get_new_names (NautilusBatchRename *dialog)
+{
+ GList *result = NULL;
+ GList *selection;
+ gchar *entry_text;
+ gchar *replace_text;
+
+ selection = dialog->selection;
+
+ entry_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)));
+ replace_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->replace_entry)));
+
+ result = get_new_names_list (dialog->mode, selection, entry_text, replace_text);
+
+ g_free (entry_text);
+
+ result = g_list_reverse (result);
+
+ return result;
+}
+
+static void
+rename_files_on_names_accepted (NautilusBatchRename *dialog,
+ GList *new_names)
+{
+ /* do the actual rename here */
+ GList *l1;
+ GList *l2;
+ GList *selection;
+ NautilusFile *file;
+
+ selection = dialog->selection;
+
+ for (l1 = selection, l2 = new_names; l1 != NULL && l2 != NULL; l1 = l1->next, l2 = l2->next) {
+ file = NAUTILUS_FILE (l1->data);
+
+ /* Put it on the queue for reveal after the view acknowledges the change */
+ //do this sometime...
+ /*g_hash_table_insert (dialog->view->details->pending_reveal,
+ file,
+ GUINT_TO_POINTER (FALSE));*/
+
+ nautilus_rename_file (file, l2->data, NULL, NULL);
+ }
+
+ batch_rename_dialog_on_closed (GTK_DIALOG (dialog));
+}
+
+static void
+batch_rename_add_text_changed (GtkComboBoxText *widget,
+ NautilusBatchRename *dialog)
+{
+ gchar* active_item;
+
+ active_item = gtk_combo_box_text_get_active_text (widget);
+
+ if (strcmp (active_item, "Append") == 0)
+ dialog->mode = NAUTILUS_BATCH_RENAME_APPEND;
+
+ if (strcmp (active_item, "Prepend") == 0)
+ dialog->mode = NAUTILUS_BATCH_RENAME_PREPEND;
+
+ /* update display text */
+ file_names_widget_entry_on_changed (dialog);
+}
+
+static void
+switch_to_replace_mode (NautilusBatchRename *dialog)
+{
+ GValue width = G_VALUE_INIT;
+
+ g_value_init (&width, G_TYPE_INT);
+ g_value_set_int (&width, 3);
+
+ gtk_stack_set_visible_child (GTK_STACK (dialog->left_stack), GTK_WIDGET (dialog->find_label));
+ gtk_stack_set_visible_child (GTK_STACK (dialog->right_stack), GTK_WIDGET (dialog->replace_box));
+ gtk_widget_show (GTK_WIDGET (dialog->replace_box));
+
+ gtk_widget_grab_focus (dialog->name_entry);
+
+ gtk_container_child_set_property (GTK_CONTAINER (dialog->grid), dialog->name_entry, "width",&width);
+
+ gtk_widget_set_size_request (dialog->name_entry, REPLACE_ENTRY_SIZE, -1);
+}
+
+static void
+switch_to_add_text_mode (NautilusBatchRename *dialog)
+{
+ GValue width = G_VALUE_INIT;
+
+ g_value_init (&width, G_TYPE_INT);
+ g_value_set_int (&width, 6);
+
+ gtk_stack_set_visible_child (GTK_STACK (dialog->left_stack), GTK_WIDGET (dialog->add_text_options));
+ gtk_widget_hide (GTK_WIDGET (dialog->replace_box));
+
+ gtk_widget_grab_focus (dialog->name_entry);
+
+ gtk_container_child_set_property (GTK_CONTAINER (dialog->grid), dialog->name_entry, "width",&width);
+
+ gtk_widget_set_size_request (dialog->name_entry, ADD_TEXT_ENTRY_SIZE, -1);
+}
+
+static void
+batch_rename_mode_changed (GtkComboBoxText *widget,
+ NautilusBatchRename *dialog)
+{
+ gchar* active_item;
+
+ active_item = gtk_combo_box_text_get_active_text (widget);
+
+ if (strcmp (active_item, "Replace") == 0) {
+ dialog->mode = NAUTILUS_BATCH_RENAME_REPLACE;
+ switch_to_replace_mode (dialog);
+ }
+
+ /* check whether before it was append or prepend */
+ if (strcmp (active_item, "Add Text") == 0) {
+ batch_rename_add_text_changed (GTK_COMBO_BOX_TEXT (dialog->add_text_options), dialog);
+
+ switch_to_add_text_mode (dialog);
+ }
+
+ /* update display text */
+ file_names_widget_entry_on_changed (dialog);
+}
+
+static void
+file_names_widget_entry_on_changed (NautilusBatchRename *dialog)
+{
+ gchar *entry_text;
+ gchar *replace_text;
+ gchar *file_name;
+ gchar *display_text = NULL;
+ NautilusFile *file;
+
+ if(dialog->selection == NULL)
+ return;
+
+ file = NAUTILUS_FILE (dialog->selection->data);
+
+ file_name = g_strdup (nautilus_file_get_name (file));
+ entry_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)));
+ replace_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->replace_entry)));
+
+ if (entry_text == NULL ) {
+ gtk_label_set_label (GTK_LABEL (dialog->error_label), file_name);
+ g_free (file_name);
+
+ return;
+ }
+
+ display_text = get_new_display_name (dialog->mode, file_name, entry_text, replace_text);
+
+ gtk_label_set_label (GTK_LABEL (dialog->error_label), display_text);
+
+ g_free (entry_text);
+ g_free (file_name);
+ g_free (replace_text);
+ g_free (display_text);
+}
+
+static void
+batch_rename_dialog_on_closed (GtkDialog *dialog)
+{
+ gtk_window_close (GTK_WINDOW (dialog));
+
+}
+
+static void
+file_names_widget_on_activate (NautilusBatchRename *dialog)
+{
+ GList *new_names;
+ /* check if all names are all right i.e no conflicts, valid name, etc...*/
+
+ new_names = batch_rename_get_new_names(dialog);
+
+ /* if names are all right call rename_files_on_names_accepted*/
+ rename_files_on_names_accepted (dialog, new_names);
+ g_list_free (new_names);
+}
+
+static void
+nautilus_batch_rename_class_init (NautilusBatchRenameClass *klass)
+{
+ GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ dialog_class->close = batch_rename_dialog_on_closed;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/nautilus/ui/nautilus-batch-rename-dialog.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, grid);
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, add_text_options);
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, cancel_button);
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, error_label);
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, name_entry);
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, rename_button);
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, rename_modes);
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, find_label);
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, left_stack);
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, right_stack);
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, replace_label);
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, replace_entry);
+ gtk_widget_class_bind_template_child (widget_class, NautilusBatchRename, replace_box);
+
+ gtk_widget_class_bind_template_callback (widget_class, file_names_widget_entry_on_changed);
+ gtk_widget_class_bind_template_callback (widget_class, batch_rename_dialog_on_closed);
+ gtk_widget_class_bind_template_callback (widget_class, batch_rename_mode_changed);
+ gtk_widget_class_bind_template_callback (widget_class, file_names_widget_on_activate);
+ gtk_widget_class_bind_template_callback (widget_class, batch_rename_add_text_changed);
+}
+
+GtkWidget*
+nautilus_batch_rename_new (NautilusFilesView *view)
+{
+ NautilusBatchRename *dialog;
+
+ dialog = g_object_new (NAUTILUS_TYPE_BATCH_RENAME, NULL);
+
+ dialog->selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
+ dialog->view = view;
+
+ gtk_window_set_transient_for (GTK_WINDOW (dialog),
+ GTK_WINDOW (nautilus_files_view_get_window (view)));
+
+ gtk_widget_grab_focus (dialog->name_entry);
+
+ /* update display text */
+ file_names_widget_entry_on_changed (dialog);
+
+ return GTK_WIDGET (dialog);
+}
+
+static void
+nautilus_batch_rename_init (NautilusBatchRename *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->add_text_options), 1);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->rename_modes), 0);
+
+ self->mode = NAUTILUS_BATCH_RENAME_PREPEND;
+}
\ No newline at end of file
diff --git a/src/nautilus-batch-rename.h b/src/nautilus-batch-rename.h
new file mode 100644
index 0000000..63fab69
--- /dev/null
+++ b/src/nautilus-batch-rename.h
@@ -0,0 +1,26 @@
+
+#ifndef NAUTILUS_BATCH_RENAME_H
+#define NAUTILUS_BATCH_RENAME_H
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include "nautilus-files-view.h"
+
+G_BEGIN_DECLS
+
+typedef enum {
+ NAUTILUS_BATCH_RENAME_APPEND = 0,
+ NAUTILUS_BATCH_RENAME_PREPEND = 1,
+ NAUTILUS_BATCH_RENAME_REPLACE = 2,
+ NAUTILUS_BATCH_RENAME_FORMAT = 3,
+} NautilusBatchRenameModes;
+
+#define NAUTILUS_TYPE_BATCH_RENAME (nautilus_batch_rename_get_type())
+
+G_DECLARE_FINAL_TYPE (NautilusBatchRename, nautilus_batch_rename, NAUTILUS, BATCH_RENAME, GtkDialog);
+
+GtkWidget* nautilus_batch_rename_new (NautilusFilesView *view);
+
+G_END_DECLS
+
+#endif
\ No newline at end of file
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index e3cbdfe..349255c 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -1525,6 +1525,21 @@ real_can_rename (NautilusFile *file)
}
gboolean
+nautilus_file_can_rename_files (GList *selection)
+{
+ GList *l;
+ NautilusFile *file;
+
+ for(l = selection; l != NULL; l = l->next) {
+ file = NAUTILUS_FILE (l->data);
+
+ if (!nautilus_file_can_rename (file))
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean
nautilus_file_can_delete (NautilusFile *file)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
diff --git a/src/nautilus-file.h b/src/nautilus-file.h
index 1050575..5723423 100644
--- a/src/nautilus-file.h
+++ b/src/nautilus-file.h
@@ -266,6 +266,7 @@ gboolean nautilus_file_can_read (Nautilu
gboolean nautilus_file_can_write (NautilusFile
*file);
gboolean nautilus_file_can_execute (NautilusFile
*file);
gboolean nautilus_file_can_rename (NautilusFile
*file);
+gboolean nautilus_file_can_rename_files (GList
*selection);
gboolean nautilus_file_can_delete (NautilusFile
*file);
gboolean nautilus_file_can_trash (NautilusFile
*file);
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 9452cda..c23f97c 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -28,6 +28,7 @@
#include "nautilus-files-view.h"
#include "nautilus-application.h"
+#include "nautilus-batch-rename.h"
#include "nautilus-error-reporting.h"
#include "nautilus-floating-bar.h"
#include "nautilus-list-view.h"
@@ -5500,6 +5501,7 @@ real_action_rename (NautilusFilesView *view,
{
NautilusFile *file;
GList *selection;
+ NautilusBatchRename *dialog;
g_assert (NAUTILUS_IS_FILES_VIEW (view));
@@ -5510,6 +5512,10 @@ real_action_rename (NautilusFilesView *view,
if (selection->next != NULL) {
if (have_bulk_rename_tool ()) {
invoke_external_bulk_rename_utility (view, selection);
+ } else {
+ dialog = nautilus_batch_rename_new (view);
+
+ gtk_widget_show (GTK_WIDGET (dialog));
}
} else {
file = NAUTILUS_FILE (selection->data);
@@ -6295,8 +6301,12 @@ real_update_actions_state (NautilusFilesView *view)
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
"rename");
if (selection_count > 1) {
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
- have_bulk_rename_tool ());
+ if (have_bulk_rename_tool())
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+ have_bulk_rename_tool ());
+ else
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+ nautilus_file_can_rename_files (selection));//use
nautilus_file_can_rename_files
} else {
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
selection_count == 1 &&
diff --git a/src/nautilus-rename-utilities.c b/src/nautilus-rename-utilities.c
new file mode 100644
index 0000000..c9ec0f6
--- /dev/null
+++ b/src/nautilus-rename-utilities.c
@@ -0,0 +1,166 @@
+#include "nautilus-batch-rename.h"
+#include "nautilus-rename-utilities.h"
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <string.h>
+#include <stdarg.h>
+
+#define MAX_DISPLAY_LEN 40
+
+static gchar*
+batch_rename_prepend (gchar *file_name,
+ gchar *entry_text)
+{
+ gchar *result;
+
+ result = malloc (strlen (entry_text) + strlen (file_name) + 1);
+ if (result == NULL) {
+ return strdup (file_name);
+ }
+ sprintf (result, "%s%s", file_name, entry_text);
+
+ return result;
+}
+
+static gchar*
+batch_rename_append (gchar *file_name,
+ gchar *entry_text)
+{
+ gchar *result;
+
+ result = malloc (strlen (entry_text) + strlen (file_name) + 1);
+ if (result == NULL) {
+ return strdup (file_name);
+ }
+
+ sprintf (result, "%s%s", entry_text, file_name);
+
+ return result;
+}
+
+static gchar*
+batch_rename_replace (gchar *string,
+ gchar *substr,
+ gchar *replacement)
+{
+ gchar *tok = NULL;
+ gchar *newstr = NULL;
+ gchar *oldstr = NULL;
+ gint skip_chars;
+
+ if (substr == NULL || replacement == NULL) {
+ return strdup (string);
+ }
+
+ if (strcmp (substr, "") == 0) {
+ return strdup (string);
+ }
+
+ newstr = strdup (string);
+
+ skip_chars = 0;
+
+ while ((tok = strstr (newstr + skip_chars, substr))) {
+ oldstr = newstr;
+ newstr = malloc (strlen (oldstr) - strlen (substr) + strlen (replacement) + 1);
+
+ if (newstr == NULL) {
+ g_free (oldstr);
+ return strdup (string);
+ }
+
+ memcpy (newstr, oldstr, tok - oldstr);
+ memcpy (newstr + (tok - oldstr), replacement, strlen (replacement));
+ memcpy (newstr + (tok - oldstr) + strlen( replacement ), tok + strlen ( substr ),
+ strlen (oldstr) - strlen (substr) - (tok - oldstr));
+ memset (newstr + strlen (oldstr) - strlen (substr) + strlen (replacement) , '\0', 1 );
+
+ skip_chars = strlen (oldstr) - strlen (tok) + strlen (replacement);
+ g_free (oldstr);
+ }
+
+ return newstr;
+}
+
+gchar*
+get_new_name (NautilusBatchRenameModes mode,
+ gchar *file_name,
+ gchar *entry_text,
+ ...)
+{
+ va_list args;
+ gchar *result;
+
+ result = NULL;
+
+ if (mode == NAUTILUS_BATCH_RENAME_REPLACE) {
+
+ va_start (args, entry_text);
+
+ result = batch_rename_replace (file_name, entry_text, va_arg(args, gchar*));
+
+ va_end (args);
+ }
+
+ if (mode == NAUTILUS_BATCH_RENAME_APPEND)
+ result = batch_rename_append (file_name, entry_text);
+
+ if (mode == NAUTILUS_BATCH_RENAME_PREPEND)
+ result = batch_rename_prepend (file_name, entry_text);
+
+ return result;
+}
+
+GList*
+get_new_names_list (NautilusBatchRenameModes mode,
+ GList *selection,
+ gchar *entry_text,
+ gchar *replace_text)
+{
+ GList *l;
+ GList *result;
+ gchar *file_name;
+ NautilusFile *file;
+
+ result = NULL;
+
+ for (l = selection; l != NULL; l = l->next) {
+ file = NAUTILUS_FILE (l->data);
+
+ file_name = strdup (nautilus_file_get_name (file));
+
+ /* get the new name here and add it to the list*/
+ if (mode == NAUTILUS_BATCH_RENAME_PREPEND)
+ result = g_list_prepend (result,
+ (gpointer) batch_rename_prepend (file_name, entry_text));
+
+ if (mode == NAUTILUS_BATCH_RENAME_APPEND)
+ result = g_list_prepend (result,
+ (gpointer) batch_rename_append (file_name, entry_text));
+
+ if (mode == NAUTILUS_BATCH_RENAME_REPLACE)
+ result = g_list_prepend (result,
+ (gpointer) batch_rename_replace (file_name, entry_text,
replace_text));
+
+ g_free (file_name);
+ }
+
+ return result;
+}
+
+gchar*
+get_new_display_name (NautilusBatchRenameModes mode,
+ gchar *file_name,
+ gchar *entry_text,
+ gchar *replace_text)
+{
+ gchar *result;
+
+ result = get_new_name (mode, file_name, entry_text, replace_text);
+
+ if (strlen (result) >= MAX_DISPLAY_LEN)
+ memcpy (result + MAX_DISPLAY_LEN, "...\0",4);
+
+ return result;
+}
\ No newline at end of file
diff --git a/src/nautilus-rename-utilities.h b/src/nautilus-rename-utilities.h
new file mode 100644
index 0000000..cef2125
--- /dev/null
+++ b/src/nautilus-rename-utilities.h
@@ -0,0 +1,22 @@
+#ifndef NAUTILUS_RENAME_UTILITIES_H
+#define NAUTILUS_RENAME_UTILITIES_H
+
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+
+gchar* get_new_name (NautilusBatchRenameModes mode,
+ gchar *file_name,
+ gchar *entry_text,
+ ...);
+
+GList* get_new_names_list (NautilusBatchRenameModes mode,
+ GList *selection,
+ gchar *entry_text,
+ gchar *replace_text);
+
+gchar* get_new_display_name (NautilusBatchRenameModes mode,
+ gchar *file_name,
+ gchar *entry_text,
+ gchar *replace_text);
+
+#endif /* NAUTILUS_RENAME_UTILITIES_H */
\ No newline at end of file
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index 0acbc70..fd92ea2 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -17,6 +17,7 @@
<file>ui/nautilus-no-search-results.ui</file>
<file>ui/nautilus-folder-is-empty.ui</file>
<file>gtk/help-overlay.ui</file>
+ <file>ui/nautilus-batch-rename-dialog.ui</file>
<file alias="gtk/ui/nautilusgtkplacesview.ui">../gtk/nautilusgtkplacesview.ui</file>
<file alias="gtk/ui/nautilusgtkplacesviewrow.ui">../gtk/nautilusgtkplacesviewrow.ui</file>
<file alias="icons/thumbnail_frame.png">../../icons/thumbnail_frame.png</file>
diff --git a/src/resources/ui/nautilus-batch-rename-dialog.ui
b/src/resources/ui/nautilus-batch-rename-dialog.ui
new file mode 100644
index 0000000..f0dfa27
--- /dev/null
+++ b/src/resources/ui/nautilus-batch-rename-dialog.ui
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="NautilusBatchRename" parent="GtkDialog">
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="title">Batch rename</property>
+
+ <child internal-child="vbox">
+ <object class="GtkBox" id="vbox">
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="margin">10</property>
+ <property name="row-spacing">6</property>
+ <property name="column-spacing">6</property>
+ <property name="hexpand">True</property>
+ <property name="row-homogeneous">False</property>
+ <property name="column-homogeneous">False</property>
+ <child>
+ <object class="GtkComboBoxText" id="rename_modes">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="expand">False</property>
+ <signal name="changed" handler="batch_rename_mode_changed" swapped="no" />
+ <items>
+ <item translatable="yes" id="add_text">Add Text</item>
+ <item translatable="yes" id="replace">Replace</item>
+ <item translatable="yes" id="format">Format</item>
+ </items>
+ </object>
+ <packing>
+ <property name="left-attach">0</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>
+ <property name="width_request">275</property>
+ <property name="hexpand">False</property>
+ <property name="activates-default">True</property>
+ <signal name="changed" handler="file_names_widget_entry_on_changed" swapped="yes" />
+ <signal name="activate" handler="file_names_widget_on_activate" swapped="yes" />
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ <property name="width">3</property>
+ </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>
+ <signal name="clicked" handler="batch_rename_dialog_on_closed" swapped="yes" />
+ </object>
+ <packing>
+ <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>
+ <signal name="clicked" handler="file_names_widget_on_activate" swapped="yes" />
+ <style>
+ <class name="suggested-action"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left-attach">6</property>
+ <property name="top-attach">2</property>
+ <property name="width">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="error_label">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">2</property>
+ <property name="width">8</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkStack" id="left_stack">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hhomogeneous">True</property>
+ <child>
+ <object class="GtkComboBoxText" id="add_text_options">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="expand">False</property>
+ <signal name="changed" handler="batch_rename_add_text_changed" swapped="no" />
+ <items>
+ <item translatable="yes" id="append">Append</item>
+ <item translatable="yes" id="prepend">Prepend</item>
+ </items>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="find_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Replace:</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ <property name="width">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkStack" id="right_stack">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hhomogeneous">True</property>
+ <child>
+ <object class="GtkBox" id="replace_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="replace_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">With:</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkEntry" id="replace_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="width_request">275</property>
+ <signal name="changed" handler="file_names_widget_entry_on_changed" swapped="yes" />
+ <signal name="activate" handler="file_names_widget_on_activate" swapped="yes" />
+ </object>
+ </child>
+
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">4</property>
+ <property name="top-attach">1</property>
+ <property name="width">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]