From cc7f303e08116cb77b4fdc515b38591977bc3dde Mon Sep 17 00:00:00 2001 From: RKrom Date: Tue, 29 Jul 2014 16:13:12 +0200 Subject: [PATCH] Changed the destination picker behavior to not sort, this makes it possible to do the sorting in the destinations itself. OneNote places the current page on top, the printer list also starts with the default... etc. --- Greenshot/Destinations/PrinterDestination.cs | 16 ++++++++++++++++ Greenshot/Forms/ImageEditorForm.cs | 7 +++++++ .../additional_files/readme.txt.template | 4 ++-- .../Destinations/OutlookDestination.cs | 2 +- .../OfficeExport/ExcelExporter.cs | 1 + .../OfficeExport/OutlookEmailExporter.cs | 4 ++-- .../OfficeExport/PowerpointExporter.cs | 2 +- .../OfficeExport/WordExporter.cs | 1 + GreenshotPlugin/Core/AbstractDestination.cs | 2 -- 9 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Greenshot/Destinations/PrinterDestination.cs b/Greenshot/Destinations/PrinterDestination.cs index c98fafce7..acd35e543 100644 --- a/Greenshot/Destinations/PrinterDestination.cs +++ b/Greenshot/Destinations/PrinterDestination.cs @@ -91,7 +91,23 @@ namespace Greenshot.Destinations { /// /// IEnumerable public override IEnumerable DynamicDestinations() { + PrinterSettings settings = new PrinterSettings(); + string defaultPrinter = settings.PrinterName; + List printers = new List(); + foreach (string printer in PrinterSettings.InstalledPrinters) { + printers.Add(printer); + } + printers.Sort(delegate(string p1, string p2) { + if(defaultPrinter.Equals(p1)) { + return -1; + } + if(defaultPrinter.Equals(p2)) { + return 1; + } + return p1.CompareTo(p2); + }); + foreach(string printer in printers) { yield return new PrinterDestination(printer); } } diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs index f5394bbbf..a39be467d 100644 --- a/Greenshot/Forms/ImageEditorForm.cs +++ b/Greenshot/Forms/ImageEditorForm.cs @@ -73,6 +73,13 @@ namespace Greenshot { public static List Editors { get { + try { + editorList.Sort(delegate(IImageEditor e1, IImageEditor e2) { + return e1.Surface.CaptureDetails.Title.CompareTo(e2.Surface.CaptureDetails.Title); + }); + } catch(Exception ex) { + LOG.Warn("Sorting of editors failed.", ex); + } return editorList; } } diff --git a/Greenshot/releases/additional_files/readme.txt.template b/Greenshot/releases/additional_files/readme.txt.template index 5fda45f00..e6dbd6eca 100644 --- a/Greenshot/releases/additional_files/readme.txt.template +++ b/Greenshot/releases/additional_files/readme.txt.template @@ -24,8 +24,8 @@ Bugs resolved: * BUG-1653: Accessibility issues: Editor "File" menu entry can't be activated and missing translations Changes: -* We cleaned up the dynamic destination context-menu: if an entry (e.g export to the editor) has child items (export to open editors) the parent is still selectable, we also no longer repeat the parent in the children. - +* Dynamic destination context-menu: If a destination has child items the parent is still selectable and executes the default export, we now no longer repeat the parent in the children. +* Dynamic destination context-menu: We are now leaving the sorting to the destination code, this allows us to e.g. show the default printer on top of the list. 1.1.9.13-g01ce82d Windows 8.1 & Box bug-fix Release diff --git a/GreenshotOfficePlugin/Destinations/OutlookDestination.cs b/GreenshotOfficePlugin/Destinations/OutlookDestination.cs index e129b2e96..982b7e403 100644 --- a/GreenshotOfficePlugin/Destinations/OutlookDestination.cs +++ b/GreenshotOfficePlugin/Destinations/OutlookDestination.cs @@ -133,7 +133,7 @@ namespace GreenshotOfficePlugin { } public override IEnumerable DynamicDestinations() { - Dictionary inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets(); + IDictionary inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets(); if (inspectorCaptions != null) { foreach (string inspectorCaption in inspectorCaptions.Keys) { yield return new OutlookDestination(inspectorCaption, inspectorCaptions[inspectorCaption]); diff --git a/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs b/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs index 88915a9e9..cfc00964d 100644 --- a/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs +++ b/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs @@ -54,6 +54,7 @@ namespace Greenshot.Interop.Office { } } } + currentWorkbooks.Sort(); return currentWorkbooks; } diff --git a/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs b/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs index ef8fed2e9..b3911fc99 100644 --- a/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs +++ b/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs @@ -56,8 +56,8 @@ namespace Greenshot.Interop.Office { /// A method to retrieve all inspectors which can act as an export target /// /// List with inspector captions (window title) - public static Dictionary RetrievePossibleTargets() { - Dictionary inspectorCaptions = new Dictionary(); + public static IDictionary RetrievePossibleTargets() { + IDictionary inspectorCaptions = new SortedDictionary(); try { using (IOutlookApplication outlookApplication = GetOutlookApplication()) { if (outlookApplication == null) { diff --git a/GreenshotOfficePlugin/OfficeExport/PowerpointExporter.cs b/GreenshotOfficePlugin/OfficeExport/PowerpointExporter.cs index d60499b64..3f51ce132 100644 --- a/GreenshotOfficePlugin/OfficeExport/PowerpointExporter.cs +++ b/GreenshotOfficePlugin/OfficeExport/PowerpointExporter.cs @@ -69,7 +69,7 @@ namespace Greenshot.Interop.Office { } catch (Exception ex) { LOG.Warn("Problem retrieving word destinations, ignoring: ", ex); } - + foundPresentations.Sort(); return foundPresentations; } diff --git a/GreenshotOfficePlugin/OfficeExport/WordExporter.cs b/GreenshotOfficePlugin/OfficeExport/WordExporter.cs index 17d681cb1..16556a630 100644 --- a/GreenshotOfficePlugin/OfficeExport/WordExporter.cs +++ b/GreenshotOfficePlugin/OfficeExport/WordExporter.cs @@ -227,6 +227,7 @@ namespace Greenshot.Interop.Office { } catch (Exception ex) { LOG.Warn("Problem retrieving word destinations, ignoring: ", ex); } + openDocuments.Sort(); return openDocuments; } diff --git a/GreenshotPlugin/Core/AbstractDestination.cs b/GreenshotPlugin/Core/AbstractDestination.cs index f518689d7..136d5c700 100644 --- a/GreenshotPlugin/Core/AbstractDestination.cs +++ b/GreenshotPlugin/Core/AbstractDestination.cs @@ -321,8 +321,6 @@ namespace GreenshotPlugin.Core { LOG.ErrorFormat("Skipping {0}, due to the following error: {1}", Description, ex.Message); } if (subDestinations.Count > 0) { - subDestinations.Sort(); - ToolStripMenuItem destinationMenuItem = null; if (useDynamicsOnly && subDestinations.Count == 1) {