Revert "app: item uniquefy algorithm allowing generic numbering schemes."

This reverts commit 56b6dbaa87.
It has been discussed and decided that the no-hash numbering scheme
would have unwanted side-effects for people using number-ending layer
names for other purposes than incrementation.
This revert has been modified to keep commit c402f10.
This commit is contained in:
Jehan 2015-11-19 18:58:31 +01:00
parent e38e262ac1
commit e12a520c99
2 changed files with 5 additions and 10 deletions

View File

@ -546,7 +546,7 @@ gimp_item_real_duplicate (GimpItem *item,
if ((strlen (name) >= len &&
strcmp (&name[strlen (name) - len], _("copy")) == 0) ||
g_regex_match_simple ("([0-9]+)\\s*$", name, 0, 0))
g_regex_match_simple ("#([0-9]+)\\s*$", name, 0, 0))
{
/* don't have redundant "copy"s */
new_name = g_strdup (name);

View File

@ -661,19 +661,15 @@ gimp_item_tree_uniquefy_name (GimpItemTree *tree,
gchar *new_name = NULL;
gint number = 0;
gint precision = 1;
gboolean hashed = TRUE;
GRegex *end_numbers = g_regex_new ("(^|[^0-9])([0-9]+)\\s*$", 0, 0, NULL);
GRegex *end_numbers = g_regex_new (" ?#([0-9]+)\\s*$", 0, 0, NULL);
GMatchInfo *match_info = NULL;
if (g_regex_match (end_numbers, name, 0, &match_info))
{
/* Allow counting styles without a hash as alternative. */
gchar *match;
gint start_pos;
hashed = FALSE;
match = g_match_info_fetch (match_info, 2);
match = g_match_info_fetch (match_info, 1);
if (match && match[0] == '0')
{
precision = strlen (match);
@ -681,7 +677,7 @@ gimp_item_tree_uniquefy_name (GimpItemTree *tree,
number = atoi (match);
g_free (match);
g_match_info_fetch_pos (match_info, 2,
g_match_info_fetch_pos (match_info, 0,
&start_pos, NULL);
name[start_pos] = '\0';
}
@ -694,9 +690,8 @@ gimp_item_tree_uniquefy_name (GimpItemTree *tree,
g_free (new_name);
new_name = g_strdup_printf ("%s%s%.*d",
new_name = g_strdup_printf ("%s #%.*d",
name,
hashed ? " #" : "",
precision,
number);
}