[Shotwell] New feature: suffix number when edit multiple picture title
- From: Colin Vidal <colin cvidal org>
- To: shotwell-list gnome org
- Subject: [Shotwell] New feature: suffix number when edit multiple picture title
- Date: Sun, 24 Jul 2016 16:19:36 +0200
Hi all,
I would add a new feature in Shotwell. When edit title of multiples
pictures, I would like a check-box in the text dialog to allow a
suffix in the name.
For instance, if a set a name "Foo" for 3 pictures, I would like the
following names : Foo 1, Foo 2, Foo 3.
Adding an increment suffix seems simple at first glance, with the
following patch*:
diff --git a/src/Commands.vala b/src/Commands.vala
index d922c7d..0713383 100644
--- a/src/Commands.vala
+++ b/src/Commands.vala
@@ -616,8 +616,11 @@ public class EditMultipleTitlesCommand : MultipleDataSourceAtOnceCommand {
}
public override void execute_on_all(Gee.Collection<DataSource> sources) {
- foreach (DataSource source in sources)
- ((MediaSource) source).set_title(new_title);
+ int idx = sources.size > 1 ? 1 : 0;
+
+ foreach (DataSource source in sources) {
+ ((MediaSource) source).set_title(new_title + (idx > 1 ? (idx++).to_string() : ""));
+ }
}
However, I suppose this is not the good way. Probably the better idea
should be to add an integer on constructor of
EditMultipleTitlesCommand, telling if user want a suffix on names
(according to the check-box value).
Here comes the problem of UI. I never use Gtk before. It seems that
on_edit_title method in src/MainPage.vala:1051 uses EditTitleDialog to
build a dialog box, based on TextEntryDialog. Is a good approach to
make a new subclass of EditTitleDialog to add a radio button?
In that case, the other problem is that we need to get the new name
(returned by EditTitleDialog.execute), but also a boolean telling if
the check-box is checked or not. The only solution I see is to simply
check an attribute in the object, since we can't return a pair (not
compatible with string)
Thanks!
Colin
* Even if this patch works, the order of pictures is lost since the list
is copied into a set, in MultipleDataSourceAtOnceCommand
(src/Commands.vala:413), but that's another problem... :-)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]