sort template names under File->New->...

Bug #681625 reported by Łukasz Stelmach
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Wishlist
John Smith

Bug Description

I've got more than thirty templates available in File->New menu and I find it quite difficult to find the one I want when business_card_84x55 is right after the default, business_card_85x54 is four lines down between no_layers and Letter_landscape and business_card_90x50 is somewhere near the bottom.

IMHO sp_menu_append_new_templates() in interface.cpp should sort the names before adding them to the GUI.

I attach a patch against r22636 (which seems to be the latest in svn). I The patched file gives on errors during compilation (few warnings but from different parts of code) but I haven't built whole inkscape with it yet so I can't tell if it really works. However, it gives general Idea how it might be implemented (I am sure someone with better C++ skills will do it much better).

Tags: ui
Revision history for this message
Łukasz Stelmach (steelman) wrote :
jazzynico (jazzynico)
tags: added: ui
Changed in inkscape:
importance: Undecided → Wishlist
status: New → In Progress
Revision history for this message
jazzynico (jazzynico) wrote :

Thanks for this patch.

FYI, Inkscape moved from SVN to BZR just after 0.47 and is now available here: https://code.launchpad.net/~inkscape.dev/inkscape/trunk
Details available on the wiki (http://wiki.inkscape.org/wiki/index.php/Working_with_Bazaar).

As for the File>New menu, see also the "'New from template' dialog" blueprint (https://blueprints.launchpad.net/inkscape/+spec/new-from-template-dialog), which is currently in (slow) progress.

Revision history for this message
jazzynico (jazzynico) wrote :

Related (almost duplicate): Bug #669433 "The 'New' menu is cluttered".

Revision history for this message
jazzynico (jazzynico) wrote :

Compile fails on Ubuntu 10.04, inkscape trunk revision 9923:

interface.cpp: In function ‘void sp_menu_append_new_templates(GtkWidget*, Inkscape::UI::View::View*)’:
interface.cpp:798: error: invalid conversion from ‘const gchar*’ to ‘gchar*’
interface.cpp:798: error: initializing argument 1 of ‘void std::list<_Tp, _Alloc>::push_front(const _Tp&) [with _Tp = gchar*, _Alloc = std::allocator<gchar*>]’

(patch applies an offset of -57 lines)

Revision history for this message
Łukasz Stelmach (steelman) wrote :

I am afraid I can't reproduce this compiler error. More, I don't understand it because I declare files as std::list<gchar const*> same as filepath.

What's even worse is that I can't run rev 9923 because I get

(inkscape:27560): Gtk-CRITICAL **: gtk_misc_set_alignment: assertion `GTK_IS_MISC (misc)' failed

and a segfault. Do I need to install inkscape or can I run it from the source tree?

Revision history for this message
Łukasz Stelmach (steelman) wrote :

The segfault has nothing to do with the failed assertion. It happens while reading ICC profiles from ~/.local/share/share/devices/display. I will file a separate bug for this.

As far as the sorting goes the patch works for me as you may see on the attached screenshot. There is a slight mistake in the first version of the patch. The second's been made against 9930 from lp:inkscape. However, there is one thing I am sure, these are memory leaks. Please, someone who knows C++ and Glib better than I do check if there aren't any.

Revision history for this message
Łukasz Stelmach (steelman) wrote :

It works for me.

Revision history for this message
jazzynico (jazzynico) wrote :

New patch tested successfully on Ubuntu 10.04, Inkscape 9930.

> However, there is one thing I am sure, these are memory leaks. Please, someone who knows C++ and Glib better than I do check if there aren't any.

Do you mean there are memory leaks in your patch or in the interface.cpp code?

Revision history for this message
Łukasz Stelmach (steelman) wrote :

I mean: "I did as much as I could to prevent them, however, I do not write C++ code with Glib on daily basis to know which function I've used allocates memory I have to free and which just returns a pointer to already allocated memory. Please check this." The structure and algorithm looks fine to me but I am *not sure* about the memory allocation.

Revision history for this message
su_v (suv-lp) wrote :

Patch tested with Inkscape 0.48+devel r9926 on osx (GTK+ 2.22.1, Glib 2.26.1): see attached comparison of the 'New…' menu w/o patch.
The 'New…' menu was alphabetically sorted already - without the patch - but 'grouped' the user templates above the shared templates. With the patch the two groups are no longer separated and unix-style sorting (upper case before lower case) is enforced.

Honestly, I preferred the old solution (templates sorted, but user templates first, then system (shared) templates. Thus my local templates are always on top of the list... Mileage may vary of course, and maybe it's just because I got used to this. Note also that on OS X, in the native file manager 'Finder' files normally are sorted ignoring upper/lower case, so the 'New' menu in the current version from trunk looks familiar for OS X users.

<off-topic>
To me, the sorting of the file formats in the Open/Save dialogs is more confusing and illogical than the current one for new templates.
</off-topic>

Revision history for this message
jazzynico (jazzynico) wrote :

@suv - On Ubuntu 10.04, the list is not sorted at all (see attachment).

Revision history for this message
Kris (kris-degussem) wrote :

<some more off-topic:> can the default template names be made translatable? This would be a nice addition. Also the underscores in the template names do not look very nice...

Revision history for this message
Kris (kris-degussem) wrote :

I second the that it is handy to have user templates on top of the list.
Maybe the sorting could be triggered by a user setting...

Revision history for this message
su_v (suv-lp) wrote :

@JazzyNico - that's odd. Possibly the difference is due to one of the patches used for the OS X port of glib2 (via MacPorts)?

<http://trac.macports.org/browser/trunk/dports/devel/glib2/files>

Revision history for this message
su_v (suv-lp) wrote :

Reconsidering my earlier comment (#11) about user/shared templates: if the files are sorted correctly, user templates can still be 'grouped' by using a common prefix. Thus the patch provides more flexibility and is clearly an improvement of the current situation, across platforms.

The same would be needed (IMHO) for the file formats: at the moment they also list first by source (internal, user, shared), then by name: it is thus not possibly to define if a custom/user input/output extension overrides a default one (i.e. is listed first). Could the same sorting fix be ported to the loaded input/output extensions so that the name of the file type alone defines the position in the list of available file types?

Revision history for this message
jazzynico (jazzynico) wrote :

@~suv - Yes very odd. And you know what, it doesn't affect Windows XP, which work exactly like OSX...

@Kris - The "'New from template' dialog" blueprint (https://blueprints.launchpad.net/inkscape/+spec/new-from-template-dialog) is still in progress and should greatly improve the UI.

Revision history for this message
jazzynico (jazzynico) wrote :

@~suv - I second your suggestion. The current I/O extensions sorting is indeed very confusing. New RFE?

Revision history for this message
su_v (suv-lp) wrote :

@JazzyNico - done :)

Bug #682462 “Sort the list of file types in Save/Open dialogs alphabetically”
<https://bugs.launchpad.net/inkscape/+bug/682462>

Revision history for this message
Łukasz Stelmach (steelman) wrote :

"Ask and it will be given to you". This patch after the previous apply and sorted templates shall you see. Possible improvements:

+ UI for the option, I don't know how to do it.

+ Separators in menu.

According to http://library.gnome.org/devel/glib/unstable/glib-File-Utilities.html#g-dir-read-name returns file names in random order. The list in Inkscape may be sorted if the underlying OS provides does the sorting. Furthermore, inkscape scans user's and system directory one after another so it is quite possible you get grouped and sorted list. But this is according to Glib docs OS dependent.

Revision history for this message
Łukasz Stelmach (steelman) wrote :

My bad. This is a full patch on 9930.

Revision history for this message
John Smith (john-smithi) wrote :

Not sure of the status of the 'New from template dialog' blueprint, but if it is not planned to land before 0.49, i propose we commit sorting of the templates, grouped by user as per steelman's patch above (thanks !!).

Attached patch adds some small changes to the above (comment #20)
* On Windows the user templates should come before the system templates (as is the case pre-patch)
* Add a menu separator

I think we are safe to assume users who are making their own templates will understand the separation of their templates from the system defaults in the menu, so no need for any new UI.

Tested on Ubuntu 12.04 and WIndows 7.

Changed in inkscape:
assignee: nobody → John Smith (john-smithi)
Revision history for this message
su_v (suv-lp) wrote :

> 681625.v1.patch
> (…)
> * On Windows the user templates should come before the system templates

Looks fine on OS X 10.7.4 too (tested with r11714, GTK+ 2.24.13, both backends: x11 (glib 2.32.4), quartz (glib 2.33.10 + new patch for collation order on 64bit OS X from bugzilla): user templates are listed (alphabetically sorted) above the shared system templates.

> * Add a menu separator

I'd probably consider adding another menu separator - right below the top entry 'Default' - as well (the default template might be, but doesn't necessarily have to be loaded from the user templates).

Revision history for this message
John Smith (john-smithi) wrote :

Committed to trunk r11717.
Thanks for the patch steelman !

> I'd probably consider adding another menu separator - right below the top entry 'Default'
Included in the commit.

Changed in inkscape:
status: In Progress → Fix Committed
su_v (suv-lp)
Changed in inkscape:
milestone: none → 0.49
Bryce Harrington (bryce)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Related blueprints

Remote bug watches

Bug watches keep track of this bug in other bug trackers.