mirror of https://github.com/GNOME/gimp.git
Bug 739488 - Set default brush, brush pipe, pattern name to the file's basename
If there is no gimp-[brush|pattern|brush-pipe]-name parasite, default to the file's basename without extension, instead of always "GIMP Brush" etc. Also clean up the code, and make the plug-ins do the same things the same way.
This commit is contained in:
parent
d91cc01d84
commit
84182125cf
|
@ -207,11 +207,13 @@ run (const gchar *name,
|
||||||
}
|
}
|
||||||
else if (strcmp (name, SAVE_PROC) == 0)
|
else if (strcmp (name, SAVE_PROC) == 0)
|
||||||
{
|
{
|
||||||
|
GFile *file;
|
||||||
GimpParasite *parasite;
|
GimpParasite *parasite;
|
||||||
gint32 orig_image_ID;
|
gint32 orig_image_ID;
|
||||||
|
|
||||||
image_ID = param[1].data.d_int32;
|
image_ID = param[1].data.d_int32;
|
||||||
drawable_ID = param[2].data.d_int32;
|
drawable_ID = param[2].data.d_int32;
|
||||||
|
file = g_file_new_for_uri (param[3].data.d_string);
|
||||||
|
|
||||||
orig_image_ID = image_ID;
|
orig_image_ID = image_ID;
|
||||||
|
|
||||||
|
@ -235,25 +237,40 @@ run (const gchar *name,
|
||||||
|
|
||||||
/* Possibly retrieve data */
|
/* Possibly retrieve data */
|
||||||
gimp_get_data (SAVE_PROC, &info);
|
gimp_get_data (SAVE_PROC, &info);
|
||||||
|
|
||||||
|
parasite = gimp_image_get_parasite (orig_image_ID,
|
||||||
|
"gimp-brush-name");
|
||||||
|
if (parasite)
|
||||||
|
{
|
||||||
|
strncpy (info.description,
|
||||||
|
gimp_parasite_data (parasite),
|
||||||
|
MIN (sizeof (info.description),
|
||||||
|
gimp_parasite_data_size (parasite)));
|
||||||
|
info.description[sizeof (info.description) - 1] = '\0';
|
||||||
|
|
||||||
|
gimp_parasite_free (parasite);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gchar *name = g_path_get_basename (gimp_file_get_utf8_name (file));
|
||||||
|
|
||||||
|
if (g_str_has_suffix (name, ".gbr"))
|
||||||
|
name[strlen (name) - 4] = '\0';
|
||||||
|
|
||||||
|
if (strlen (name))
|
||||||
|
{
|
||||||
|
strncpy (info.description, name, sizeof (info.description));
|
||||||
|
info.description[sizeof (info.description) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (name);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
parasite = gimp_image_get_parasite (orig_image_ID, "gimp-brush-name");
|
|
||||||
if (parasite)
|
|
||||||
{
|
|
||||||
gchar *name = g_strndup (gimp_parasite_data (parasite),
|
|
||||||
gimp_parasite_data_size (parasite));
|
|
||||||
gimp_parasite_free (parasite);
|
|
||||||
|
|
||||||
strncpy (info.description, name, sizeof (info.description));
|
|
||||||
info.description[sizeof (info.description) - 1] = '\0';
|
|
||||||
|
|
||||||
g_free (name);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (run_mode)
|
switch (run_mode)
|
||||||
{
|
{
|
||||||
case GIMP_RUN_INTERACTIVE:
|
case GIMP_RUN_INTERACTIVE:
|
||||||
|
@ -281,8 +298,7 @@ run (const gchar *name,
|
||||||
|
|
||||||
if (status == GIMP_PDB_SUCCESS)
|
if (status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
if (save_image (g_file_new_for_uri (param[3].data.d_string),
|
if (save_image (file, image_ID, drawable_ID, &error))
|
||||||
image_ID, drawable_ID, &error))
|
|
||||||
{
|
{
|
||||||
gimp_set_data (SAVE_PROC, &info, sizeof (info));
|
gimp_set_data (SAVE_PROC, &info, sizeof (info));
|
||||||
}
|
}
|
||||||
|
@ -295,7 +311,7 @@ run (const gchar *name,
|
||||||
if (export == GIMP_EXPORT_EXPORT)
|
if (export == GIMP_EXPORT_EXPORT)
|
||||||
gimp_image_delete (image_ID);
|
gimp_image_delete (image_ID);
|
||||||
|
|
||||||
if (info.description && strlen (info.description))
|
if (strlen (info.description))
|
||||||
{
|
{
|
||||||
GimpParasite *parasite;
|
GimpParasite *parasite;
|
||||||
|
|
||||||
|
@ -783,23 +799,11 @@ save_dialog (void)
|
||||||
table, TRUE, TRUE, 0);
|
table, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
|
|
||||||
adj = (GtkAdjustment *) gtk_adjustment_new (info.spacing, 1, 1000, 1, 10, 0);
|
|
||||||
spinbutton = gtk_spin_button_new (adj, 1.0, 0);
|
|
||||||
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
|
||||||
gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE);
|
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
|
||||||
_("Spacing:"), 1.0, 0.5,
|
|
||||||
spinbutton, 1, TRUE);
|
|
||||||
|
|
||||||
g_signal_connect (adj, "value-changed",
|
|
||||||
G_CALLBACK (gimp_int_adjustment_update),
|
|
||||||
&info.spacing);
|
|
||||||
|
|
||||||
entry = gtk_entry_new ();
|
entry = gtk_entry_new ();
|
||||||
gtk_widget_set_size_request (entry, 200, -1);
|
gtk_entry_set_width_chars (GTK_ENTRY (entry), 20);
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry), info.description);
|
|
||||||
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
gtk_entry_set_text (GTK_ENTRY (entry), info.description);
|
||||||
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||||
_("Description:"), 1.0, 0.5,
|
_("Description:"), 1.0, 0.5,
|
||||||
entry, 1, FALSE);
|
entry, 1, FALSE);
|
||||||
|
|
||||||
|
@ -807,6 +811,18 @@ save_dialog (void)
|
||||||
G_CALLBACK (entry_callback),
|
G_CALLBACK (entry_callback),
|
||||||
info.description);
|
info.description);
|
||||||
|
|
||||||
|
adj = (GtkAdjustment *) gtk_adjustment_new (info.spacing, 1, 1000, 1, 10, 0);
|
||||||
|
spinbutton = gtk_spin_button_new (adj, 1.0, 0);
|
||||||
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
||||||
|
gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE);
|
||||||
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||||
|
_("Spacing:"), 1.0, 0.5,
|
||||||
|
spinbutton, 1, TRUE);
|
||||||
|
|
||||||
|
g_signal_connect (adj, "value-changed",
|
||||||
|
G_CALLBACK (gimp_int_adjustment_update),
|
||||||
|
&info.spacing);
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (dialog);
|
||||||
|
|
||||||
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
|
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
|
||||||
|
|
|
@ -53,39 +53,20 @@
|
||||||
#include "libgimp/stdplugins-intl.h"
|
#include "libgimp/stdplugins-intl.h"
|
||||||
|
|
||||||
|
|
||||||
#define LOAD_PROC "file-gih-load"
|
#define LOAD_PROC "file-gih-load"
|
||||||
#define SAVE_PROC "file-gih-save"
|
#define SAVE_PROC "file-gih-save"
|
||||||
#define PLUG_IN_BINARY "file-gih"
|
#define PLUG_IN_BINARY "file-gih"
|
||||||
#define PLUG_IN_ROLE "gimp-file-gih"
|
#define PLUG_IN_ROLE "gimp-file-gih"
|
||||||
#define DUMMY_PATTERN_NAME "x"
|
|
||||||
#define MAXDESCLEN 256
|
|
||||||
|
|
||||||
/* Parameters applicable each time we save a gih, saved in the
|
/* Parameters applicable each time we save a gih, saved in the
|
||||||
* main gimp application between invocations of this plug-in.
|
* main gimp application between invocations of this plug-in.
|
||||||
*/
|
*/
|
||||||
static struct
|
typedef struct
|
||||||
{
|
{
|
||||||
guint spacing;
|
gchar description[256];
|
||||||
gchar description[MAXDESCLEN+1];
|
gint spacing;
|
||||||
} info =
|
} BrushInfo;
|
||||||
/* Initialize to this, change if non-interactive later */
|
|
||||||
{
|
|
||||||
20,
|
|
||||||
"GIMP Brush Pipe"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static gint num_layers = 0;
|
|
||||||
|
|
||||||
static const gchar *selection_modes[] = { "incremental",
|
|
||||||
"angular",
|
|
||||||
"random",
|
|
||||||
"velocity",
|
|
||||||
"pressure",
|
|
||||||
"xtilt",
|
|
||||||
"ytilt" };
|
|
||||||
|
|
||||||
static GimpPixPipeParams gihparams;
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -105,35 +86,33 @@ typedef struct
|
||||||
GtkWidget *mode_entry[GIMP_PIXPIPE_MAXDIM];
|
GtkWidget *mode_entry[GIMP_PIXPIPE_MAXDIM];
|
||||||
} SizeAdjustmentData;
|
} SizeAdjustmentData;
|
||||||
|
|
||||||
/* static gint32 *vguides, *hguides; */
|
|
||||||
/* static gint nvguides = 0, nhguides = 0; */
|
|
||||||
|
|
||||||
/* Declare some local functions.
|
/* local function prototypes */
|
||||||
*/
|
|
||||||
static void query (void);
|
|
||||||
static void run (const gchar *name,
|
|
||||||
gint nparams,
|
|
||||||
const GimpParam *param,
|
|
||||||
gint *nreturn_vals,
|
|
||||||
GimpParam **return_vals);
|
|
||||||
|
|
||||||
static gint32 gih_load_image (GFile *file,
|
static void query (void);
|
||||||
GError **error);
|
static void run (const gchar *name,
|
||||||
static gboolean gih_load_one_brush (GInputStream *input,
|
gint nparams,
|
||||||
gint32 image_ID,
|
const GimpParam *param,
|
||||||
GError **error);
|
gint *nreturn_vals,
|
||||||
|
GimpParam **return_vals);
|
||||||
|
|
||||||
static gboolean gih_save_dialog (gint32 image_ID);
|
static gint32 gih_load_image (GFile *file,
|
||||||
static gboolean gih_save_one_brush (GOutputStream *output,
|
GError **error);
|
||||||
gint32 drawable_ID,
|
static gboolean gih_load_one_brush (GInputStream *input,
|
||||||
GeglRectangle *rect,
|
gint32 image_ID,
|
||||||
const gchar *name,
|
GError **error);
|
||||||
GError **error);
|
|
||||||
static gboolean gih_save_image (GFile *file,
|
static gboolean gih_save_dialog (gint32 image_ID);
|
||||||
gint32 image_ID,
|
static gboolean gih_save_one_brush (GOutputStream *output,
|
||||||
gint32 orig_image_ID,
|
gint32 drawable_ID,
|
||||||
gint32 drawable_ID,
|
GeglRectangle *rect,
|
||||||
GError **error);
|
const gchar *name,
|
||||||
|
GError **error);
|
||||||
|
static gboolean gih_save_image (GFile *file,
|
||||||
|
gint32 image_ID,
|
||||||
|
gint32 orig_image_ID,
|
||||||
|
gint32 drawable_ID,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
const GimpPlugInInfo PLUG_IN_INFO =
|
const GimpPlugInInfo PLUG_IN_INFO =
|
||||||
|
@ -144,6 +123,27 @@ const GimpPlugInInfo PLUG_IN_INFO =
|
||||||
run, /* run_proc */
|
run, /* run_proc */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* private variables */
|
||||||
|
|
||||||
|
static BrushInfo info =
|
||||||
|
{
|
||||||
|
"GIMP Brush Pipe",
|
||||||
|
20
|
||||||
|
};
|
||||||
|
|
||||||
|
static gint num_layers = 0;
|
||||||
|
static GimpPixPipeParams gihparams = { 0, };
|
||||||
|
|
||||||
|
static const gchar * const selection_modes[] = { "incremental",
|
||||||
|
"angular",
|
||||||
|
"random",
|
||||||
|
"velocity",
|
||||||
|
"pressure",
|
||||||
|
"xtilt",
|
||||||
|
"ytilt" };
|
||||||
|
|
||||||
|
|
||||||
MAIN ()
|
MAIN ()
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -177,10 +177,9 @@ query (void)
|
||||||
};
|
};
|
||||||
static const GimpParamDef gih_load_return_vals[] =
|
static const GimpParamDef gih_load_return_vals[] =
|
||||||
{
|
{
|
||||||
{ GIMP_PDB_IMAGE, "image", "Output image" }
|
{ GIMP_PDB_IMAGE, "image", "Output image" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
gimp_install_procedure (LOAD_PROC,
|
gimp_install_procedure (LOAD_PROC,
|
||||||
"loads images in GIMP brush pipe format",
|
"loads images in GIMP brush pipe format",
|
||||||
"This plug-in loads a GIMP brush pipe as an image.",
|
"This plug-in loads a GIMP brush pipe as an image.",
|
||||||
|
@ -234,10 +233,7 @@ run (const gchar *name,
|
||||||
static GimpParam values[2];
|
static GimpParam values[2];
|
||||||
GimpRunMode run_mode;
|
GimpRunMode run_mode;
|
||||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||||
GimpParasite *name_parasite;
|
|
||||||
GimpParasite *pipe_parasite;
|
|
||||||
gint32 image_ID;
|
gint32 image_ID;
|
||||||
gint32 orig_image_ID;
|
|
||||||
gint32 drawable_ID;
|
gint32 drawable_ID;
|
||||||
gint i;
|
gint i;
|
||||||
GimpExportReturn export = GIMP_EXPORT_CANCEL;
|
GimpExportReturn export = GIMP_EXPORT_CANCEL;
|
||||||
|
@ -272,10 +268,17 @@ run (const gchar *name,
|
||||||
}
|
}
|
||||||
else if (strcmp (name, SAVE_PROC) == 0)
|
else if (strcmp (name, SAVE_PROC) == 0)
|
||||||
{
|
{
|
||||||
image_ID = orig_image_ID = param[1].data.d_int32;
|
GFile *file;
|
||||||
drawable_ID = param[2].data.d_int32;
|
GimpParasite *name_parasite;
|
||||||
|
GimpParasite *pipe_parasite;
|
||||||
|
gint32 orig_image_ID;
|
||||||
|
|
||||||
|
image_ID = param[1].data.d_int32;
|
||||||
|
drawable_ID = param[2].data.d_int32;
|
||||||
|
file = g_file_new_for_uri (param[3].data.d_string);
|
||||||
|
|
||||||
|
orig_image_ID = image_ID;
|
||||||
|
|
||||||
/* eventually export the image */
|
|
||||||
switch (run_mode)
|
switch (run_mode)
|
||||||
{
|
{
|
||||||
case GIMP_RUN_INTERACTIVE:
|
case GIMP_RUN_INTERACTIVE:
|
||||||
|
@ -293,58 +296,71 @@ run (const gchar *name,
|
||||||
values[0].data.d_status = GIMP_PDB_CANCEL;
|
values[0].data.d_status = GIMP_PDB_CANCEL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Possibly retrieve data */
|
||||||
|
gimp_get_data (SAVE_PROC, &info);
|
||||||
|
|
||||||
|
name_parasite = gimp_image_get_parasite (orig_image_ID,
|
||||||
|
"gimp-brush-pipe-name");
|
||||||
|
if (name_parasite)
|
||||||
|
{
|
||||||
|
strncpy (info.description,
|
||||||
|
gimp_parasite_data (name_parasite),
|
||||||
|
MIN (sizeof (info.description),
|
||||||
|
gimp_parasite_data_size (name_parasite)));
|
||||||
|
info.description[sizeof (info.description) - 1] = '\0';
|
||||||
|
|
||||||
|
gimp_parasite_free (name_parasite);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gchar *name = g_path_get_basename (gimp_file_get_utf8_name (file));
|
||||||
|
|
||||||
|
if (g_str_has_suffix (name, ".gih"))
|
||||||
|
name[strlen (name) - 4] = '\0';
|
||||||
|
|
||||||
|
if (strlen (name))
|
||||||
|
{
|
||||||
|
strncpy (info.description, name, sizeof (info.description));
|
||||||
|
info.description[sizeof (info.description) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (name);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (gimp_image_get_layers (image_ID, &num_layers));
|
g_free (gimp_image_get_layers (image_ID, &num_layers));
|
||||||
|
|
||||||
|
gimp_pixpipe_params_init (&gihparams);
|
||||||
|
|
||||||
switch (run_mode)
|
switch (run_mode)
|
||||||
{
|
{
|
||||||
case GIMP_RUN_INTERACTIVE:
|
case GIMP_RUN_INTERACTIVE:
|
||||||
/* Possibly retrieve data */
|
|
||||||
gimp_get_data (SAVE_PROC, &info);
|
|
||||||
|
|
||||||
gimp_pixpipe_params_init (&gihparams);
|
|
||||||
|
|
||||||
/* Setup default values */
|
|
||||||
if (gihparams.rows < 1) gihparams.rows = 1;
|
|
||||||
if (gihparams.cols < 1) gihparams.cols = 1;
|
|
||||||
|
|
||||||
gihparams.ncells = (num_layers * gihparams.rows * gihparams.cols);
|
gihparams.ncells = (num_layers * gihparams.rows * gihparams.cols);
|
||||||
|
|
||||||
if (gihparams.cellwidth == 1 && gihparams.cellheight == 1)
|
gihparams.cellwidth = gimp_image_width (image_ID) / gihparams.cols;
|
||||||
{
|
gihparams.cellheight = gimp_image_height (image_ID) / gihparams.rows;
|
||||||
gihparams.cellwidth =
|
|
||||||
gimp_image_width (image_ID) / gihparams.cols;
|
|
||||||
gihparams.cellheight =
|
|
||||||
gimp_image_height (image_ID) / gihparams.rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
name_parasite =
|
pipe_parasite = gimp_image_get_parasite (orig_image_ID,
|
||||||
gimp_image_get_parasite (orig_image_ID,
|
"gimp-brush-pipe-parameters");
|
||||||
"gimp-brush-pipe-name");
|
|
||||||
if (name_parasite)
|
|
||||||
{
|
|
||||||
strncpy (info.description,
|
|
||||||
gimp_parasite_data (name_parasite),
|
|
||||||
MIN (MAXDESCLEN, gimp_parasite_data_size (name_parasite)));
|
|
||||||
info.description[MAXDESCLEN] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pipe_parasite =
|
|
||||||
gimp_image_get_parasite (orig_image_ID,
|
|
||||||
"gimp-brush-pipe-parameters");
|
|
||||||
if (pipe_parasite)
|
if (pipe_parasite)
|
||||||
gimp_pixpipe_params_parse (gimp_parasite_data (pipe_parasite),
|
{
|
||||||
&gihparams);
|
gimp_pixpipe_params_parse (gimp_parasite_data (pipe_parasite),
|
||||||
|
&gihparams);
|
||||||
|
gimp_parasite_free (pipe_parasite);
|
||||||
|
}
|
||||||
|
|
||||||
/* Force default rank to same as number of cells if there is just one dim */
|
/* Force default rank to same as number of cells if there is
|
||||||
|
* just one dim
|
||||||
|
*/
|
||||||
if (gihparams.dim == 1)
|
if (gihparams.dim == 1)
|
||||||
gihparams.rank[0] = gihparams.ncells;
|
gihparams.rank[0] = gihparams.ncells;
|
||||||
|
|
||||||
if (!gih_save_dialog (image_ID))
|
if (! gih_save_dialog (image_ID))
|
||||||
status = GIMP_PDB_CANCEL;
|
status = GIMP_PDB_CANCEL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -356,10 +372,9 @@ run (const gchar *name,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info.spacing = param[5].data.d_int32;
|
info.spacing = param[5].data.d_int32;
|
||||||
strncpy (info.description, param[6].data.d_string, MAXDESCLEN);
|
strncpy (info.description, param[6].data.d_string,
|
||||||
info.description[MAXDESCLEN] = 0;
|
sizeof (info.description));
|
||||||
|
info.description[sizeof (info.description) - 1] = '\0';
|
||||||
gimp_pixpipe_params_init (&gihparams);
|
|
||||||
|
|
||||||
gihparams.cellwidth = param[7].data.d_int32;
|
gihparams.cellwidth = param[7].data.d_int32;
|
||||||
gihparams.cellheight = param[8].data.d_int32;
|
gihparams.cellheight = param[8].data.d_int32;
|
||||||
|
@ -385,33 +400,21 @@ run (const gchar *name,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_RUN_WITH_LAST_VALS:
|
case GIMP_RUN_WITH_LAST_VALS:
|
||||||
gimp_get_data (SAVE_PROC, &info);
|
pipe_parasite = gimp_image_get_parasite (orig_image_ID,
|
||||||
|
"gimp-brush-pipe-parameters");
|
||||||
name_parasite =
|
|
||||||
gimp_image_get_parasite (orig_image_ID,
|
|
||||||
"gimp-brush-pipe-name");
|
|
||||||
if (name_parasite)
|
|
||||||
{
|
|
||||||
strncpy (info.description,
|
|
||||||
gimp_parasite_data (name_parasite),
|
|
||||||
MIN (MAXDESCLEN, gimp_parasite_data_size (name_parasite)));
|
|
||||||
info.description[MAXDESCLEN] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pipe_parasite =
|
|
||||||
gimp_image_get_parasite (orig_image_ID,
|
|
||||||
"gimp-brush-pipe-parameters");
|
|
||||||
gimp_pixpipe_params_init (&gihparams);
|
|
||||||
if (pipe_parasite)
|
if (pipe_parasite)
|
||||||
gimp_pixpipe_params_parse (gimp_parasite_data (pipe_parasite),
|
{
|
||||||
&gihparams);
|
gimp_pixpipe_params_parse (gimp_parasite_data (pipe_parasite),
|
||||||
|
&gihparams);
|
||||||
|
gimp_parasite_free (pipe_parasite);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == GIMP_PDB_SUCCESS)
|
if (status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
if (gih_save_image (g_file_new_for_uri (param[3].data.d_string),
|
if (gih_save_image (file, image_ID, orig_image_ID, drawable_ID,
|
||||||
image_ID, orig_image_ID, drawable_ID, &error))
|
&error))
|
||||||
{
|
{
|
||||||
gimp_set_data (SAVE_PROC, &info, sizeof (info));
|
gimp_set_data (SAVE_PROC, &info, sizeof (info));
|
||||||
}
|
}
|
||||||
|
@ -786,14 +789,13 @@ gih_load_image (GFile *file,
|
||||||
/* save routines */
|
/* save routines */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
size_adjustment_callback (GtkWidget *widget,
|
size_adjustment_callback (GtkWidget *widget,
|
||||||
gpointer data)
|
SizeAdjustmentData *adj)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
gint size;
|
gint size;
|
||||||
gint newn;
|
gint newn;
|
||||||
gchar buf[10];
|
gchar buf[10];
|
||||||
SizeAdjustmentData *adj = (SizeAdjustmentData *) data;
|
|
||||||
|
|
||||||
for (i = 0; i < adj->nguides; i++)
|
for (i = 0; i < adj->nguides; i++)
|
||||||
gimp_image_delete_guide (adj->image, adj->guides[i]);
|
gimp_image_delete_guide (adj->image, adj->guides[i]);
|
||||||
|
@ -825,7 +827,7 @@ size_adjustment_callback (GtkWidget *widget,
|
||||||
*(adj->value) * (i+1));
|
*(adj->value) * (i+1));
|
||||||
}
|
}
|
||||||
gimp_displays_flush ();
|
gimp_displays_flush ();
|
||||||
sprintf (buf, "%2d", newn);
|
g_snprintf (buf, sizeof (buf), "%2d", newn);
|
||||||
gtk_label_set_text (GTK_LABEL (adj->count_label), buf);
|
gtk_label_set_text (GTK_LABEL (adj->count_label), buf);
|
||||||
|
|
||||||
*(adj->count) = newn;
|
*(adj->count) = newn;
|
||||||
|
@ -847,9 +849,9 @@ entry_callback (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
if (data == info.description)
|
if (data == info.description)
|
||||||
{
|
{
|
||||||
strncpy (info.description,
|
strncpy (info.description, gtk_entry_get_text (GTK_ENTRY (widget)),
|
||||||
gtk_entry_get_text (GTK_ENTRY (widget)), MAXDESCLEN);
|
sizeof (info.description));
|
||||||
info.description[MAXDESCLEN] = 0;
|
info.description[sizeof (info.description) - 1] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,7 +867,7 @@ cb_callback (GtkWidget *widget,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dim_callback (GtkAdjustment *adjustment,
|
dim_callback (GtkAdjustment *adjustment,
|
||||||
SizeAdjustmentData *data)
|
SizeAdjustmentData *data)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
|
@ -910,28 +912,13 @@ gih_save_dialog (gint32 image_ID)
|
||||||
table, TRUE, TRUE, 0);
|
table, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
|
|
||||||
/*
|
|
||||||
* Spacing: __
|
|
||||||
*/
|
|
||||||
adjustment = (GtkAdjustment *) gtk_adjustment_new (info.spacing,
|
|
||||||
1, 1000, 1, 10, 0);
|
|
||||||
spinbutton = gtk_spin_button_new (adjustment, 1.0, 0);
|
|
||||||
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
|
||||||
_("Spacing (percent):"), 0.0, 0.5,
|
|
||||||
spinbutton, 1, TRUE);
|
|
||||||
|
|
||||||
g_signal_connect (adjustment, "value-changed",
|
|
||||||
G_CALLBACK (gimp_int_adjustment_update),
|
|
||||||
&info.spacing);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description: ___________
|
* Description: ___________
|
||||||
*/
|
*/
|
||||||
entry = gtk_entry_new ();
|
entry = gtk_entry_new ();
|
||||||
gtk_widget_set_size_request (entry, 200, -1);
|
gtk_widget_set_size_request (entry, 200, -1);
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry), info.description);
|
gtk_entry_set_text (GTK_ENTRY (entry), info.description);
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||||
_("Description:"), 0.0, 0.5,
|
_("Description:"), 0.0, 0.5,
|
||||||
entry, 1, FALSE);
|
entry, 1, FALSE);
|
||||||
|
|
||||||
|
@ -939,6 +926,21 @@ gih_save_dialog (gint32 image_ID)
|
||||||
G_CALLBACK (entry_callback),
|
G_CALLBACK (entry_callback),
|
||||||
info.description);
|
info.description);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Spacing: __
|
||||||
|
*/
|
||||||
|
adjustment = (GtkAdjustment *) gtk_adjustment_new (info.spacing,
|
||||||
|
1, 1000, 1, 10, 0);
|
||||||
|
spinbutton = gtk_spin_button_new (adjustment, 1.0, 0);
|
||||||
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
||||||
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||||
|
_("Spacing (percent):"), 0.0, 0.5,
|
||||||
|
spinbutton, 1, TRUE);
|
||||||
|
|
||||||
|
g_signal_connect (adjustment, "value-changed",
|
||||||
|
G_CALLBACK (gimp_int_adjustment_update),
|
||||||
|
&info.spacing);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cell size: __ x __ pixels
|
* Cell size: __ x __ pixels
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -180,11 +180,13 @@ run (const gchar *name,
|
||||||
}
|
}
|
||||||
else if (strcmp (name, SAVE_PROC) == 0)
|
else if (strcmp (name, SAVE_PROC) == 0)
|
||||||
{
|
{
|
||||||
|
GFile *file;
|
||||||
GimpParasite *parasite;
|
GimpParasite *parasite;
|
||||||
gint32 orig_image_ID;
|
gint32 orig_image_ID;
|
||||||
|
|
||||||
image_ID = param[1].data.d_int32;
|
image_ID = param[1].data.d_int32;
|
||||||
drawable_ID = param[2].data.d_int32;
|
drawable_ID = param[2].data.d_int32;
|
||||||
|
file = g_file_new_for_uri (param[3].data.d_string);
|
||||||
|
|
||||||
orig_image_ID = image_ID;
|
orig_image_ID = image_ID;
|
||||||
|
|
||||||
|
@ -208,29 +210,44 @@ run (const gchar *name,
|
||||||
|
|
||||||
/* Possibly retrieve data */
|
/* Possibly retrieve data */
|
||||||
gimp_get_data (SAVE_PROC, description);
|
gimp_get_data (SAVE_PROC, description);
|
||||||
|
|
||||||
|
parasite = gimp_image_get_parasite (orig_image_ID,
|
||||||
|
"gimp-pattern-name");
|
||||||
|
if (parasite)
|
||||||
|
{
|
||||||
|
strncpy (description,
|
||||||
|
gimp_parasite_data (parasite),
|
||||||
|
MIN (sizeof (description),
|
||||||
|
gimp_parasite_data_size (parasite)));
|
||||||
|
description[sizeof (description) - 1] = '\0';
|
||||||
|
|
||||||
|
gimp_parasite_free (parasite);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gchar *name = g_path_get_basename (gimp_file_get_utf8_name (file));
|
||||||
|
|
||||||
|
if (g_str_has_suffix (name, ".pat"))
|
||||||
|
name[strlen (name) - 4] = '\0';
|
||||||
|
|
||||||
|
if (strlen (name))
|
||||||
|
{
|
||||||
|
strncpy (description, name, sizeof (description));
|
||||||
|
description[sizeof (description) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (name);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
parasite = gimp_image_get_parasite (orig_image_ID, "gimp-pattern-name");
|
|
||||||
if (parasite)
|
|
||||||
{
|
|
||||||
gchar *name = g_strndup (gimp_parasite_data (parasite),
|
|
||||||
gimp_parasite_data_size (parasite));
|
|
||||||
gimp_parasite_free (parasite);
|
|
||||||
|
|
||||||
strncpy (description, name, sizeof (description));
|
|
||||||
description[sizeof (description) - 1] = '\0';
|
|
||||||
|
|
||||||
g_free (name);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (run_mode)
|
switch (run_mode)
|
||||||
{
|
{
|
||||||
case GIMP_RUN_INTERACTIVE:
|
case GIMP_RUN_INTERACTIVE:
|
||||||
if (!save_dialog ())
|
if (! save_dialog ())
|
||||||
status = GIMP_PDB_CANCEL;
|
status = GIMP_PDB_CANCEL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -253,8 +270,7 @@ run (const gchar *name,
|
||||||
|
|
||||||
if (status == GIMP_PDB_SUCCESS)
|
if (status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
if (save_image (g_file_new_for_uri (param[3].data.d_string),
|
if (save_image (file, image_ID, drawable_ID, &error))
|
||||||
image_ID, drawable_ID, &error))
|
|
||||||
{
|
{
|
||||||
gimp_set_data (SAVE_PROC, description, sizeof (description));
|
gimp_set_data (SAVE_PROC, description, sizeof (description));
|
||||||
}
|
}
|
||||||
|
@ -599,9 +615,9 @@ save_dialog (void)
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
|
|
||||||
entry = gtk_entry_new ();
|
entry = gtk_entry_new ();
|
||||||
gtk_widget_set_size_request (entry, 200, -1);
|
gtk_entry_set_width_chars (GTK_ENTRY (entry), 20);
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry), description);
|
|
||||||
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (entry), description);
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||||
_("Description:"), 1.0, 0.5,
|
_("Description:"), 1.0, 0.5,
|
||||||
entry, 1, FALSE);
|
entry, 1, FALSE);
|
||||||
|
|
Loading…
Reference in New Issue