mirror of https://github.com/GNOME/gimp.git
fixed some issues (mainly coding style) with the new load and save
2003-02-02 Sven Neumann <sven@gimp.org> * plug-ins/ifscompose/ifscompose.c: fixed some issues (mainly coding style) with the new load and save routines.
This commit is contained in:
parent
76e8bf6a6a
commit
0b90802f3b
|
@ -1,3 +1,8 @@
|
|||
2003-02-02 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/ifscompose/ifscompose.c: fixed some issues (mainly
|
||||
coding style) with the new load and save routines.
|
||||
|
||||
2003-02-02 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/ifscompose/ifscompose.c: applied a large patch from
|
||||
|
|
4
NEWS
4
NEWS
|
@ -14,6 +14,8 @@ Overview of Changes in GIMP 1.3.12
|
|||
- Lots of text tool changes [Sven]
|
||||
- Factored common code out of a number of plug-ins [Maurits]
|
||||
- Cleaned up and improved the code that handles the plug-ins [Mitch]
|
||||
- Finished colorblindness display filter using the algorithm contributed
|
||||
by Alex Wade and Robert Dougherty.
|
||||
- Updated the gimprc man-page, or actually, wrote a tool that does it [Sven]
|
||||
- Improved the code that handles all the menus [Mitch]
|
||||
- Added new PSD save plug-in [Bolsh]
|
||||
|
@ -28,7 +30,7 @@ Overview of Changes in GIMP 1.3.12
|
|||
|
||||
Other contributors:
|
||||
Garry R. Osgood, Jakub Steiner, Simon Budig, Henrik Brix Andersen,
|
||||
Akkana, Carol Spears, Seth Burgess, Nathan Summers
|
||||
Akkana, Carol Spears, Seth Burgess, Nathan Summers, David Necas
|
||||
|
||||
|
||||
Overview of Changes in GIMP 1.3.11
|
||||
|
|
|
@ -288,7 +288,6 @@ static void ifs_compose_load_callback (GtkWidget *widget,
|
|||
gpointer data);
|
||||
static void ifs_compose_save_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void ifs_compose_ok_callback (GtkWidget *widget,
|
||||
GtkWidget *window);
|
||||
|
||||
|
@ -310,7 +309,6 @@ static gint undo_cur = -1;
|
|||
static gint undo_num = 0;
|
||||
static gint undo_start = 0;
|
||||
|
||||
static gchar ifsfile_path[PATH_MAX] = { '\0' };
|
||||
|
||||
/* num_elements = 0, signals not inited */
|
||||
static IfsComposeVals ifsvals =
|
||||
|
@ -2550,7 +2548,8 @@ ifs_compose_set_defaults (void)
|
|||
|
||||
gimp_palette_get_foreground (&color);
|
||||
|
||||
ifsvals.aspect_ratio = (gdouble)ifsD->drawable_height / ifsD->drawable_width;
|
||||
ifsvals.aspect_ratio =
|
||||
(gdouble)ifsD->drawable_height / ifsD->drawable_width;
|
||||
|
||||
for (i = 0; i < ifsvals.num_elements; i++)
|
||||
aff_element_free (elements[i]);
|
||||
|
@ -2622,16 +2621,20 @@ ifs_compose_defaults_callback (GtkWidget *widget,
|
|||
}
|
||||
|
||||
/* show a transient message dialog */
|
||||
void
|
||||
ifscompose_message_dialog (GtkMessageType type, GtkWindow *parent,
|
||||
gchar *title, gchar *message)
|
||||
static void
|
||||
ifscompose_message_dialog (GtkMessageType type,
|
||||
GtkWindow *parent,
|
||||
const gchar *title,
|
||||
const gchar *message)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
|
||||
dlg = gtk_message_dialog_new (parent, 0, type, GTK_BUTTONS_OK, "%s", message);
|
||||
dlg = gtk_message_dialog_new (parent, 0, type, GTK_BUTTONS_OK, message);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dlg), parent);
|
||||
|
||||
if (title)
|
||||
gtk_window_set_title (GTK_WINDOW (dlg), title);
|
||||
|
||||
gtk_window_set_wmclass (GTK_WINDOW (dlg), "message", "Gimp");
|
||||
gtk_dialog_run (GTK_DIALOG (dlg));
|
||||
gtk_widget_destroy (dlg);
|
||||
|
@ -2639,24 +2642,29 @@ ifscompose_message_dialog (GtkMessageType type, GtkWindow *parent,
|
|||
|
||||
/* save an ifs file */
|
||||
static void
|
||||
ifsfile_save (GtkWidget *widget, GtkWidget *file_select)
|
||||
ifsfile_save (GtkWidget *widget,
|
||||
GtkWidget *file_select)
|
||||
{
|
||||
gchar *str = ifsvals_stringify (&ifsvals, elements);
|
||||
const gchar *filename;
|
||||
gchar *str;
|
||||
FILE *fh;
|
||||
|
||||
g_strlcpy (ifsfile_path,
|
||||
gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_select)),
|
||||
PATH_MAX);
|
||||
fh = fopen(ifsfile_path, "w");
|
||||
if (fh) {
|
||||
fputs(str, fh);
|
||||
fclose(fh);
|
||||
gtk_widget_destroy (file_select);
|
||||
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_select));
|
||||
|
||||
str = ifsvals_stringify (&ifsvals, elements);
|
||||
|
||||
fh = fopen (filename, "w");
|
||||
if (fh)
|
||||
{
|
||||
fputs (str, fh);
|
||||
fclose (fh);
|
||||
gtk_widget_hide (file_select);
|
||||
}
|
||||
else {
|
||||
gchar *message = g_strdup_printf (_("Cannot save into file `%s'.\n"
|
||||
"Check the path and permissions.\n"),
|
||||
ifsfile_path);
|
||||
else
|
||||
{
|
||||
gchar *message = g_strdup_printf (_("Cannot save file '%s'.\n"
|
||||
"Check the path and permissions."),
|
||||
filename);
|
||||
ifscompose_message_dialog (GTK_MESSAGE_ERROR, GTK_WINDOW (file_select),
|
||||
"Save failed", message);
|
||||
g_free (message);
|
||||
|
@ -2679,7 +2687,8 @@ ifsfile_replace_ifsvals (IfsComposeVals *new_ifsvals,
|
|||
|
||||
ifsvals = *new_ifsvals;
|
||||
elements = new_elements;
|
||||
for (i = 0; i < ifsvals.num_elements; i++) {
|
||||
for (i = 0; i < ifsvals.num_elements; i++)
|
||||
{
|
||||
aff_element_compute_trans (elements[i], width, height,
|
||||
ifsvals.center_x, ifsvals.center_y);
|
||||
aff_element_compute_color_trans (elements[i]);
|
||||
|
@ -2690,7 +2699,8 @@ ifsfile_replace_ifsvals (IfsComposeVals *new_ifsvals,
|
|||
for (i = 0; i < ifsvals.num_elements; i++)
|
||||
element_selected[i] = FALSE;
|
||||
|
||||
if (ifsOptD) {
|
||||
if (ifsOptD)
|
||||
{
|
||||
value_pair_update (ifsOptD->iterations_pair);
|
||||
value_pair_update (ifsOptD->subdivide_pair);
|
||||
value_pair_update (ifsOptD->radius_pair);
|
||||
|
@ -2709,18 +2719,21 @@ ifsfile_replace_ifsvals (IfsComposeVals *new_ifsvals,
|
|||
|
||||
/* load an ifs file */
|
||||
static void
|
||||
ifsfile_load (GtkWidget *widget, GtkWidget *file_select)
|
||||
ifsfile_load (GtkWidget *widget,
|
||||
GtkWidget *file_select)
|
||||
{
|
||||
const gchar *filename;
|
||||
gchar *buffer;
|
||||
AffElement **new_elements;
|
||||
IfsComposeVals new_ifsvals;
|
||||
GError *error = NULL;
|
||||
|
||||
g_strlcpy (ifsfile_path,
|
||||
gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_select)),
|
||||
PATH_MAX);
|
||||
if (g_file_get_contents (ifsfile_path, &buffer, NULL, &error)) {
|
||||
if (ifsvals_parse_string (buffer, &new_ifsvals, &new_elements)) {
|
||||
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_select));
|
||||
|
||||
if (g_file_get_contents (filename, &buffer, NULL, &error))
|
||||
{
|
||||
if (ifsvals_parse_string (buffer, &new_ifsvals, &new_elements))
|
||||
{
|
||||
guint i;
|
||||
|
||||
undo_begin ();
|
||||
|
@ -2732,62 +2745,79 @@ ifsfile_load (GtkWidget *widget, GtkWidget *file_select)
|
|||
if (ifsD->auto_preview)
|
||||
ifs_compose_preview ();
|
||||
|
||||
gtk_widget_destroy (file_select);
|
||||
gtk_widget_hide (file_select);
|
||||
design_area_redraw ();
|
||||
}
|
||||
else {
|
||||
gchar *message = g_strdup_printf (_("File `%s' doesn't seem to be "
|
||||
"an IFS Compose file.\n"),
|
||||
ifsfile_path);
|
||||
ifscompose_message_dialog (GTK_MESSAGE_ERROR, GTK_WINDOW (file_select),
|
||||
else
|
||||
{
|
||||
gchar *message = g_strdup_printf (_("File '%s' doesn't seem to be "
|
||||
"an IFS Compose file."),
|
||||
filename);
|
||||
ifscompose_message_dialog (GTK_MESSAGE_ERROR,
|
||||
GTK_WINDOW (file_select),
|
||||
_("Load failed"), message);
|
||||
g_free (message);
|
||||
}
|
||||
|
||||
g_free (buffer);
|
||||
}
|
||||
else {
|
||||
gchar *message = g_strdup_printf("%s.\n", error->message);
|
||||
ifscompose_message_dialog (GTK_MESSAGE_ERROR, GTK_WINDOW (file_select),
|
||||
else
|
||||
{
|
||||
ifscompose_message_dialog (GTK_MESSAGE_ERROR,
|
||||
GTK_WINDOW (file_select),
|
||||
_("Load failed"), error->message);
|
||||
g_error_free (error);
|
||||
g_free (message);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ifs_compose_save_callback (GtkWidget *widget, gpointer data)
|
||||
ifs_compose_save_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *file_select;
|
||||
static GtkWidget *file_select = NULL;
|
||||
|
||||
if (!file_select)
|
||||
{
|
||||
file_select = gtk_file_selection_new (_("Save as IFS file"));
|
||||
|
||||
gimp_help_connect (file_select, gimp_standard_help_func,
|
||||
"filters/ifscompose.html");
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (file_select),
|
||||
ifsfile_path);
|
||||
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (file_select)->ok_button),
|
||||
"clicked", G_CALLBACK (ifsfile_save), file_select);
|
||||
g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (file_select)->cancel_button),
|
||||
"clicked", G_CALLBACK (gtk_widget_destroy),
|
||||
|
||||
g_signal_connect (GTK_FILE_SELECTION (file_select)->ok_button, "clicked",
|
||||
G_CALLBACK (ifsfile_save),
|
||||
file_select);
|
||||
gtk_widget_show (file_select);
|
||||
g_signal_connect_swapped (GTK_FILE_SELECTION (file_select)->cancel_button,
|
||||
"clicked",
|
||||
G_CALLBACK (gtk_widget_destroy),
|
||||
file_select);
|
||||
}
|
||||
|
||||
gtk_window_present (GTK_WINDOW (file_select));
|
||||
}
|
||||
|
||||
static void
|
||||
ifs_compose_load_callback (GtkWidget *widget, gpointer data)
|
||||
ifs_compose_load_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *file_select;
|
||||
static GtkWidget *file_select = NULL;
|
||||
|
||||
if (!file_select)
|
||||
{
|
||||
file_select = gtk_file_selection_new (_("Load IFS file"));
|
||||
|
||||
gimp_help_connect (file_select, gimp_standard_help_func,
|
||||
"filters/ifscompose.html");
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (file_select),
|
||||
ifsfile_path);
|
||||
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (file_select)->ok_button),
|
||||
"clicked", G_CALLBACK (ifsfile_load), file_select);
|
||||
g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (file_select)->cancel_button),
|
||||
"clicked", G_CALLBACK (gtk_widget_destroy),
|
||||
|
||||
g_signal_connect (GTK_FILE_SELECTION (file_select)->ok_button, "clicked",
|
||||
G_CALLBACK (ifsfile_load),
|
||||
file_select);
|
||||
gtk_widget_show (file_select);
|
||||
g_signal_connect_swapped (GTK_FILE_SELECTION (file_select)->cancel_button,
|
||||
"clicked",
|
||||
G_CALLBACK (gtk_widget_hide),
|
||||
file_select);
|
||||
}
|
||||
|
||||
gtk_window_present (GTK_WINDOW (file_select));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2939,8 +2969,9 @@ ifs_compose_preview (void)
|
|||
if (ifsD->preview_iterations == 0)
|
||||
g_idle_add (preview_idle_render, NULL);
|
||||
|
||||
ifsD->preview_iterations = ifsvals.iterations*((gdouble)width*height/
|
||||
(ifsD->drawable_width*ifsD->drawable_height));
|
||||
ifsD->preview_iterations =
|
||||
ifsvals.iterations * ((gdouble) width * height /
|
||||
(ifsD->drawable_width * ifsD->drawable_height));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue