[pdfmod] Small patch for opening more than one PDF at the the same time through d'n'd



Hi,

I don't know if this funtionality is wanted, but I thought it is a
nice addition since calling PdfMod through the command line with
multiple filenames does the same thing.

Basically i took the code from "LoadFiles" in Client.cs and adjusted
it for the d'n'd event.

This is my first time working with Mono, GTK# and offering a patch to
gnome at all. So please bear with me if I did anything wrong and tell
me what to do different.


diff --git a/src/PdfMod/Gui/DocumentIconView.cs
b/src/PdfMod/Gui/DocumentIconView.cs
index 921fab3..f2e16f9 100644
--- a/src/PdfMod/Gui/DocumentIconView.cs
+++ b/src/PdfMod/Gui/DocumentIconView.cs
@@ -6,6 +6,10 @@ using System.Linq;
 using Gtk;
 using Gdk;

+using Mono.Unix;
+
+using Hyena.Gui;
+
 using PdfSharp.Pdf;

 using PdfMod.Pdf;
@@ -307,8 +311,32 @@ namespace PdfMod.Gui
                 args.RetVal = true;
             } else if (target == uri_src_target.Target) {
                 var uris = System.Text.Encoding.UTF8.GetString
(args.SelectionData.Data).Split (newline,
StringSplitOptions.RemoveEmptyEntries);
-                if (uris.Length == 1 && app.Document == null) {
-                    app.LoadPath (uris[0]);
+                //if (uris.Length == 1 && app.Document == null) {
+				if (uris.Length >= 1 && app.Document == null) {
+					if (uris.Length == 1) {
+		                app.LoadPath (uris[0]);
+		            } else if (uris.Length > 1) {
+		                // Make sure the user wants to open N windows
+		                var message_dialog = new Hyena.Widgets.HigMessageDialog (
+		                    app.Window, DialogFlags.Modal,
MessageType.Question, ButtonsType.None,
+		                    String.Format (Catalog.GetPluralString (
+		                        "Continue, opening {0} document in separate
windows?", "Continue, opening all {0} documents in separate windows?",
uris.Length),
+		                        uris.Length),
+		                    String.Empty);
+		                message_dialog.AddButton (Stock.Cancel,
ResponseType.Cancel, false);
+		                message_dialog.AddButton (Catalog.GetString ("Open
_First"), ResponseType.Accept, false);
+		                message_dialog.AddButton (Catalog.GetString ("Open
_All"), ResponseType.Ok, true);
+		                var response = message_dialog.Run ();
+		                message_dialog.Destroy ();
+		
+		                if ((Gtk.ResponseType)response == Gtk.ResponseType.Ok) {
+		                    foreach (var uri in uris) {
+		                        app.LoadPath (uri.ToString());
+		                    }
+		                } else if ((Gtk.ResponseType)response ==
Gtk.ResponseType.Accept) {
+		                    app.LoadPath (uris[0]);
+		                }
+		            }
                     args.RetVal = true;
                 } else {
                     int to_index = GetDropIndex (args.X, args.Y);



--
Chaos, Panik und Unordnung - mein Werk hier ist vollendet.
http://exitus.dynalias.org


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]