Commit 64424f6c authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

write comment to top of gimprc.

2001-12-28  Sven Neumann  <sven@gimp.org>

	* app/config/gimprc.c: write comment to top of gimprc.

	* app/core/gimpscanconvert.c: removed redundant CLAMP statements.

	* app/plug-in/plug-in-rc.[ch]
	* app/plug-in/plug-in.c: rewrote pluginrc scanner and moved the code
	that writes the pluginrc into plug-in-rc.c.
parent e43620f8
2001-12-28 Sven Neumann <sven@gimp.org>
* app/config/gimprc.c: write comment to top of gimprc.
* app/core/gimpscanconvert.c: removed redundant CLAMP statements.
* app/plug-in/plug-in-rc.[ch]
* app/plug-in/plug-in.c: rewrote pluginrc scanner and moved the code
that writes the pluginrc into plug-in-rc.c.
2001-12-28 Sven Neumann <sven@gimp.org>
* app/tools/gimpmagnifytool.c: calculate mouse movement in screen
......
......@@ -24,10 +24,8 @@
#include <gtk/gtk.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
......@@ -162,7 +160,6 @@ static void plug_in_handle_proc_run (GPProcRun *proc_run);
static void plug_in_handle_proc_return (GPProcReturn *proc_return);
static void plug_in_handle_proc_install (GPProcInstall *proc_install);
static void plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall);
static void plug_in_write_rc (const gchar *filename);
static void plug_in_init_file (const gchar *filename,
gpointer loader_data);
static void plug_in_query (PlugInDef *plug_in_def);
......@@ -415,7 +412,7 @@ plug_in_init (Gimp *gimp,
if (gimp->be_verbose)
g_print (_("writing \"%s\"\n"), filename);
plug_in_write_rc (filename);
plug_in_rc_write (plug_in_defs, filename);
}
g_free (filename);
......@@ -650,15 +647,9 @@ plug_in_def_new (const gchar *prog)
g_return_val_if_fail (prog != NULL, NULL);
plug_in_def = g_new (PlugInDef, 1);
plug_in_def = g_new0 (PlugInDef, 1);
plug_in_def->prog = g_strdup (prog);
plug_in_def->proc_defs = NULL;
plug_in_def->locale_domain = NULL;
plug_in_def->locale_path = NULL;
plug_in_def->help_path = NULL;
plug_in_def->mtime = 0;
plug_in_def->query = FALSE;
plug_in_def->prog = g_strdup (prog);
return plug_in_def;
}
......@@ -671,12 +662,9 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list;
g_free (plug_in_def->prog);
if (plug_in_def->locale_domain)
g_free (plug_in_def->locale_domain);
if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
g_free (plug_in_def->locale_domain);
g_free (plug_in_def->locale_path);
g_free (plug_in_def->help_path);
if (free_proc_defs)
{
......@@ -2306,156 +2294,6 @@ plug_in_pop (void)
}
}
static void
plug_in_write_rc_string (FILE *fp,
gchar *str)
{
fputc ('"', fp);
if (str)
while (*str)
{
if (*str == '\n')
{
fputc ('\\', fp);
fputc ('n', fp);
}
else if (*str == '\r')
{
fputc ('\\', fp);
fputc ('r', fp);
}
else if (*str == '\032') /* ^Z is problematic on Windows */
{
fputc ('\\', fp);
fputc ('z', fp);
}
else
{
if ((*str == '"') || (*str == '\\'))
fputc ('\\', fp);
fputc (*str, fp);
}
str += 1;
}
fputc ('"', fp);
}
static void
plug_in_write_rc (const gchar *filename)
{
FILE *fp;
PlugInDef *plug_in_def;
PlugInProcDef *proc_def;
GSList *tmp;
GSList *tmp2;
gint i;
fp = fopen (filename, "w");
if (!fp)
return;
tmp = plug_in_defs;
while (tmp)
{
plug_in_def = tmp->data;
tmp = tmp->next;
if (plug_in_def->proc_defs)
{
fprintf (fp, "(plug-in-def ");
plug_in_write_rc_string (fp, plug_in_def->prog);
fprintf (fp, " %ld", (long) plug_in_def->mtime);
tmp2 = plug_in_def->proc_defs;
if (tmp2)
fprintf (fp, "\n");
while (tmp2)
{
proc_def = tmp2->data;
tmp2 = tmp2->next;
fprintf (fp, "\t(proc-def \"%s\" %d\n",
proc_def->db_info.name, proc_def->db_info.proc_type);
fprintf (fp, "\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.blurb);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.help);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.author);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.copyright);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.date);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->menu_path);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->extensions);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->prefixes);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->magics);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->image_types);
fprintf (fp, "\n\t\t%d %d\n",
proc_def->db_info.num_args, proc_def->db_info.num_values);
for (i = 0; i < proc_def->db_info.num_args; i++)
{
fprintf (fp, "\t\t(proc-arg %d ",
proc_def->db_info.args[i].arg_type);
plug_in_write_rc_string (fp, proc_def->db_info.args[i].name);
plug_in_write_rc_string (fp, proc_def->db_info.args[i].description);
fprintf (fp, ")%s",
(proc_def->db_info.num_values ||
(i < (proc_def->db_info.num_args - 1))) ? "\n" : "");
}
for (i = 0; i < proc_def->db_info.num_values; i++)
{
fprintf (fp, "\t\t(proc-arg %d ",
proc_def->db_info.values[i].arg_type);
plug_in_write_rc_string (fp, proc_def->db_info.values[i].name);
plug_in_write_rc_string (fp, proc_def->db_info.values[i].description);
fprintf (fp, ")%s", (i < (proc_def->db_info.num_values - 1)) ? "\n" : "");
}
fprintf (fp, ")");
if (tmp2)
fprintf (fp, "\n");
}
if (plug_in_def->locale_domain)
{
fprintf (fp, "\n\t(locale-def \"%s\"", plug_in_def->locale_domain);
if (plug_in_def->locale_path)
fprintf (fp, " \"%s\")", plug_in_def->locale_path);
else
fprintf (fp, ")");
}
if (plug_in_def->help_path)
{
fprintf (fp, "\n\t(help-def \"%s\")", plug_in_def->help_path);
}
fprintf (fp, ")\n");
if (tmp)
fprintf (fp, "\n");
}
}
fclose (fp);
}
static void
plug_in_init_file (const gchar *filename,
gpointer loader_data)
......
......@@ -23,6 +23,7 @@
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
......@@ -49,6 +50,7 @@ static gboolean gimp_rc_deserialize (GObject *object,
static void gimp_rc_serialize_changed_properties (GimpRc *new,
GimpRc *old,
gint fd);
static void gimp_rc_write_header (gint fd);
static gboolean gimp_values_equal (const GValue *a,
const GValue *b);
......@@ -145,6 +147,7 @@ gimp_rc_write_changes (GimpRc *new,
return FALSE;
}
gimp_rc_write_header (fd);
gimp_rc_serialize_changed_properties (new, old, fd);
gimp_config_serialize_unknown_tokens (G_OBJECT (new), fd);
......@@ -216,7 +219,31 @@ gimp_rc_serialize_changed_properties (GimpRc *new,
g_free (property_specs);
g_string_free (str, TRUE);
}
static void
gimp_rc_write_header (gint fd)
{
gchar *filename;
const gchar *top =
"# This is your personal gimprc file. Any variable defined in this file\n"
"# takes precedence over the value defined in the system-wide gimprc:\n"
"# ";
const gchar *bottom =
"\n"
"# Most values can be set automatically within the GIMP, if you press\n"
"# the \"Save\" button after changing some options in the Preferences\n"
"# dialog.\n\n";
filename = g_build_filename (gimp_sysconf_directory (), "gimprc", NULL);
write (fd, top, strlen (top));
write (fd, filename, strlen (filename));
write (fd, bottom, strlen (bottom));
g_free (filename);
}
static gboolean
gimp_values_equal (const GValue *a,
const GValue *b)
......
......@@ -84,7 +84,7 @@ main (int argc,
gimp_config_foreach_unknown_token (G_OBJECT (gimprc),
output_unknown_token, &header);
g_print ("\n Testing gimp_rc_write_changes() ... ");
g_print ("\n\nTesting gimp_rc_write_changes() ... \n\n");
gimprc2 = gimp_rc_new ();
g_object_set (G_OBJECT (gimprc2), "show-tips", FALSE, NULL);
......
......@@ -252,7 +252,7 @@ gimp_scan_convert_to_channel (GimpScanConvert *sc,
guchar *b;
gint *vals;
gint val;
gint x, x2, w;
gint x, w;
gint i, j;
antialias = sc->antialias;
......@@ -312,11 +312,7 @@ gimp_scan_convert_to_channel (GimpScanConvert *sc,
}
else
{
/* bounds checking */
x = CLAMP (x, 0, widtha);
x2 = CLAMP (GPOINTER_TO_INT (list->data), 0, widtha);
w = x2 - x;
w = GPOINTER_TO_INT (list->data) - x;
if (w > 0)
{
......
......@@ -24,10 +24,8 @@
#include <gtk/gtk.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
......@@ -162,7 +160,6 @@ static void plug_in_handle_proc_run (GPProcRun *proc_run);
static void plug_in_handle_proc_return (GPProcReturn *proc_return);
static void plug_in_handle_proc_install (GPProcInstall *proc_install);
static void plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall);
static void plug_in_write_rc (const gchar *filename);
static void plug_in_init_file (const gchar *filename,
gpointer loader_data);
static void plug_in_query (PlugInDef *plug_in_def);
......@@ -415,7 +412,7 @@ plug_in_init (Gimp *gimp,
if (gimp->be_verbose)
g_print (_("writing \"%s\"\n"), filename);
plug_in_write_rc (filename);
plug_in_rc_write (plug_in_defs, filename);
}
g_free (filename);
......@@ -650,15 +647,9 @@ plug_in_def_new (const gchar *prog)
g_return_val_if_fail (prog != NULL, NULL);
plug_in_def = g_new (PlugInDef, 1);
plug_in_def = g_new0 (PlugInDef, 1);
plug_in_def->prog = g_strdup (prog);
plug_in_def->proc_defs = NULL;
plug_in_def->locale_domain = NULL;
plug_in_def->locale_path = NULL;
plug_in_def->help_path = NULL;
plug_in_def->mtime = 0;
plug_in_def->query = FALSE;
plug_in_def->prog = g_strdup (prog);
return plug_in_def;
}
......@@ -671,12 +662,9 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list;
g_free (plug_in_def->prog);
if (plug_in_def->locale_domain)
g_free (plug_in_def->locale_domain);
if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
g_free (plug_in_def->locale_domain);
g_free (plug_in_def->locale_path);
g_free (plug_in_def->help_path);
if (free_proc_defs)
{
......@@ -2306,156 +2294,6 @@ plug_in_pop (void)
}
}
static void
plug_in_write_rc_string (FILE *fp,
gchar *str)
{
fputc ('"', fp);
if (str)
while (*str)
{
if (*str == '\n')
{
fputc ('\\', fp);
fputc ('n', fp);
}
else if (*str == '\r')
{
fputc ('\\', fp);
fputc ('r', fp);
}
else if (*str == '\032') /* ^Z is problematic on Windows */
{
fputc ('\\', fp);
fputc ('z', fp);
}
else
{
if ((*str == '"') || (*str == '\\'))
fputc ('\\', fp);
fputc (*str, fp);
}
str += 1;
}
fputc ('"', fp);
}
static void
plug_in_write_rc (const gchar *filename)
{
FILE *fp;
PlugInDef *plug_in_def;
PlugInProcDef *proc_def;
GSList *tmp;
GSList *tmp2;
gint i;
fp = fopen (filename, "w");
if (!fp)
return;
tmp = plug_in_defs;
while (tmp)
{
plug_in_def = tmp->data;
tmp = tmp->next;
if (plug_in_def->proc_defs)
{
fprintf (fp, "(plug-in-def ");
plug_in_write_rc_string (fp, plug_in_def->prog);
fprintf (fp, " %ld", (long) plug_in_def->mtime);
tmp2 = plug_in_def->proc_defs;
if (tmp2)
fprintf (fp, "\n");
while (tmp2)
{
proc_def = tmp2->data;
tmp2 = tmp2->next;
fprintf (fp, "\t(proc-def \"%s\" %d\n",
proc_def->db_info.name, proc_def->db_info.proc_type);
fprintf (fp, "\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.blurb);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.help);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.author);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.copyright);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.date);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->menu_path);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->extensions);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->prefixes);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->magics);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->image_types);
fprintf (fp, "\n\t\t%d %d\n",
proc_def->db_info.num_args, proc_def->db_info.num_values);
for (i = 0; i < proc_def->db_info.num_args; i++)
{
fprintf (fp, "\t\t(proc-arg %d ",
proc_def->db_info.args[i].arg_type);
plug_in_write_rc_string (fp, proc_def->db_info.args[i].name);
plug_in_write_rc_string (fp, proc_def->db_info.args[i].description);
fprintf (fp, ")%s",
(proc_def->db_info.num_values ||
(i < (proc_def->db_info.num_args - 1))) ? "\n" : "");
}
for (i = 0; i < proc_def->db_info.num_values; i++)
{
fprintf (fp, "\t\t(proc-arg %d ",
proc_def->db_info.values[i].arg_type);
plug_in_write_rc_string (fp, proc_def->db_info.values[i].name);
plug_in_write_rc_string (fp, proc_def->db_info.values[i].description);
fprintf (fp, ")%s", (i < (proc_def->db_info.num_values - 1)) ? "\n" : "");
}
fprintf (fp, ")");
if (tmp2)
fprintf (fp, "\n");
}
if (plug_in_def->locale_domain)
{
fprintf (fp, "\n\t(locale-def \"%s\"", plug_in_def->locale_domain);
if (plug_in_def->locale_path)
fprintf (fp, " \"%s\")", plug_in_def->locale_path);
else
fprintf (fp, ")");
}
if (plug_in_def->help_path)
{
fprintf (fp, "\n\t(help-def \"%s\")", plug_in_def->help_path);
}
fprintf (fp, ")\n");
if (tmp)
fprintf (fp, "\n");
}
}
fclose (fp);
}
static void
plug_in_init_file (const gchar *filename,
gpointer loader_data)
......
......@@ -24,10 +24,8 @@
#include <gtk/gtk.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
......@@ -162,7 +160,6 @@ static void plug_in_handle_proc_run (GPProcRun *proc_run);
static void plug_in_handle_proc_return (GPProcReturn *proc_return);
static void plug_in_handle_proc_install (GPProcInstall *proc_install);
static void plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall);
static void plug_in_write_rc (const gchar *filename);
static void plug_in_init_file (const gchar *filename,
gpointer loader_data);
static void plug_in_query (PlugInDef *plug_in_def);
......@@ -415,7 +412,7 @@ plug_in_init (Gimp *gimp,
if (gimp->be_verbose)
g_print (_("writing \"%s\"\n"), filename);
plug_in_write_rc (filename);
plug_in_rc_write (plug_in_defs, filename);
}
g_free (filename);
......@@ -650,15 +647,9 @@ plug_in_def_new (const gchar *prog)
g_return_val_if_fail (prog != NULL, NULL);
plug_in_def = g_new (PlugInDef, 1);
plug_in_def = g_new0 (PlugInDef, 1);
plug_in_def->prog = g_strdup (prog);
plug_in_def->proc_defs = NULL;
plug_in_def->locale_domain = NULL;
plug_in_def->locale_path = NULL;
plug_in_def->help_path = NULL;
plug_in_def->mtime = 0;
plug_in_def->query = FALSE;
plug_in_def->prog = g_strdup (prog);
return plug_in_def;
}
......@@ -671,12 +662,9 @@ plug_in_def_free (PlugInDef *plug_in_def,
GSList *list;
g_free (plug_in_def->prog);
if (plug_in_def->locale_domain)
g_free (plug_in_def->locale_domain);
if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
g_free (plug_in_def->locale_domain);
g_free (plug_in_def->locale_path);
g_free (plug_in_def->help_path);
if (free_proc_defs)
{
......@@ -2306,156 +2294,6 @@ plug_in_pop (void)
}
}
static void
plug_in_write_rc_string (FILE *fp,
gchar *str)
{
fputc ('"', fp);
if (str)
while (*str)
{
if (*str == '\n')
{
fputc ('\\', fp);
fputc ('n', fp);
}
else if (*str == '\r')
{
fputc ('\\', fp);
fputc ('r', fp);
}
else if (*str == '\032') /* ^Z is problematic on Windows */
{
fputc ('\\', fp);
fputc ('z', fp);
}
else
{
if ((*str == '"') || (*str == '\\'))
fputc ('\\', fp);
fputc (*str, fp);
}
str += 1;
}
fputc ('"', fp);
}
static void
plug_in_write_rc (const gchar *filename)
{
FILE *fp;
PlugInDef *plug_in_def;
PlugInProcDef *proc_def;
GSList *tmp;
GSList *tmp2;
gint i;
fp = fopen (filename, "w");
if (!fp)
return;
tmp = plug_in_defs;
while (tmp)
{
plug_in_def = tmp->data;
tmp = tmp->next;
if (plug_in_def->proc_defs)
{
fprintf (fp, "(plug-in-def ");
plug_in_write_rc_string (fp, plug_in_def->prog);
fprintf (fp, " %ld", (long) plug_in_def->mtime);
tmp2 = plug_in_def->proc_defs;
if (tmp2)
fprintf (fp, "\n");
while (tmp2)
{
proc_def = tmp2->data;
tmp2 = tmp2->next;
fprintf (fp, "\t(proc-def \"%s\" %d\n",
proc_def->db_info.name, proc_def->db_info.proc_type);
fprintf (fp, "\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.blurb);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.help);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.author);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.copyright);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->db_info.date);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->menu_path);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->extensions);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->prefixes);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->magics);
fprintf (fp, "\n\t\t");
plug_in_write_rc_string (fp, proc_def->image_types);
fprintf (fp, "\n\t\t%d %d\n",
proc_def->db_info.num_args, proc_def->db_info.num_values);
for (i = 0; i < proc_def->db_info.num_args; i++)
{
fprintf (fp, "\t\t(proc-arg %d ",
proc_def->db_info.args[i].arg_type);
plug_in_write_rc_string (fp, proc_def->db_info.args[i].name);
plug_in_write_rc_string (fp, proc_def->db_info.args[i].description);
fprintf (fp, ")%s",
(proc_def->db_info.num_values ||
(i < (proc_def->db_info.num_args - 1))) ? "\n" : "");
}
for (i = 0; i < proc_def->db_info.num_values; i++)
{
fprintf (fp, "\t\t(proc-arg %d ",
proc_def->db_info.values[i].arg_type);
plug_in_write_rc_string (fp, proc_def->db_info.values[i].name);
plug_in_write_rc_string (fp, proc_def->db_info.values[i].description);
fprintf (fp, ")%s", (i < (proc_def->db_info.num_values - 1)) ? "\n" : "");
}
fprintf (fp, ")");