Esempio n. 1
0
        static void OnLogNotify(LogNotifyArgs args)
        {
            ThreadAssist.ProxyToMain(delegate {
                Gtk.MessageType mtype = Gtk.MessageType.Error;
                var entry             = args.Entry;

                switch (entry.Type)
                {
                case LogEntryType.Warning:
                    mtype = Gtk.MessageType.Warning;
                    break;

                case LogEntryType.Information:
                    mtype = Gtk.MessageType.Info;
                    break;

                case LogEntryType.Error:
                default:
                    mtype = Gtk.MessageType.Error;
                    break;
                }

                Hyena.Widgets.HigMessageDialog dialog = new Hyena.Widgets.HigMessageDialog(
                    null, Gtk.DialogFlags.Modal, mtype, Gtk.ButtonsType.Close, entry.Message, entry.Details);

                dialog.Title = String.Empty;
                dialog.Run();
                dialog.Destroy();
            });
        }
Esempio n. 2
0
        public override void LoadFiles(IList <string> files)
        {
            if (files.Count == 1)
            {
                LoadPath(files[0]);
            }
            else if (files.Count > 1)
            {
                // Make sure the user wants to open N windows
                var dialog = new Hyena.Widgets.HigMessageDialog(
                    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?", files.Count),
                                  files.Count),
                    String.Empty);
                dialog.AddButton(Stock.Cancel, ResponseType.Cancel, false);
                dialog.AddButton(Catalog.GetString("Open _First"), ResponseType.Accept, false);
                dialog.AddButton(Catalog.GetString("Open _All"), ResponseType.Ok, true);
                var response = dialog.Run();
                dialog.Destroy();

                if ((Gtk.ResponseType)response == Gtk.ResponseType.Ok)
                {
                    foreach (string file in files)
                    {
                        LoadPath(file);
                    }
                }
                else if ((Gtk.ResponseType)response == Gtk.ResponseType.Accept)
                {
                    LoadPath(files[0]);
                }
            }
        }
Esempio n. 3
0
        private void ShowLogCoreEntry(LogEntry entry)
        {
            Gtk.Window      window = null;
            Gtk.MessageType mtype;

            if (ServiceManager.Contains <GtkElementsService> ())
            {
                window = ServiceManager.Get <GtkElementsService> ().PrimaryWindow;
            }

            switch (entry.Type)
            {
            case LogEntryType.Warning:
                mtype = Gtk.MessageType.Warning;
                break;

            case LogEntryType.Information:
                mtype = Gtk.MessageType.Info;
                break;

            case LogEntryType.Error:
            default:
                mtype = Gtk.MessageType.Error;
                break;
            }

            Hyena.Widgets.HigMessageDialog dialog = new Hyena.Widgets.HigMessageDialog(
                window, Gtk.DialogFlags.Modal, mtype, Gtk.ButtonsType.Close, entry.Message, entry.Details);

            dialog.Title = String.Empty;
            dialog.Run();
            dialog.Destroy();
        }
