summaryrefslogtreecommitdiffstats
path: root/src/nautilus-batch-rename-dialog.h
blob: 0749fa3c4660936faa3a8c66d6b886291d815ac4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/* nautilus-batch-rename-utilities.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 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, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include <glib.h>
#include <glib/gprintf.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "nautilus-files-view.h"

G_BEGIN_DECLS

typedef enum
{
    EQUIPMENT,
    CREATION_DATE,
    SEASON_NUMBER,
    EPISODE_NUMBER,
    TRACK_NUMBER,
    ARTIST_NAME,
    TITLE,
    ALBUM_NAME,
    ORIGINAL_FILE_NAME,
    METADATA_INVALID,
} MetadataType;

typedef enum
{
    NUMBERING_NO_ZERO_PAD,
    NUMBERING_ONE_ZERO_PAD,
    NUMBERING_TWO_ZERO_PAD,
    NUMBERING_INVALID,
} NumberingType;

typedef enum {
    NAUTILUS_BATCH_RENAME_DIALOG_APPEND = 0,
    NAUTILUS_BATCH_RENAME_DIALOG_PREPEND = 1,
    NAUTILUS_BATCH_RENAME_DIALOG_REPLACE = 2,
    NAUTILUS_BATCH_RENAME_DIALOG_FORMAT = 3,
} NautilusBatchRenameDialogMode;

typedef enum {
    ORIGINAL_ASCENDING = 0,
    ORIGINAL_DESCENDING = 1,
    FIRST_MODIFIED = 2,
    LAST_MODIFIED = 3,
    FIRST_CREATED = 4,
    LAST_CREATED = 5,
} SortMode;

typedef struct
{
    const gchar *action_name;
    const gchar *label;
    MetadataType metadata_type;
    NumberingType numbering_type;
    gboolean is_metadata;
} TagConstants;

typedef struct
{
    const gchar *action_target_name;
    const gchar *label;
    const SortMode sort_mode;
} SortConstants;

static const SortConstants sorts_constants[] =
{
    {
        "name-ascending",
        N_("Original Name (Ascending)"),
        ORIGINAL_ASCENDING,
    },
    {
        "name-descending",
        N_("Original Name (Descending)"),
        ORIGINAL_DESCENDING,
    },
    {
        "first-modified",
        N_("First Modified"),
        FIRST_MODIFIED,
    },
    {
        "last-modified",
        N_("Last Modified"),
        LAST_MODIFIED,
    },
    {
        "first-created",
        N_("First Created"),
        FIRST_CREATED,
    },
    {
        "last-created",
        N_("Last Created"),
        LAST_CREATED,
    },
};

static const TagConstants metadata_tags_constants[] =
{
    {
        "add-equipment-tag",
        N_("Camera model"),
        EQUIPMENT,
        NUMBERING_INVALID,
        TRUE,
    },
    {
        "add-creation-date-tag",
        N_("Creation date"),
        CREATION_DATE,
        NUMBERING_INVALID,
        TRUE,
    },
    {
        "add-season-number-tag",
        N_("Season number"),
        SEASON_NUMBER,
        NUMBERING_INVALID,
        TRUE,
    },
    {
        "add-episode-number-tag",
        N_("Episode number"),
        EPISODE_NUMBER,
        NUMBERING_INVALID,
        TRUE,
    },
    {
        "add-track-number-tag",
        N_("Track number"),
        TRACK_NUMBER,
        NUMBERING_INVALID,
        TRUE,
    },
    {
        "add-artist-name-tag",
        N_("Artist name"),
        ARTIST_NAME,
        NUMBERING_INVALID,
        TRUE,
    },
    {
        "add-title-tag",
        N_("Title"),
        TITLE,
        NUMBERING_INVALID,
        TRUE,
    },
    {
        "add-album-name-tag",
        N_("Album name"),
        ALBUM_NAME,
        NUMBERING_INVALID,
        TRUE,
    },
    {
        "add-original-file-name-tag",
        N_("Original file name"),
        ORIGINAL_FILE_NAME,
        NUMBERING_INVALID,
        TRUE,
    },
};

static const TagConstants numbering_tags_constants[] =
{
    {
        "add-numbering-no-zero-pad-tag",
        N_("1, 2, 3"),
        METADATA_INVALID,
        NUMBERING_NO_ZERO_PAD,
        FALSE,
    },
    {
        "add-numbering-one-zero-pad-tag",
        N_("01, 02, 03"),
        METADATA_INVALID,
        NUMBERING_ONE_ZERO_PAD,
        FALSE,
    },
    {
        "add-numbering-two-zero-pad-tag",
        N_("001, 002, 003"),
        METADATA_INVALID,
        NUMBERING_TWO_ZERO_PAD,
        FALSE,
    },
};

typedef struct
{
    gchar *name;
    gint index;
} ConflictData;

typedef struct {
    GString *file_name;
    GString *metadata [G_N_ELEMENTS (metadata_tags_constants)];
} FileMetadata;

#define NAUTILUS_TYPE_BATCH_RENAME_DIALOG (nautilus_batch_rename_dialog_get_type())

G_DECLARE_FINAL_TYPE (NautilusBatchRenameDialog, nautilus_batch_rename_dialog, NAUTILUS, BATCH_RENAME_DIALOG, GtkDialog);

GtkWidget*      nautilus_batch_rename_dialog_new                      (GList                     *selection,
                                                                       NautilusDirectory         *directory,
                                                                       NautilusWindow            *window);

void            nautilus_batch_rename_dialog_query_finished           (NautilusBatchRenameDialog *dialog,
                                                                       GHashTable                *hash_table,
                                                                       GList                     *selection_metadata);

G_END_DECLS