Commit 38d437ac authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

Implemented the rename series command

parent cb4b90c4
......@@ -238,6 +238,9 @@ extensions/image_viewer/data/ui/Makefile
extensions/list_tools/Makefile
extensions/list_tools/data/Makefile
extensions/list_tools/data/ui/Makefile
extensions/rename_series/Makefile
extensions/rename_series/data/Makefile
extensions/rename_series/data/ui/Makefile
extensions/search/Makefile
extensions/search/data/Makefile
extensions/search/data/ui/Makefile
......
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkVBox" id="overwrite_dialog_box">
<property name="visible">True</property>
<property name="border_width">6</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label124">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Overwrite the old file with the new one?</property>
<property name="justify">center</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox46">
<property name="visible">True</property>
<property name="spacing">12</property>
<child>
<object class="GtkVBox" id="vbox57">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<child>
<object class="GtkHBox" id="hbox110">
<property name="visible">True</property>
<property name="border_width">6</property>
<property name="spacing">6</property>
<child>
<object class="GtkFrame" id="old_image_frame">
<property name="width_request">256</property>
<property name="height_request">256</property>
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label137">
<property name="visible">True</property>
<property name="label" translatable="yes">Old File:</property>
</object>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTable" id="table15">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkLabel" id="old_image_size_label">
<property name="visible">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="old_image_time_label">
<property name="visible">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEventBox" id="old_image_filename_eventbox">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="old_image_filename_label">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="wrap">True</property>
</object>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox58">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<child>
<object class="GtkHBox" id="hbox111">
<property name="visible">True</property>
<property name="border_width">6</property>
<property name="spacing">6</property>
<child>
<object class="GtkFrame" id="new_image_frame">
<property name="width_request">256</property>
<property name="height_request">256</property>
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label138">
<property name="visible">True</property>
<property name="label" translatable="yes">New File:</property>
</object>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTable" id="table16">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkLabel" id="new_image_size_label">
<property name="visible">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="new_image_time_label">
<property name="visible">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEventBox" id="new_image_filename_eventbox">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="new_image_filename_label">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="wrap">True</property>
</object>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="padding">5</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator1">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="overwrite_yes_radiobutton">
<property name="label" translatable="yes">Over_write the old file</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="overwrite_no_radiobutton">
<property name="label" translatable="yes">Do not overwrite _the old file</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">overwrite_yes_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="overwrite_all_radiobutton">
<property name="label" translatable="yes">Overwrite _all files</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">overwrite_yes_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="overwrite_none_radiobutton">
<property name="label" translatable="yes">_Do not overwrite any file</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">overwrite_yes_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox112">
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="overwrite_rename_radiobutton">
<property name="label" translatable="yes">_Save the new file as:</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">overwrite_yes_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="overwrite_rename_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="activates_default">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">7</property>
</packing>
</child>
</object>
</interface>
SUBDIRS = catalogs comments exiv2 file_manager file_tools file_viewer image_viewer list_tools search
SUBDIRS = catalogs comments exiv2 file_manager file_tools file_viewer image_viewer list_tools rename_series search
-include $(top_srcdir)/git.mk
......@@ -333,7 +333,7 @@ gth_browser_activate_action_edit_paste (GtkAction *action,
paste_data = g_new0 (PasteData, 1);
paste_data->browser = g_object_ref (browser);
paste_data->destination = g_object_ref (gth_browser_get_location (browser));
paste_data->destination = g_object_ref (gth_browser_get_location_data (browser));
gtk_clipboard_request_contents (gtk_widget_get_clipboard (GTK_WIDGET (browser), GDK_SELECTION_CLIPBOARD),
GNOME_COPIED_FILES,
......@@ -361,13 +361,6 @@ gth_browser_activate_action_edit_duplicate (GtkAction *action,
}
void
gth_browser_activate_action_edit_rename (GtkAction *action,
GthBrowser *browser)
{
}
static void
delete_file_permanently (GtkWindow *window,
GList *file_list)
......@@ -513,7 +506,7 @@ gth_browser_activate_action_folder_open_in_file_manager (GtkAction *action,
gtk_get_current_event_time (),
&error))
{
_gtk_error_dialog_from_gerror_run (GTK_WINDOW (browser), _("Could not open location"), &error);
_gtk_error_dialog_from_gerror_run (GTK_WINDOW (browser), _("Could not open the location"), &error);
}
g_free (uri);
......
......@@ -33,7 +33,6 @@ DEFINE_ACTION(gth_browser_activate_action_edit_cut_files)
DEFINE_ACTION(gth_browser_activate_action_edit_copy_files)
DEFINE_ACTION(gth_browser_activate_action_edit_paste)
DEFINE_ACTION(gth_browser_activate_action_edit_duplicate)
DEFINE_ACTION(gth_browser_activate_action_edit_rename)
DEFINE_ACTION(gth_browser_activate_action_edit_trash)
DEFINE_ACTION(gth_browser_activate_action_edit_delete)
DEFINE_ACTION(gth_browser_activate_action_folder_open_in_file_manager)
......
......@@ -37,7 +37,6 @@ static const char *vfs_ui_info =
" <menu name='Edit' action='EditMenu'>"
" <placeholder name='Folder_Actions'>"
" <menuitem action='Edit_Duplicate'/>"
" <menuitem action='Edit_Rename'/>"
" <separator/>"
" <menuitem action='Edit_Trash'/>"
" <menuitem action='Edit_Delete'/>"
......@@ -140,10 +139,6 @@ static GtkActionEntry action_entries[] = {
N_("D_uplicate"), "<control><shift>D",
N_("Duplicate the selected files"),
G_CALLBACK (gth_browser_activate_action_edit_duplicate) },
{ "Edit_Rename", NULL,
N_("_Rename"), "F2",
N_("Rename the selected files"),
G_CALLBACK (gth_browser_activate_action_edit_rename) },
{ "Edit_Trash", "user-trash",
N_("Mo_ve to Trash"), "Delete",
N_("Move the selected files to the Trash"),
......@@ -425,7 +420,6 @@ fm__gth_browser_update_sensitivity_cb (GthBrowser *browser)
set_action_sensitive (data, "Edit_Trash", sensitive);
set_action_sensitive (data, "Edit_Delete", sensitive);
set_action_sensitive (data, "Edit_Duplicate", sensitive);
set_action_sensitive (data, "Edit_Rename", sensitive);
folder = gth_folder_tree_get_selected (GTH_FOLDER_TREE (gth_browser_get_folder_tree (browser)));
set_action_sensitive (data, "Folder_Create", (folder != NULL) && g_file_info_get_attribute_boolean (folder->info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE));
......
......@@ -28,8 +28,8 @@
void
gth_browser_action_list_tools_edit_scripts (GtkAction *action,
GthBrowser *browser)
gth_browser_action_edit_scripts (GtkAction *action,
GthBrowser *browser)
{
dlg_personalize_scripts (browser);
}
......@@ -27,6 +27,6 @@
#define DEFINE_ACTION(x) void x (GtkAction *action, gpointer data);
DEFINE_ACTION(gth_browser_action_list_tools_edit_scripts)
DEFINE_ACTION(gth_browser_action_edit_scripts)
#endif /* ACTIONS_H */
......@@ -63,7 +63,7 @@ static GtkActionEntry action_entries[] = {
{ "ListTools_EditScripts", GTK_STOCK_EDIT,
N_("Personalize..."), NULL,
NULL,
G_CALLBACK (gth_browser_action_list_tools_edit_scripts) }
G_CALLBACK (gth_browser_action_edit_scripts) }
};
......
......@@ -146,7 +146,7 @@ gth_script_editor_dialog_construct (GthScriptEditorDialog *self,
gtk_window_set_transient_for (GTK_WINDOW (self), parent);
gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (self)->vbox), 5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 5);
gtk_container_set_border_width (GTK_CONTAINER (self), 5);
gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
......@@ -157,7 +157,7 @@ gth_script_editor_dialog_construct (GthScriptEditorDialog *self,
content = _gtk_builder_get_widget (self->priv->builder, "script_editor");
gtk_container_set_border_width (GTK_CONTAINER (content), 5);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (self)->vbox), content, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), content, TRUE, TRUE, 0);
g_signal_connect (GET_WIDGET ("command_entry"),
"icon-press",
......
......@@ -423,7 +423,7 @@ gth_script_get_requested_attributes (GthScript *script)
char **b;
char *attributes;
re = g_regex_new ("%prop\\{([^}]+)\\}", 0, 0, NULL);
re = g_regex_new ("%attr\\{([^}]+)\\}", 0, 0, NULL);
a = g_regex_split (re, script->priv->command, 0);
for (i = 0, n = 0; a[i] != NULL; i++)
if ((i > 0) && (i % 2 == 0))
......@@ -663,12 +663,16 @@ create_attribute_list (GList *file_list,
GString *s;
GList *scan;
re = g_regex_new ("%prop\\{([^}]+)\\}", 0, 0, NULL);
re = g_regex_new ("%attr\\{([^}]+)\\}", 0, 0, NULL);
a = g_regex_split (re, match, 0);
if (g_strv_length (a) >= 2)
attribute = g_strstrip (a[1]);
if (attribute == NULL)
if (attribute == NULL) {
g_strfreev (a);
g_regex_unref (re);
return NULL;
}
s = g_string_new ("");
for (scan = file_list; scan; scan = scan->next) {
......@@ -715,8 +719,8 @@ command_line_eval_cb (const GMatchInfo *info,
gpointer data)
{
ReplaceData *replace_data = data;
char *r = NULL;
char *match;
char *r;
match = g_match_info_fetch (info, 0);
if (strcmp (match, "%U") == 0)
......@@ -731,7 +735,7 @@ command_line_eval_cb (const GMatchInfo *info,
r = create_file_list (replace_data->file_list, get_ext_func, replace_data->quote_values);
else if (strcmp (match, "%P") == 0)
r = create_file_list (replace_data->file_list, get_parent_func, replace_data->quote_values);
else if (strncmp (match, "%prop", 5) == 0) {
else if (strncmp (match, "%attr", 5) == 0) {
r = create_attribute_list (replace_data->file_list, match, replace_data->quote_values);
if (r == NULL)
*replace_data->error = g_error_new_literal (GTH_TASK_ERROR, GTH_TASK_ERROR_FAILED, _("Malformed command"));
......
SUBDIRS = data
extensiondir = $(libdir)/gthumb-2.0/extensions
extension_LTLIBRARIES = librename_series.la
librename_series_la_SOURCES = \
actions.c \
actions.h \
callbacks.c \
callbacks.h \
dlg-rename-series.c \
dlg-rename-series.h \
gth-rename-task.c \
gth-rename-task.h \
main.c
librename_series_la_CFLAGS = $(GTHUMB_CFLAGS) $(DISABLE_DEPRECATED) $(WARNINGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
librename_series_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
librename_series_la_LIBADD = $(GTHUMB_LIBS)
librename_series_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
extensioninidir = $(extensiondir)
extensionini_in_files = rename_series.extension.in.in
extensionini_DATA = $(extensionini_in_files:.extension.in.in=.extension)
%.extension.in: %.extension.in.in $(extension_LTLIBRARIES)
sed -e "s|%LIBRARY%|`. ./$(extension_LTLIBRARIES) && echo $$dlname`|" \
$< > $@
%.extension: %.extension.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@
EXTRA_DIST = $(extensionini_in_files)
DISTCLEANFILES = $(extensionini_DATA)
-include $(top_srcdir)/git.mk
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <glib/gi18n.h>
#include <gthumb.h>
#include "dlg-rename-series.h"
void
gth_browser_activate_action_edit_rename (GtkAction *action,
GthBrowser *browser)
{
GList *items;
GList *file_list;
items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
dlg_rename_series (browser, file_list);