gimp/plug-ins/common/mail.c

876 lines
26 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
1997-11-25 06:05:25 +08:00
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
* Copyright (C) 1997 Daniel Risacher
1997-11-25 06:05:25 +08:00
*
* This program is free software: you can redistribute it and/or modify
1997-11-25 06:05:25 +08:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
1997-11-25 06:05:25 +08:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1997-11-25 06:05:25 +08:00
*/
/*
* GUMP - Gimp Useless Mail Plugin
* (or Gump Useless Mail Plugin if you prefer)
*
* by Adrian Likins <adrian@gimp.org>
* MIME encapsulation by Reagan Blundell <reagan@emails.net>
*
* As always: The utility of this plugin is left as an exercise for
* the reader
*
1997-11-25 06:05:25 +08:00
*/
#include "config.h"
#include <string.h>
#ifdef SENDMAIL
1999-05-17 20:27:10 +08:00
#include <sys/types.h>
1997-11-25 06:05:25 +08:00
#include <sys/wait.h>
#endif
#include <glib/gstdio.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
1997-11-25 06:05:25 +08:00
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
#include "libgimp/stdplugins-intl.h"
1997-11-25 06:05:25 +08:00
2019-08-15 04:06:19 +08:00
#define BUFFER_SIZE 256
#define PLUG_IN_PROC "plug-in-mail-image"
#define PLUG_IN_BINARY "mail"
#define PLUG_IN_ROLE "gimp-mail"
2019-08-15 04:06:19 +08:00
typedef struct _Mail Mail;
typedef struct _MailClass MailClass;
struct _Mail
{
GimpPlugIn parent_instance;
};
struct _MailClass
{
GimpPlugInClass parent_class;
};
#define MAIL_TYPE (mail_get_type ())
#define MAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_TYPE, Mail))
2019-08-15 04:06:19 +08:00
GType mail_get_type (void) G_GNUC_CONST;
static GList * mail_init_procedures (GimpPlugIn *plug_in);
static GimpProcedure * mail_create_procedure (GimpPlugIn *plug_in,
const gchar *name);
static GimpValueArray * mail_run (GimpProcedure *procedure,
GimpRunMode run_mode,
GimpImage *image,
gint n_drawables,
GimpDrawable **drawables,
GimpProcedureConfig *config,
2019-08-15 04:06:19 +08:00
gpointer run_data);
static GimpPDBStatusType send_image (GObject *config,
GimpImage *image,
gint n_drawables,
GimpDrawable **drawables,
gint32 run_mode);
static gboolean send_dialog (GimpProcedure *procedure,
GObject *config);
static gboolean valid_file (GFile *file);
static gchar * find_extension (const gchar *filename);
#ifdef SENDMAIL
static gchar * sendmail_content_type (const gchar *filename);
static void sendmail_create_headers (FILE *mailpipe,
GObject *config);
static gboolean sendmail_to64 (const gchar *filename,
FILE *outfile,
GError **error);
static FILE * sendmail_pipe (gchar **cmd,
GPid *pid);
#endif
1997-11-25 06:05:25 +08:00
2019-08-15 04:06:19 +08:00
G_DEFINE_TYPE (Mail, mail, GIMP_TYPE_PLUG_IN)
GIMP_MAIN (MAIL_TYPE)
DEFINE_STD_SET_I18N
2019-08-15 04:06:19 +08:00
1997-11-25 06:05:25 +08:00
#ifdef SENDMAIL
static gchar *mesg_body = NULL;
#endif
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
1997-11-25 06:05:25 +08:00
2019-08-15 04:06:19 +08:00
static void
mail_class_init (MailClass *klass)
{
GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass);
plug_in_class->init_procedures = mail_init_procedures;
plug_in_class->create_procedure = mail_create_procedure;
plug_in_class->set_i18n = STD_SET_I18N;
2019-08-15 04:06:19 +08:00
}
1997-11-25 06:05:25 +08:00
static void
2019-08-15 04:06:19 +08:00
mail_init (Mail *mail)
1997-11-25 06:05:25 +08:00
{
2019-08-15 04:06:19 +08:00
}
2019-08-15 04:06:19 +08:00
static GList *
mail_init_procedures (GimpPlugIn *plug_in)
{
GList *list = NULL;
gchar *email_bin;
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
/* Check if xdg-email or sendmail is installed.
* TODO: allow setting the location of the executable in preferences.
*/
#ifdef SENDMAIL
if (strlen (SENDMAIL) == 0)
{
email_bin = g_find_program_in_path ("sendmail");
}
else
{
/* If a directory has been set at build time, we assume that sendmail
* can only be in this directory. */
email_bin = g_build_filename (SENDMAIL, "sendmail", NULL);
if (! g_file_test (email_bin, G_FILE_TEST_IS_EXECUTABLE))
{
g_free (email_bin);
email_bin = NULL;
}
}
#else
email_bin = g_find_program_in_path ("xdg-email");
#endif
2019-08-15 04:06:19 +08:00
if (email_bin)
list = g_list_append (list, g_strdup (PLUG_IN_PROC));
return list;
}
static GimpProcedure *
mail_create_procedure (GimpPlugIn *plug_in,
const gchar *name)
{
GimpProcedure *procedure = NULL;
if (! strcmp (name, PLUG_IN_PROC))
{
procedure = gimp_image_procedure_new (plug_in, name,
GIMP_PDB_PROC_TYPE_PLUGIN,
mail_run, NULL, NULL);
2019-08-15 04:06:19 +08:00
gimp_procedure_set_image_types (procedure, "*");
gimp_procedure_set_sensitivity_mask (procedure,
GIMP_PROCEDURE_SENSITIVE_DRAWABLE |
GIMP_PROCEDURE_SENSITIVE_DRAWABLES |
GIMP_PROCEDURE_SENSITIVE_NO_DRAWABLES);
2019-08-15 04:06:19 +08:00
gimp_procedure_set_menu_label (procedure, _("Send by E_mail..."));
gimp_procedure_set_icon_name (procedure, GIMP_ICON_EDIT);
gimp_procedure_add_menu_path (procedure, "<Image>/File/[Send]");
2019-08-15 04:06:19 +08:00
gimp_procedure_set_documentation (procedure,
_("Send the image by email"),
#ifdef SENDMAIL
_("Sendmail is used to send emails "
"and must be properly configured."),
#else /* xdg-email */
_("The preferred email composer is "
"used to send emails and must be "
"properly configured."),
#endif
2019-08-15 04:06:19 +08:00
name);
gimp_procedure_set_attribution (procedure,
"Adrian Likins, Reagan Blundell",
"Adrian Likins, Reagan Blundell, "
"Daniel Risacher, "
"Spencer Kimball and Peter Mattis",
"1995-1997");
gimp_procedure_add_string_argument (procedure, "filename",
_("File_name"),
_("The name of the file to save the image in"),
NULL,
G_PARAM_READWRITE);
gimp_procedure_add_string_argument (procedure, "to-address",
_("_To"),
_("The email address to send to"),
"",
G_PARAM_READWRITE);
gimp_procedure_add_string_argument (procedure, "from-address",
_("_From"),
_("The email address for the From: field"),
"",
G_PARAM_READWRITE);
gimp_procedure_add_string_argument (procedure, "subject",
_("Su_bject"),
_("The subject"),
"",
G_PARAM_READWRITE);
gimp_procedure_add_string_argument (procedure, "comment",
_("Co_mment"),
_("The comment"),
NULL,
G_PARAM_READWRITE);
2019-08-15 04:06:19 +08:00
}
return procedure;
1997-11-25 06:05:25 +08:00
}
2019-08-15 04:06:19 +08:00
static GimpValueArray *
mail_run (GimpProcedure *procedure,
GimpRunMode run_mode,
GimpImage *image,
gint n_drawables,
GimpDrawable **drawables,
GimpProcedureConfig *config,
2019-08-15 04:06:19 +08:00
gpointer run_data)
1997-11-25 06:05:25 +08:00
{
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
if (run_mode == GIMP_RUN_INTERACTIVE)
1997-11-25 06:05:25 +08:00
{
gchar *filename = g_file_get_path (gimp_image_get_file (image));
2019-08-15 04:06:19 +08:00
if (filename)
{
gchar *basename = g_filename_display_basename (filename);
gchar buffername[BUFFER_SIZE];
g_strlcpy (buffername, basename, BUFFER_SIZE);
2019-08-15 04:06:19 +08:00
g_object_set (config,
"filename", buffername,
NULL);
g_free (basename);
g_free (filename);
}
2019-08-15 04:06:19 +08:00
if (! send_dialog (procedure, G_OBJECT (config)))
return gimp_procedure_new_return_values (procedure, GIMP_PDB_CANCEL, NULL);
2019-08-15 04:06:19 +08:00
}
status = send_image (G_OBJECT (config),
image,
n_drawables, drawables,
2019-08-15 04:06:19 +08:00
run_mode);
1997-11-25 06:05:25 +08:00
2019-08-15 04:06:19 +08:00
return gimp_procedure_new_return_values (procedure, status, NULL);
1997-11-25 06:05:25 +08:00
}
static GimpPDBStatusType
send_image (GObject *config,
GimpImage *image,
gint n_drawables,
GimpDrawable **drawables,
gint32 run_mode)
1997-11-25 06:05:25 +08:00
{
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gchar *ext;
GFile *tmpfile;
gchar *tmpname;
#ifndef SENDMAIL /* xdg-email */
gchar *mailcmd[9];
gchar *filepath = NULL;
GFile *tmp_dir = NULL;
GFileEnumerator *enumerator;
gint i;
#else /* SENDMAIL */
gchar *mailcmd[3];
GPid mailpid;
FILE *mailpipe = NULL;
#endif
GError *error = NULL;
gchar *filename = NULL;
gchar *receipt = NULL;
gchar *from = NULL;
gchar *subject = NULL;
gchar *comment = NULL;
g_object_get (config,
"filename", &filename,
"to-address", &receipt,
"from-address", &from,
"subject", &subject,
"comment", &comment,
NULL);
ext = find_extension (filename);
if (ext == NULL)
return GIMP_PDB_CALLING_ERROR;
1997-11-25 06:05:25 +08:00
/* get a temp name with the right extension and save into it. */
tmpfile = gimp_temp_file (ext + 1);
tmpname = g_file_get_path (tmpfile);
1997-11-25 06:05:25 +08:00
if (! (gimp_file_save (run_mode, image, tmpfile) &&
valid_file (tmpfile)))
{
goto error;
}
#ifndef SENDMAIL /* xdg-email */
/* From xdg-email doc:
* "Some e-mail applications require the file to remain present
* after xdg-email returns."
* As a consequence, the file cannot be removed at the end of the
* function. We actually have no way to ever know *when* the file can
* be removed since the caller could leave the email window opened for
* hours. Yet we still want to clean sometimes and not have temporary
* images piling up.
* So I use a known directory that we control under $GIMP_DIRECTORY/tmp/,
* and clean it out each time the plugin runs. This means that *if* you
* are in the above case (your email client requires the file to stay
* alive), you cannot run twice the plugin at the same time.
*/
tmp_dir = gimp_directory_file ("tmp", PLUG_IN_PROC, NULL);
if (g_mkdir_with_parents (gimp_file_get_utf8_name (tmp_dir),
S_IRUSR | S_IWUSR | S_IXUSR) == -1)
{
g_message ("Temporary directory %s could not be created.",
gimp_file_get_utf8_name (tmp_dir));
g_error_free (error);
goto error;
}
enumerator = g_file_enumerate_children (tmp_dir,
G_FILE_ATTRIBUTE_STANDARD_TYPE,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL, NULL);
if (enumerator)
{
GFileInfo *info;
while ((info = g_file_enumerator_next_file (enumerator,
NULL, NULL)))
{
if (g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_REGULAR)
{
GFile *file = g_file_enumerator_get_child (enumerator, info);
g_file_delete (file, NULL, NULL);
g_object_unref (file);
}
g_object_unref (info);
}
g_object_unref (enumerator);
}
filepath = g_build_filename (gimp_file_get_utf8_name (tmp_dir), filename,
NULL);
if (g_rename (tmpname, filepath) == -1)
{
/* But on some system, I got an 'Invalid cross-device link' errno
* with g_rename().
* On the other hand, g_file_move() seems to be more robust.
*/
GFile *source = tmpfile;
GFile *target = g_file_new_for_path (filepath);
if (! g_file_move (source, target, G_FILE_COPY_NONE, NULL, NULL, NULL, &error))
{
g_message ("%s", error->message);
g_clear_error (&error);
g_object_unref (target);
goto error;
}
g_object_unref (target);
}
mailcmd[0] = g_strdup ("xdg-email");
mailcmd[1] = "--attach";
mailcmd[2] = filepath;
i = 3;
if (subject != NULL && strlen (subject) > 0)
{
mailcmd[i++] = "--subject";
mailcmd[i++] = subject;
}
if (comment != NULL && strlen (comment) > 0)
{
mailcmd[i++] = "--body";
mailcmd[i++] = comment;
}
if (receipt != NULL && strlen (receipt) > 0)
{
mailcmd[i++] = receipt;
}
mailcmd[i] = NULL;
if (! g_spawn_async (NULL, mailcmd, NULL,
G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, &error))
{
g_message ("%s", error->message);
g_error_free (error);
goto error;
}
#else /* SENDMAIL */
1997-11-25 06:05:25 +08:00
/* construct the "sendmail user@location" line */
if (strlen (SENDMAIL) == 0)
mailcmd[0] = g_strdup ("sendmail");
else
mailcmd[0] = g_build_filename (SENDMAIL, "sendmail", NULL);
mailcmd[1] = receipt;
mailcmd[2] = NULL;
1997-11-25 06:05:25 +08:00
/* create a pipe to sendmail */
mailpipe = sendmail_pipe (mailcmd, &mailpid);
if (mailpipe == NULL)
return GIMP_PDB_EXECUTION_ERROR;
sendmail_create_headers (mailpipe, config);
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
fflush (mailpipe);
1997-11-25 06:05:25 +08:00
if (! sendmail_to64 (tmpname, mailpipe, &error))
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
{
g_message ("%s", error->message);
g_error_free (error);
goto error;
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
}
fprintf (mailpipe, "\n--GUMP-MIME-boundary--\n");
#endif
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
goto cleanup;
error:
/* stop sendmail from doing anything */
#ifdef SENDMAIL
kill (mailpid, SIGINT);
#endif
status = GIMP_PDB_EXECUTION_ERROR;
cleanup:
/* close out the sendmail process */
#ifdef SENDMAIL
if (mailpipe)
{
fclose (mailpipe);
waitpid (mailpid, NULL, 0);
g_spawn_close_pid (mailpid);
}
1997-11-25 06:05:25 +08:00
/* delete the tmpfile that was generated */
g_unlink (tmpname);
#else
if (tmp_dir)
g_object_unref (tmp_dir);
if (filepath)
g_free (filepath);
#endif
g_free (filename);
g_free (receipt);
g_free (from);
g_free (subject);
g_free (comment);
g_free (mailcmd[0]);
g_free (tmpname);
g_object_unref (tmpfile);
return status;
1997-11-25 06:05:25 +08:00
}
static gboolean
send_dialog (GimpProcedure *procedure,
GObject *config)
1997-11-25 06:05:25 +08:00
{
GtkWidget *dlg;
GtkWidget *main_vbox;
GtkWidget *entry;
GtkWidget *real_entry;
2018-05-09 07:11:12 +08:00
GtkWidget *grid;
GtkWidget *button;
#ifdef SENDMAIL
GtkWidget *scrolled_window;
GtkWidget *text_view;
#endif
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
gchar *gump_from;
gboolean run;
1997-11-25 06:05:25 +08:00
gimp_ui_init (PLUG_IN_BINARY);
1997-11-25 06:05:25 +08:00
/* check gimprc for a preferred "From:" address */
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
gump_from = gimp_gimprc_query ("gump-from");
if (gump_from)
{
g_object_set (config,
"from-address", gump_from,
NULL);
g_free (gump_from);
}
dlg = gimp_procedure_dialog_new (procedure,
GIMP_PROCEDURE_CONFIG (config),
_("Send by Email"));
/* Change "Ok" button to "Send" */
button = gtk_dialog_get_widget_for_response (GTK_DIALOG (dlg),
GTK_RESPONSE_OK);
gtk_button_set_label (GTK_BUTTON (button), _("Send"));
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dlg),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
Added parent window API to the GimpProgress interface and to the libgimp 2005-09-09 Michael Natterer <mitch@gimp.org> Added parent window API to the GimpProgress interface and to the libgimp progress stuff. Might look strange, but does the right thing in almost all cases (image window, file dialog, script-fu dialog etc). Fixes bug #62988. * app/core/gimpprogress.[ch]: added GimpProgress::get_window() which should return a toplevel window ID if the progress is in a window that wants to be the transient parent of plug-in dialogs. * app/widgets/gimpwidgets-utils.[ch] (gimp_window_get_native): new function which returns the window handle of a GtkWindow's GdkWindow. * app/widgets/gimpfiledialog.c: implement ::get_window(). * app/display/gimpdisplay.[ch]: ditto. Removed window handle API. * app/gui/gui-vtable.c: changed accordingly. * libgimpbase/gimpbaseenums.[ch] (enum GimpProgressCommand): added GIMP_PROGRESS_COMMAND_GET_WINDOW. * app/plug-in/plug-in-progress.[ch] (plug_in_progress_get_window): new function. Also renamed some functions to match the GimpProgress interface, and not the legacy PDB procedure names. * tools/pdbgen/pdb/progress.pdb * app/core/gimppdbprogress.c: implement get_window() on both sides of the wire, keeping backward compatibility (hopefully). * libgimp/gimpprogress.[ch]: deprecated gimp_progress_install() and added gimp_progress_install_vtable() which takes a vtable with padding to be extensible. Added get_window() vtable entry and dispatch it accordingly. Also added pulse() which was implemented in a hackish way before. Everything is of course backward compatible. * libgimp/gimpprogressbar.c: inmplement the get_window() stuff so a plug-in dialog containing a progress can be the transient parent of another dialog in another plug-in. * libgimp/gimpui.[ch] (gimp_ui_get_progress_window): new function which returns a foreign GdkWindow of this plug-ins progress window. Renamed gimp_window_set_transient_for_default_display() to gimp_window_set_transient() and make it use the progress' window handle instead of the display's (which is the right thing to do in almost all cases). * libgimp/gimp.def * libgimp/gimpui.def: add the new functions. * tools/pdbgen/enums.pl * app/pdb/internal_procs.c * app/pdb/progress_cmds.c * libgimp/gimpprogress_pdb.[ch]: regenerated. * libgimp/gimpexport.c * plug-ins/*/*.c: follow API change.
2005-09-10 02:07:31 +08:00
gimp_window_set_transient (GTK_WINDOW (dlg));
2011-09-30 18:17:53 +08:00
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
main_vbox, TRUE, TRUE, 0);
gtk_widget_show (main_vbox);
2018-05-09 07:11:12 +08:00
/* grid */
grid = gtk_grid_new ();
gtk_box_pack_start (GTK_BOX (main_vbox), grid, FALSE, FALSE, 0);
gtk_widget_show (grid);
1997-11-25 06:05:25 +08:00
2018-05-09 07:11:12 +08:00
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
1997-11-25 06:05:25 +08:00
/* Filename entry */
entry = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dlg),
"filename", GIMP_TYPE_LABEL_ENTRY);
real_entry = gimp_label_entry_get_entry (GIMP_LABEL_ENTRY (entry));
gtk_widget_set_size_request (real_entry, 200, -1);
gtk_entry_set_activates_default (GTK_ENTRY (real_entry), TRUE);
gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dlg),
"filename",
NULL);
gtk_entry_set_max_length (GTK_ENTRY (real_entry),
BUFFER_SIZE - 1);
#ifdef SENDMAIL
/* To entry */
entry = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dlg),
"to-address",
GIMP_TYPE_LABEL_ENTRY);
real_entry = gimp_label_entry_get_entry (GIMP_LABEL_ENTRY (entry));
gtk_widget_set_size_request (real_entry, 200, -1);
gtk_entry_set_max_length (GTK_ENTRY (real_entry), BUFFER_SIZE - 1);
gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dlg),
"to-address",
NULL);
gtk_entry_set_max_length (GTK_ENTRY (real_entry),
BUFFER_SIZE - 1);
gtk_widget_grab_focus (real_entry);
1999-11-27 02:03:59 +08:00
/* From entry */
entry = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dlg),
"from-address",
GIMP_TYPE_LABEL_ENTRY);
real_entry = gimp_label_entry_get_entry (GIMP_LABEL_ENTRY (entry));
gtk_widget_set_size_request (real_entry, 200, -1);
gtk_entry_set_max_length (GTK_ENTRY (real_entry), BUFFER_SIZE - 1);
gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dlg),
"from-address",
NULL);
gtk_entry_set_max_length (GTK_ENTRY (real_entry),
BUFFER_SIZE - 1);
1997-11-25 06:05:25 +08:00
/* Subject entry */
entry = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dlg),
"subject",
GIMP_TYPE_LABEL_ENTRY);
real_entry = gimp_label_entry_get_entry (GIMP_LABEL_ENTRY (entry));
gtk_widget_set_size_request (real_entry, 200, -1);
gtk_entry_set_max_length (GTK_ENTRY (real_entry), BUFFER_SIZE - 1);
gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dlg),
"subject",
NULL);
gtk_entry_set_max_length (GTK_ENTRY (real_entry),
BUFFER_SIZE - 1);
1997-11-25 06:05:25 +08:00
/* Body */
text_view = gimp_procedure_dialog_get_widget (GIMP_PROCEDURE_DIALOG (dlg),
"comment",
GTK_TYPE_TEXT_VIEW);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
scrolled_window =
gimp_procedure_dialog_fill_scrolled_window (GIMP_PROCEDURE_DIALOG (dlg),
"comment-scrolled",
"comment");
plug-ins/FractalExplorer/Dialogs.c 2003-11-15 Michael Natterer <mitch@gimp.org> * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/bmp/bmpread.c * plug-ins/bmp/bmpwrite.c * plug-ins/common/CEL.c * plug-ins/common/CML_explorer.c * plug-ins/common/animoptimize.c * plug-ins/common/bz2.c * plug-ins/common/convmatrix.c * plug-ins/common/curve_bend.c * plug-ins/common/dicom.c * plug-ins/common/gauss_iir.c * plug-ins/common/gauss_rle.c * plug-ins/common/gbr.c * plug-ins/common/gif.c * plug-ins/common/gifload.c * plug-ins/common/gih.c * plug-ins/common/grid.c * plug-ins/common/gtm.c * plug-ins/common/gz.c * plug-ins/common/hrz.c * plug-ins/common/jpeg.c * plug-ins/common/mail.c * plug-ins/common/mapcolor.c * plug-ins/common/pat.c * plug-ins/common/pcx.c * plug-ins/common/pix.c * plug-ins/common/png.c * plug-ins/common/pnm.c * plug-ins/common/ps.c * plug-ins/common/psd.c * plug-ins/common/psd_save.c * plug-ins/common/psp.c * plug-ins/common/sel_gauss.c * plug-ins/common/spheredesigner.c * plug-ins/common/sunras.c * plug-ins/common/svg.c * plug-ins/common/tga.c * plug-ins/common/tiff.c * plug-ins/common/wmf.c * plug-ins/common/xbm.c * plug-ins/common/xwd.c * plug-ins/faxg3/faxg3.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/brush.c * plug-ins/gimpressionist/ppmtool.c * plug-ins/helpbrowser/domain.c * plug-ins/ifscompose/ifscompose.c * plug-ins/sgi/sgi.c * plug-ins/twain/twain.c * plug-ins/winsnap/winsnap.c * plug-ins/xjt/xjt.c: removed explicit newlines from messages. Made file open/save messages the same all over the place. Reduced number of translatable strings by adding some more "standard" messages. Removed plug-in names from messages. Added some random mnemonics. Unmarked some strings for translation and added some that were forgotten. General message cleanup. Removed trailing whitespace.
2003-11-15 21:53:33 +08:00
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dlg),
"comment-scrolled",
NULL);
#endif
1997-11-25 06:05:25 +08:00
gtk_widget_show (dlg);
run = gimp_procedure_dialog_run (GIMP_PROCEDURE_DIALOG (dlg));
1997-11-25 06:05:25 +08:00
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
gtk_widget_destroy (dlg);
return run;
1997-11-25 06:05:25 +08:00
}
static gboolean
valid_file (GFile *file)
1997-11-25 06:05:25 +08:00
{
GStatBuf buf;
gboolean valid;
1997-11-25 06:05:25 +08:00
valid = g_stat (g_file_peek_path (file), &buf) == 0 && buf.st_size > 0;
return valid;
1997-11-25 06:05:25 +08:00
}
static gchar *
find_extension (const gchar *filename)
1997-11-25 06:05:25 +08:00
{
gchar *filename_copy;
gchar *ext;
1997-11-25 06:05:25 +08:00
/* we never free this copy - aren't we evil! */
filename_copy = g_strdup (filename);
1997-11-25 06:05:25 +08:00
/* find the extension, boy! */
ext = strrchr (filename_copy, '.');
while (TRUE)
1997-11-25 06:05:25 +08:00
{
if (!ext || ext[1] == '\0' || strchr (ext, G_DIR_SEPARATOR))
{
g_message (_("some sort of error with the file extension "
"or lack thereof"));
removed our own action_area API and use GtkDialog's one. Create all 2003-11-06 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpdialog.[ch]: removed our own action_area API and use GtkDialog's one. Create all dialogs without separator. Changed almost everything else too. Fixes bug #125143. * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpunitmenu.c: changed accordingly. * libgimp/gimpexport.[ch]: ditto. Renamed enum GimpExportReturnType to GimpExportReturn. * libgimp/gimpcompat.h: added a #define for the old name. * themes/Default/gtkrc: increased action_area border to 6 pixels. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-scale.c * app/display/gimpprogress.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-notebook.c * app/gui/convert-dialog.c * app/gui/file-new-dialog.c * app/gui/font-select.c * app/gui/gradient-editor-commands.c * app/gui/gradient-select.c * app/gui/grid-dialog.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/stroke-dialog.c * app/gui/templates-commands.c * app/gui/user-install-dialog.c * app/gui/vectors-commands.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptexteditor.c * app/widgets/gimptooldialog.[ch] * app/widgets/gimpviewabledialog.[ch] * app/widgets/gimpwidgets-utils.c: changed accordingly and increased the dialogs' outer borders to 6 pixels all over the place. * plug-ins/*/*.c: changed accordingly. The plug-ins may be arbitrarily broken, I tested none of them.
2003-11-06 23:27:05 +08:00
return NULL;
}
if (0 != g_ascii_strcasecmp (ext, ".gz") &&
0 != g_ascii_strcasecmp (ext, ".bz2"))
{
return ext;
}
1997-11-25 06:05:25 +08:00
else
{
/* we found something, loop back, and look again */
*ext = 0;
ext = strrchr (filename_copy, '.');
}
1997-11-25 06:05:25 +08:00
}
2010-11-10 02:03:47 +08:00
g_free (filename_copy);
1997-11-25 06:05:25 +08:00
return ext;
}
#ifdef SENDMAIL
static gchar *
sendmail_content_type (const gchar *filename)
{
/* This function returns a MIME Content-type: value based on the
filename it is given. */
const gchar *type_mappings[20] =
{
"gif" , "image/gif",
"jpg" , "image/jpeg",
"jpeg", "image/jpeg",
"tif" , "image/tiff",
"tiff", "image/tiff",
"png" , "image/png",
"g3" , "image/g3fax",
"ps" , "application/postscript",
"eps" , "application/postscript",
NULL, NULL
};
gchar *ext;
gint i;
ext = find_extension (filename);
if (!ext)
{
return g_strdup ("application/octet-stream");
}
i = 0;
ext += 1;
while (type_mappings[i])
{
if (g_ascii_strcasecmp (ext, type_mappings[i]) == 0)
{
return g_strdup (type_mappings[i + 1]);
}
i += 2;
}
return g_strdup_printf ("image/x-%s", ext);
}
1997-11-25 06:05:25 +08:00
static void
sendmail_create_headers (FILE *mailpipe,
GObject *config)
1997-11-25 06:05:25 +08:00
{
gchar *filename = NULL;
gchar *receipt = NULL;
gchar *from = NULL;
gchar *subject = NULL;
gchar *comment = NULL;
g_object_get (config,
"filename", &filename,
"to-address", &receipt,
"from-address", &from,
"subject", &subject,
"comment", &comment,
NULL);
1997-11-25 06:05:25 +08:00
/* create all the mail header stuff. Feel free to add your own */
/* It is advisable to leave the X-Mailer header though, as */
2013-01-27 23:52:38 +08:00
/* there is a possibility of a Gimp mail scanner/reader in the */
/* future. It will probably need that header. */
1997-11-25 06:05:25 +08:00
fprintf (mailpipe, "To: %s \n", receipt);
fprintf (mailpipe, "Subject: %s \n", subject);
if (from != NULL && strlen (from) > 0)
fprintf (mailpipe, "From: %s \n", from);
fprintf (mailpipe, "X-Mailer: GIMP Useless Mail plug-in %s\n", GIMP_VERSION);
fprintf (mailpipe, "MIME-Version: 1.0\n");
fprintf (mailpipe, "Content-type: multipart/mixed; "
"boundary=GUMP-MIME-boundary\n");
1997-11-25 06:05:25 +08:00
fprintf (mailpipe, "\n\n");
fprintf (mailpipe, "--GUMP-MIME-boundary\n");
fprintf (mailpipe, "Content-type: text/plain; charset=UTF-8\n\n");
if (mesg_body)
fprintf (mailpipe, "%s", mesg_body);
fprintf (mailpipe, "\n\n");
{
gchar *content = sendmail_content_type (filename);
fprintf (mailpipe, "--GUMP-MIME-boundary\n");
fprintf (mailpipe, "Content-type: %s\n", content);
fprintf (mailpipe, "Content-transfer-encoding: base64\n");
fprintf (mailpipe, "Content-disposition: attachment; filename=\"%s\"\n",
filename);
fprintf (mailpipe, "Content-description: %s\n\n", filename);
g_free (content);
}
g_free (filename);
g_free (receipt);
g_free (from);
g_free (subject);
g_free (comment);
1997-11-25 06:05:25 +08:00
}
static gboolean
sendmail_to64 (const gchar *filename,
FILE *outfile,
GError **error)
1997-11-25 06:05:25 +08:00
{
GMappedFile *infile;
const guchar *in;
gchar out[2048];
gint state = 0;
gint save = 0;
gsize len;
gsize bytes;
gsize c;
infile = g_mapped_file_new (filename, FALSE, error);
if (! infile)
return FALSE;
in = (const guchar *) g_mapped_file_get_contents (infile);
len = g_mapped_file_get_length (infile);
for (c = 0; c < len;)
{
gsize step = MIN (1024, len - c);
bytes = g_base64_encode_step (in + c, step, TRUE, out, &state, &save);
fwrite (out, 1, bytes, outfile);
c += step;
1997-11-25 06:05:25 +08:00
}
bytes = g_base64_encode_close (TRUE, out, &state, &save);
fwrite (out, 1, bytes, outfile);
1997-11-25 06:05:25 +08:00
g_mapped_file_unref (infile);
configure.in po-plug-ins/POTFILES.in plug-ins/common/Makefile.am 2000-01-25 Michael Natterer <mitch@gimp.org> * configure.in * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/megawidget/*: removed. (There were only 3 functions left which were used by ~5 plugins, so I moved the resp. functions to the plugins). More preview stuff to come... * app/airbrush_blob.c * modules/colorsel_triangle.c * modules/colorsel_water.c: use G_PI instead of M_PI. * app/procedural_db.h * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: new PDB return value STATUS_CANCEL which indicates that "Cancel" was pressed in a plugin dialog. (Useful only for file load/save plugins). * app/fileops.[ch] * app/menus.c: changes to handle STATUS_CANCEL correctly. Did some code cleanup in fileops.[ch]. Pop up a warning if File->Save failed. * app/plug_in.c: return_val[0] is of type PDB_STATUS, not PDB_INT32. * libgimp/gimpmath.h: new constant G_MAXRAND which equals to RAND_MAX if it exists or to G_MAXINT otherwise. * libgimp/gimpwidgets.[ch]: new function gimp_random_seed_new() which creates a spinbutton and a "Time" toggle. Call the function which does the "set_sensitive" magic from the radio button callback. * plug-ins/[75 plugins]: - Return STATUS_CANCEL in all file load/save dialogs if "Cancel" was pressed. - Standardized the file plugins' "run" functions. - Use G_PI and G_MAXRAND everywhere. - Added tons of scales and spinbuttons instead of text entries. - Applied uniform packing/spacings all over the place. - Reorganized some UIs (stuff like moving the preview to the top left corner of the dialog). - Removed many ui helper functions and callbacks and use the stuff from libgimp instead. - I tried not to restrict the range of possible values when I replaced entries with spinbuttons/scales but may have failed, though in some cases. Please test ;-) - #include <libgimp/gimpmath.h> where appropriate and use it's constants. - Indentation, s/int/gint/ et.al., code cleanup. RFC: The plugins are definitely not useable with GIMP 1.0 any more, so shouldn't we remove all the remaining compatibility stuff ??? (like "#ifdef GIMP_HAVE_PARASITES")
2000-01-26 01:46:56 +08:00
return TRUE;
1997-11-25 06:05:25 +08:00
}
static FILE *
sendmail_pipe (gchar **cmd,
GPid *pid)
{
gint fd;
GError *err = NULL;
if (! g_spawn_async_with_pipes (NULL, cmd, NULL,
G_SPAWN_DO_NOT_REAP_CHILD |
G_SPAWN_SEARCH_PATH,
NULL, NULL, pid, &fd, NULL, NULL, &err))
{
g_message (_("Could not start sendmail (%s)"), err->message);
g_error_free (err);
*pid = -1;
return NULL;
}
return fdopen (fd, "wb");
}
#endif