Esempio n. 4
0
        bool PromptIfUnsavedChanges()
        {
            if (Document != null && Document.HasUnsavedChanges)
            {
                var dialog = new Hyena.Widgets.HigMessageDialog(
                    Window, DialogFlags.Modal, MessageType.Warning, ButtonsType.None,
                    Catalog.GetString("Save the changes made to this document?"),
                    String.Empty
                    );
                dialog.AddButton(Catalog.GetString("Close _Without Saving"), ResponseType.Close, false);
                dialog.AddButton(Stock.Cancel, ResponseType.Cancel, false);
                dialog.AddButton(Stock.SaveAs, ResponseType.Ok, true);

                var response = (ResponseType)dialog.Run();
                dialog.Destroy();

                switch (response)
                {
                case ResponseType.Ok:
                    Actions["SaveAs"].Activate();
                    return(PromptIfUnsavedChanges());

                case ResponseType.Close:
                    return(false);

                case ResponseType.Cancel:
                case ResponseType.DeleteEvent:
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 5
0
        // Help menu actions

        void OnHelp(object o, EventArgs args)
        {
            bool shown = false;

            try {
                IntPtr lang_ptr = g_get_language_names();
                var    langs    = GLib.Marshaller.NullTermPtrToStringArray(lang_ptr, false);

                string help_dir = null;
                foreach (var dir in new string [] { Core.Defines.PREFIX + "/share/gnome/help/", "/usr/local/share/gnome/help/", "docs/" })
                {
                    help_dir = dir;
                    if (System.IO.Directory.Exists(dir + "pdfmod/"))
                    {
                        break;
                    }
                }

                foreach (var lang in langs)
                {
                    var help_path = CombinePaths(help_dir, "pdfmod", lang, "pdfmod.xml");
                    if (System.IO.File.Exists(help_path))
                    {
                        System.Diagnostics.Process.Start(String.Format("ghelp://{0}", help_path));
                        shown = true;
                        break;
                    }
                }
            } catch (Exception e) {
                Hyena.Log.Exception("Error opening help", e);
            }

            if (!shown)
            {
                var message_dialog = new Hyena.Widgets.HigMessageDialog(
                    app.Window, DialogFlags.Modal, MessageType.Warning, ButtonsType.None,
                    Catalog.GetString("Error opening help"),
                    Catalog.GetString("Would you like to open PDF Mod's online documentation?")
                    );
                message_dialog.AddButton(Stock.No, ResponseType.No, false);
                message_dialog.AddButton(Stock.Yes, ResponseType.Yes, true);

                var response = (ResponseType)message_dialog.Run();
                message_dialog.Destroy();
                if (response == ResponseType.Yes)
                {
                    System.Diagnostics.Process.Start(DOCS_URL);
                }
            }
        }
Esempio n. 6
0
        private static bool ConfirmUnmap(IUnmapableSource source)
        {
            string key        = "no_confirm_unmap_" + source.GetType().Name.ToLower();
            bool   do_not_ask = ConfigurationClient.Get <bool> ("sources", key, false);

            if (do_not_ask)
            {
                return(true);
            }

            Hyena.Widgets.HigMessageDialog dialog = new Hyena.Widgets.HigMessageDialog(
                ServiceManager.Get <GtkElementsService> ().PrimaryWindow,
                Gtk.DialogFlags.Modal,
                Gtk.MessageType.Question,
                Gtk.ButtonsType.Cancel,
                String.Format(Catalog.GetString("Are you sure you want to delete this {0}?"),
                              source.GenericName.ToLower()),
                source.Name);

            dialog.AddButton(Gtk.Stock.Delete, Gtk.ResponseType.Ok, false);

            Gtk.Alignment alignment = new Gtk.Alignment(0.0f, 0.0f, 0.0f, 0.0f);
            alignment.TopPadding = 10;
            Gtk.CheckButton confirm_button = new Gtk.CheckButton(String.Format(Catalog.GetString(
                                                                                   "Do not ask me this again"), source.GenericName.ToLower()));
            confirm_button.Toggled += delegate {
                do_not_ask = confirm_button.Active;
            };
            alignment.Add(confirm_button);
            alignment.ShowAll();
            dialog.LabelVBox.PackStart(alignment, false, false, 0);

            try {
                if (dialog.Run() == (int)Gtk.ResponseType.Ok)
                {
                    ConfigurationClient.Set <bool> ("sources", key, do_not_ask);
                    return(true);
                }

                return(false);
            } finally {
                dialog.Destroy();
            }
        }
Esempio n. 7
0
        private void OnCancelClicked(object o, EventArgs args)
        {
            if (cancel_dialog != null)
            {
                return;
            }

            Window parent = null;

            if (ServiceManager.Contains <GtkElementsService> ())
            {
                parent = ServiceManager.Get <GtkElementsService> ().PrimaryWindow;
            }

            cancel_dialog = new Hyena.Widgets.HigMessageDialog(parent,
                                                               DialogFlags.Modal, MessageType.Question, ButtonsType.None,
                                                               job.Title == null
                    ? Catalog.GetString("Stop Operation")
                    : String.Format(Catalog.GetString("Stop {0}"), job.Title),
                                                               job.CancelMessage == null
                    ? (job.Title == null
                        ? Catalog.GetString("This operation is still performing work. Would you like to stop it?")
                        : String.Format(Catalog.GetString(
                                            "The '{0}' operation is still performing work. Would you like to stop it?"), job.Title))
                    : job.CancelMessage);

            cancel_dialog.AddButton(job.Title == null
                ? Catalog.GetString("Continue")
                : String.Format(Catalog.GetString("Continue {0}"), job.Title),
                                    ResponseType.No, true);
            cancel_dialog.AddButton(Stock.Stop, ResponseType.Yes, false);
            cancel_dialog.DefaultResponse = ResponseType.Cancel;

            if (cancel_dialog.Run() == (int)ResponseType.Yes)
            {
                if (job.CanCancel)
                {
                    ServiceManager.JobScheduler.Cancel(job);
                }
            }

            cancel_dialog.Destroy();
            cancel_dialog = null;
        }
Esempio n. 8
0
        public void PasswordProvider(PdfPasswordProviderArgs args)
        {
            // This method is called from some random thread, but we need
            // to do the dialog on the GUI thread; use the reset_event
            // to block this thread until the user is done with the dialog.
            ThreadAssist.BlockingProxyToMain(delegate {
                Log.Debug("Password requested to open document");
                var dialog = new Hyena.Widgets.HigMessageDialog(
                    Window, DialogFlags.Modal, MessageType.Question, ButtonsType.None,
                    Catalog.GetString("Document is Encrypted"),
                    Catalog.GetString("Enter the document's password to open it:")
                    );
                dialog.Image = Gtk.IconTheme.Default.LoadIcon("dialog-password", 48, 0);

                var password_entry = new Entry()
                {
                    Visibility = false
                };
                password_entry.Show();
                dialog.LabelVBox.PackStart(password_entry, false, false, 12);

                dialog.AddButton(Stock.Cancel, ResponseType.Cancel, false);
                dialog.AddButton(Stock.Ok, ResponseType.Ok, true);

                var response    = (ResponseType)dialog.Run();
                string password = password_entry.Text;
                dialog.Destroy();

                if (response == ResponseType.Ok)
                {
                    args.Password = Document.Password = password;
                }
                else
                {
                    Log.Information("Password dialog cancelled");
                    args.Abort = true;
                }
            });
        }
Esempio n. 9
0
        private static bool ConfirmUnmap (IUnmapableSource source)
        {
            string key = "no_confirm_unmap_" + source.GetType ().Name.ToLower ();
            bool do_not_ask = ConfigurationClient.Get<bool> ("sources", key, false);

            if (do_not_ask) {
                return true;
            }

            Hyena.Widgets.HigMessageDialog dialog = new Hyena.Widgets.HigMessageDialog (
                ServiceManager.Get<GtkElementsService> ().PrimaryWindow,
                Gtk.DialogFlags.Modal,
                Gtk.MessageType.Question,
                Gtk.ButtonsType.Cancel,
                String.Format (Catalog.GetString ("Are you sure you want to delete this {0}?"),
                    source.GenericName.ToLower ()),
                source.Name);

            dialog.AddButton (Gtk.Stock.Delete, Gtk.ResponseType.Ok, false);

            Gtk.Alignment alignment = new Gtk.Alignment (0.0f, 0.0f, 0.0f, 0.0f);
            alignment.TopPadding = 10;
            Gtk.CheckButton confirm_button = new Gtk.CheckButton (String.Format (Catalog.GetString (
                "Do not ask me this again"), source.GenericName.ToLower ()));
            confirm_button.Toggled += delegate {
                do_not_ask = confirm_button.Active;
            };
            alignment.Add (confirm_button);
            alignment.ShowAll ();
            dialog.LabelVBox.PackStart (alignment, false, false, 0);

            try {
                if (dialog.Run () == (int)Gtk.ResponseType.Ok) {
                    ConfigurationClient.Set<bool> ("sources", key, do_not_ask);
                    return true;
                }

                return false;
            } finally {
                dialog.Destroy ();
            }
        }
Esempio n. 10
0
        private void OnCancelClicked(object o, EventArgs args)
        {
            if (cancel_dialog != null) {
                return;
            }

            Window parent = null;
            if (ServiceManager.Contains<GtkElementsService> ()) {
                parent = ServiceManager.Get<GtkElementsService> ().PrimaryWindow;
            }

            cancel_dialog = new Hyena.Widgets.HigMessageDialog (parent,
                DialogFlags.Modal, MessageType.Question, ButtonsType.None,
                job.Title == null
                    ? Catalog.GetString ("Stop Operation")
                    : String.Format (Catalog.GetString ("Stop {0}"), job.Title),
                job.CancelMessage == null
                    ? (job.Title == null
                        ? Catalog.GetString ("This operation is still performing work. Would you like to stop it?")
                        : String.Format (Catalog.GetString (
                            "The '{0}' operation is still performing work. Would you like to stop it?"), job.Title))
                    : job.CancelMessage);

            cancel_dialog.AddButton (job.Title == null
                ? Catalog.GetString ("Continue")
                : String.Format (Catalog.GetString ("Continue {0}"), job.Title),
                ResponseType.No, true);
            cancel_dialog.AddButton (Stock.Stop, ResponseType.Yes, false);
            cancel_dialog.DefaultResponse = ResponseType.Cancel;

            if (cancel_dialog.Run () == (int)ResponseType.Yes) {
                if (job.CanCancel) {
                    ServiceManager.JobScheduler.Cancel (job);
                }
            }

            cancel_dialog.Destroy ();
            cancel_dialog = null;
        }
Esempio n. 11
0
        static void OnLogNotify (LogNotifyArgs args)
        {
            ThreadAssist.ProxyToMain (delegate {
                Gtk.MessageType mtype = Gtk.MessageType.Error;
                var entry = args.Entry;

                switch (entry.Type) {
                    case LogEntryType.Warning:
                        mtype = Gtk.MessageType.Warning;
                        break;
                    case LogEntryType.Information:
                        mtype = Gtk.MessageType.Info;
                        break;
                    case LogEntryType.Error:
                    default:
                        mtype = Gtk.MessageType.Error;
                        break;
                }

                Hyena.Widgets.HigMessageDialog dialog = new Hyena.Widgets.HigMessageDialog (
                    null, Gtk.DialogFlags.Modal, mtype, Gtk.ButtonsType.Close, entry.Message, entry.Details);

                dialog.Title = String.Empty;
                dialog.Run ();
                dialog.Destroy ();
            });
        }
Esempio n. 12
0
        public void PasswordProvider (PdfPasswordProviderArgs args)
        {
            // This method is called from some random thread, but we need
            // to do the dialog on the GUI thread; use the reset_event
            // to block this thread until the user is done with the dialog.
            ThreadAssist.BlockingProxyToMain (delegate {
                Log.Debug ("Password requested to open document");
                var dialog = new Hyena.Widgets.HigMessageDialog (
                    Window, DialogFlags.Modal, MessageType.Question, ButtonsType.None,
                    Catalog.GetString ("Document is Encrypted"),
                    Catalog.GetString ("Enter the document's password to open it:")
                );
                dialog.Image = Gtk.IconTheme.Default.LoadIcon ("dialog-password", 48, 0);

                var password_entry = new Entry () { Visibility = false };
                password_entry.Show ();
                dialog.LabelVBox.PackStart (password_entry, false, false, 12);

                dialog.AddButton (Stock.Cancel, ResponseType.Cancel, false);
                dialog.AddButton (Stock.Ok, ResponseType.Ok, true);

                var response = (ResponseType)dialog.Run ();
                string password = password_entry.Text;
                dialog.Destroy ();

                if (response == ResponseType.Ok) {
                    args.Password = Document.Password = password;
                } else {
                    Log.Information ("Password dialog cancelled");
                    args.Abort = true;
                }
            });
        }
Esempio n. 13
0
        public override void LoadFiles (IList<string> files)
        {
            if (files.Count == 1) {
                LoadPath (files[0]);
            } else if (files.Count > 1) {
                // Make sure the user wants to open N windows
                var dialog = new Hyena.Widgets.HigMessageDialog (
                    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?", files.Count),
                        files.Count),
                    String.Empty);
                dialog.AddButton (Stock.Cancel, ResponseType.Cancel, false);
                dialog.AddButton (Catalog.GetString ("Open _First"), ResponseType.Accept, false);
                dialog.AddButton (Catalog.GetString ("Open _All"), ResponseType.Ok, true);
                var response = dialog.Run ();
                dialog.Destroy ();

                if ((Gtk.ResponseType)response == Gtk.ResponseType.Ok) {
                    foreach (string file in files) {
                        LoadPath (file);
                    }
                } else if ((Gtk.ResponseType)response == Gtk.ResponseType.Accept) {
                    LoadPath (files[0]);
                }
            }
        }
Esempio n. 14
0
        bool PromptIfUnsavedChanges ()
        {
            if (Document != null && Document.HasUnsavedChanges) {
                var dialog = new Hyena.Widgets.HigMessageDialog (
                    Window, DialogFlags.Modal, MessageType.Warning, ButtonsType.None,
                    Catalog.GetString ("Save the changes made to this document?"),
                    String.Empty
                );
                dialog.AddButton (Catalog.GetString ("Close _Without Saving"), ResponseType.Close, false);
                dialog.AddButton (Stock.Cancel, ResponseType.Cancel, false);
                dialog.AddButton (Stock.SaveAs, ResponseType.Ok, true);

                var response = (ResponseType) dialog.Run ();
                dialog.Destroy ();

                switch (response) {
                    case ResponseType.Ok:
                        Actions["SaveAs"].Activate ();
                        return PromptIfUnsavedChanges ();
                    case ResponseType.Close:
                        return false;
                    case ResponseType.Cancel:
                    case ResponseType.DeleteEvent:
                        return true;
                }
            }
            return false;
        }
Esempio n. 15
0
        // Help menu actions

        void OnHelp (object o, EventArgs args)
        {
            bool shown = false;
            try {
                IntPtr lang_ptr = g_get_language_names ();
                var langs = GLib.Marshaller.NullTermPtrToStringArray (lang_ptr, false);

                string help_dir = null;
                foreach (var dir in new string [] { Core.Defines.PREFIX + "/share/gnome/help/", "/usr/local/share/gnome/help/", "docs/" }) {
                    help_dir = dir;
                    if (System.IO.Directory.Exists (dir + "pdfmod/")) {
                        break;
                    }
                }

                foreach (var lang in langs) {
                    var help_path = CombinePaths (help_dir, "pdfmod", lang, "pdfmod.xml");
                    if (System.IO.File.Exists (help_path)) {
                        System.Diagnostics.Process.Start (String.Format ("ghelp://{0}", help_path));
                        shown = true;
                        break;
                    }
                }
            } catch (Exception e) {
                Hyena.Log.Exception ("Error opening help", e);
            }

            if (!shown) {
                var message_dialog = new Hyena.Widgets.HigMessageDialog (
                    app.Window, DialogFlags.Modal, MessageType.Warning, ButtonsType.None,
                    Catalog.GetString ("Error opening help"),
                    Catalog.GetString ("Would you like to open PDF Mod's online documentation?")
                );
                message_dialog.AddButton (Stock.No, ResponseType.No, false);
                message_dialog.AddButton (Stock.Yes, ResponseType.Yes, true);

                var response = (ResponseType) message_dialog.Run ();
                message_dialog.Destroy ();
                if (response == ResponseType.Yes) {
                    System.Diagnostics.Process.Start (DOCS_URL);
                }
            }
        }