1999-05-19 01:33:39 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (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, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2000-10-27 06:02:44 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-10-15 23:30:11 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gui-types.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2003-10-14 23:20:59 +08:00
|
|
|
#include "config/gimpconfig.h"
|
|
|
|
#include "config/gimpconfig-utils.h"
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2001-07-11 20:39:49 +08:00
|
|
|
#include "core/gimp.h"
|
2001-10-29 19:47:11 +08:00
|
|
|
#include "core/gimpimage.h"
|
2001-07-05 23:34:26 +08:00
|
|
|
#include "core/gimpimage-new.h"
|
2003-04-04 01:50:56 +08:00
|
|
|
#include "core/gimptemplate.h"
|
2001-07-05 23:34:26 +08:00
|
|
|
|
2004-05-11 20:13:31 +08:00
|
|
|
#include "widgets/gimpcontainercombobox.h"
|
|
|
|
#include "widgets/gimpcontainerview.h"
|
2003-08-21 23:54:47 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2003-04-11 21:17:23 +08:00
|
|
|
#include "widgets/gimptemplateeditor.h"
|
2002-05-13 23:35:27 +08:00
|
|
|
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "file-new-dialog.h"
|
1998-06-09 05:53:45 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
#define RESPONSE_RESET 1
|
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2003-04-04 01:50:56 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *confirm_dialog;
|
1999-05-19 01:33:39 +08:00
|
|
|
|
2004-05-11 20:13:31 +08:00
|
|
|
GtkWidget *combo;
|
2003-04-11 21:17:23 +08:00
|
|
|
GtkWidget *editor;
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2003-04-04 01:50:56 +08:00
|
|
|
Gimp *gimp;
|
2003-10-14 23:20:59 +08:00
|
|
|
GimpTemplate *template;
|
2003-04-12 01:42:59 +08:00
|
|
|
} FileNewDialog;
|
1998-06-09 05:53:45 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static void file_new_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2003-04-12 01:42:59 +08:00
|
|
|
FileNewDialog *dialog);
|
2004-05-12 00:01:00 +08:00
|
|
|
static void file_new_template_select (GimpContainerView *view,
|
2003-04-04 23:11:30 +08:00
|
|
|
GimpTemplate *template,
|
2003-04-04 01:50:56 +08:00
|
|
|
gpointer insert_data,
|
2003-04-12 01:42:59 +08:00
|
|
|
FileNewDialog *dialog);
|
|
|
|
static void file_new_confirm_dialog (FileNewDialog *dialog);
|
|
|
|
static void file_new_create_image (FileNewDialog *dialog);
|
1998-06-09 05:53:45 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
/* public functions */
|
1998-06-10 05:21:23 +08:00
|
|
|
|
2003-05-03 02:43:15 +08:00
|
|
|
GtkWidget *
|
|
|
|
file_new_dialog_new (Gimp *gimp)
|
1999-08-26 12:39:21 +08:00
|
|
|
{
|
2003-04-12 01:42:59 +08:00
|
|
|
FileNewDialog *dialog;
|
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *table;
|
2001-07-05 23:34:26 +08:00
|
|
|
|
2003-05-03 02:43:15 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2003-04-12 01:42:59 +08:00
|
|
|
dialog = g_new0 (FileNewDialog, 1);
|
2001-07-05 23:34:26 +08:00
|
|
|
|
2003-10-14 23:20:59 +08:00
|
|
|
dialog->gimp = gimp;
|
|
|
|
dialog->template = g_object_new (GIMP_TYPE_TEMPLATE, NULL);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2004-05-06 05:23:45 +08:00
|
|
|
dialog->dialog = gimp_dialog_new (_("Create a New Image"),
|
|
|
|
"gimp-image-new",
|
|
|
|
NULL, 0,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_FILE_NEW,
|
1999-05-31 22:11:10 +08:00
|
|
|
|
2004-05-06 05:23:45 +08:00
|
|
|
GIMP_STOCK_RESET, RESPONSE_RESET,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2004-05-06 05:23:45 +08:00
|
|
|
NULL);
|
2002-02-07 19:50:16 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_signal_connect (dialog->dialog, "response",
|
|
|
|
G_CALLBACK (file_new_response),
|
|
|
|
dialog);
|
|
|
|
|
2003-05-03 02:43:15 +08:00
|
|
|
g_object_set_data_full (G_OBJECT (dialog->dialog),
|
|
|
|
"gimp-file-new-dialog", dialog,
|
|
|
|
(GDestroyNotify) g_free);
|
|
|
|
|
2003-04-12 01:42:59 +08:00
|
|
|
gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE);
|
1998-06-09 05:53:45 +08:00
|
|
|
|
1999-05-19 01:33:39 +08:00
|
|
|
/* vbox holding the rest of the dialog */
|
2004-05-03 23:37:56 +08:00
|
|
|
main_vbox = gtk_vbox_new (FALSE, 12);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
2003-04-12 01:42:59 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->dialog)->vbox),
|
2002-09-08 00:47:39 +08:00
|
|
|
main_vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (main_vbox);
|
1999-04-03 03:46:59 +08:00
|
|
|
|
2003-04-11 04:08:56 +08:00
|
|
|
table = gtk_table_new (1, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
2003-04-04 01:50:56 +08:00
|
|
|
|
2004-05-11 20:13:31 +08:00
|
|
|
dialog->combo = gimp_container_combo_box_new (gimp->templates, NULL, 16, 0);
|
2003-04-04 01:50:56 +08:00
|
|
|
|
2003-04-11 04:08:56 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
2004-05-06 05:23:45 +08:00
|
|
|
_("_Template:"), 1.0, 0.5,
|
2004-05-11 20:13:31 +08:00
|
|
|
dialog->combo, 1, FALSE);
|
2003-04-04 01:50:56 +08:00
|
|
|
|
2004-05-11 20:13:31 +08:00
|
|
|
g_signal_connect (dialog->combo, "select_item",
|
2003-04-04 01:50:56 +08:00
|
|
|
G_CALLBACK (file_new_template_select),
|
2003-04-12 01:42:59 +08:00
|
|
|
dialog);
|
2003-04-04 01:50:56 +08:00
|
|
|
|
2003-04-11 21:17:23 +08:00
|
|
|
/* Template editor */
|
2003-10-14 23:20:59 +08:00
|
|
|
dialog->editor = gimp_template_editor_new (dialog->template, gimp, FALSE);
|
2003-04-12 01:42:59 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), dialog->editor, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (dialog->editor);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
2003-05-03 02:43:15 +08:00
|
|
|
return dialog->dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
file_new_dialog_set (GtkWidget *widget,
|
|
|
|
GimpImage *gimage,
|
|
|
|
GimpTemplate *template)
|
|
|
|
{
|
|
|
|
FileNewDialog *dialog;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
g_return_if_fail (gimage == NULL || GIMP_IS_IMAGE (gimage));
|
|
|
|
g_return_if_fail (template == NULL || GIMP_IS_TEMPLATE (template));
|
|
|
|
|
|
|
|
dialog = g_object_get_data (G_OBJECT (widget), "gimp-file-new-dialog");
|
|
|
|
|
|
|
|
g_return_if_fail (dialog != NULL);
|
|
|
|
|
2003-04-14 00:25:14 +08:00
|
|
|
if (template)
|
|
|
|
{
|
2004-05-11 20:13:31 +08:00
|
|
|
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (dialog->combo),
|
2003-04-14 00:25:14 +08:00
|
|
|
GIMP_VIEWABLE (template));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-05-03 02:43:15 +08:00
|
|
|
template = gimp_image_new_get_last_template (dialog->gimp, gimage);
|
2003-10-14 23:20:59 +08:00
|
|
|
|
2003-10-16 01:10:22 +08:00
|
|
|
gimp_config_sync (GIMP_CONFIG (template),
|
|
|
|
GIMP_CONFIG (dialog->template), 0);
|
2003-10-14 23:20:59 +08:00
|
|
|
|
2003-04-14 00:25:14 +08:00
|
|
|
g_object_unref (template);
|
|
|
|
}
|
1998-06-18 13:04:01 +08:00
|
|
|
}
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
file_new_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
FileNewDialog *dialog)
|
2001-10-29 19:47:11 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
switch (response_id)
|
|
|
|
{
|
|
|
|
case RESPONSE_RESET:
|
|
|
|
gimp_config_sync (GIMP_CONFIG (dialog->gimp->config->default_image),
|
|
|
|
GIMP_CONFIG (dialog->template), 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GTK_RESPONSE_OK:
|
2003-11-14 20:05:13 +08:00
|
|
|
if (dialog->template->initial_size >
|
2003-11-06 23:27:05 +08:00
|
|
|
GIMP_GUI_CONFIG (dialog->gimp->config)->max_new_image_size)
|
|
|
|
file_new_confirm_dialog (dialog);
|
|
|
|
else
|
|
|
|
file_new_create_image (dialog);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
gtk_widget_destroy (dialog->dialog);
|
|
|
|
break;
|
|
|
|
}
|
2003-04-11 04:08:56 +08:00
|
|
|
}
|
|
|
|
|
2003-04-04 23:11:30 +08:00
|
|
|
static void
|
2004-05-12 00:01:00 +08:00
|
|
|
file_new_template_select (GimpContainerView *view,
|
2003-04-04 23:11:30 +08:00
|
|
|
GimpTemplate *template,
|
|
|
|
gpointer insert_data,
|
2003-04-12 01:42:59 +08:00
|
|
|
FileNewDialog *dialog)
|
2003-04-04 23:11:30 +08:00
|
|
|
{
|
2003-10-15 23:30:11 +08:00
|
|
|
gchar *comment = NULL;
|
|
|
|
|
|
|
|
if (!template)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!template->comment || !strlen (template->comment))
|
|
|
|
comment = g_strdup (dialog->template->comment);
|
|
|
|
|
|
|
|
gimp_config_sync (GIMP_CONFIG (template), GIMP_CONFIG (dialog->template), 0);
|
|
|
|
|
|
|
|
if (comment)
|
|
|
|
{
|
|
|
|
g_object_set (dialog->template,
|
|
|
|
"comment", comment,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_free (comment);
|
|
|
|
}
|
2001-10-29 19:47:11 +08:00
|
|
|
}
|
|
|
|
|
2003-04-04 23:11:30 +08:00
|
|
|
|
|
|
|
/* the confirm dialog */
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
static void
|
|
|
|
file_new_confirm_dialog_callback (GtkWidget *widget,
|
|
|
|
gboolean create,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2003-04-12 01:42:59 +08:00
|
|
|
FileNewDialog *dialog = (FileNewDialog *) data;
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2003-04-12 01:42:59 +08:00
|
|
|
dialog->confirm_dialog = NULL;
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
if (create)
|
2003-04-12 01:42:59 +08:00
|
|
|
file_new_create_image (dialog);
|
2001-10-29 19:47:11 +08:00
|
|
|
else
|
2003-04-12 01:42:59 +08:00
|
|
|
gtk_widget_set_sensitive (dialog->dialog, TRUE);
|
2001-10-29 19:47:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-04-12 01:42:59 +08:00
|
|
|
file_new_confirm_dialog (FileNewDialog *dialog)
|
2001-10-29 19:47:11 +08:00
|
|
|
{
|
2003-04-04 23:11:30 +08:00
|
|
|
gchar *size_str;
|
|
|
|
gchar *max_size_str;
|
2001-10-29 19:47:11 +08:00
|
|
|
gchar *text;
|
|
|
|
|
2003-11-14 20:05:13 +08:00
|
|
|
size_str = gimp_memsize_to_string (dialog->template->initial_size);
|
2003-04-12 01:42:59 +08:00
|
|
|
max_size_str = gimp_memsize_to_string (GIMP_GUI_CONFIG (dialog->gimp->config)->max_new_image_size);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2003-11-14 23:33:40 +08:00
|
|
|
text = g_strdup_printf (_("You are trying to create an image with "
|
2001-11-27 01:12:29 +08:00
|
|
|
"an initial size of %s.\n\n"
|
2001-10-29 19:47:11 +08:00
|
|
|
"Choose OK to create this image anyway.\n"
|
2003-11-14 23:33:40 +08:00
|
|
|
"Choose Cancel if you did not intend to "
|
2001-10-29 19:47:11 +08:00
|
|
|
"create such a large image.\n\n"
|
2003-11-14 23:33:40 +08:00
|
|
|
"To prevent this dialog from appearing, "
|
|
|
|
"increase the \"Maximum Image Size\" "
|
|
|
|
"setting (currently %s) in the "
|
2001-11-27 01:12:29 +08:00
|
|
|
"Preferences dialog."),
|
2003-04-04 23:11:30 +08:00
|
|
|
size_str, max_size_str);
|
|
|
|
|
|
|
|
g_free (size_str);
|
|
|
|
g_free (max_size_str);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2003-04-12 01:42:59 +08:00
|
|
|
dialog->confirm_dialog =
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_query_boolean_box (_("Confirm Image Size"),
|
2003-11-08 23:29:47 +08:00
|
|
|
dialog->dialog,
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_standard_help_func,
|
2003-08-21 23:54:47 +08:00
|
|
|
GIMP_HELP_FILE_NEW_CONFIRM,
|
2003-03-07 00:47:34 +08:00
|
|
|
GIMP_STOCK_INFO,
|
2001-10-29 19:47:11 +08:00
|
|
|
text,
|
|
|
|
GTK_STOCK_OK, GTK_STOCK_CANCEL,
|
|
|
|
NULL, NULL,
|
|
|
|
file_new_confirm_dialog_callback,
|
2003-04-12 01:42:59 +08:00
|
|
|
dialog);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
g_free (text);
|
|
|
|
|
2003-04-12 01:42:59 +08:00
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog->confirm_dialog),
|
|
|
|
GTK_WINDOW (dialog->dialog));
|
2003-03-20 22:34:16 +08:00
|
|
|
|
2003-04-12 01:42:59 +08:00
|
|
|
gtk_widget_set_sensitive (dialog->dialog, FALSE);
|
2003-03-20 22:34:16 +08:00
|
|
|
|
2003-04-12 01:42:59 +08:00
|
|
|
gtk_widget_show (dialog->confirm_dialog);
|
2001-10-29 19:47:11 +08:00
|
|
|
}
|
2003-04-11 21:17:23 +08:00
|
|
|
|
|
|
|
static void
|
2003-04-12 01:42:59 +08:00
|
|
|
file_new_create_image (FileNewDialog *dialog)
|
2003-04-11 21:17:23 +08:00
|
|
|
{
|
|
|
|
GimpTemplate *template;
|
2003-05-03 02:43:15 +08:00
|
|
|
Gimp *gimp;
|
2003-04-11 21:17:23 +08:00
|
|
|
|
2003-10-14 23:20:59 +08:00
|
|
|
template = g_object_ref (dialog->template);
|
|
|
|
gimp = dialog->gimp;
|
2003-05-03 02:43:15 +08:00
|
|
|
|
2003-04-12 01:42:59 +08:00
|
|
|
gtk_widget_destroy (dialog->dialog);
|
2003-04-11 21:17:23 +08:00
|
|
|
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_template_create_image (gimp, template, gimp_get_user_context (gimp));
|
2003-05-03 02:43:15 +08:00
|
|
|
gimp_image_new_set_last_template (gimp, template);
|
2003-10-14 23:20:59 +08:00
|
|
|
|
2003-04-11 21:17:23 +08:00
|
|
|
g_object_unref (template);
|
|
|
|
}
|