mirror of https://github.com/GNOME/gimp.git
added g_strcompress from glib-1.3
2000-08-01 Sven Neumann <sven@gimp.org> * libgimp/gimputils.[ch]: added g_strcompress from glib-1.3 * plug-ins/gdyntext/gdyntextutil.[ch]: removed since it duplicated gimp_strescape and the newly added gimp_strcompress. * plug-ins/gdyntext/Makefile.am * plug-ins/gdyntext/gdyntext.[ch] * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/gdyntext/gdyntextcompat.c: use the new functions and got rid of some gimp_run_procedure calls since we now have proper wrappers in libgimp. * plug-ins/common/autocrop.c * plug-ins/common/gif.c * plug-ins/common/gifload.c * plug-ins/common/guillotine.c * plug-ins/common/mail.c * plug-ins/common/screenshot.c * plug-ins/common/tile.c * plug-ins/common/zealouscrop.c * plug-ins/gflare/gflare.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/pagecurl/pagecurl.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu.c: replaced gimp_run_procedure calls with functions from libgimp that wrap the PDB calls. Sorry, all this is untested but I will leave tomorrow and hope to get some hacking done at Mitch's place. So I wanted that stuff to be in CVS. There are good chances that it works...
This commit is contained in:
parent
7e304e734f
commit
261e3c6801
33
ChangeLog
33
ChangeLog
|
@ -1,3 +1,36 @@
|
|||
2000-08-01 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimp/gimputils.[ch]: added g_strcompress from glib-1.3
|
||||
|
||||
* plug-ins/gdyntext/gdyntextutil.[ch]: removed since it duplicated
|
||||
gimp_strescape and the newly added gimp_strcompress.
|
||||
|
||||
* plug-ins/gdyntext/Makefile.am
|
||||
* plug-ins/gdyntext/gdyntext.[ch]
|
||||
* plug-ins/gdyntext/gdyntext_ui.c
|
||||
* plug-ins/gdyntext/gdyntextcompat.c: use the new functions and
|
||||
got rid of some gimp_run_procedure calls since we now have proper
|
||||
wrappers in libgimp.
|
||||
|
||||
* plug-ins/common/autocrop.c
|
||||
* plug-ins/common/gif.c
|
||||
* plug-ins/common/gifload.c
|
||||
* plug-ins/common/guillotine.c
|
||||
* plug-ins/common/mail.c
|
||||
* plug-ins/common/screenshot.c
|
||||
* plug-ins/common/tile.c
|
||||
* plug-ins/common/zealouscrop.c
|
||||
* plug-ins/gflare/gflare.c
|
||||
* plug-ins/gimpressionist/gimpressionist.c
|
||||
* plug-ins/pagecurl/pagecurl.c
|
||||
* plug-ins/script-fu/script-fu-scripts.c
|
||||
* plug-ins/script-fu/script-fu.c: replaced gimp_run_procedure
|
||||
calls with functions from libgimp that wrap the PDB calls.
|
||||
|
||||
Sorry, all this is untested but I will leave tomorrow and hope to
|
||||
get some hacking done at Mitch's place. So I wanted that stuff to
|
||||
be in CVS. There are good chances that it works...
|
||||
|
||||
2000-07-31 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* plug-ins/common/gz.c (load_image,save_image): Change Win32
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "gimputils.h"
|
||||
|
||||
/**
|
||||
* gimp_strescape:
|
||||
* @source: A string to escape special characters in.
|
||||
|
@ -121,3 +123,77 @@ gimp_strescape (const gchar *source,
|
|||
return dest;
|
||||
}
|
||||
#endif /* GLIB <= 1.3 */
|
||||
|
||||
/**
|
||||
* gimp_strcompress:
|
||||
* @source: A string to that has special characters escaped.
|
||||
*
|
||||
* Does the opposite of g_strescape(), that is it converts escaped
|
||||
* characters back to their unescaped form.
|
||||
*
|
||||
* Escaped characters are either one of the sequences \b, \f, \n, \r,
|
||||
* \t, \\, \", or a three-digit octal escape sequence \nnn.
|
||||
*
|
||||
* If glib > 1.3 is installed this function is identical to
|
||||
* g_strcompress(). For systems using glib-1.2 this function provides
|
||||
* the functionality from glib-1.3.
|
||||
*
|
||||
* Returns: A newly allocated copy of the string, with all escaped
|
||||
* special characters converted to their unescaped form.
|
||||
*/
|
||||
#if !(defined (GLIB_CHECK_VERSION) && GLIB_CHECK_VERSION (1,3,1))
|
||||
gchar*
|
||||
gimp_strcompress (const gchar *source)
|
||||
{
|
||||
const gchar *p = source, *octal;
|
||||
gchar *dest = g_malloc (strlen (source) + 1);
|
||||
gchar *q = dest;
|
||||
|
||||
while (*p)
|
||||
{
|
||||
if (*p == '\\')
|
||||
{
|
||||
p++;
|
||||
switch (*p)
|
||||
{
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7':
|
||||
*q = 0;
|
||||
octal = p;
|
||||
while ((p < octal + 3) && (*p >= '0') && (*p <= '7'))
|
||||
{
|
||||
*q = (*q * 8) + (*p - '0');
|
||||
p++;
|
||||
}
|
||||
q++;
|
||||
p--;
|
||||
break;
|
||||
case 'b':
|
||||
*q++ = '\b';
|
||||
break;
|
||||
case 'f':
|
||||
*q++ = '\f';
|
||||
break;
|
||||
case 'n':
|
||||
*q++ = '\n';
|
||||
break;
|
||||
case 'r':
|
||||
*q++ = '\r';
|
||||
break;
|
||||
case 't':
|
||||
*q++ = '\t';
|
||||
break;
|
||||
default: /* Also handles \" and \\ */
|
||||
*q++ = *p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
*q++ = *p;
|
||||
p++;
|
||||
}
|
||||
*q = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
#endif /* GLIB <= 1.3 */
|
||||
|
|
|
@ -32,16 +32,18 @@ extern "C" {
|
|||
|
||||
|
||||
/*
|
||||
* Right now all you find here is the g_strescape function out of
|
||||
* glib-1.3. We need its functionality, but don't want to rely on
|
||||
* that version being installed
|
||||
* Right now all you find here are the g_strescape and g_strcompress
|
||||
* function out of glib-1.3. We need their functionality, but don't
|
||||
* want to rely on that version being installed
|
||||
*/
|
||||
|
||||
#if (defined (GLIB_CHECK_VERSION) && GLIB_CHECK_VERSION (1,3,1))
|
||||
#define gimp_strescape(string, exceptions) g_strescape (string, exceptions)
|
||||
#define gimp_strcompress(string) g_strcompress (string)
|
||||
#else
|
||||
gchar* gimp_strescape (const gchar *source,
|
||||
const gchar *exceptions);
|
||||
gchar * gimp_strescape (const gchar *source,
|
||||
const gchar *exceptions);
|
||||
gchar * gimp_strcompress (const gchar *source);
|
||||
#endif /* GLIB <= 1.3 */
|
||||
|
||||
|
||||
|
@ -50,3 +52,6 @@ gchar* gimp_strescape (const gchar *source,
|
|||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GIMPUTILS_H__ */
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "gimputils.h"
|
||||
|
||||
/**
|
||||
* gimp_strescape:
|
||||
* @source: A string to escape special characters in.
|
||||
|
@ -121,3 +123,77 @@ gimp_strescape (const gchar *source,
|
|||
return dest;
|
||||
}
|
||||
#endif /* GLIB <= 1.3 */
|
||||
|
||||
/**
|
||||
* gimp_strcompress:
|
||||
* @source: A string to that has special characters escaped.
|
||||
*
|
||||
* Does the opposite of g_strescape(), that is it converts escaped
|
||||
* characters back to their unescaped form.
|
||||
*
|
||||
* Escaped characters are either one of the sequences \b, \f, \n, \r,
|
||||
* \t, \\, \", or a three-digit octal escape sequence \nnn.
|
||||
*
|
||||
* If glib > 1.3 is installed this function is identical to
|
||||
* g_strcompress(). For systems using glib-1.2 this function provides
|
||||
* the functionality from glib-1.3.
|
||||
*
|
||||
* Returns: A newly allocated copy of the string, with all escaped
|
||||
* special characters converted to their unescaped form.
|
||||
*/
|
||||
#if !(defined (GLIB_CHECK_VERSION) && GLIB_CHECK_VERSION (1,3,1))
|
||||
gchar*
|
||||
gimp_strcompress (const gchar *source)
|
||||
{
|
||||
const gchar *p = source, *octal;
|
||||
gchar *dest = g_malloc (strlen (source) + 1);
|
||||
gchar *q = dest;
|
||||
|
||||
while (*p)
|
||||
{
|
||||
if (*p == '\\')
|
||||
{
|
||||
p++;
|
||||
switch (*p)
|
||||
{
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7':
|
||||
*q = 0;
|
||||
octal = p;
|
||||
while ((p < octal + 3) && (*p >= '0') && (*p <= '7'))
|
||||
{
|
||||
*q = (*q * 8) + (*p - '0');
|
||||
p++;
|
||||
}
|
||||
q++;
|
||||
p--;
|
||||
break;
|
||||
case 'b':
|
||||
*q++ = '\b';
|
||||
break;
|
||||
case 'f':
|
||||
*q++ = '\f';
|
||||
break;
|
||||
case 'n':
|
||||
*q++ = '\n';
|
||||
break;
|
||||
case 'r':
|
||||
*q++ = '\r';
|
||||
break;
|
||||
case 't':
|
||||
*q++ = '\t';
|
||||
break;
|
||||
default: /* Also handles \" and \\ */
|
||||
*q++ = *p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
*q++ = *p;
|
||||
p++;
|
||||
}
|
||||
*q = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
#endif /* GLIB <= 1.3 */
|
||||
|
|
|
@ -32,16 +32,18 @@ extern "C" {
|
|||
|
||||
|
||||
/*
|
||||
* Right now all you find here is the g_strescape function out of
|
||||
* glib-1.3. We need its functionality, but don't want to rely on
|
||||
* that version being installed
|
||||
* Right now all you find here are the g_strescape and g_strcompress
|
||||
* function out of glib-1.3. We need their functionality, but don't
|
||||
* want to rely on that version being installed
|
||||
*/
|
||||
|
||||
#if (defined (GLIB_CHECK_VERSION) && GLIB_CHECK_VERSION (1,3,1))
|
||||
#define gimp_strescape(string, exceptions) g_strescape (string, exceptions)
|
||||
#define gimp_strcompress(string) g_strcompress (string)
|
||||
#else
|
||||
gchar* gimp_strescape (const gchar *source,
|
||||
const gchar *exceptions);
|
||||
gchar * gimp_strescape (const gchar *source,
|
||||
const gchar *exceptions);
|
||||
gchar * gimp_strcompress (const gchar *source);
|
||||
#endif /* GLIB <= 1.3 */
|
||||
|
||||
|
||||
|
@ -50,3 +52,6 @@ gchar* gimp_strescape (const gchar *source,
|
|||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GIMPUTILS_H__ */
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -141,7 +141,6 @@ doit (GDrawable *drawable,
|
|||
gint32 nx, ny, nw, nh;
|
||||
guchar *buffer;
|
||||
guchar color[4] = {0, 0, 0, 0};
|
||||
gint nreturn_vals;
|
||||
|
||||
width = drawable->width;
|
||||
height = drawable->height;
|
||||
|
@ -227,16 +226,9 @@ doit (GDrawable *drawable,
|
|||
g_free (buffer);
|
||||
|
||||
gimp_drawable_detach (drawable);
|
||||
|
||||
if (nw != width || nh != height)
|
||||
{
|
||||
gimp_run_procedure ("gimp_crop", &nreturn_vals,
|
||||
PARAM_IMAGE, image_id,
|
||||
PARAM_INT32, nw,
|
||||
PARAM_INT32, nh,
|
||||
PARAM_INT32, nx,
|
||||
PARAM_INT32, ny,
|
||||
PARAM_END);
|
||||
}
|
||||
gimp_crop (image_id, nw, nh, nx, ny);
|
||||
}
|
||||
|
||||
static gint
|
||||
|
|
|
@ -779,7 +779,6 @@ boundscheck (gint32 image_ID)
|
|||
GDrawable *drawable;
|
||||
gint32 *layers;
|
||||
gint nlayers;
|
||||
gint nreturn_vals;
|
||||
gint i;
|
||||
gint offset_x, offset_y;
|
||||
|
||||
|
@ -809,13 +808,9 @@ boundscheck (gint32 image_ID)
|
|||
* the user and they said yes. */
|
||||
if ((run_mode == RUN_NONINTERACTIVE) || badbounds_dialog ())
|
||||
{
|
||||
gimp_run_procedure("gimp_crop", &nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_INT32, gimp_image_width(image_ID),
|
||||
PARAM_INT32, gimp_image_height(image_ID),
|
||||
PARAM_INT32, 0,
|
||||
PARAM_INT32, 0,
|
||||
PARAM_END);
|
||||
gimp_crop (image_ID,
|
||||
gimp_image_width (image_ID), gimp_image_height (image_ID),
|
||||
0, 0);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -812,7 +812,6 @@ ReadImage (FILE *fd,
|
|||
gchar *framename;
|
||||
gchar *framename_ptr;
|
||||
gboolean alpha_frame = FALSE;
|
||||
int nreturn_vals;
|
||||
static int previous_disposal;
|
||||
|
||||
|
||||
|
@ -889,9 +888,8 @@ ReadImage (FILE *fd,
|
|||
#ifdef GIFDEBUG
|
||||
g_print ("GIF: Promoting image to RGB...\n");
|
||||
#endif
|
||||
gimp_run_procedure("gimp_convert_rgb", &nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_END);
|
||||
gimp_convert_rgb (image_ID);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -137,8 +136,6 @@ guillotine (gint32 image_ID)
|
|||
gint* vguides;
|
||||
gchar filename[1024];
|
||||
gint i,x,y;
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
num_vguides = 0;
|
||||
num_hguides = 0;
|
||||
|
@ -166,12 +163,12 @@ guillotine (gint32 image_ID)
|
|||
|
||||
if (num_vguides+num_hguides)
|
||||
{
|
||||
printf("Yay... found %d horizontal guides and %d vertical guides.\n",
|
||||
num_hguides, num_vguides);
|
||||
g_print ("Yay... found %d horizontal guides and %d vertical guides.\n",
|
||||
num_hguides, num_vguides);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Poopy, no guides.\n");
|
||||
g_print ("Poopy, no guides.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -197,7 +194,7 @@ guillotine (gint32 image_ID)
|
|||
hguides[num_hguides++] =
|
||||
gimp_image_get_guide_position(image_ID, guide_num); break;
|
||||
default:
|
||||
printf("Aie! Aie! Aie! Too!\n");
|
||||
g_print ("Aie! Aie! Aie! Too!\n");
|
||||
gimp_quit();
|
||||
}
|
||||
guide_num = gimp_image_find_next_guide(image_ID, guide_num);
|
||||
|
@ -211,11 +208,11 @@ guillotine (gint32 image_ID)
|
|||
qsort(vguides, num_vguides, sizeof(gint), &unexciting);
|
||||
|
||||
for (i=0;i<num_vguides;i++)
|
||||
printf("%d,",vguides[i]);
|
||||
printf("\n");
|
||||
g_print ("%d,",vguides[i]);
|
||||
g_print ("\n");
|
||||
for (i=0;i<num_hguides;i++)
|
||||
printf("%d,",hguides[i]);
|
||||
printf("\n");
|
||||
g_print ("%d,",hguides[i]);
|
||||
g_print ("\n");
|
||||
|
||||
|
||||
/* Do the actual dup'ing and cropping... this isn't a too naive a
|
||||
|
@ -226,16 +223,11 @@ guillotine (gint32 image_ID)
|
|||
{
|
||||
gint32 new_image;
|
||||
|
||||
return_vals =
|
||||
gimp_run_procedure("gimp_channel_ops_duplicate", &nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_END);
|
||||
new_image = gimp_channel_ops_duplicate (image_ID);
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
new_image = return_vals[1].data.d_int32;
|
||||
else
|
||||
if (new_image == -1)
|
||||
{
|
||||
printf("Aie3!\n");
|
||||
g_print ("Aie3!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -249,21 +241,17 @@ guillotine (gint32 image_ID)
|
|||
/* vguides[x], hguides[y],x, y); */
|
||||
|
||||
|
||||
gimp_run_procedure("gimp_crop", &nreturn_vals,
|
||||
PARAM_IMAGE, new_image,
|
||||
PARAM_INT32, (vguides[x+1]-vguides[x]),
|
||||
PARAM_INT32, (hguides[y+1]-hguides[y]),
|
||||
PARAM_INT32, vguides[x],
|
||||
PARAM_INT32, hguides[y],
|
||||
PARAM_END);
|
||||
gimp_crop (new_image,
|
||||
vguides[x+1] - vguides[x], hguides[y+1] - hguides[y],
|
||||
vguides[x], hguides[y]);
|
||||
|
||||
/* gimp_undo_push_group_end (new_image); */
|
||||
|
||||
gimp_image_undo_enable (new_image);
|
||||
|
||||
/* show the rough coordinates of the image in the title */
|
||||
sprintf(filename, "%s-(%i,%i)", gimp_image_get_filename (image_ID),
|
||||
x, y);
|
||||
g_snprintf (filename, sizeof (filename), "%s-(%i,%i)", gimp_image_get_filename (image_ID),
|
||||
x, y);
|
||||
gimp_image_set_filename(new_image, filename);
|
||||
|
||||
gimp_display_new (new_image);
|
||||
|
|
|
@ -292,9 +292,7 @@ run (gchar *name,
|
|||
run_mode);
|
||||
|
||||
if (status == STATUS_SUCCESS)
|
||||
{
|
||||
gimp_set_data ("plug_in_mail_image", &mail_info, sizeof(m_info));
|
||||
}
|
||||
gimp_set_data ("plug_in_mail_image", &mail_info, sizeof(m_info));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -467,24 +465,19 @@ save_dialog (void)
|
|||
GtkWidget *text;
|
||||
GtkWidget *vscrollbar;
|
||||
|
||||
gchar buffer[BUFFER_SIZE];
|
||||
gint nreturn_vals;
|
||||
GParam *return_vals;
|
||||
gchar buffer[BUFFER_SIZE];
|
||||
gchar *gump_from;
|
||||
|
||||
gimp_ui_init ("mail", FALSE);
|
||||
|
||||
/* check gimprc for a preffered "From:" address */
|
||||
return_vals = gimp_run_procedure ("gimp_gimprc_query",
|
||||
&nreturn_vals,
|
||||
PARAM_STRING, "gump-from",
|
||||
PARAM_END);
|
||||
gump_from = gimp_gimprc_query ("gump-from");
|
||||
|
||||
/* check to see if we actually got a value */
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS &&
|
||||
return_vals[1].data.d_string != NULL)
|
||||
strncpy (mail_info.from, return_vals[1].data.d_string , BUFFER_SIZE);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
if (gump_from)
|
||||
{
|
||||
strncpy (mail_info.from, gump_from, BUFFER_SIZE);
|
||||
g_free (gump_from);
|
||||
}
|
||||
|
||||
dlg = gimp_dialog_new (_("Send to Mail"), "mail",
|
||||
gimp_standard_help_func, "filters/mail.html",
|
||||
|
|
|
@ -97,7 +97,6 @@ static void shoot_ok_callback (GtkWidget *widget,
|
|||
gpointer data);
|
||||
static void shoot_toggle_update (GtkWidget *widget,
|
||||
gpointer radio_button);
|
||||
static void shoot_display_image (gint32 image);
|
||||
static void shoot_delay (gint32 delay);
|
||||
static gint shoot_delay_callback (gpointer data);
|
||||
|
||||
|
@ -231,7 +230,7 @@ run (gchar *name,
|
|||
/* Store variable states for next run */
|
||||
gimp_set_data (PLUG_IN_NAME, &shootvals, sizeof (ScreenShotValues));
|
||||
/* display the image */
|
||||
shoot_display_image (image_ID);
|
||||
gimp_display_new (image_ID);
|
||||
}
|
||||
/* set return values */
|
||||
*nreturn_vals = 2;
|
||||
|
@ -334,21 +333,7 @@ shoot (void)
|
|||
if (image_ID != -1)
|
||||
{
|
||||
/* figure out the monitor resolution and set the image to it */
|
||||
params = gimp_run_procedure ("gimp_get_monitor_resolution",
|
||||
&retvals,
|
||||
PARAM_END);
|
||||
if (params[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
xres = params[1].data.d_float;
|
||||
yres = params[2].data.d_float;
|
||||
}
|
||||
else
|
||||
{
|
||||
xres = 72.0;
|
||||
yres = 72.0;
|
||||
}
|
||||
gimp_destroy_params (params, retvals);
|
||||
|
||||
gimp_get_monitor_resolution (&xres, &yres);
|
||||
gimp_image_set_resolution (image_ID, xres, yres);
|
||||
|
||||
/* unset the image filename */
|
||||
|
@ -557,17 +542,3 @@ shoot_delay_callback (gpointer data)
|
|||
return (*seconds_left);
|
||||
}
|
||||
|
||||
/* Display function */
|
||||
|
||||
void
|
||||
shoot_display_image (gint32 image)
|
||||
{
|
||||
GParam *params;
|
||||
gint retvals;
|
||||
|
||||
params = gimp_run_procedure ("gimp_display_new",
|
||||
&retvals,
|
||||
PARAM_IMAGE, image,
|
||||
PARAM_END);
|
||||
gimp_destroy_params (params, retvals);
|
||||
}
|
||||
|
|
|
@ -237,7 +237,6 @@ tile (gint32 image_id,
|
|||
gint width, height;
|
||||
gint i, j, k;
|
||||
gint progress, max_progress;
|
||||
gint nreturn_vals;
|
||||
gpointer pr;
|
||||
|
||||
/* initialize */
|
||||
|
@ -280,22 +279,10 @@ tile (gint32 image_id,
|
|||
{
|
||||
gimp_undo_push_group_start (image_id);
|
||||
|
||||
gimp_run_procedure ("gimp_image_resize", &nreturn_vals,
|
||||
PARAM_IMAGE, image_id,
|
||||
PARAM_INT32, tvals.new_width,
|
||||
PARAM_INT32, tvals.new_height,
|
||||
PARAM_INT32, 0,
|
||||
PARAM_INT32, 0,
|
||||
PARAM_END);
|
||||
gimp_image_resize (image_id, tvals.new_width, tvals.new_height, 0, 0);
|
||||
|
||||
if (gimp_drawable_is_layer (drawable_id))
|
||||
gimp_run_procedure ("gimp_layer_resize", &nreturn_vals,
|
||||
PARAM_LAYER, drawable_id,
|
||||
PARAM_INT32, tvals.new_width,
|
||||
PARAM_INT32, tvals.new_height,
|
||||
PARAM_INT32, 0,
|
||||
PARAM_INT32, 0,
|
||||
PARAM_END);
|
||||
gimp_layer_resize (drawable_id, tvals.new_width, tvals.new_height, 0, 0);
|
||||
|
||||
/* Get the specified drawable */
|
||||
drawable = gimp_drawable_get (drawable_id);
|
||||
|
@ -356,9 +343,7 @@ tile (gint32 image_id,
|
|||
gimp_drawable_detach (new_layer);
|
||||
}
|
||||
else
|
||||
gimp_run_procedure ("gimp_undo_push_group_end", &nreturn_vals,
|
||||
PARAM_IMAGE, image_id,
|
||||
PARAM_END);
|
||||
gimp_undo_push_group_end (image_id);
|
||||
|
||||
gimp_drawable_flush (drawable);
|
||||
gimp_drawable_detach (drawable);
|
||||
|
|
|
@ -146,7 +146,6 @@ do_zcrop (GDrawable *drawable,
|
|||
GPixelRgn srcPR, destPR;
|
||||
gint width, height, x, y;
|
||||
guchar *buffer;
|
||||
gint nreturn_vals;
|
||||
gint8 *killrows;
|
||||
gint8 *killcols;
|
||||
gint32 livingrows, livingcols, destrow, destcol;
|
||||
|
@ -263,25 +262,11 @@ do_zcrop (GDrawable *drawable,
|
|||
g_free(killcols);
|
||||
|
||||
gimp_progress_update(1.00);
|
||||
|
||||
gimp_run_procedure ("gimp_undo_push_group_start", &nreturn_vals,
|
||||
PARAM_IMAGE, image_id,
|
||||
PARAM_END);
|
||||
|
||||
gimp_undo_push_group_start (image_id);
|
||||
gimp_drawable_flush (drawable);
|
||||
gimp_drawable_merge_shadow (drawable->id, TRUE);
|
||||
|
||||
gimp_run_procedure("gimp_crop", &nreturn_vals,
|
||||
PARAM_IMAGE, image_id,
|
||||
PARAM_INT32, (gint32)livingcols,
|
||||
PARAM_INT32, (gint32)livingrows,
|
||||
PARAM_INT32, 0,
|
||||
PARAM_INT32, 0,
|
||||
PARAM_END);
|
||||
|
||||
gimp_run_procedure ("gimp_undo_push_group_end", &nreturn_vals,
|
||||
PARAM_IMAGE, image_id,
|
||||
PARAM_END);
|
||||
gimp_crop (image_id, livingcols, livingrows, 0, 0);
|
||||
gimp_undo_push_group_end (image_id);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,8 +41,6 @@ gdyntext_SOURCES = \
|
|||
gdyntext.h \
|
||||
gdyntextcompat.c \
|
||||
gdyntextcompat.h \
|
||||
gdyntextutil.c \
|
||||
gdyntextutil.h \
|
||||
gdyntext_ui.c \
|
||||
gdyntext_ui.h \
|
||||
message_window.c \
|
||||
|
|
|
@ -37,11 +37,15 @@
|
|||
|
||||
|
||||
|
||||
static void gdt_query(void);
|
||||
static void gdt_run(char *name, int nparams, GParam *param, int *nreturn_vals, GParam **return_vals);
|
||||
static void gdt_query (void);
|
||||
static void gdt_run (char *name,
|
||||
int nparams,
|
||||
GimpParam *param,
|
||||
int *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
|
||||
|
||||
GPlugInInfo PLUG_IN_INFO =
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -62,7 +66,7 @@ static void gdt_query(void)
|
|||
INIT_I18N_UI();
|
||||
|
||||
{
|
||||
static GParamDef gdt_args[] = {
|
||||
static GimpParamDef gdt_args[] = {
|
||||
/* standard params */
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_IMAGE, "image", "Input image" },
|
||||
|
@ -77,7 +81,7 @@ static void gdt_query(void)
|
|||
{ PARAM_INT32, "layer_alignment", "Layer alignment { NONE = 0, BOTTOM_LEFT = 1, BOTTOM_CENTER = 2, BOTTOM_RIGHT = 3, MIDDLE_LEFT = 4, CENTER = 5, MIDDLE_RIGHT = 6, TOP_LEFT = 7, TOP_CENTER = 8, TOP_RIGHT = 9 }" },
|
||||
{ PARAM_STRING, "fontname", "The fontname (conforming to the X Logical Font Description Conventions)" },
|
||||
};
|
||||
static GParamDef gdt_rets[] = {
|
||||
static GimpParamDef gdt_rets[] = {
|
||||
{ PARAM_LAYER, "layer", "The text layer" },
|
||||
};
|
||||
static int ngdt_args = sizeof(gdt_args) / sizeof(gdt_args[0]);
|
||||
|
@ -97,11 +101,11 @@ static void gdt_query(void)
|
|||
}
|
||||
|
||||
|
||||
static void gdt_run(char *name, int nparams, GParam *param, int *nreturn_vals,
|
||||
GParam **return_vals)
|
||||
static void gdt_run(char *name, int nparams, GimpParam *param, int *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
{
|
||||
static GParam values[2];
|
||||
GRunModeType run_mode;
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
GdtVals oldvals;
|
||||
|
||||
|
||||
|
@ -262,7 +266,7 @@ void gdt_load(GdtVals *data)
|
|||
strncpy(data->xlfd, params[XLFD], sizeof(data->xlfd));
|
||||
strncpy(data->text, params[TEXT], sizeof(data->text));
|
||||
{
|
||||
gchar *text = strunescape(data->text);
|
||||
gchar *text = gimp_strcompress(data->text);
|
||||
g_snprintf(data->text, sizeof(data->text), "%s", text);
|
||||
g_free(text);
|
||||
}
|
||||
|
@ -276,7 +280,7 @@ void gdt_save(GdtVals *data)
|
|||
gchar *lname, *text;
|
||||
GimpParasite *parasite;
|
||||
|
||||
text = strescape(data->text);
|
||||
text = gimp_strescape (data->text, NULL);
|
||||
lname = g_strdup_printf(GDYNTEXT_MAGIC
|
||||
"{%s}{%d}{%d}{%d}{%d}{%06X}{%d}{%s}",
|
||||
text,
|
||||
|
@ -329,24 +333,18 @@ void gdt_render_text_p(GdtVals *data, gboolean show_progress)
|
|||
gimp_progress_init (_("GIMP Dynamic Text"));
|
||||
|
||||
/* undo start */
|
||||
ret_vals = gimp_run_procedure("gimp_undo_push_group_start", &nret_vals,
|
||||
PARAM_IMAGE, gdtvals.image_id, PARAM_END);
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
gimp_undo_push_group_start (gdtvals.image_id);
|
||||
|
||||
/* save and remove current selection */
|
||||
ret_vals = gimp_run_procedure("gimp_selection_is_empty", &nret_vals,
|
||||
PARAM_IMAGE, data->image_id, PARAM_END);
|
||||
selection_empty = ret_vals[1].data.d_int32;
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
selection_empty = gimp_selection_is_empty (data->image_id);
|
||||
if (selection_empty == FALSE) {
|
||||
/* there is an active selection to save */
|
||||
ret_vals = gimp_run_procedure("gimp_selection_save", &nret_vals,
|
||||
PARAM_IMAGE, data->image_id, PARAM_END);
|
||||
selection_channel = ret_vals[1].data.d_int32;
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
ret_vals = gimp_run_procedure("gimp_selection_none", &nret_vals,
|
||||
PARAM_IMAGE, data->image_id, PARAM_END);
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
|
||||
gimp_selection_none (data->image_id);
|
||||
}
|
||||
|
||||
text_xlfd = g_strsplit(data->xlfd, "-", -1);
|
||||
|
@ -362,22 +360,24 @@ void gdt_render_text_p(GdtVals *data, gboolean show_progress)
|
|||
g_strfreev(text_xlfd);
|
||||
|
||||
/* retrieve space char width */
|
||||
ret_vals = gimp_run_procedure("gimp_text_get_extents_fontname", &nret_vals,
|
||||
PARAM_STRING, "A A",
|
||||
PARAM_FLOAT, font_size,
|
||||
PARAM_INT32, font_size_type,
|
||||
PARAM_STRING, data->xlfd,
|
||||
PARAM_END);
|
||||
space_width = ret_vals[1].data.d_int32;
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
ret_vals = gimp_run_procedure("gimp_text_get_extents_fontname", &nret_vals,
|
||||
PARAM_STRING, "AA",
|
||||
PARAM_FLOAT, font_size,
|
||||
PARAM_INT32, font_size_type,
|
||||
PARAM_STRING, data->xlfd,
|
||||
PARAM_END);
|
||||
space_width -= ret_vals[1].data.d_int32;
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
gimp_text_get_extents_fontname ("AA",
|
||||
font_size,
|
||||
font_size_type,
|
||||
data->xlfd,
|
||||
&text_width,
|
||||
&text_height,
|
||||
&text_ascent,
|
||||
&text_descent);
|
||||
space_width = text_width;
|
||||
gimp_text_get_extents_fontname ("AA",
|
||||
font_size,
|
||||
font_size_type,
|
||||
data->xlfd,
|
||||
&text_width,
|
||||
&text_height,
|
||||
&text_ascent,
|
||||
&text_descent);
|
||||
space_width -= text_width;
|
||||
#ifdef DEBUG
|
||||
printf("GDT: space width = %d\n", space_width);
|
||||
#endif
|
||||
|
@ -388,20 +388,17 @@ void gdt_render_text_p(GdtVals *data, gboolean show_progress)
|
|||
text_lines_w = g_new0(gint32, i);
|
||||
layer_width = layer_height = 0;
|
||||
for (i = 0; text_lines[i]; i++) {
|
||||
ret_vals = gimp_run_procedure("gimp_text_get_extents_fontname", &nret_vals,
|
||||
PARAM_STRING, strlen(text_lines[i]) > 0 ? text_lines[i] : " ",
|
||||
PARAM_FLOAT, font_size,
|
||||
PARAM_INT32, font_size_type,
|
||||
PARAM_STRING, data->xlfd,
|
||||
PARAM_END);
|
||||
text_width = ret_vals[1].data.d_int32;
|
||||
text_height = ret_vals[2].data.d_int32;
|
||||
text_ascent = ret_vals[3].data.d_int32;
|
||||
text_descent = ret_vals[4].data.d_int32;
|
||||
gimp_text_get_extents_fontname (strlen(text_lines[i]) > 0 ? text_lines[i] : " ",
|
||||
font_size,
|
||||
font_size_type,
|
||||
data->xlfd,
|
||||
&text_width,
|
||||
&text_height,
|
||||
&text_ascent,
|
||||
&text_descent);
|
||||
#ifdef DEBUG
|
||||
printf("GDT: %4dx%4d A:%3d D:%3d [%s]\n", text_width, text_height, text_ascent, text_descent, text_lines[i]);
|
||||
#endif
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
text_lines_w[i] = text_width;
|
||||
if (layer_width < text_width)
|
||||
layer_width = text_width;
|
||||
|
@ -427,28 +424,20 @@ void gdt_render_text_p(GdtVals *data, gboolean show_progress)
|
|||
|
||||
/* clear layer */
|
||||
gimp_layer_set_preserve_transparency(data->layer_id, 0);
|
||||
ret_vals = gimp_run_procedure("gimp_edit_clear", &nret_vals,
|
||||
PARAM_DRAWABLE, data->drawable_id,
|
||||
PARAM_END);
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
gimp_edit_clear (data->drawable_id);
|
||||
|
||||
/* get layer offsets */
|
||||
gimp_drawable_offsets(data->layer_id, &layer_ox, &layer_oy);
|
||||
|
||||
/* get foreground color */
|
||||
ret_vals = gimp_run_procedure("gimp_palette_get_foreground", &nret_vals,
|
||||
PARAM_END);
|
||||
memcpy(&old_color, &ret_vals[1].data.d_color, sizeof(GParamColor));
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
|
||||
gimp_palette_get_foreground (&old_color.red,
|
||||
&old_color.green,
|
||||
&old_color.blue);
|
||||
|
||||
/* set foreground color to the wanted text color */
|
||||
text_color.red = (data->color & 0xff0000) >> 16;
|
||||
text_color.green = (data->color & 0xff00) >> 8;
|
||||
text_color.blue = data->color & 0xff;
|
||||
ret_vals = gimp_run_procedure("gimp_palette_set_foreground", &nret_vals,
|
||||
PARAM_COLOR, &text_color,
|
||||
PARAM_END);
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
gimp_palette_set_foreground (text_color.red,
|
||||
text_color.green,
|
||||
text_color.blue);
|
||||
|
||||
/* write text */
|
||||
for (i = 0; text_lines[i]; i++) {
|
||||
|
@ -465,31 +454,25 @@ void gdt_render_text_p(GdtVals *data, gboolean show_progress)
|
|||
default:
|
||||
xoffs = 0;
|
||||
}
|
||||
ret_vals = gimp_run_procedure("gimp_text_fontname", &nret_vals,
|
||||
PARAM_IMAGE, data->image_id,
|
||||
PARAM_DRAWABLE, data->drawable_id,
|
||||
PARAM_FLOAT, (gdouble)layer_ox +
|
||||
strspn(text_lines[i], " ") * space_width + xoffs, /* x */
|
||||
PARAM_FLOAT, (gdouble)layer_oy + i * (text_height + data->line_spacing), /* y */
|
||||
PARAM_STRING, text_lines[i],
|
||||
PARAM_INT32, 0, /* border */
|
||||
PARAM_INT32, data->antialias,
|
||||
PARAM_FLOAT, font_size,
|
||||
PARAM_INT32, font_size_type,
|
||||
PARAM_STRING, data->xlfd,
|
||||
PARAM_END);
|
||||
layer_f = ret_vals[1].data.d_layer;
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
|
||||
layer_f = gimp_text_fontname (data->image_id,
|
||||
data->drawable_id,
|
||||
(gdouble)layer_ox +
|
||||
strspn(text_lines[i], " ") * space_width + xoffs, /* x */
|
||||
(gdouble)layer_oy + i * (text_height + data->line_spacing), /* y */
|
||||
text_lines[i],
|
||||
0, /* border */
|
||||
data->antialias,
|
||||
font_size,
|
||||
font_size_type,
|
||||
data->xlfd);
|
||||
|
||||
/* FIXME: ascent/descent stuff, use gimp_layer_translate */
|
||||
#ifdef DEBUG
|
||||
printf("GDT: MH:%d LH:%d\n", text_height, gimp_drawable_height(layer_f));
|
||||
#endif
|
||||
|
||||
ret_vals = gimp_run_procedure("gimp_floating_sel_anchor", &nret_vals,
|
||||
PARAM_LAYER, layer_f,
|
||||
PARAM_END);
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
gimp_floating_sel_anchor (layer_f);
|
||||
|
||||
if (show_progress)
|
||||
gimp_progress_update((double)(i + 2) * 100.0 * (double)text_height /
|
||||
(double)layer_height);
|
||||
|
@ -498,19 +481,15 @@ void gdt_render_text_p(GdtVals *data, gboolean show_progress)
|
|||
g_free(text_lines_w);
|
||||
|
||||
/* set foreground color to the old one */
|
||||
ret_vals = gimp_run_procedure("gimp_palette_set_foreground", &nret_vals,
|
||||
PARAM_COLOR, &old_color,
|
||||
PARAM_END);
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
gimp_palette_set_foreground (old_color.red,
|
||||
old_color.green,
|
||||
old_color.blue);
|
||||
|
||||
/* apply rotation */
|
||||
if (data->rotation != 0 && abs(data->rotation) != 360) {
|
||||
ret_vals = gimp_run_procedure("gimp_rotate", &nret_vals,
|
||||
PARAM_DRAWABLE, data->drawable_id,
|
||||
PARAM_INT32, TRUE,
|
||||
PARAM_FLOAT, (double)data->rotation * M_PI / 180.0,
|
||||
PARAM_END);
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
gimp_rotate (data->drawable_id,
|
||||
TRUE,
|
||||
(gdouble)data->rotation * M_PI / 180.0);
|
||||
gimp_layer_set_offsets(data->layer_id, layer_ox, layer_oy);
|
||||
}
|
||||
|
||||
|
@ -570,9 +549,7 @@ void gdt_render_text_p(GdtVals *data, gboolean show_progress)
|
|||
gdt_save(data);
|
||||
|
||||
/* undo end */
|
||||
ret_vals = gimp_run_procedure("gimp_undo_push_group_end", &nret_vals,
|
||||
PARAM_IMAGE, gdtvals.image_id, PARAM_END);
|
||||
gimp_destroy_params(ret_vals, nret_vals);
|
||||
gimp_undo_push_group_end (gdtvals.image_id);
|
||||
|
||||
if (show_progress)
|
||||
gimp_progress_update(100.0);
|
||||
|
|
|
@ -113,7 +113,6 @@ typedef struct {
|
|||
|
||||
|
||||
#include "gdyntext_ui.h"
|
||||
#include "gdyntextutil.h"
|
||||
#include "gdyntextcompat.h"
|
||||
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimp/gimp.h"
|
||||
#include "libgimp/gimpui.h"
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
#include "gdyntext.h"
|
||||
|
|
|
@ -142,7 +142,7 @@ gboolean gdt_compat_load(GdtVals *data)
|
|||
|
||||
strncpy(data->text, params[C_TEXT], sizeof(data->text));
|
||||
{
|
||||
gchar *text = strunescape(data->text);
|
||||
gchar *text = gimp_strcompress (data->text);
|
||||
g_snprintf(data->text, sizeof(data->text), "%s", text);
|
||||
g_free(text);
|
||||
}
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* GIMP Dynamic Text -- This is a plug-in for The GIMP 1.0
|
||||
* Copyright (C) 1998,1999,2000 Marco Lamberto <lm@geocities.com>
|
||||
* Web page: http://www.geocities.com/Tokyo/1474/gimp/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "gdyntextutil.h"
|
||||
|
||||
|
||||
/* substitution of '\' escaped sequences */
|
||||
gchar *strunescape(const gchar *text)
|
||||
{
|
||||
gchar *str = NULL;
|
||||
gchar *bstr = NULL;
|
||||
gchar *ustr = NULL;
|
||||
|
||||
str = bstr = g_strdup(text);
|
||||
while ((str = strchr(str, '\\'))) {
|
||||
memcpy(str, str + 1, strlen(str) + 1);
|
||||
/* escape sequences recognition */
|
||||
switch (*str) {
|
||||
case 'n':
|
||||
*str = '\n';
|
||||
break;
|
||||
case 't':
|
||||
*str = '\t';
|
||||
break;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
ustr = g_strdup(bstr);
|
||||
g_free(bstr);
|
||||
return ustr;
|
||||
}
|
||||
|
||||
|
||||
/* escapes by prepending a '\' to the following chars: '{' '}' '\n' '\t' '\' */
|
||||
gchar *strescape(const gchar *_text)
|
||||
{
|
||||
gchar *str = NULL;
|
||||
gchar *str_esc = NULL;
|
||||
gchar *text = NULL;
|
||||
gchar *buff = NULL;
|
||||
|
||||
text = g_strdup(_text);
|
||||
buff = g_new0(char, (strlen(text) << 1) + 1);
|
||||
strcpy(buff, text);
|
||||
for (str = text, str_esc = buff; *str; str++, str_esc++) {
|
||||
switch (*str) {
|
||||
case '{':
|
||||
case '}':
|
||||
case '\\':
|
||||
case '\t':
|
||||
case '\n':
|
||||
strcpy(str_esc + 1, str);
|
||||
*str_esc = '\\';
|
||||
str_esc++;
|
||||
switch (*str) {
|
||||
case '\t': *str_esc = 't'; break;
|
||||
case '\n': *str_esc = 'n'; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
str_esc = g_strdup(buff);
|
||||
g_free(buff);
|
||||
g_free(text);
|
||||
return str_esc;
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* GIMP Dynamic Text -- This is a plug-in for The GIMP 1.0
|
||||
* Copyright (C) 1998,1999,2000 Marco Lamberto <lm@geocities.com>
|
||||
* Web page: http://www.geocities.com/Tokyo/1474/gimp/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _GDYNTEXTUTIL_H_
|
||||
#define _GDYNTEXTUTIL_H_
|
||||
|
||||
gchar *strunescape(const gchar *text);
|
||||
gchar *strescape(const gchar *text);
|
||||
|
||||
#endif /* _GDYNTEXTUTIL_H_ */
|
||||
|
||||
/* vim: set ts=2 sw=2 tw=79 ai nowrap: */
|
|
@ -972,8 +972,7 @@ plugin_run (gchar *name,
|
|||
void
|
||||
plug_in_parse_gflare_path (void)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gchar *gflare_path;
|
||||
|
||||
GList *fail_list = NULL;
|
||||
GList *list;
|
||||
|
@ -981,35 +980,29 @@ plug_in_parse_gflare_path (void)
|
|||
gimp_path_free (gflare_path_list);
|
||||
gflare_path_list = NULL;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_gimprc_query",
|
||||
&nreturn_vals,
|
||||
PARAM_STRING, "gflare-path",
|
||||
PARAM_END);
|
||||
gflare_path = gimp_gimprc_query ("gflare-path");
|
||||
|
||||
if (return_vals[0].data.d_status != STATUS_SUCCESS ||
|
||||
return_vals[1].data.d_string == NULL)
|
||||
if (!gflare_path)
|
||||
{
|
||||
gchar *gimprc = gimp_personal_rc_file ("gimprc");
|
||||
gchar *path = gimp_strescape
|
||||
("${gimp_dir}" G_DIR_SEPARATOR_S "gflare"
|
||||
G_SEARCHPATH_SEPARATOR_S
|
||||
"${gimp_data_dir}" G_DIR_SEPARATOR_S "gflare",
|
||||
NULL);
|
||||
gchar *path = gimp_strescape ("${gimp_dir}" G_DIR_SEPARATOR_S "gflare"
|
||||
G_SEARCHPATH_SEPARATOR_S
|
||||
"${gimp_data_dir}" G_DIR_SEPARATOR_S "gflare",
|
||||
NULL);
|
||||
g_message (_("No gflare-path in gimprc:\n"
|
||||
"You need to add an entry like\n"
|
||||
"(gflare-path \"%s\")\n"
|
||||
"to your %s file."), path, gimprc);
|
||||
g_free (gimprc);
|
||||
g_free (path);
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
gflare_path_list = gimp_path_parse (return_vals[1].data.d_string,
|
||||
gflare_path_list = gimp_path_parse (gflare_path,
|
||||
16, TRUE, &fail_list);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
g_free (gflare_path);
|
||||
|
||||
if (fail_list)
|
||||
{
|
||||
|
|
|
@ -47,8 +47,6 @@ struct ppm inalpha = {0,0,NULL};
|
|||
|
||||
GList * parsepath (void)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
static GList *lastpath = NULL;
|
||||
gchar *gimpdatasubdir, *defaultpath, *tmps;
|
||||
struct stat st;
|
||||
|
@ -78,12 +76,9 @@ GList * parsepath (void)
|
|||
tmps = g_strdup (defaultpath);
|
||||
else
|
||||
{
|
||||
return_vals = gimp_run_procedure ("gimp_gimprc_query", &nreturn_vals,
|
||||
PARAM_STRING, "gimpressionist-path",
|
||||
PARAM_END);
|
||||
tmps = gimp_gimprc_query ("gimpressionist-path");
|
||||
|
||||
if (return_vals[0].data.d_status != STATUS_SUCCESS ||
|
||||
return_vals[1].data.d_string == NULL)
|
||||
if (!tmps)
|
||||
{
|
||||
if (stat (gimpdatasubdir, &st) != 0
|
||||
|| !S_ISDIR(st.st_mode))
|
||||
|
@ -103,11 +98,6 @@ GList * parsepath (void)
|
|||
}
|
||||
tmps = g_strdup (defaultpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmps = g_strdup (return_vals[1].data.d_string);
|
||||
}
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
lastpath = gimp_path_parse (tmps, 16, FALSE, NULL);
|
||||
|
|
|
@ -1069,18 +1069,12 @@ clear_curled_region (void)
|
|||
static void
|
||||
page_curl (void)
|
||||
{
|
||||
int nreturn_vals;
|
||||
gimp_run_procedure ("gimp_undo_push_group_start", &nreturn_vals,
|
||||
PARAM_IMAGE, image_id,
|
||||
PARAM_END);
|
||||
|
||||
gimp_undo_push_group_start (image_id);
|
||||
gimp_progress_init ( _("Page Curl..."));
|
||||
init_calculation ();
|
||||
do_curl_effect ();
|
||||
clear_curled_region ();
|
||||
gimp_run_procedure ("gimp_undo_push_group_end", &nreturn_vals,
|
||||
PARAM_IMAGE, image_id,
|
||||
PARAM_END);
|
||||
gimp_undo_push_group_end (image_id);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -263,8 +263,6 @@ extern gchar siod_err_msg[];
|
|||
void
|
||||
script_fu_find_scripts (void)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gchar *path_str;
|
||||
gchar *home;
|
||||
gchar *local_path;
|
||||
|
@ -291,102 +289,93 @@ script_fu_find_scripts (void)
|
|||
script_list = g_tree_new ((GCompareFunc)strcmp);
|
||||
#endif
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_gimprc_query",
|
||||
&nreturn_vals,
|
||||
PARAM_STRING, "script-fu-path",
|
||||
PARAM_END);
|
||||
path_str = gimp_gimprc_query ("script-fu-path");
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
if (path_str == NULL)
|
||||
return;
|
||||
|
||||
/* Set local path to contain temp_path, where (supposedly)
|
||||
* there may be working files.
|
||||
*/
|
||||
home = g_get_home_dir ();
|
||||
local_path = g_strdup (path_str);
|
||||
|
||||
/* Search through all directories in the local path */
|
||||
|
||||
next_token = local_path;
|
||||
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
{
|
||||
path_str = return_vals[1].data.d_string;
|
||||
|
||||
if (path_str == NULL)
|
||||
return;
|
||||
|
||||
/* Set local path to contain temp_path, where (supposedly)
|
||||
* there may be working files.
|
||||
*/
|
||||
home = g_get_home_dir ();
|
||||
local_path = g_strdup (path_str);
|
||||
|
||||
/* Search through all directories in the local path */
|
||||
|
||||
next_token = local_path;
|
||||
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
if (*token == '~')
|
||||
{
|
||||
if (*token == '~')
|
||||
{
|
||||
path = g_malloc (strlen (home) + strlen (token) + 2);
|
||||
sprintf (path, "%s%s", home, token + 1);
|
||||
}
|
||||
path = g_malloc (strlen (home) + strlen (token) + 2);
|
||||
sprintf (path, "%s%s", home, token + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = g_malloc (strlen (token) + 2);
|
||||
strcpy (path, token);
|
||||
} /* else */
|
||||
|
||||
/* Check if directory exists and if it has any items in it */
|
||||
my_err = stat (path, &filestat);
|
||||
|
||||
if (!my_err && S_ISDIR (filestat.st_mode))
|
||||
{
|
||||
if (path[strlen (path) - 1] != G_DIR_SEPARATOR)
|
||||
strcat (path, G_DIR_SEPARATOR_S);
|
||||
|
||||
/* Open directory */
|
||||
dir = opendir (path);
|
||||
|
||||
if (!dir)
|
||||
g_message ("error reading script directory \"%s\"", path);
|
||||
else
|
||||
{
|
||||
path = g_malloc (strlen (token) + 2);
|
||||
strcpy (path, token);
|
||||
} /* else */
|
||||
|
||||
/* Check if directory exists and if it has any items in it */
|
||||
my_err = stat (path, &filestat);
|
||||
|
||||
if (!my_err && S_ISDIR (filestat.st_mode))
|
||||
{
|
||||
if (path[strlen (path) - 1] != G_DIR_SEPARATOR)
|
||||
strcat (path, G_DIR_SEPARATOR_S);
|
||||
|
||||
/* Open directory */
|
||||
dir = opendir (path);
|
||||
|
||||
if (!dir)
|
||||
g_message ("error reading script directory \"%s\"", path);
|
||||
else
|
||||
while ((dir_ent = readdir (dir)))
|
||||
{
|
||||
while ((dir_ent = readdir (dir)))
|
||||
filename = g_strdup_printf ("%s%s", path, dir_ent->d_name);
|
||||
|
||||
if (g_strcasecmp (filename + strlen (filename) - 4, ".scm") == 0)
|
||||
{
|
||||
filename = g_strdup_printf ("%s%s", path, dir_ent->d_name);
|
||||
|
||||
if (g_strcasecmp (filename + strlen (filename) - 4, ".scm") == 0)
|
||||
/* Check the file and see that it is not a sub-directory */
|
||||
my_err = stat (filename, &filestat);
|
||||
|
||||
if (!my_err && S_ISREG (filestat.st_mode))
|
||||
{
|
||||
/* Check the file and see that it is not a sub-directory */
|
||||
my_err = stat (filename, &filestat);
|
||||
|
||||
if (!my_err && S_ISREG (filestat.st_mode))
|
||||
{
|
||||
char *qf = ESCAPE (filename);
|
||||
char *qf = ESCAPE (filename);
|
||||
#ifdef __EMX__
|
||||
_fnslashify(qf);
|
||||
_fnslashify(qf);
|
||||
#endif
|
||||
command = g_strdup_printf ("(load \"%s\")", qf);
|
||||
g_free (qf);
|
||||
repl_c_string (command, 0, 0, 1);
|
||||
command = g_strdup_printf ("(load \"%s\")", qf);
|
||||
g_free (qf);
|
||||
repl_c_string (command, 0, 0, 1);
|
||||
#ifdef G_OS_WIN32
|
||||
/* No, I don't know why, but this is
|
||||
* necessary on NT 4.0.
|
||||
*/
|
||||
Sleep(0);
|
||||
/* No, I don't know why, but this is
|
||||
* necessary on NT 4.0.
|
||||
*/
|
||||
Sleep(0);
|
||||
#endif
|
||||
g_free (command);
|
||||
}
|
||||
g_free (command);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
} /* while */
|
||||
|
||||
closedir (dir);
|
||||
} /* else */
|
||||
} /* if */
|
||||
|
||||
g_free (filename);
|
||||
} /* while */
|
||||
|
||||
closedir (dir);
|
||||
} /* else */
|
||||
} /* if */
|
||||
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
} /* while */
|
||||
|
||||
g_free (local_path);
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
} /* while */
|
||||
|
||||
g_free (local_path);
|
||||
g_free (path_str);
|
||||
|
||||
/* now that all scripts are read in and sorted, tell gimp about them */
|
||||
g_tree_traverse (script_list,
|
||||
|
|
|
@ -263,8 +263,6 @@ extern gchar siod_err_msg[];
|
|||
void
|
||||
script_fu_find_scripts (void)
|
||||
{
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gchar *path_str;
|
||||
gchar *home;
|
||||
gchar *local_path;
|
||||
|
@ -291,102 +289,93 @@ script_fu_find_scripts (void)
|
|||
script_list = g_tree_new ((GCompareFunc)strcmp);
|
||||
#endif
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_gimprc_query",
|
||||
&nreturn_vals,
|
||||
PARAM_STRING, "script-fu-path",
|
||||
PARAM_END);
|
||||
path_str = gimp_gimprc_query ("script-fu-path");
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
if (path_str == NULL)
|
||||
return;
|
||||
|
||||
/* Set local path to contain temp_path, where (supposedly)
|
||||
* there may be working files.
|
||||
*/
|
||||
home = g_get_home_dir ();
|
||||
local_path = g_strdup (path_str);
|
||||
|
||||
/* Search through all directories in the local path */
|
||||
|
||||
next_token = local_path;
|
||||
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
{
|
||||
path_str = return_vals[1].data.d_string;
|
||||
|
||||
if (path_str == NULL)
|
||||
return;
|
||||
|
||||
/* Set local path to contain temp_path, where (supposedly)
|
||||
* there may be working files.
|
||||
*/
|
||||
home = g_get_home_dir ();
|
||||
local_path = g_strdup (path_str);
|
||||
|
||||
/* Search through all directories in the local path */
|
||||
|
||||
next_token = local_path;
|
||||
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
if (*token == '~')
|
||||
{
|
||||
if (*token == '~')
|
||||
{
|
||||
path = g_malloc (strlen (home) + strlen (token) + 2);
|
||||
sprintf (path, "%s%s", home, token + 1);
|
||||
}
|
||||
path = g_malloc (strlen (home) + strlen (token) + 2);
|
||||
sprintf (path, "%s%s", home, token + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = g_malloc (strlen (token) + 2);
|
||||
strcpy (path, token);
|
||||
} /* else */
|
||||
|
||||
/* Check if directory exists and if it has any items in it */
|
||||
my_err = stat (path, &filestat);
|
||||
|
||||
if (!my_err && S_ISDIR (filestat.st_mode))
|
||||
{
|
||||
if (path[strlen (path) - 1] != G_DIR_SEPARATOR)
|
||||
strcat (path, G_DIR_SEPARATOR_S);
|
||||
|
||||
/* Open directory */
|
||||
dir = opendir (path);
|
||||
|
||||
if (!dir)
|
||||
g_message ("error reading script directory \"%s\"", path);
|
||||
else
|
||||
{
|
||||
path = g_malloc (strlen (token) + 2);
|
||||
strcpy (path, token);
|
||||
} /* else */
|
||||
|
||||
/* Check if directory exists and if it has any items in it */
|
||||
my_err = stat (path, &filestat);
|
||||
|
||||
if (!my_err && S_ISDIR (filestat.st_mode))
|
||||
{
|
||||
if (path[strlen (path) - 1] != G_DIR_SEPARATOR)
|
||||
strcat (path, G_DIR_SEPARATOR_S);
|
||||
|
||||
/* Open directory */
|
||||
dir = opendir (path);
|
||||
|
||||
if (!dir)
|
||||
g_message ("error reading script directory \"%s\"", path);
|
||||
else
|
||||
while ((dir_ent = readdir (dir)))
|
||||
{
|
||||
while ((dir_ent = readdir (dir)))
|
||||
filename = g_strdup_printf ("%s%s", path, dir_ent->d_name);
|
||||
|
||||
if (g_strcasecmp (filename + strlen (filename) - 4, ".scm") == 0)
|
||||
{
|
||||
filename = g_strdup_printf ("%s%s", path, dir_ent->d_name);
|
||||
|
||||
if (g_strcasecmp (filename + strlen (filename) - 4, ".scm") == 0)
|
||||
/* Check the file and see that it is not a sub-directory */
|
||||
my_err = stat (filename, &filestat);
|
||||
|
||||
if (!my_err && S_ISREG (filestat.st_mode))
|
||||
{
|
||||
/* Check the file and see that it is not a sub-directory */
|
||||
my_err = stat (filename, &filestat);
|
||||
|
||||
if (!my_err && S_ISREG (filestat.st_mode))
|
||||
{
|
||||
char *qf = ESCAPE (filename);
|
||||
char *qf = ESCAPE (filename);
|
||||
#ifdef __EMX__
|
||||
_fnslashify(qf);
|
||||
_fnslashify(qf);
|
||||
#endif
|
||||
command = g_strdup_printf ("(load \"%s\")", qf);
|
||||
g_free (qf);
|
||||
repl_c_string (command, 0, 0, 1);
|
||||
command = g_strdup_printf ("(load \"%s\")", qf);
|
||||
g_free (qf);
|
||||
repl_c_string (command, 0, 0, 1);
|
||||
#ifdef G_OS_WIN32
|
||||
/* No, I don't know why, but this is
|
||||
* necessary on NT 4.0.
|
||||
*/
|
||||
Sleep(0);
|
||||
/* No, I don't know why, but this is
|
||||
* necessary on NT 4.0.
|
||||
*/
|
||||
Sleep(0);
|
||||
#endif
|
||||
g_free (command);
|
||||
}
|
||||
g_free (command);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
} /* while */
|
||||
|
||||
closedir (dir);
|
||||
} /* else */
|
||||
} /* if */
|
||||
|
||||
g_free (filename);
|
||||
} /* while */
|
||||
|
||||
closedir (dir);
|
||||
} /* else */
|
||||
} /* if */
|
||||
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
} /* while */
|
||||
|
||||
g_free (local_path);
|
||||
}
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
} /* while */
|
||||
|
||||
g_free (local_path);
|
||||
g_free (path_str);
|
||||
|
||||
/* now that all scripts are read in and sorted, tell gimp about them */
|
||||
g_tree_traverse (script_list,
|
||||
|
|
|
@ -372,26 +372,17 @@ init_procedures (void)
|
|||
static void
|
||||
init_constants (void)
|
||||
{
|
||||
GParam *return_vals = NULL;
|
||||
gint nreturn_vals;
|
||||
gchar *gimp_plugin_dir;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_gimprc_query",
|
||||
&nreturn_vals,
|
||||
PARAM_STRING, "gimp_data_dir",
|
||||
PARAM_END);
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
setvar (cintern ("gimp-data-dir"), strcons (-1, return_vals[1].data.d_string), NIL);
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_gimprc_query",
|
||||
&nreturn_vals,
|
||||
PARAM_STRING, "gimp_plugin_dir",
|
||||
PARAM_END);
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
setvar (cintern ("gimp-plugin-dir"), strcons (-1, return_vals[1].data.d_string), NIL);
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
setvar (cintern ("gimp-data-dir"), strcons (-1, gimp_data_directory ()), NIL);
|
||||
|
||||
gimp_plugin_dir = gimp_gimprc_query ("gimp_plugin_dir");
|
||||
if (gimp_plugin_dir)
|
||||
{
|
||||
setvar (cintern ("gimp-plugin-dir"), strcons (-1, gimp_plugin_dir), NIL);
|
||||
g_free (gimp_plugin_dir);
|
||||
}
|
||||
|
||||
/* Generated constants */
|
||||
init_generated_constants ();
|
||||
|
||||
|
|
Loading…
Reference in New Issue