Esempio n. 1
0
        void OnExportImages (object o, EventArgs args)
        {
            var pages = app.IconView.SelectedPages.ToList ();
            var action = new ExportImagesAction (app.Document, pages);
            if (action.ExportableImageCount == 0) {
                Log.Information ("Found zero exportable images in the selected pages");
                return;
            }

            var export_path_base = Path.Combine (
                Path.GetDirectoryName (app.Document.SuggestedSavePath),
                Hyena.StringUtil.EscapeFilename (String.Format ("{0} [{1}]",
                    Path.GetFileNameWithoutExtension (app.Document.SuggestedSavePath),
                    GLib.Markup.EscapeText (Document.GetPageSummary (pages, 10))))
            );

            var export_path = export_path_base;
            int i = 1;
            while (Directory.Exists (export_path) && i < 100) {
                export_path = String.Format ("{0} ({1})", export_path_base, i++);
            }

            try {
                Directory.CreateDirectory (export_path);
            } catch (Exception e) {
                Hyena.Log.Exception (e);
            }

            action.Do (export_path);
            System.Diagnostics.Process.Start (export_path);
        }
Esempio n. 2
0
        void Update ()
        {
            bool have_doc = app.Document != null;
            foreach (string action in require_doc_actions)
                UpdateAction (action, true, have_doc);

            bool have_page = have_doc && app.IconView.SelectedItems.Length > 0;
            foreach (string action in require_page_actions)
                UpdateAction (action, true, have_page);

            int exportable_imgs = 0;
            if (have_page) {
                exportable_imgs = new ExportImagesAction (app.Document, app.IconView.SelectedPages).ExportableImageCount;
            }
            UpdateAction ("ExportImages", true, exportable_imgs > 0);
            this["ExportImages"].Label = String.Format (Catalog.GetPluralString (
                "Export Image", "Export {0} Images", exportable_imgs), exportable_imgs);

            this["ExportImages"].Tooltip = String.Format (Catalog.GetPluralString (
                "Save image from the selected pages to a new folder", "Save {0} images from the selected pages to a new folder", exportable_imgs), exportable_imgs);

            UpdateAction ("Undo", true, have_doc && undo_manager.CanUndo);
            UpdateAction ("Redo", true, have_doc && undo_manager.CanRedo);

            var undo = undo_manager.UndoAction as IDescribedUndoAction;
            this["Undo"].Label = undo == null
                ? Catalog.GetString ("_Undo")
                : String.Format (Catalog.GetString ("Undo {0}"), undo.Description);

            var redo = undo_manager.RedoAction as IDescribedUndoAction;
            this["Redo"].Label = redo == null
                ? Catalog.GetString ("_Redo")
                : String.Format (Catalog.GetString ("Redo {0}"), redo.Description);

            UpdateAction ("Save", true, have_doc && app.Document.HasUnsavedChanges);
            UpdateAction ("ZoomIn", true, have_doc && app.IconView.CanZoomIn);
            UpdateAction ("ZoomOut", true, have_doc && app.IconView.CanZoomOut);

            int selection_count = app.IconView.SelectedItems.Length;
            this["Remove"].Label = String.Format (Catalog.GetPluralString (
                "Remove Page", "Remove {0} Pages", selection_count),
                selection_count);
            this["Remove"].Tooltip = String.Format (Catalog.GetPluralString (
                "Remove the selected page", "Remove the {0} selected pages", selection_count),
                selection_count);
            this["Extract"].Label = String.Format (Catalog.GetPluralString (
                "Extract Page", "Extract {0} Pages", selection_count),
                selection_count);
            this["Extract"].Tooltip = String.Format (Catalog.GetPluralString (
                "Extract the selected page", "Extract the {0} selected pages", selection_count),
                selection_count);
        }