From e63d677b3b067df789826feb4844618a5cb26c30 Mon Sep 17 00:00:00 2001 From: "GMT 1999 Adam D. Moss" Date: Sun, 7 Feb 1999 22:13:10 +0000 Subject: [PATCH] app/dialog_handler.c Various bugfixes and speedups w.r.t. thumbnail Sun Feb 7 22:06:04 GMT 1999 Adam D. Moss * app/dialog_handler.c * app/fileops.c: Various bugfixes and speedups w.r.t. thumbnail loading. Now has a 'generate thumbnail' button. * app/brightness_contrast.c * app/color_balance.c * app/curves.c * app/hue_saturation.c: Changed some gint to gint32. It doesn't matter right now, but it might if the optimized CLAMP0255 gets fixed. --- ChangeLog | 13 ++ app/base/color-balance.c | 3 +- app/base/curves.c | 5 +- app/base/hue-saturation.c | 4 - app/brightness_contrast.c | 2 +- app/color_balance.c | 3 +- app/curves.c | 5 +- app/dialog_handler.c | 12 ++ app/fileops.c | 177 +++++++++++++++++-------- app/hue_saturation.c | 4 - app/tools/brightness_contrast.c | 2 +- app/tools/color_balance.c | 3 +- app/tools/curves.c | 5 +- app/tools/gimpbrightnesscontrasttool.c | 2 +- app/tools/gimpcolorbalancetool.c | 3 +- app/tools/gimpcurvestool.c | 5 +- app/tools/gimphuesaturationtool.c | 4 - app/tools/hue_saturation.c | 4 - 18 files changed, 170 insertions(+), 86 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95fd49e046..f6673087a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Sun Feb 7 22:06:04 GMT 1999 Adam D. Moss + + * app/dialog_handler.c + * app/fileops.c: Various bugfixes and speedups w.r.t. + thumbnail loading. Now has a 'generate thumbnail' button. + + * app/brightness_contrast.c + * app/color_balance.c + * app/curves.c + * app/hue_saturation.c: Changed some gint to gint32. It + doesn't matter right now, but it might if the optimized + CLAMP0255 gets fixed. + Sun Feb 7 18:29:26 GMT 1999 Adam D. Moss * app/fileops.c: A unidirectional error-spread makes diff --git a/app/base/color-balance.c b/app/base/color-balance.c index a9d2edc368..125a20c402 100644 --- a/app/base/color-balance.c +++ b/app/base/color-balance.c @@ -596,7 +596,8 @@ color_balance_create_lookup_tables (ColorBalanceDialog *cbd) double *cyan_red_transfer[3]; double *magenta_green_transfer[3]; double *yellow_blue_transfer[3]; - int i, r_n, g_n, b_n; + int i; + gint32 r_n, g_n, b_n; /* Set the transfer arrays (for speed) */ cyan_red_transfer[SHADOWS] = (cbd->cyan_red[SHADOWS] > 0) ? shadows_add : shadows_sub; cyan_red_transfer[MIDTONES] = (cbd->cyan_red[MIDTONES] > 0) ? midtones_add : midtones_sub; diff --git a/app/base/curves.c b/app/base/curves.c index 2b9bb3fbf5..af9fd57bca 100644 --- a/app/base/curves.c +++ b/app/base/curves.c @@ -693,7 +693,7 @@ curves_plot_curve (CurvesDialog *cd, double y, dy, dy2, dy3; double d, d2, d3; int lastx, lasty; - int newx, newy; + gint32 newx, newy; int i; /* construct the geometry matrix from the segment */ @@ -905,7 +905,8 @@ curves_smooth_callback (GtkWidget *w, gpointer client_data) { CurvesDialog *cd; - int i, index; + int i; + gint32 index; cd = (CurvesDialog *) client_data; diff --git a/app/base/hue-saturation.c b/app/base/hue-saturation.c index d3d53d15f3..63fc5dc40f 100644 --- a/app/base/hue-saturation.c +++ b/app/base/hue-saturation.c @@ -164,14 +164,10 @@ hue_saturation_calculate_transfers (HueSaturationDialog *hsd) /* Saturation */ value = (hsd->saturation[0] + hsd->saturation[hue + 1]) * 255.0 / 100.0; value = BOUNDS (value, -255, 255); -#if 0 - saturation_transfer[hue][i] = (unsigned char) (CLAMP0255 ((i * (255 + value)) / 255)); -#else if (value < 0) saturation_transfer[hue][i] = (unsigned char) ((i * (255 + value)) / 255); else saturation_transfer[hue][i] = (unsigned char) (i + ((255 - i) * value) / 255); -#endif } } diff --git a/app/brightness_contrast.c b/app/brightness_contrast.c index 157f142347..86ce891873 100644 --- a/app/brightness_contrast.c +++ b/app/brightness_contrast.c @@ -110,7 +110,7 @@ brightness_contrast (PixelRegion *srcPR, int has_alpha; int alpha; int w, h, b; - int value; + gint32 value; int i; bcd = (BrightnessContrastDialog *) user_data; diff --git a/app/color_balance.c b/app/color_balance.c index a9d2edc368..125a20c402 100644 --- a/app/color_balance.c +++ b/app/color_balance.c @@ -596,7 +596,8 @@ color_balance_create_lookup_tables (ColorBalanceDialog *cbd) double *cyan_red_transfer[3]; double *magenta_green_transfer[3]; double *yellow_blue_transfer[3]; - int i, r_n, g_n, b_n; + int i; + gint32 r_n, g_n, b_n; /* Set the transfer arrays (for speed) */ cyan_red_transfer[SHADOWS] = (cbd->cyan_red[SHADOWS] > 0) ? shadows_add : shadows_sub; cyan_red_transfer[MIDTONES] = (cbd->cyan_red[MIDTONES] > 0) ? midtones_add : midtones_sub; diff --git a/app/curves.c b/app/curves.c index 2b9bb3fbf5..af9fd57bca 100644 --- a/app/curves.c +++ b/app/curves.c @@ -693,7 +693,7 @@ curves_plot_curve (CurvesDialog *cd, double y, dy, dy2, dy3; double d, d2, d3; int lastx, lasty; - int newx, newy; + gint32 newx, newy; int i; /* construct the geometry matrix from the segment */ @@ -905,7 +905,8 @@ curves_smooth_callback (GtkWidget *w, gpointer client_data) { CurvesDialog *cd; - int i, index; + int i; + gint32 index; cd = (CurvesDialog *) client_data; diff --git a/app/dialog_handler.c b/app/dialog_handler.c index e2a9179580..e6b3700fc0 100644 --- a/app/dialog_handler.c +++ b/app/dialog_handler.c @@ -37,6 +37,8 @@ static gint doing_update = FALSE; /* Prevent multiple keypresses from unsetting me. */ +extern GtkWidget * fileload; /* It's in fileops.c */ + /* State of individual dialogs */ typedef struct _dialog_state DIALOGSTATE,*DIALOGSTATEP; @@ -165,6 +167,11 @@ dialog_idle_all() { change_win_cursor (toolbox_shell->d->window, GDK_WATCH); } + + if (fileload && GTK_WIDGET_VISIBLE (fileload)) + { + change_win_cursor (fileload->window, GDK_WATCH); + } } /* And remove the hourglass again. */ @@ -190,6 +197,11 @@ dialog_unidle_all() { unset_win_cursor (toolbox_shell->d->window); } + + if (fileload && GTK_WIDGET_VISIBLE (fileload)) + { + unset_win_cursor (fileload->window); + } } /* Register a dialog that we can handle */ diff --git a/app/fileops.c b/app/fileops.c index 993f77b341..d8be7fd469 100644 --- a/app/fileops.c +++ b/app/fileops.c @@ -28,6 +28,7 @@ #include "appenv.h" #include "actionarea.h" +#include "cursorutil.h" #include "gdisplay.h" #include "general.h" #include "gimage.h" @@ -71,6 +72,9 @@ static gint file_overwrite_delete_callback (GtkWidget *w, static GimpImage* file_open_image (char *filename, char *raw_filename); +static void genbutton_callback (GtkWidget *w, + gpointer client_data); + static void file_open_clistrow_callback (GtkWidget *w, int client_data); static void file_open_ok_callback (GtkWidget *w, @@ -110,15 +114,19 @@ static void file_update_menus (GSList *procs, int image_type); -static GtkWidget *fileload = NULL; -static GtkWidget *filesave = NULL; -static GtkWidget *open_options = NULL; -static GtkWidget *save_options = NULL; +GtkWidget *fileload = NULL; /* Shared with dialog_handler.c */ +static GtkWidget *filesave = NULL; +static GtkWidget *open_options = NULL; +static GtkWidget *save_options = NULL; /* widgets for the open_options menu */ static GtkPreview *open_options_preview = NULL; static GtkWidget *open_options_fixed = NULL; static GtkWidget *open_options_label = NULL; static GtkWidget *open_options_frame = NULL; +static GtkWidget *open_options_genbutton = NULL; +/* Some state for the thumbnailer */ +static gchar *preview_fullname = NULL; + /* Load by extension. */ @@ -590,9 +598,21 @@ file_open_callback (GtkWidget *w, gtk_container_set_border_width (GTK_CONTAINER (hbox), 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + open_options_genbutton = gtk_button_new_with_label + ("generate\npreview"); + { + gtk_signal_connect (GTK_OBJECT (open_options_genbutton), + "clicked", + (GtkSignalFunc) genbutton_callback, + open_options_genbutton); + gtk_box_pack_end (GTK_BOX (hbox), open_options_genbutton, + FALSE, FALSE, 0); + } + gtk_widget_show (open_options_genbutton); + open_options_fixed = gtk_fixed_new (); { - gtk_widget_set_usize (open_options_fixed, 1, 1); + gtk_widget_set_usize (open_options_fixed, 80, 60); gtk_box_pack_start (GTK_BOX (hbox), open_options_fixed, FALSE, FALSE, 0); @@ -610,13 +630,10 @@ file_open_callback (GtkWidget *w, open_options_label = gtk_label_new (""); { - /* gtk_label_set_justify (GTK_LABEL (open_options_label), - GTK_JUSTIFY_LEFT); - gtk_label_set_line_wrap (GTK_LABEL (open_options_label), TRUE);*/ gtk_box_pack_end (GTK_BOX (vbox), open_options_label, FALSE, TRUE, 0); } - gtk_widget_show (open_options_label); + gtk_widget_show (open_options_label); } gtk_widget_show (vbox); } @@ -629,7 +646,8 @@ file_open_callback (GtkWidget *w, gtk_frame_set_label (GTK_FRAME(open_options_frame), _("Preview")); gtk_label_set_text (GTK_LABEL(open_options_label), "No selection."); - gtk_widget_hide (open_options_fixed); + gtk_widget_set_sensitive (GTK_WIDGET(open_options_genbutton), FALSE); + gtk_widget_hide (GTK_WIDGET(open_options_preview)); gtk_widget_show (open_options); file_dialog_show (fileload); @@ -895,35 +913,39 @@ file_open (char *filename, char *raw_filename) return FALSE; } + static gboolean file_save_thumbnail (GimpImage* gimage, - char *filename, - char *raw_filename) + const char *full_source_filename) { TempBuf* tempbuf; gint i,j; unsigned char* tbd; - gchar* pname; - gchar* xpname; - gchar* fname; + gchar* pathname; + gchar* filename; + gchar* xvpathname; + gchar* thumbnailname; gint w,h; GimpImageBaseType basetype; FILE* fp; if (gimp_image_preview_valid (gimage, Gray)) { - printf("(gimage already has valid preview - %dx%d)\n", + /* just for debugging */ + printf("(incidentally, gimage already has a valid preview - %dx%d)\n", gimage->comp_preview->width, gimage->comp_preview->height); } - pname = g_dirname(filename); - xpname = g_strconcat(pname,G_DIR_SEPARATOR_S,".xvpics", - NULL); + pathname = g_dirname(full_source_filename); + filename = g_basename(full_source_filename); /* Don't free! */ - fname = g_strconcat (xpname,G_DIR_SEPARATOR_S, - raw_filename, - NULL); + xvpathname = g_strconcat(pathname, G_DIR_SEPARATOR_S, ".xvpics", + NULL); + + thumbnailname = g_strconcat (xvpathname, G_DIR_SEPARATOR_S, + filename, + NULL); if (gimage->width<=80 && gimage->height<=60) { @@ -958,12 +980,12 @@ file_save_thumbnail (GimpImage* gimage, h = tempbuf->height; printf("tn: %d x %d\n", w, h);fflush(stdout); - mkdir (xpname, 0755); + mkdir (xvpathname, 0755); - fp = fopen(fname,"wb"); - g_free(pname); - g_free(xpname); - g_free(fname); + fp = fopen(thumbnailname,"wb"); + g_free(pathname); + g_free(xvpathname); + g_free(thumbnailname); if (fp) { @@ -1097,16 +1119,17 @@ file_save (GimpImage* gimage, /* these calls must come before the call to gimage_set_filename */ idea_add (filename); menus_last_opened_add (filename); - - /* set the image title */ - gimp_image_set_filename (gimage, filename); /* use the same plug-in for this image next time */ /* DISABLED - gets stuck on first saved format... needs attention --Adam */ /* gimage_set_save_proc(gimage, file_proc); */ - file_save_thumbnail (gimage, filename, raw_filename); + file_save_thumbnail (gimage, filename); + + /* set the image title */ + gimp_image_set_filename (gimage, filename); + /* note: 'filename' may have been free'd by above call! */ } g_free (return_vals); @@ -1205,10 +1228,8 @@ readXVThumb(const gchar *fnam, static void -file_open_clistrow_callback (GtkWidget *w, - int client_data) +set_preview (const gchar* fullfname) { - gchar *rawfname = NULL; guchar *thumb_rgb; guchar *raw_thumb; gint tnw,tnh; @@ -1219,37 +1240,38 @@ file_open_clistrow_callback (GtkWidget *w, struct stat file_stat; struct stat thumb_stat; gboolean thumb_may_be_outdated = FALSE; + gboolean show_generate_button = FALSE; + - rawfname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(fileload)); - - pname = g_dirname (rawfname); - fname = g_basename (rawfname); /* Don't free this! */ + pname = g_dirname (fullfname); + fname = g_basename (fullfname); /* Don't free this! */ tname = g_strconcat (pname, G_DIR_SEPARATOR_S, ".xvpics", G_DIR_SEPARATOR_S, fname, NULL); g_free (pname); - /*g_warning ("clique! %s", fname);*/ - /*gtk_clist_get_text(GTK_CLIST(w), client_data, 0, &txt); - g_warning ("clique! %p %d %s [%s]", w, client_data, txt, fname);*/ - /* If the file is newer than its thumbnail, the thumbnail may be out of date. */ - if ((stat(tname, &thumb_stat)==0) && - (stat(rawfname, &file_stat )==0)) + if ((stat(tname, &thumb_stat)==0) && + (stat(fullfname, &file_stat )==0)) { if ((thumb_stat.st_mtime) < (file_stat.st_mtime)) { thumb_may_be_outdated = TRUE; + show_generate_button = TRUE; } } raw_thumb = readXVThumb(tname, &tnw, &tnh, &imginfo); + g_free (tname); gtk_frame_set_label (GTK_FRAME(open_options_frame), fname); + if (preview_fullname) + g_free (preview_fullname); + preview_fullname = g_strdup (fullfname); if (raw_thumb) { @@ -1264,22 +1286,20 @@ file_open_clistrow_callback (GtkWidget *w, } gtk_preview_size (open_options_preview, tnw, tnh); - gtk_widget_set_usize (open_options_fixed, tnw, tnh); - gtk_widget_show (open_options_fixed); for (i=0; i>> %s\n", mfilename);*/ /*fflush (stdout);*/ diff --git a/app/hue_saturation.c b/app/hue_saturation.c index d3d53d15f3..63fc5dc40f 100644 --- a/app/hue_saturation.c +++ b/app/hue_saturation.c @@ -164,14 +164,10 @@ hue_saturation_calculate_transfers (HueSaturationDialog *hsd) /* Saturation */ value = (hsd->saturation[0] + hsd->saturation[hue + 1]) * 255.0 / 100.0; value = BOUNDS (value, -255, 255); -#if 0 - saturation_transfer[hue][i] = (unsigned char) (CLAMP0255 ((i * (255 + value)) / 255)); -#else if (value < 0) saturation_transfer[hue][i] = (unsigned char) ((i * (255 + value)) / 255); else saturation_transfer[hue][i] = (unsigned char) (i + ((255 - i) * value) / 255); -#endif } } diff --git a/app/tools/brightness_contrast.c b/app/tools/brightness_contrast.c index 157f142347..86ce891873 100644 --- a/app/tools/brightness_contrast.c +++ b/app/tools/brightness_contrast.c @@ -110,7 +110,7 @@ brightness_contrast (PixelRegion *srcPR, int has_alpha; int alpha; int w, h, b; - int value; + gint32 value; int i; bcd = (BrightnessContrastDialog *) user_data; diff --git a/app/tools/color_balance.c b/app/tools/color_balance.c index a9d2edc368..125a20c402 100644 --- a/app/tools/color_balance.c +++ b/app/tools/color_balance.c @@ -596,7 +596,8 @@ color_balance_create_lookup_tables (ColorBalanceDialog *cbd) double *cyan_red_transfer[3]; double *magenta_green_transfer[3]; double *yellow_blue_transfer[3]; - int i, r_n, g_n, b_n; + int i; + gint32 r_n, g_n, b_n; /* Set the transfer arrays (for speed) */ cyan_red_transfer[SHADOWS] = (cbd->cyan_red[SHADOWS] > 0) ? shadows_add : shadows_sub; cyan_red_transfer[MIDTONES] = (cbd->cyan_red[MIDTONES] > 0) ? midtones_add : midtones_sub; diff --git a/app/tools/curves.c b/app/tools/curves.c index 2b9bb3fbf5..af9fd57bca 100644 --- a/app/tools/curves.c +++ b/app/tools/curves.c @@ -693,7 +693,7 @@ curves_plot_curve (CurvesDialog *cd, double y, dy, dy2, dy3; double d, d2, d3; int lastx, lasty; - int newx, newy; + gint32 newx, newy; int i; /* construct the geometry matrix from the segment */ @@ -905,7 +905,8 @@ curves_smooth_callback (GtkWidget *w, gpointer client_data) { CurvesDialog *cd; - int i, index; + int i; + gint32 index; cd = (CurvesDialog *) client_data; diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c index 157f142347..86ce891873 100644 --- a/app/tools/gimpbrightnesscontrasttool.c +++ b/app/tools/gimpbrightnesscontrasttool.c @@ -110,7 +110,7 @@ brightness_contrast (PixelRegion *srcPR, int has_alpha; int alpha; int w, h, b; - int value; + gint32 value; int i; bcd = (BrightnessContrastDialog *) user_data; diff --git a/app/tools/gimpcolorbalancetool.c b/app/tools/gimpcolorbalancetool.c index a9d2edc368..125a20c402 100644 --- a/app/tools/gimpcolorbalancetool.c +++ b/app/tools/gimpcolorbalancetool.c @@ -596,7 +596,8 @@ color_balance_create_lookup_tables (ColorBalanceDialog *cbd) double *cyan_red_transfer[3]; double *magenta_green_transfer[3]; double *yellow_blue_transfer[3]; - int i, r_n, g_n, b_n; + int i; + gint32 r_n, g_n, b_n; /* Set the transfer arrays (for speed) */ cyan_red_transfer[SHADOWS] = (cbd->cyan_red[SHADOWS] > 0) ? shadows_add : shadows_sub; cyan_red_transfer[MIDTONES] = (cbd->cyan_red[MIDTONES] > 0) ? midtones_add : midtones_sub; diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c index 2b9bb3fbf5..af9fd57bca 100644 --- a/app/tools/gimpcurvestool.c +++ b/app/tools/gimpcurvestool.c @@ -693,7 +693,7 @@ curves_plot_curve (CurvesDialog *cd, double y, dy, dy2, dy3; double d, d2, d3; int lastx, lasty; - int newx, newy; + gint32 newx, newy; int i; /* construct the geometry matrix from the segment */ @@ -905,7 +905,8 @@ curves_smooth_callback (GtkWidget *w, gpointer client_data) { CurvesDialog *cd; - int i, index; + int i; + gint32 index; cd = (CurvesDialog *) client_data; diff --git a/app/tools/gimphuesaturationtool.c b/app/tools/gimphuesaturationtool.c index d3d53d15f3..63fc5dc40f 100644 --- a/app/tools/gimphuesaturationtool.c +++ b/app/tools/gimphuesaturationtool.c @@ -164,14 +164,10 @@ hue_saturation_calculate_transfers (HueSaturationDialog *hsd) /* Saturation */ value = (hsd->saturation[0] + hsd->saturation[hue + 1]) * 255.0 / 100.0; value = BOUNDS (value, -255, 255); -#if 0 - saturation_transfer[hue][i] = (unsigned char) (CLAMP0255 ((i * (255 + value)) / 255)); -#else if (value < 0) saturation_transfer[hue][i] = (unsigned char) ((i * (255 + value)) / 255); else saturation_transfer[hue][i] = (unsigned char) (i + ((255 - i) * value) / 255); -#endif } } diff --git a/app/tools/hue_saturation.c b/app/tools/hue_saturation.c index d3d53d15f3..63fc5dc40f 100644 --- a/app/tools/hue_saturation.c +++ b/app/tools/hue_saturation.c @@ -164,14 +164,10 @@ hue_saturation_calculate_transfers (HueSaturationDialog *hsd) /* Saturation */ value = (hsd->saturation[0] + hsd->saturation[hue + 1]) * 255.0 / 100.0; value = BOUNDS (value, -255, 255); -#if 0 - saturation_transfer[hue][i] = (unsigned char) (CLAMP0255 ((i * (255 + value)) / 255)); -#else if (value < 0) saturation_transfer[hue][i] = (unsigned char) ((i * (255 + value)) / 255); else saturation_transfer[hue][i] = (unsigned char) (i + ((255 - i) * value) / 255); -#endif } }