1 /* nautilus-batch-rename-utilities.c
2  *
3  * Copyright (C) 2016 Alexandru Pandelea <alexandru.pandelea@gmail.com>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include <glib.h>
22 #include <glib/gprintf.h>
23 #include <glib/gi18n.h>
24 #include <gtk/gtk.h>
25 #include "nautilus-files-view.h"
26 
27 G_BEGIN_DECLS
28 
29 typedef enum
30 {
31     EQUIPMENT,
32     CREATION_DATE,
33     SEASON_NUMBER,
34     EPISODE_NUMBER,
35     TRACK_NUMBER,
36     ARTIST_NAME,
37     TITLE,
38     ALBUM_NAME,
39     ORIGINAL_FILE_NAME,
40     METADATA_INVALID,
41 } MetadataType;
42 
43 typedef enum
44 {
45     NUMBERING_NO_ZERO_PAD,
46     NUMBERING_ONE_ZERO_PAD,
47     NUMBERING_TWO_ZERO_PAD,
48     NUMBERING_INVALID,
49 } NumberingType;
50 
51 typedef enum {
52     NAUTILUS_BATCH_RENAME_DIALOG_APPEND = 0,
53     NAUTILUS_BATCH_RENAME_DIALOG_PREPEND = 1,
54     NAUTILUS_BATCH_RENAME_DIALOG_REPLACE = 2,
55     NAUTILUS_BATCH_RENAME_DIALOG_FORMAT = 3,
56 } NautilusBatchRenameDialogMode;
57 
58 typedef enum {
59     ORIGINAL_ASCENDING = 0,
60     ORIGINAL_DESCENDING = 1,
61     FIRST_MODIFIED = 2,
62     LAST_MODIFIED = 3,
63     FIRST_CREATED = 4,
64     LAST_CREATED = 5,
65 } SortMode;
66 
67 typedef struct
68 {
69     const gchar *action_name;
70     const gchar *label;
71     MetadataType metadata_type;
72     NumberingType numbering_type;
73     gboolean is_metadata;
74 } TagConstants;
75 
76 typedef struct
77 {
78     const gchar *action_target_name;
79     const gchar *label;
80     const SortMode sort_mode;
81 } SortConstants;
82 
83 static const SortConstants sorts_constants[] =
84 {
85     {
86         "name-ascending",
87         N_("Original Name (Ascending)"),
88         ORIGINAL_ASCENDING,
89     },
90     {
91         "name-descending",
92         N_("Original Name (Descending)"),
93         ORIGINAL_DESCENDING,
94     },
95     {
96         "first-modified",
97         N_("First Modified"),
98         FIRST_MODIFIED,
99     },
100     {
101         "last-modified",
102         N_("Last Modified"),
103         LAST_MODIFIED,
104     },
105     {
106         "first-created",
107         N_("First Created"),
108         FIRST_CREATED,
109     },
110     {
111         "last-created",
112         N_("Last Created"),
113         LAST_CREATED,
114     },
115 };
116 
117 static const TagConstants metadata_tags_constants[] =
118 {
119     {
120         "add-equipment-tag",
121         N_("Camera model"),
122         EQUIPMENT,
123         NUMBERING_INVALID,
124         TRUE,
125     },
126     {
127         "add-creation-date-tag",
128         N_("Creation date"),
129         CREATION_DATE,
130         NUMBERING_INVALID,
131         TRUE,
132     },
133     {
134         "add-season-number-tag",
135         N_("Season number"),
136         SEASON_NUMBER,
137         NUMBERING_INVALID,
138         TRUE,
139     },
140     {
141         "add-episode-number-tag",
142         N_("Episode number"),
143         EPISODE_NUMBER,
144         NUMBERING_INVALID,
145         TRUE,
146     },
147     {
148         "add-track-number-tag",
149         N_("Track number"),
150         TRACK_NUMBER,
151         NUMBERING_INVALID,
152         TRUE,
153     },
154     {
155         "add-artist-name-tag",
156         N_("Artist name"),
157         ARTIST_NAME,
158         NUMBERING_INVALID,
159         TRUE,
160     },
161     {
162         "add-title-tag",
163         N_("Title"),
164         TITLE,
165         NUMBERING_INVALID,
166         TRUE,
167     },
168     {
169         "add-album-name-tag",
170         N_("Album name"),
171         ALBUM_NAME,
172         NUMBERING_INVALID,
173         TRUE,
174     },
175     {
176         "add-original-file-name-tag",
177         N_("Original file name"),
178         ORIGINAL_FILE_NAME,
179         NUMBERING_INVALID,
180         TRUE,
181     },
182 };
183 
184 static const TagConstants numbering_tags_constants[] =
185 {
186     {
187         "add-numbering-no-zero-pad-tag",
188         N_("1, 2, 3"),
189         METADATA_INVALID,
190         NUMBERING_NO_ZERO_PAD,
191         FALSE,
192     },
193     {
194         "add-numbering-one-zero-pad-tag",
195         N_("01, 02, 03"),
196         METADATA_INVALID,
197         NUMBERING_ONE_ZERO_PAD,
198         FALSE,
199     },
200     {
201         "add-numbering-two-zero-pad-tag",
202         N_("001, 002, 003"),
203         METADATA_INVALID,
204         NUMBERING_TWO_ZERO_PAD,
205         FALSE,
206     },
207 };
208 
209 typedef struct
210 {
211     gchar *name;
212     gint index;
213 } ConflictData;
214 
215 typedef struct {
216     GString *file_name;
217     GString *metadata [G_N_ELEMENTS (metadata_tags_constants)];
218 } FileMetadata;
219 
220 #define NAUTILUS_TYPE_BATCH_RENAME_DIALOG (nautilus_batch_rename_dialog_get_type())
221 
222 G_DECLARE_FINAL_TYPE (NautilusBatchRenameDialog, nautilus_batch_rename_dialog, NAUTILUS, BATCH_RENAME_DIALOG, GtkDialog);
223 
224 GtkWidget*      nautilus_batch_rename_dialog_new                      (GList                     *selection,
225                                                                        NautilusDirectory         *directory,
226                                                                        NautilusWindow            *window);
227 
228 void            nautilus_batch_rename_dialog_query_finished           (NautilusBatchRenameDialog *dialog,
229                                                                        GHashTable                *hash_table,
230                                                                        GList                     *selection_metadata);
231 
232 G_END_DECLS