[gimp] Export layers as pages to pdf / Reverse pages order
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Export layers as pages to pdf / Reverse pages order
- Date: Mon, 19 Jun 2017 20:16:19 +0000 (UTC)
commit 4a05ddebabe0c3b7564d60330d586ccf3fe4f105
Author: Lionel N <lionel libreart info>
Date: Fri Jun 16 23:36:03 2017 +0200
Export layers as pages to pdf / Reverse pages order
Added a "Reverse Order" option when "Layers as pages" is checked.
"Layers as pages" option is greyed out if the image has only 1 layer.
plug-ins/common/file-pdf-save.c | 41 +++++++++++++++++++++++++++++++++++---
1 files changed, 37 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/common/file-pdf-save.c b/plug-ins/common/file-pdf-save.c
index 3889a76..257930a 100644
--- a/plug-ins/common/file-pdf-save.c
+++ b/plug-ins/common/file-pdf-save.c
@@ -150,6 +150,7 @@ typedef enum
SA_IGNORE_HIDDEN,
SA_APPLY_MASKS,
SA_LAYERS_AS_PAGES,
+ SA_REVERSE_ORDER,
SA_ARG_COUNT
} SaveArgs;
@@ -172,6 +173,7 @@ typedef struct
gboolean ignore_hidden;
gboolean apply_masks;
gboolean layers_as_pages;
+ gboolean reverse_order;
} PdfOptimize;
typedef struct
@@ -263,7 +265,8 @@ static PdfOptimize optimize =
TRUE, /* vectorize */
TRUE, /* ignore_hidden */
TRUE, /* apply_masks */
- FALSE /* layers_as_pages */
+ FALSE, /* layers_as_pages */
+ FALSE /* reverse_order */
};
static GtkTreeModel *model;
@@ -307,7 +310,8 @@ query (void)
{ GIMP_PDB_INT32, "vectorize", "Convert bitmaps to vector graphics where possible. TRUE or
FALSE" },
{ GIMP_PDB_INT32, "ignore-hidden", "Omit hidden layers and layers with zero opacity. TRUE or FALSE"
},
{ GIMP_PDB_INT32, "apply-masks", "Apply layer masks before saving. TRUE or FALSE (Keeping them
will not change the output)" },
- { GIMP_PDB_INT32, "layers-as-pages", "Layers as pages. TRUE or FALSE" }
+ { GIMP_PDB_INT32, "layers-as-pages", "Layers as pages. TRUE or FALSE" },
+ { GIMP_PDB_INT32, "reverse-order", "Reverse the pages order. TRUE or FALSE" }
};
static GimpParamDef save_multi_args[] =
@@ -577,13 +581,18 @@ run (const gchar *name,
/* Now, we should loop over the layers of each image */
for (j = 0; j < n_layers; j++)
{
- gint32 layer_ID = layers [n_layers - j - 1];
+ gint32 layer_ID;
gint32 mask_ID = -1;
cairo_surface_t *mask_image = NULL;
gdouble opacity;
gboolean single_color;
gint x, y;
+ if (optimize.reverse_order && optimize.layers_as_pages)
+ layer_ID = layers [j];
+ else
+ layer_ID = layers [n_layers - j - 1];
+
opacity = gimp_layer_get_opacity (layer_ID) / 100.0;
if ((gimp_item_get_visible (layer_ID) && opacity > 0.0) ||
@@ -738,7 +747,7 @@ init_vals (const gchar *name,
gint32 i;
gint32 image;
- if ((g_str_equal (name, SAVE_PROC) && nparams == SA_ARG_COUNT - 1) ||
+ if ((g_str_equal (name, SAVE_PROC) && nparams == SA_ARG_COUNT - 2) ||
(g_str_equal (name, SAVE2_PROC) && nparams == SA_ARG_COUNT))
{
single = TRUE;
@@ -752,7 +761,10 @@ init_vals (const gchar *name,
optimize.vectorize = param[SA_VECTORIZE].data.d_int32;
optimize.ignore_hidden = param[SA_IGNORE_HIDDEN].data.d_int32;
if (nparams == SA_ARG_COUNT)
+ {
optimize.layers_as_pages = param[SA_LAYERS_AS_PAGES].data.d_int32;
+ optimize.reverse_order = param[SA_REVERSE_ORDER].data.d_int32;
+ }
}
else
defaults = TRUE;
@@ -884,7 +896,9 @@ gui_single (void)
GtkWidget *ignore_hidden_c;
GtkWidget *apply_c;
GtkWidget *layers_as_pages_c;
+ GtkWidget *reverse_order_c;
gboolean run;
+ gint32 n_layers;
gimp_ui_init (PLUG_IN_BINARY, FALSE);
@@ -912,11 +926,28 @@ gui_single (void)
gtk_box_pack_end (GTK_BOX (vbox), apply_c, TRUE, TRUE, 0);
gimp_help_set_help_data (apply_c, _("Keeping the masks will not change the output"), NULL);
+ reverse_order_c = gtk_check_button_new_with_label (_("Reverse the pages order"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (reverse_order_c),
+ optimize.reverse_order);
+ gtk_box_pack_end (GTK_BOX (vbox), reverse_order_c, TRUE, TRUE, 0);
+
layers_as_pages_c = gtk_check_button_new_with_label (_("Layers as pages"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (layers_as_pages_c),
optimize.layers_as_pages);
+ gimp_image_get_layers (multi_page.images[0], &n_layers);
gtk_box_pack_end (GTK_BOX (vbox), layers_as_pages_c, TRUE, TRUE, 0);
+ if (n_layers <= 1)
+ {
+ gtk_widget_set_sensitive(layers_as_pages_c, FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (layers_as_pages_c),
+ FALSE);
+ }
+
+ g_object_bind_property (layers_as_pages_c, "active",
+ reverse_order_c, "sensitive",
+ G_BINDING_SYNC_CREATE);
+
gtk_widget_show_all (window);
run = gtk_dialog_run (GTK_DIALOG (window)) == GTK_RESPONSE_OK;
@@ -929,6 +960,8 @@ gui_single (void)
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (apply_c));
optimize.layers_as_pages =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (layers_as_pages_c));
+ optimize.reverse_order =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (reverse_order_c));
gtk_widget_destroy (window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]