From 74710fccf462152ccdd2a345644b33c557590b77 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 2 Jul 2003 17:11:00 +0000 Subject: [PATCH] changed GimpDatafileLoaderFunc to take a separate "gpointer user_data" 2003-07-02 Michael Natterer * libgimpbase/gimpbasetypes.h: changed GimpDatafileLoaderFunc to take a separate "gpointer user_data" parameter (passing user_data in a struct was a quite nonstandard API design). Made the GimpDatafileData pointer const. * libgimpbase/gimpdatafiles.[ch]: removed user_data from the GimpDatafileData struct and added "const gchar *basename" so we don't need to g_path_get_basename() in many callbacks. * libgimp/gimpmiscui.[ch]: changed gimp_plug_in_parse_path() to gimp_plug_in_get_path() and return the unparsed path. * app/core/gimpdatafactory.c * app/core/gimpenvirontable.c * app/gui/gui.c * app/plug-in/plug-ins.c * libgimpmodule/gimpmoduledb.c * plug-ins/script-fu/script-fu-scripts.c: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.[ch] * plug-ins/FractalExplorer/Globals.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c: use gimp_datafiles_read_directories() instead of fiddling with g_dir_open() manually. Random cleanups. --- ChangeLog | 28 +++ app/core/gimpdatafactory.c | 10 +- app/core/gimpenvirontable.c | 8 +- app/gui/gui.c | 18 +- app/plug-in/gimpenvirontable.c | 8 +- app/plug-in/gimppluginmanager.c | 16 +- app/plug-in/plug-ins.c | 16 +- libgimp/gimpmiscui.c | 36 ++- libgimp/gimpmiscui.h | 2 +- libgimpbase/gimpbasetypes.h | 3 +- libgimpbase/gimpdatafiles.c | 34 ++- libgimpbase/gimpdatafiles.h | 3 +- libgimpmodule/gimpmoduledb.c | 8 +- plug-ins/FractalExplorer/Dialogs.c | 11 +- plug-ins/FractalExplorer/FractalExplorer.c | 105 +++------ plug-ins/FractalExplorer/FractalExplorer.h | 33 ++- plug-ins/FractalExplorer/Globals.c | 82 +++---- plug-ins/gfig/gfig.c | 112 ++++------ plug-ins/gflare/gflare.c | 243 +++++++++++---------- plug-ins/script-fu/script-fu-interface.c | 6 +- plug-ins/script-fu/script-fu-scripts.c | 6 +- 21 files changed, 377 insertions(+), 411 deletions(-) diff --git a/ChangeLog b/ChangeLog index 813a406d06..40542305e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2003-07-02 Michael Natterer + + * libgimpbase/gimpbasetypes.h: changed GimpDatafileLoaderFunc to + take a separate "gpointer user_data" parameter (passing user_data + in a struct was a quite nonstandard API design). Made the + GimpDatafileData pointer const. + + * libgimpbase/gimpdatafiles.[ch]: removed user_data from the + GimpDatafileData struct and added "const gchar *basename" so we + don't need to g_path_get_basename() in many callbacks. + + * libgimp/gimpmiscui.[ch]: changed gimp_plug_in_parse_path() to + gimp_plug_in_get_path() and return the unparsed path. + + * app/core/gimpdatafactory.c + * app/core/gimpenvirontable.c + * app/gui/gui.c + * app/plug-in/plug-ins.c + * libgimpmodule/gimpmoduledb.c + * plug-ins/script-fu/script-fu-scripts.c: changed accordingly. + + * plug-ins/FractalExplorer/Dialogs.c + * plug-ins/FractalExplorer/FractalExplorer.[ch] + * plug-ins/FractalExplorer/Globals.c + * plug-ins/gfig/gfig.c + * plug-ins/gflare/gflare.c: use gimp_datafiles_read_directories() + instead of fiddling with g_dir_open() manually. Random cleanups. + 2003-07-02 Sven Neumann * plug-ins: last bunch of plug-ins adapted to libgimp changes. diff --git a/app/core/gimpdatafactory.c b/app/core/gimpdatafactory.c index 1c65f0f733..fae6c0d72d 100644 --- a/app/core/gimpdatafactory.c +++ b/app/core/gimpdatafactory.c @@ -49,7 +49,8 @@ static void gimp_data_factory_finalize (GObject *object); static gsize gimp_data_factory_get_memsize (GimpObject *object); -static void gimp_data_factory_load_callback (GimpDatafileData *file_data); +static void gimp_data_factory_load_data (const GimpDatafileData *file_data, + gpointer user_data); static GimpObjectClass *parent_class = NULL; @@ -205,7 +206,7 @@ gimp_data_factory_data_init (GimpDataFactory *factory, gimp_datafiles_read_directories (path, G_FILE_TEST_EXISTS, - gimp_data_factory_load_callback, + gimp_data_factory_load_data, factory); } @@ -415,12 +416,13 @@ gimp_data_factory_data_get_standard (GimpDataFactory *factory) } static void -gimp_data_factory_load_callback (GimpDatafileData *file_data) +gimp_data_factory_load_data (const GimpDatafileData *file_data, + gpointer user_data) { GimpDataFactory *factory; gint i; - factory = (GimpDataFactory *) file_data->user_data; + factory = GIMP_DATA_FACTORY (user_data); for (i = 0; i < factory->n_loader_entries; i++) { diff --git a/app/core/gimpenvirontable.c b/app/core/gimpenvirontable.c index 46f1bd459e..519c079f2e 100644 --- a/app/core/gimpenvirontable.c +++ b/app/core/gimpenvirontable.c @@ -54,7 +54,8 @@ static void gimp_environ_table_init (GimpEnvironTable *enviro static void gimp_environ_table_finalize (GObject *object); -static void gimp_environ_table_load_env_file (GimpDatafileData *file_data); +static void gimp_environ_table_load_env_file (const GimpDatafileData *file_data, + gpointer user_data); static gboolean gimp_environ_table_legal_name (gchar *name); static void gimp_environ_table_populate (GimpEnvironTable *environ_table); @@ -240,7 +241,8 @@ gimp_environ_table_get_envp (GimpEnvironTable *environ_table) /* private */ static void -gimp_environ_table_load_env_file (GimpDatafileData *file_data) +gimp_environ_table_load_env_file (const GimpDatafileData *file_data, + gpointer user_data) { GimpEnvironTable *environ_table; FILE *env; @@ -249,7 +251,7 @@ gimp_environ_table_load_env_file (GimpDatafileData *file_data) gchar *name, *value, *separator, *p, *q; GimpEnvironValue *val; - environ_table = GIMP_ENVIRON_TABLE (file_data->user_data); + environ_table = GIMP_ENVIRON_TABLE (user_data); env = fopen (file_data->filename, "r"); if (! env) diff --git a/app/gui/gui.c b/app/gui/gui.c index 6e5e1099ac..2e07ada75c 100644 --- a/app/gui/gui.c +++ b/app/gui/gui.c @@ -79,7 +79,8 @@ static void gui_message (Gimp *gimp, static GimpObject * gui_display_new (GimpImage *gimage, guint scale); -static void gui_themes_dir_foreach_func (GimpDatafileData *file_data); +static void gui_themes_dir_foreach_func (const GimpDatafileData *file_data, + gpointer user_data); static gboolean gui_exit_callback (Gimp *gimp, gboolean kill_it); static gboolean gui_exit_finish_callback (Gimp *gimp, @@ -456,20 +457,19 @@ gui_display_new (GimpImage *gimage, } static void -gui_themes_dir_foreach_func (GimpDatafileData *file_data) +gui_themes_dir_foreach_func (const GimpDatafileData *file_data, + gpointer user_data) { - Gimp *gimp; - gchar *basename; + Gimp *gimp; - gimp = (Gimp *) file_data->user_data; - - basename = g_path_get_basename (file_data->filename); + gimp = GIMP (user_data); if (gimp->be_verbose) - g_print (_("Adding theme '%s' (%s)\n"), basename, file_data->filename); + g_print (_("Adding theme '%s' (%s)\n"), + file_data->basename, file_data->filename); g_hash_table_insert (themes_hash, - basename, + g_strdup (file_data->basename), g_strdup (file_data->filename)); } diff --git a/app/plug-in/gimpenvirontable.c b/app/plug-in/gimpenvirontable.c index 46f1bd459e..519c079f2e 100644 --- a/app/plug-in/gimpenvirontable.c +++ b/app/plug-in/gimpenvirontable.c @@ -54,7 +54,8 @@ static void gimp_environ_table_init (GimpEnvironTable *enviro static void gimp_environ_table_finalize (GObject *object); -static void gimp_environ_table_load_env_file (GimpDatafileData *file_data); +static void gimp_environ_table_load_env_file (const GimpDatafileData *file_data, + gpointer user_data); static gboolean gimp_environ_table_legal_name (gchar *name); static void gimp_environ_table_populate (GimpEnvironTable *environ_table); @@ -240,7 +241,8 @@ gimp_environ_table_get_envp (GimpEnvironTable *environ_table) /* private */ static void -gimp_environ_table_load_env_file (GimpDatafileData *file_data) +gimp_environ_table_load_env_file (const GimpDatafileData *file_data, + gpointer user_data) { GimpEnvironTable *environ_table; FILE *env; @@ -249,7 +251,7 @@ gimp_environ_table_load_env_file (GimpDatafileData *file_data) gchar *name, *value, *separator, *p, *q; GimpEnvironValue *val; - environ_table = GIMP_ENVIRON_TABLE (file_data->user_data); + environ_table = GIMP_ENVIRON_TABLE (user_data); env = fopen (file_data->filename, "r"); if (! env) diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c index 08a64ab601..f2eb4302e8 100644 --- a/app/plug-in/gimppluginmanager.c +++ b/app/plug-in/gimppluginmanager.c @@ -75,7 +75,8 @@ struct _PlugInHelpPathDef }; -static void plug_ins_init_file (GimpDatafileData *file_data); +static void plug_ins_init_file (const GimpDatafileData *file_data, + gpointer user_data); static void plug_ins_add_to_db (Gimp *gimp); static PlugInProcDef * plug_ins_proc_def_insert (Gimp *gimp, PlugInProcDef *proc_def); @@ -796,16 +797,14 @@ plug_ins_image_types_parse (gchar *image_types) /* private functions */ static void -plug_ins_init_file (GimpDatafileData *file_data) +plug_ins_init_file (const GimpDatafileData *file_data, + gpointer user_data) { PlugInDef *plug_in_def; GSList **plug_in_defs; GSList *list; - gchar *basename; - plug_in_defs = file_data->user_data; - - basename = g_path_get_basename (file_data->filename); + plug_in_defs = (GSList **) user_data; for (list = *plug_in_defs; list; list = g_slist_next (list)) { @@ -815,13 +814,12 @@ plug_ins_init_file (GimpDatafileData *file_data) plug_in_name = g_path_get_basename (plug_in_def->prog); - if (g_ascii_strcasecmp (basename, plug_in_name) == 0) + if (g_ascii_strcasecmp (file_data->basename, plug_in_name) == 0) { g_print ("skipping duplicate plug-in: \"%s\"\n", file_data->filename); g_free (plug_in_name); - g_free (basename); return; } @@ -829,8 +827,6 @@ plug_ins_init_file (GimpDatafileData *file_data) g_free (plug_in_name); } - g_free (basename); - plug_in_def = plug_in_def_new (file_data->filename); plug_in_def_set_mtime (plug_in_def, file_data->mtime); diff --git a/app/plug-in/plug-ins.c b/app/plug-in/plug-ins.c index 08a64ab601..f2eb4302e8 100644 --- a/app/plug-in/plug-ins.c +++ b/app/plug-in/plug-ins.c @@ -75,7 +75,8 @@ struct _PlugInHelpPathDef }; -static void plug_ins_init_file (GimpDatafileData *file_data); +static void plug_ins_init_file (const GimpDatafileData *file_data, + gpointer user_data); static void plug_ins_add_to_db (Gimp *gimp); static PlugInProcDef * plug_ins_proc_def_insert (Gimp *gimp, PlugInProcDef *proc_def); @@ -796,16 +797,14 @@ plug_ins_image_types_parse (gchar *image_types) /* private functions */ static void -plug_ins_init_file (GimpDatafileData *file_data) +plug_ins_init_file (const GimpDatafileData *file_data, + gpointer user_data) { PlugInDef *plug_in_def; GSList **plug_in_defs; GSList *list; - gchar *basename; - plug_in_defs = file_data->user_data; - - basename = g_path_get_basename (file_data->filename); + plug_in_defs = (GSList **) user_data; for (list = *plug_in_defs; list; list = g_slist_next (list)) { @@ -815,13 +814,12 @@ plug_ins_init_file (GimpDatafileData *file_data) plug_in_name = g_path_get_basename (plug_in_def->prog); - if (g_ascii_strcasecmp (basename, plug_in_name) == 0) + if (g_ascii_strcasecmp (file_data->basename, plug_in_name) == 0) { g_print ("skipping duplicate plug-in: \"%s\"\n", file_data->filename); g_free (plug_in_name); - g_free (basename); return; } @@ -829,8 +827,6 @@ plug_ins_init_file (GimpDatafileData *file_data) g_free (plug_in_name); } - g_free (basename); - plug_in_def = plug_in_def_new (file_data->filename); plug_in_def_set_mtime (plug_in_def, file_data->mtime); diff --git a/libgimp/gimpmiscui.c b/libgimp/gimpmiscui.c index eca28a6080..731039854c 100644 --- a/libgimp/gimpmiscui.c +++ b/libgimp/gimpmiscui.c @@ -509,45 +509,41 @@ gimp_fixme_preview_fill_scaled (GimpFixMePreview *preview, preview->height = GTK_PREVIEW (preview->widget)->buffer_height; } -GList * -gimp_plug_in_parse_path (const gchar *path_name, - const gchar *dir_name) +gchar * +gimp_plug_in_get_path (const gchar *path_name, + const gchar *dir_name) { - GList *path_list = NULL; gchar *path; + g_return_val_if_fail (path_name != NULL, NULL); + g_return_val_if_fail (dir_name != NULL, NULL); + path = gimp_gimprc_query (path_name); - if (!path) + if (! path) { gchar *gimprc = gimp_personal_rc_file ("gimprc"); gchar *full_path; gchar *esc_path; - full_path = g_strconcat - ("${gimp_dir}", G_DIR_SEPARATOR_S, dir_name, - G_SEARCHPATH_SEPARATOR_S, - "${gimp_data_dir}", G_DIR_SEPARATOR_S, dir_name, - NULL); + full_path = + g_strconcat ("${gimp_dir}", G_DIR_SEPARATOR_S, dir_name, + G_SEARCHPATH_SEPARATOR_S, + "${gimp_data_dir}", G_DIR_SEPARATOR_S, dir_name, + NULL); esc_path = g_strescape (full_path, NULL); + g_free (full_path); g_message (_("No %s in gimprc:\n" "You need to add an entry like\n" "(%s \"%s\")\n" - "to your %s file."), path_name, path_name, esc_path, - gimprc); + "to your %s file."), + path_name, path_name, esc_path, gimprc); g_free (gimprc); - g_free (full_path); g_free (esc_path); - - return NULL; } - path_list = gimp_path_parse (path, 16, TRUE, NULL); - - g_free (path); - - return path_list; + return path; } diff --git a/libgimp/gimpmiscui.h b/libgimp/gimpmiscui.h index ead317d3ab..01d8ade759 100644 --- a/libgimp/gimpmiscui.h +++ b/libgimp/gimpmiscui.h @@ -94,7 +94,7 @@ void gimp_fixme_preview_get_pixel (GimpFixMePreview *preview, gint y, guchar *pixel); -GList * gimp_plug_in_parse_path (const gchar *path_name, +gchar * gimp_plug_in_get_path (const gchar *path_name, const gchar *dir_name); diff --git a/libgimpbase/gimpbasetypes.h b/libgimpbase/gimpbasetypes.h index 32d7fea488..daf390ae20 100644 --- a/libgimpbase/gimpbasetypes.h +++ b/libgimpbase/gimpbasetypes.h @@ -33,7 +33,8 @@ typedef struct _GimpParasite GimpParasite; typedef struct _GimpDatafileData GimpDatafileData; -typedef void (* GimpDatafileLoaderFunc) (GimpDatafileData *file_data); +typedef void (* GimpDatafileLoaderFunc) (const GimpDatafileData *file_data, + gpointer user_data); typedef enum diff --git a/libgimpbase/gimpdatafiles.c b/libgimpbase/gimpdatafiles.c index 495e31f60e..cf4b636a59 100644 --- a/libgimpbase/gimpdatafiles.c +++ b/libgimpbase/gimpdatafiles.c @@ -131,24 +131,22 @@ gimp_datafiles_read_directories (const gchar *path_str, g_return_if_fail (path_str != NULL); g_return_if_fail (loader_func != NULL); - file_data.user_data = user_data; - local_path = g_strdup (path_str); -#ifdef __EMX__ - /* - * Change drive so opendir works. - */ - if (local_path[1] == ':') - { - _chdrive (local_path[0]); - } -#endif - path = gimp_path_parse (local_path, 16, TRUE, NULL); for (list = path; list; list = g_list_next (list)) { +#ifdef __EMX__ + /* + * Change drive so opendir works. + */ + if (((gchar *) list->data)[1] == ':') + { + _chdrive (((gchar *) list->data)[0]); + } +#endif + dir = g_dir_open ((gchar *) list->data, 0, NULL); if (dir) @@ -158,10 +156,10 @@ gimp_datafiles_read_directories (const gchar *path_str, filename = g_build_filename ((gchar *) list->data, dir_ent, NULL); - /* Check the file and see that it is not a sub-directory */ err = stat (filename, &filestat); file_data.filename = filename; + file_data.basename = dir_ent; file_data.atime = filestat.st_atime; file_data.mtime = filestat.st_mtime; file_data.ctime = filestat.st_ctime; @@ -170,23 +168,23 @@ gimp_datafiles_read_directories (const gchar *path_str, { if (flags & G_FILE_TEST_EXISTS) { - (* loader_func) (&file_data); + (* loader_func) (&file_data, user_data); } else if ((flags & G_FILE_TEST_IS_REGULAR) && S_ISREG (filestat.st_mode)) { - (* loader_func) (&file_data); + (* loader_func) (&file_data, user_data); } else if ((flags & G_FILE_TEST_IS_DIR) && S_ISDIR (filestat.st_mode)) { - (* loader_func) (&file_data); + (* loader_func) (&file_data, user_data); } #ifndef G_OS_WIN32 else if ((flags & G_FILE_TEST_IS_SYMLINK) && S_ISLNK (filestat.st_mode)) { - (* loader_func) (&file_data); + (* loader_func) (&file_data, user_data); } #endif else if ((flags & G_FILE_TEST_IS_EXECUTABLE) && @@ -195,7 +193,7 @@ gimp_datafiles_read_directories (const gchar *path_str, (S_ISREG (filestat.st_mode) && is_script (filename)))) { - (* loader_func) (&file_data); + (* loader_func) (&file_data, user_data); } } diff --git a/libgimpbase/gimpdatafiles.h b/libgimpbase/gimpdatafiles.h index 6b36ed38d3..bde6f4e38d 100644 --- a/libgimpbase/gimpdatafiles.h +++ b/libgimpbase/gimpdatafiles.h @@ -28,12 +28,11 @@ struct _GimpDatafileData { const gchar *filename; + const gchar *basename; time_t atime; time_t mtime; time_t ctime; - - gpointer user_data; }; diff --git a/libgimpmodule/gimpmoduledb.c b/libgimpmodule/gimpmoduledb.c index 5bafa04a6c..9a37655beb 100644 --- a/libgimpmodule/gimpmoduledb.c +++ b/libgimpmodule/gimpmoduledb.c @@ -56,7 +56,8 @@ static void gimp_module_db_init (GimpModuleDB *db); static void gimp_module_db_finalize (GObject *object); -static void gimp_module_db_module_initialize (GimpDatafileData *file_data); +static void gimp_module_db_module_initialize (const GimpDatafileData *file_data, + gpointer user_data); static GimpModule * gimp_module_db_module_find_by_path (GimpModuleDB *db, const char *fullpath); @@ -389,13 +390,14 @@ valid_module_name (const gchar *filename) } static void -gimp_module_db_module_initialize (GimpDatafileData *file_data) +gimp_module_db_module_initialize (const GimpDatafileData *file_data, + gpointer user_data) { GimpModuleDB *db; GimpModule *module; gboolean load_inhibit; - db = GIMP_MODULE_DB (file_data->user_data); + db = GIMP_MODULE_DB (user_data); if (! valid_module_name (file_data->filename)) return; diff --git a/plug-ins/FractalExplorer/Dialogs.c b/plug-ins/FractalExplorer/Dialogs.c index a7d5758504..00e54f2d7a 100644 --- a/plug-ins/FractalExplorer/Dialogs.c +++ b/plug-ins/FractalExplorer/Dialogs.c @@ -276,7 +276,8 @@ explorer_dialog (void) gimp_ui_init ("fractalexplorer", TRUE); - plug_in_parse_fractalexplorer_path (); + fractalexplorer_path = gimp_plug_in_get_path ("fractalexplorer-path", + "fractalexplorer"); wint.wimage = g_new (guchar, preview_width * preview_height * 3); elements = g_new (DialogElements, 1); @@ -1743,11 +1744,14 @@ create_file_selection (void) { gtk_file_selection_set_filename (GTK_FILE_SELECTION (window), tpath); } - else if (fractalexplorer_path_list) + else if (fractalexplorer_path) { + GList *path_list; gchar *dir; - dir = gimp_path_get_user_writable_dir (fractalexplorer_path_list); + path_list = gimp_path_parse (fractalexplorer_path, 16, FALSE, NULL); + + dir = gimp_path_get_user_writable_dir (path_list); if (!dir) dir = g_strdup (gimp_directory ()); @@ -1755,6 +1759,7 @@ create_file_selection (void) gtk_file_selection_set_filename (GTK_FILE_SELECTION (window), dir); g_free (dir); + gimp_path_free (path_list); } else { diff --git a/plug-ins/FractalExplorer/FractalExplorer.c b/plug-ins/FractalExplorer/FractalExplorer.c index 20af88b8f2..83cfa704f2 100644 --- a/plug-ins/FractalExplorer/FractalExplorer.c +++ b/plug-ins/FractalExplorer/FractalExplorer.c @@ -151,7 +151,7 @@ static void fractalexplorer_list_free_all (void); static fractalexplorerOBJ * fractalexplorer_load (const gchar *filename, const gchar *name); -static void fractalexplorer_list_load_all (GList *plist); +static void fractalexplorer_list_load_all (const gchar *path); static void fractalexplorer_rescan_ok_callback (GtkWidget *widget, gpointer data); static void fractalexplorer_rescan_list (void); @@ -1113,13 +1113,6 @@ list_button_press (GtkWidget *widget, return FALSE; } -void -plug_in_parse_fractalexplorer_path (void) -{ - fractalexplorer_path_list = - gimp_plug_in_parse_path ("fractalexplorer-path", "fractalexplorer"); -} - static void fractalexplorer_free (fractalexplorerOBJ *fractalexplorer) { @@ -1208,59 +1201,39 @@ fractalexplorer_load (const gchar *filename, } static void -fractalexplorer_list_load_all (GList *plist) +fractalexplorer_list_load_one (const GimpDatafileData *file_data, + gpointer user_data) { fractalexplorerOBJ *fractalexplorer; - GList *list; - gchar *path; - gchar *filename; - GDir *dir; - const gchar *dir_ent; + fractalexplorer = fractalexplorer_load (file_data->filename, + file_data->basename); + + if (fractalexplorer) + { + /* Read only ?*/ + if (access (filename, W_OK)) + fractalexplorer->obj_status |= fractalexplorer_READONLY; + + fractalexplorer_list_insert (fractalexplorer); + } +} + +static void +fractalexplorer_list_load_all (const gchar *path) +{ /* Make sure to clear any existing fractalexplorers */ current_obj = pic_obj = NULL; fractalexplorer_list_free_all (); - list = plist; - while (list) + + gimp_datafiles_read_directories (path, G_FILE_TEST_IS_REGULAR, + fractalexplorer_list_load_one, + NULL); + + if (! fractalexplorer_list) { - path = list->data; - list = list->next; + fractalexplorerOBJ *fractalexplorer; - /* Open directory */ - dir = g_dir_open (path, 0, NULL); - - if (!dir) - { - g_warning ("error reading fractalexplorer folder \"%s\"", path); - } - else - { - while ((dir_ent = g_dir_read_name (dir))) - { - filename = g_build_filename (path, dir_ent, NULL); - - if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) - { - fractalexplorer = fractalexplorer_load (filename, dir_ent); - - if (fractalexplorer) - { - /* Read only ?*/ - if (access (filename, W_OK)) - fractalexplorer->obj_status |= fractalexplorer_READONLY; - - fractalexplorer_list_insert (fractalexplorer); - } - } - - g_free (filename); - } - g_dir_close (dir); - } - } - - if (!fractalexplorer_list) - { /* lets have at least one! */ fractalexplorer = fractalexplorer_new (); fractalexplorer->draw_name = g_strdup (_("My first fractal")); @@ -1306,7 +1279,7 @@ add_objects_list (void) list); gtk_widget_show (list); - fractalexplorer_list_load_all (fractalexplorer_path_list); + fractalexplorer_list_load_all (fractalexplorer_path); build_list_items (list); /* Put buttons in */ @@ -1342,26 +1315,20 @@ fractalexplorer_rescan_ok_callback (GtkWidget *widget, gpointer data) { GtkWidget *patheditor; - gchar *raw_path; gtk_widget_set_sensitive (GTK_WIDGET (data), FALSE); - gimp_path_free (fractalexplorer_path_list); - fractalexplorer_path_list = NULL; - patheditor = GTK_WIDGET (g_object_get_data (G_OBJECT (data), "patheditor")); - raw_path = gimp_path_editor_get_path (GIMP_PATH_EDITOR (patheditor)); + g_free (fractalexplorer_path); + fractalexplorer_path = + gimp_path_editor_get_path (GIMP_PATH_EDITOR (patheditor)); - fractalexplorer_path_list = gimp_path_parse (raw_path, 16, FALSE, NULL); - - g_free (raw_path); - - if (fractalexplorer_path_list) + if (fractalexplorer_path) { gtk_list_clear_items (GTK_LIST (fractalexplorer_gtk_list), 0, -1); - fractalexplorer_list_load_all (fractalexplorer_path_list); + fractalexplorer_list_load_all (fractalexplorer_path); build_list_items (fractalexplorer_gtk_list); list_button_update (current_obj); } @@ -1375,7 +1342,6 @@ fractalexplorer_rescan_list (void) static GtkWidget *dlg = NULL; GtkWidget *patheditor; - gchar *path; if (dlg) { @@ -1400,16 +1366,13 @@ fractalexplorer_rescan_list (void) G_CALLBACK (gtk_widget_destroyed), &dlg); - path = gimp_path_to_str (fractalexplorer_path_list); - - patheditor = gimp_path_editor_new (_("Add FractalExplorer Path"), path); + patheditor = gimp_path_editor_new (_("Add FractalExplorer Path"), + fractalexplorer_path); gtk_container_set_border_width (GTK_CONTAINER (patheditor), 6); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), patheditor, TRUE, TRUE, 0); gtk_widget_show (patheditor); - g_free (path); - g_object_set_data (G_OBJECT (dlg), "patheditor", patheditor); gtk_widget_show (dlg); diff --git a/plug-ins/FractalExplorer/FractalExplorer.h b/plug-ins/FractalExplorer/FractalExplorer.h index a9e2fb2bf6..9fa528d2e5 100644 --- a/plug-ins/FractalExplorer/FractalExplorer.h +++ b/plug-ins/FractalExplorer/FractalExplorer.h @@ -163,27 +163,26 @@ extern fractalexplorerOBJ *current_obj; extern fractalexplorerOBJ *pic_obj; extern GtkWidget *delete_dialog; -GtkWidget * add_objects_list (void); -void plug_in_parse_fractalexplorer_path (void); +GtkWidget * add_objects_list (void); /********************************************************************** Global variables *********************************************************************/ -extern double xmin, - xmax, - ymin, - ymax; -extern double xbild, - ybild, - xdiff, - ydiff; -extern double x_press, - y_press; -extern double x_release, - y_release; -extern float cx; -extern float cy; +extern gdouble xmin; +extern gdouble xmax; +extern gdouble ymin; +extern gdouble ymax; +extern gdouble xbild; +extern gdouble ybild; +extern gdouble xdiff; +extern gdouble ydiff; +extern gdouble x_press; +extern gdouble y_press; +extern gdouble x_release; +extern gdouble y_release; +extern gfloat cx; +extern gfloat cy; extern GimpDrawable *drawable; extern gint tile_width, tile_height; @@ -224,7 +223,7 @@ extern gdouble *gg; extern int line_no; extern gchar *filename; extern clrmap colormap; -extern GList *fractalexplorer_path_list; +extern gchar *fractalexplorer_path; extern GList *fractalexplorer_list; extern GList *gradient_list; extern gchar *tpath; diff --git a/plug-ins/FractalExplorer/Globals.c b/plug-ins/FractalExplorer/Globals.c index bdab8163d7..bd98803851 100644 --- a/plug-ins/FractalExplorer/Globals.c +++ b/plug-ins/FractalExplorer/Globals.c @@ -10,41 +10,41 @@ Global variables *********************************************************************/ -double xmin = -2, - xmax = 1, - ymin = -1.5, - ymax = 1.5; -double xbild, - ybild, - xdiff, - ydiff; -double x_press = -1.0, - y_press = -1.0; -double x_release = -1.0, - y_release = -1.0; -float cx = -0.75; -float cy = -0.2; +gdouble xmin = -2; +gdouble xmax = 1; +gdouble ymin = -1.5; +gdouble ymax = 1.5; +gdouble xbild; +gdouble ybild; +gdouble xdiff; +gdouble ydiff; +gdouble x_press = -1.0; +gdouble y_press = -1.0; +gdouble x_release = -1.0; +gdouble y_release = -1.0; +gfloat cx = -0.75; +gfloat cy = -0.2; GimpDrawable *drawable; -gint tile_width, - tile_height; -gint img_width, - img_height, - img_bpp; -gint sel_x1, - sel_y1, - sel_x2, - sel_y2; -gint sel_width, - sel_height; -gint preview_width, - preview_height; -GimpTile *the_tile = NULL; -double cen_x, - cen_y; -double xpos, - ypos, - oldxpos = -1, - oldypos = -1; +gint tile_width; +gint tile_height; +gint img_width; +gint img_height; +gint img_bpp; +gint sel_x1; +gint sel_y1; +gint sel_x2; +gint sel_y2; +gint sel_width; +gint sel_height; +gint preview_width; +gint preview_height; +GimpTile *the_tile = NULL; +gdouble cen_x; +gdouble cen_y; +gdouble xpos; +gdouble ypos; +gdouble oldxpos = -1; +gdouble oldypos = -1; GtkWidget *maindlg; GtkWidget *logodlg; GtkWidget *cmap_preview; @@ -53,19 +53,19 @@ GtkWidget *fractalexplorer_gtk_list; GtkWidget *save_menu_item; GtkWidget *fractalexplorer_op_menu; GdkCursor *MyCursor; -int ready_now = FALSE; +gboolean ready_now = FALSE; explorer_vals_t zooms[100]; DialogElements *elements = NULL; -int zoomindex = 1; -int zoommax = 1; +gint zoomindex = 1; +gint zoommax = 1; gdouble *gg; -int line_no; +gint line_no; gchar *filename; clrmap colormap; -GList *fractalexplorer_path_list = NULL; +gchar *fractalexplorer_path = NULL; GList *fractalexplorer_list = NULL; -GList *gradient_list = NULL; -gchar *tpath = NULL; +GList *gradient_list = NULL; +gchar *tpath = NULL; fractalexplorerOBJ *fractalexplorer_obj_for_menu; GList *rescan_list = NULL; diff --git a/plug-ins/gfig/gfig.c b/plug-ins/gfig/gfig.c index 64440753ca..3d95e71a43 100644 --- a/plug-ins/gfig/gfig.c +++ b/plug-ins/gfig/gfig.c @@ -416,8 +416,8 @@ struct selection_option }; -static GList *gfig_path_list = NULL; -static GList *gfig_list = NULL; +static gchar *gfig_path = NULL; +static GList *gfig_list = NULL; static gint line_no; static gint poly_num_sides = 3; /* Default to three sided object */ @@ -900,61 +900,39 @@ gfig_list_free_all (void) gfig_list = NULL; } +static void +gfig_list_load_one (const GimpDatafileData *file_data, + gpointer user_data) +{ + GFigObj *gfig; + + gfig = gfig_load (file_data->filename, file_data->basename); + + if (gfig) + { + /* Read only ?*/ + if (access (file_data->filename, W_OK)) + gfig->obj_status |= GFIG_READONLY; + + gfig_list_insert (gfig); + } +} static void -gfig_list_load_all (GList *plist) +gfig_list_load_all (const gchar *path) { - GFigObj *gfig; - GList *list; - gchar *path; - gchar *filename; - GDir *dir; - const gchar *dir_ent; - /* Make sure to clear any existing gfigs */ current_obj = pic_obj = NULL; gfig_list_free_all (); - list = plist; - while (list) + gimp_datafiles_read_directories (path, G_FILE_TEST_EXISTS, + gfig_list_load_one, + NULL); + + if (! gfig_list) { - path = list->data; - list = list->next; + GFigObj *gfig; - /* Open directory */ - dir = g_dir_open (path, 0, NULL); - - if (!dir) - g_warning ("Error reading Gfig folder \"%s\"", path); - else - { - while ((dir_ent = g_dir_read_name (dir))) - { - filename = g_build_filename (path, dir_ent, NULL); - - /* Check the file and see that it is not a sub-directory */ - if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) - { - gfig = gfig_load (filename, dir_ent); - - if (gfig) - { - /* Read only ?*/ - if (access (filename, W_OK)) - gfig->obj_status |= GFIG_READONLY; - - gfig_list_insert (gfig); - } - } - - g_free (filename); - } - g_dir_close (dir); - } - } - - if (!gfig_list) - { /* lets have at least one! */ gfig = gfig_new (); gfig->draw_name = g_strdup (_("First Gfig")); @@ -1472,13 +1450,16 @@ create_file_selection (GFigObj *obj, { gtk_file_selection_set_filename (GTK_FILE_SELECTION (window), tpath); } - else if (gfig_path_list) + else if (gfig_path) { + GList *list; gchar *dir; - dir = gimp_path_get_user_writable_dir (gfig_path_list); + list = gimp_path_parse (gfig_path, 16, FALSE, 0); + dir = gimp_path_get_user_writable_dir (list); + gimp_path_free (list); - if (!dir) + if (! dir) dir = g_strdup (gimp_directory ()); gtk_file_selection_set_filename (GTK_FILE_SELECTION (window), dir); @@ -1492,8 +1473,7 @@ create_file_selection (GFigObj *obj, gtk_file_selection_set_filename (GTK_FILE_SELECTION (window), tmp); } - if (!GTK_WIDGET_VISIBLE (window)) - gtk_widget_show (window); + gtk_window_present (GTK_WINDOW (window)); } static void @@ -3387,7 +3367,7 @@ add_objects_list (void) gtk_widget_show (list); /* Load saved objects */ - gfig_list_load_all (gfig_path_list); + gfig_list_load_all (gfig_path); /* Put list in */ build_list_items (list); @@ -3760,7 +3740,7 @@ gfig_dialog (void) xxx = gdk_rgb_get_colormap (); - gfig_path_list = gimp_plug_in_parse_path ("gfig-path", "gfig"); + gfig_path = gimp_plug_in_get_path ("gfig-path", "gfig"); /*cache_preview (); Get the preview image and store it also set has_alpha */ @@ -4272,26 +4252,19 @@ gfig_rescan_ok_callback (GtkWidget *widget, gpointer data) { GtkWidget *patheditor; - gchar *raw_path; gtk_widget_set_sensitive (GTK_WIDGET (data), FALSE); - gimp_path_free (gfig_path_list); - gfig_path_list = NULL; - patheditor = GTK_WIDGET (g_object_get_data (G_OBJECT (data), "patheditor")); - raw_path = gimp_path_editor_get_path (GIMP_PATH_EDITOR (patheditor)); + g_free (gfig_path); + gfig_path = gimp_path_editor_get_path (GIMP_PATH_EDITOR (patheditor)); - gfig_path_list = gimp_path_parse (raw_path, 16, FALSE, NULL); - - g_free (raw_path); - - if (gfig_path_list) + if (gfig_path) { clear_list_items (GTK_LIST (gfig_gtk_list)); - gfig_list_load_all (gfig_path_list); + gfig_list_load_all (gfig_path); build_list_items (gfig_gtk_list); list_button_update (current_obj); } @@ -4305,7 +4278,6 @@ gfig_rescan_list (void) static GtkWidget *dlg = NULL; GtkWidget *patheditor; - gchar *path; if (dlg) { @@ -4331,16 +4303,12 @@ gfig_rescan_list (void) G_CALLBACK (gtk_widget_destroyed), &dlg); - path = gimp_path_to_str (gfig_path_list); - - patheditor = gimp_path_editor_new (_("Add Gfig Path"), path); + patheditor = gimp_path_editor_new (_("Add Gfig Path"), gfig_path); gtk_container_set_border_width (GTK_CONTAINER (patheditor), 6); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), patheditor, TRUE, TRUE, 0); gtk_widget_show (patheditor); - g_free (path); - g_object_set_data (G_OBJECT (dlg), "patheditor", patheditor); gtk_widget_show (dlg); diff --git a/plug-ins/gflare/gflare.c b/plug-ins/gflare/gflare.c index 101df8c8a9..878676b6ac 100644 --- a/plug-ins/gflare/gflare.c +++ b/plug-ins/gflare/gflare.c @@ -586,8 +586,8 @@ static GimpPixelFetcher *tk_write; static GFlareDialog *dlg = NULL; static GFlareEditor *ed = NULL; static GList *gflares_list = NULL; -static gint num_gflares = 0; -static GList *gflare_path_list = NULL; +static gint num_gflares = 0; +static gchar *gflare_path = NULL; static CalcParams calc; static GList *gradient_menus; static gchar **gradient_names = NULL; @@ -824,13 +824,13 @@ plugin_query (void) { GIMP_PDB_FLOAT, "asupsample_threshold", "Threshold for adaptive supersampling"} }; - gchar *help_string = - " This plug-in produces a lense flare effect using custom gradients." - " In interactive call, the user can edit his/her own favorite lense flare" - " (GFlare) and render it. Edited gflare is saved automatically to" - " the folder in gflare-path, if it is defined in gimprc." - " In non-interactive call, the user can only render one of GFlare" - " which has been stored in gflare-path already."; + const gchar *help_string = + "This plug-in produces a lense flare effect using custom gradients. " + "In interactive call, the user can edit his/her own favorite lense flare " + "(GFlare) and render it. Edited gflare is saved automatically to " + "the folder in gflare-path, if it is defined in gimprc. " + "In non-interactive call, the user can only render one of GFlare " + "which has been stored in gflare-path already."; gimp_install_procedure ("plug_in_gflare", "Produce lense flare effect using custom gradients", @@ -890,8 +890,7 @@ plugin_run (const gchar *name, * Parse gflare path from gimprc and load gflares */ - gflare_path_list = - gimp_plug_in_parse_path ("gflare-path", "gflare"); + gflare_path = gimp_plug_in_get_path ("gflare-path", "gflare"); gflares_list_load_all (); gimp_tile_cache_ntiles (drawable->width / gimp_tile_width () + 2); @@ -1185,11 +1184,13 @@ plugin_progress_func (gint y1, */ static GFlare * -gflare_new () +gflare_new (void) { GFlare *gflare = g_new0 (GFlare, 1); - gflare->name = NULL; + + gflare->name = NULL; gflare->filename = NULL; + return gflare; } @@ -1200,7 +1201,8 @@ gflare_new_with_default (const gchar *new_name) } static GFlare * -gflare_dup (const GFlare *src, const gchar *new_name) +gflare_dup (const GFlare *src, + const gchar *new_name) { GFlare *dest = g_new0 (GFlare, 1); @@ -1213,7 +1215,8 @@ gflare_dup (const GFlare *src, const gchar *new_name) } static void -gflare_copy (GFlare *dest, const GFlare *src) +gflare_copy (GFlare *dest, + const GFlare *src) { gchar *name, *filename; @@ -1238,7 +1241,8 @@ gflare_free (GFlare *gflare) } GFlare * -gflare_load (const gchar *filename, const gchar *name) +gflare_load (const gchar *filename, + const gchar *name) { FILE *fp; GFlareFile *gf; @@ -1323,7 +1327,8 @@ gflare_load (const gchar *filename, const gchar *name) } static void -gflare_read_int (gint *intvar, GFlareFile *gf) +gflare_read_int (gint *intvar, + GFlareFile *gf) { if (gf->error) return; @@ -1333,7 +1338,8 @@ gflare_read_int (gint *intvar, GFlareFile *gf) } static void -gflare_read_double (gdouble *dblvar, GFlareFile *gf) +gflare_read_double (gdouble *dblvar, + GFlareFile *gf) { gchar buf[30]; @@ -1421,33 +1427,41 @@ gflare_save (GFlare *gflare) if (gflare->filename == NULL) { - if (gflare_path_list == NULL) + GList *list; + + if (gflare_path == NULL) { - if (!message_ok) + if (! message_ok) { - gchar *gimprc = gimp_personal_rc_file ("gimprc"); - gchar *gflare_path = g_strescape - ("${gimp_dir}" G_DIR_SEPARATOR_S "gflare", - NULL); - gchar *dir = gimp_personal_rc_file ("gflare"); + gchar *gimprc = gimp_personal_rc_file ("gimprc"); + gchar *dir = gimp_personal_rc_file ("gflare"); + gchar *gflare_dir; + + gflare_dir = + g_strescape ("${gimp_dir}" G_DIR_SEPARATOR_S "gflare", NULL); g_message (_("GFlare `%s' is not saved.\n" "If you add a new entry in %s, like:\n" "(gflare-path \"%s\")\n" "and make a folder %s,\n" - "then you can save your own GFlare's into that folder."), - gflare->name, gimprc, gflare_path, dir); + "then you can save your own GFlares into that folder."), + gflare->name, gimprc, gflare_dir, dir); + g_free (gimprc); - g_free (gflare_path); + g_free (gflare_dir); g_free (dir); + message_ok = TRUE; } + return; } - path = gimp_path_get_user_writable_dir (gflare_path_list); + list = gimp_path_parse (gflare_path, 16, FALSE, NULL); + path = gimp_path_get_user_writable_dir (list); + gimp_path_free (list); - if (!path) + if (! path) path = g_strdup (gimp_directory ()); gflare->filename = g_build_filename (path, gflare->name, NULL); @@ -1502,7 +1516,8 @@ gflare_save (GFlare *gflare) } static void -gflare_write_gradient_name (GradientName name, FILE *fp) +gflare_write_gradient_name (GradientName name, + FILE *fp) { gchar enc[1024]; @@ -1515,7 +1530,8 @@ gflare_write_gradient_name (GradientName name, FILE *fp) } static void -gflare_name_copy (gchar *dest, const gchar *src) +gflare_name_copy (gchar *dest, + const gchar *src) { strncpy (dest, src, GFLARE_NAME_MAX); dest[GFLARE_NAME_MAX-1] = '\0'; @@ -1528,7 +1544,8 @@ gflare_name_copy (gchar *dest, const gchar *src) /*************************************************************************/ static gint -gflare_compare (const GFlare *flare1, const GFlare *flare2) +gflare_compare (const GFlare *flare1, + const GFlare *flare2) { return strcmp (flare1->name, flare2->name); } @@ -1543,7 +1560,8 @@ gflares_list_insert (GFlare *gflare) } static gint -gflare_compare_name (const GFlare *flare, const gchar *name) +gflare_compare_name (const GFlare *flare, + const gchar *name) { return strcmp (flare->name, name); } @@ -1590,50 +1608,27 @@ gflares_list_remove (GFlare *gflare) /* * Load all gflares, which are founded in gflare-path-list, into gflares_list. */ +static void +gflares_list_load_one (const GimpDatafileData *file_data, + gpointer user_data) +{ + GFlare *gflare; + + gflare = gflare_load (file_data->filename, file_data->basename); + + if (gflare) + gflares_list_insert (gflare); +} + static void gflares_list_load_all (void) { - GFlare *gflare; - GList *list; - gchar *path; - gchar *filename; - GDir *dir; - const gchar *dir_ent; - /* Make sure to clear any existing gflares */ gflares_list_free_all (); - list = gflare_path_list; - while (list) - { - path = list->data; - list = list->next; - - /* Open directory */ - dir = g_dir_open (path, 0, NULL); - - if (!dir) - g_message (_("Error reading GFlare folder '%s'"), path); - else - { - while ((dir_ent = g_dir_read_name (dir))) - { - filename = g_build_filename (path, dir_ent, NULL); - - /* Check the file and see that it is not a sub-directory */ - if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) - { - gflare = gflare_load (filename, dir_ent); - if (gflare) - gflares_list_insert (gflare); - } - - g_free (filename); - } /* while */ - - g_dir_close (dir); - } /* else */ - } + gimp_datafiles_read_directories (gflare_path, G_FILE_TEST_EXISTS, + gflares_list_load_one, + NULL); } static void @@ -1660,29 +1655,34 @@ gflares_list_free_all (void) */ static void -calc_init_params (GFlare *gflare, gint calc_type, - gdouble xcenter, gdouble ycenter, - gdouble radius, gdouble rotation, gdouble hue, - gdouble vangle, gdouble vlength) +calc_init_params (GFlare *gflare, + gint calc_type, + gdouble xcenter, + gdouble ycenter, + gdouble radius, + gdouble rotation, + gdouble hue, + gdouble vangle, + gdouble vlength) { - calc.type = calc_type; - calc.gflare = gflare; - calc.xcenter = xcenter; - calc.ycenter = ycenter; - calc.radius = radius; - calc.rotation = rotation * G_PI / 180.0; - calc.hue = hue; - calc.vangle = vangle * G_PI / 180.0; - calc.vlength = radius * vlength / 100.0; - calc.glow_radius = radius * gflare->glow_size / 100.0; - calc.rays_radius = radius * gflare->rays_size / 100.0; - calc.sflare_radius = radius * gflare->sflare_size / 100.0; - calc.glow_rotation = (rotation + gflare->glow_rotation) * G_PI / 180.0; - calc.rays_rotation = (rotation + gflare->rays_rotation) * G_PI / 180.0; + calc.type = calc_type; + calc.gflare = gflare; + calc.xcenter = xcenter; + calc.ycenter = ycenter; + calc.radius = radius; + calc.rotation = rotation * G_PI / 180.0; + calc.hue = hue; + calc.vangle = vangle * G_PI / 180.0; + calc.vlength = radius * vlength / 100.0; + calc.glow_radius = radius * gflare->glow_size / 100.0; + calc.rays_radius = radius * gflare->rays_size / 100.0; + calc.sflare_radius = radius * gflare->sflare_size / 100.0; + calc.glow_rotation = (rotation + gflare->glow_rotation) * G_PI / 180.0; + calc.rays_rotation = (rotation + gflare->rays_rotation) * G_PI / 180.0; calc.sflare_rotation = (rotation + gflare->sflare_rotation) * G_PI / 180.0; - calc.glow_opacity = gflare->glow_opacity * 255 / 100.0; - calc.rays_opacity = gflare->rays_opacity * 255 / 100.0; - calc.sflare_opacity = gflare->sflare_opacity * 255 / 100.0; + calc.glow_opacity = gflare->glow_opacity * 255 / 100.0; + calc.rays_opacity = gflare->rays_opacity * 255 / 100.0; + calc.sflare_opacity = gflare->sflare_opacity * 255 / 100.0; calc.glow_bounds.x0 = calc.xcenter - calc.glow_radius - 0.1; calc.glow_bounds.x1 = calc.xcenter + calc.glow_radius + 0.1; @@ -1694,9 +1694,9 @@ calc_init_params (GFlare *gflare, gint calc_type, calc.rays_bounds.y1 = calc.ycenter + calc.rays_radius + 0.1; /* Thanks to Marcelo Malheiros for this algorithm */ - calc.rays_thinness = log (gflare->rays_thickness / 100.0) / log(0.8); + calc.rays_thinness = log (gflare->rays_thickness / 100.0) / log(0.8); - calc.rays_spike_mod = 1.0 / (2 * gflare->rays_nspikes); + calc.rays_spike_mod = 1.0 / (2 * gflare->rays_nspikes); /* Initialize part of sflare @@ -1710,21 +1710,21 @@ calc_init_params (GFlare *gflare, gint calc_type, calc.sflare_factor = 1.0 / cos (calc.sflare_angle); } - calc.glow_radial = NULL; - calc.glow_angular = NULL; - calc.glow_angular_size = NULL; - calc.rays_radial = NULL; - calc.rays_angular = NULL; - calc.rays_angular_size = NULL; - calc.sflare_radial = NULL; - calc.sflare_sizefac = NULL; + calc.glow_radial = NULL; + calc.glow_angular = NULL; + calc.glow_angular_size = NULL; + calc.rays_radial = NULL; + calc.rays_angular = NULL; + calc.rays_angular_size = NULL; + calc.sflare_radial = NULL; + calc.sflare_sizefac = NULL; calc.sflare_probability = NULL; calc.init = TRUE; } static int -calc_init_progress () +calc_init_progress (void) { if (calc_sample_one_gradient ()) return TRUE; @@ -1737,7 +1737,7 @@ calc_init_progress () this routine is called during Calc initialization this code is very messy... :( */ static int -calc_sample_one_gradient () +calc_sample_one_gradient (void) { static struct { guchar **values; @@ -1823,7 +1823,7 @@ calc_sample_one_gradient () } static void -calc_place_sflare () +calc_place_sflare (void) { GFlare *gflare; CalcSFlare *sflare; @@ -1894,7 +1894,7 @@ calc_place_sflare () } static void -calc_deinit () +calc_deinit (void) { if (!calc.init) { @@ -1931,7 +1931,7 @@ calc_deinit () * guchar pix[4] */ static void -calc_get_gradient(guchar *pix, guchar *gradient, gdouble pos) +calc_get_gradient (guchar *pix, guchar *gradient, gdouble pos) { gint ipos; gdouble frac; @@ -2475,7 +2475,8 @@ ed_preview_calc_window (void) } static gboolean -dlg_preview_handle_event (GtkWidget *widget, GdkEvent *event) +dlg_preview_handle_event (GtkWidget *widget, + GdkEvent *event) { GdkEventButton *bevent; gint bx, by, x, y; @@ -2517,7 +2518,7 @@ dlg_preview_handle_event (GtkWidget *widget, GdkEvent *event) } static void -dlg_preview_update () +dlg_preview_update (void) { if (!dlg->init && dlg->update_preview) { @@ -3905,7 +3906,7 @@ ed_put_gradient_menu (GtkWidget *table, gchar *caption, GradientMenu *gm) { - GtkWidget *label; + GtkWidget *label; label = gtk_label_new (caption); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); @@ -3924,9 +3925,10 @@ ed_put_gradient_menu (GtkWidget *table, } static void -ed_mode_menu_callback (GtkWidget *widget, gpointer data) +ed_mode_menu_callback (GtkWidget *widget, + gpointer data) { - GFlareMode *mode_var; + GFlareMode *mode_var; mode_var = data; *mode_var = (GFlareMode) gtk_object_get_user_data (GTK_OBJECT (widget)); @@ -3935,7 +3937,8 @@ ed_mode_menu_callback (GtkWidget *widget, gpointer data) } static void -ed_gradient_menu_callback (const gchar *gradient_name, gpointer data) +ed_gradient_menu_callback (const gchar *gradient_name, + gpointer data) { gchar *dest_string = data; @@ -3954,9 +3957,10 @@ ed_shape_radio_callback (GtkWidget *widget, } static void -ed_ientry_callback (GtkWidget *widget, gpointer data) +ed_ientry_callback (GtkWidget *widget, + gpointer data) { - gint new_val; + gint new_val; new_val = atoi (gtk_entry_get_text (GTK_ENTRY (widget))); *(gint *)data = new_val; @@ -3969,9 +3973,10 @@ ed_ientry_callback (GtkWidget *widget, gpointer data) signal of changing pages of gtknotebook. */ static void -ed_page_map_callback (GtkWidget *widget, gpointer data) +ed_page_map_callback (GtkWidget *widget, + gpointer data) { - gint page_num = GPOINTER_TO_INT (data); + gint page_num = GPOINTER_TO_INT (data); DEBUG_PRINT(("ed_page_map_callback\n")); @@ -3981,7 +3986,7 @@ ed_page_map_callback (GtkWidget *widget, gpointer data) static void -ed_preview_update () +ed_preview_update (void) { if (ed->init) return; diff --git a/plug-ins/script-fu/script-fu-interface.c b/plug-ins/script-fu/script-fu-interface.c index 58578c461d..d3a34c0477 100644 --- a/plug-ins/script-fu/script-fu-interface.c +++ b/plug-ins/script-fu/script-fu-interface.c @@ -141,7 +141,8 @@ extern long nlength (LISP obj); * Local Functions */ -static void script_fu_load_script (GimpDatafileData *file_data); +static void script_fu_load_script (const GimpDatafileData *file_data, + gpointer user_data); static gboolean script_fu_install_script (gpointer foo, SFScript *script, gpointer bar); @@ -660,7 +661,8 @@ script_fu_report_cc (gchar *command) /* private functions */ static void -script_fu_load_script (GimpDatafileData *file_data) +script_fu_load_script (const GimpDatafileData *file_data, + gpointer user_data) { if (gimp_datafiles_check_extension (file_data->filename, ".scm")) { diff --git a/plug-ins/script-fu/script-fu-scripts.c b/plug-ins/script-fu/script-fu-scripts.c index 58578c461d..d3a34c0477 100644 --- a/plug-ins/script-fu/script-fu-scripts.c +++ b/plug-ins/script-fu/script-fu-scripts.c @@ -141,7 +141,8 @@ extern long nlength (LISP obj); * Local Functions */ -static void script_fu_load_script (GimpDatafileData *file_data); +static void script_fu_load_script (const GimpDatafileData *file_data, + gpointer user_data); static gboolean script_fu_install_script (gpointer foo, SFScript *script, gpointer bar); @@ -660,7 +661,8 @@ script_fu_report_cc (gchar *command) /* private functions */ static void -script_fu_load_script (GimpDatafileData *file_data) +script_fu_load_script (const GimpDatafileData *file_data, + gpointer user_data) { if (gimp_datafiles_check_extension (file_data->filename, ".scm")) {