Commit 582a0966 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/dialogs/Makefile.am removed these files.

2004-09-13  Michael Natterer  <mitch@gimp.org>

	* app/dialogs/Makefile.am
	* app/dialogs/file-dialog-utils.[ch]: removed these files.

	* app/dialogs/file-save-dialog.[ch]: removed functions
	file_save_dialog_show() and file_save_a_copy_dialog_show() and
	changed internal function file_save_dialog_create() to
	file_save_dialog_new().

	* app/dialogs/dialogs.c
	* app/dialogs/dialogs-constructors.[ch]: made it completely
	managed by the dialog factory.

	* app/actions/file-commands.c: create it using the dialog
	factory. Attach it to the image so we open only one save
	dialog per image.

	* app/dialogs/file-open-dialog.c: added precondition checks
	to file_open_dialog_new().
parent 2449510d
2004-09-13 Michael Natterer <mitch@gimp.org>
* app/dialogs/Makefile.am
* app/dialogs/file-dialog-utils.[ch]: removed these files.
* app/dialogs/file-save-dialog.[ch]: removed functions
file_save_dialog_show() and file_save_a_copy_dialog_show() and
changed internal function file_save_dialog_create() to
file_save_dialog_new().
* app/dialogs/dialogs.c
* app/dialogs/dialogs-constructors.[ch]: made it completely
managed by the dialog factory.
* app/actions/file-commands.c: create it using the dialog
factory. Attach it to the image so we open only one save
dialog per image.
* app/dialogs/file-open-dialog.c: added precondition checks
to file_open_dialog_new().
2004-09-13 Sven Neumann <sven@gimp.org>
* plug-ins/common/jpeg.c: some code cleanup.
......
......@@ -49,7 +49,6 @@
#include "menus/menus.h"
#include "dialogs/dialogs.h"
#include "dialogs/file-save-dialog.h"
#include "actions.h"
#include "file-commands.h"
......@@ -215,14 +214,57 @@ file_save_cmd_callback (GtkAction *action,
}
}
static void
file_dialog_destroyed (GimpFileDialog *dialog,
GimpImage *gimage)
{
if (dialog->gimage == gimage)
g_object_set_data (G_OBJECT (gimage), "gimp-file-save-dialog", NULL);
}
void
file_save_as_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *gdisp;
GtkWidget *widget;
GtkWidget *dialog;
return_if_no_display (gdisp, data);
return_if_no_widget (widget, data);
if (! gimp_image_active_drawable (gdisp->gimage))
return;
dialog = g_object_get_data (G_OBJECT (gdisp->gimage),
"gimp-file-save-dialog");
if (! dialog)
{
dialog = gimp_dialog_factory_dialog_new (global_dialog_factory,
gtk_widget_get_screen (widget),
"gimp-file-save-dialog",
-1, FALSE);
file_save_dialog_show (gdisp->gimage, gdisp->shell);
if (dialog)
{
g_object_set_data_full (G_OBJECT (gdisp->gimage),
"gimp-file-save-dialog", dialog,
(GDestroyNotify) gtk_widget_destroy);
g_signal_connect (dialog, "destroy",
G_CALLBACK (file_dialog_destroyed),
gdisp->gimage);
}
}
if (dialog)
{
gtk_window_set_title (GTK_WINDOW (dialog), _("Save Image"));
gimp_file_dialog_set_image (GIMP_FILE_DIALOG (dialog), gdisp->gimage,
TRUE, TRUE);
gtk_window_present (GTK_WINDOW (dialog));
}
}
void
......@@ -230,9 +272,45 @@ file_save_a_copy_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *gdisp;
GtkWidget *widget;
GtkWidget *dialog;
return_if_no_display (gdisp, data);
return_if_no_widget (widget, data);
if (! gimp_image_active_drawable (gdisp->gimage))
return;
dialog = g_object_get_data (G_OBJECT (gdisp->gimage),
"gimp-file-save-dialog");
if (! dialog)
{
dialog = gimp_dialog_factory_dialog_new (global_dialog_factory,
gtk_widget_get_screen (widget),
"gimp-file-save-dialog",
-1, FALSE);
if (dialog)
{
g_object_set_data_full (G_OBJECT (gdisp->gimage),
"gimp-file-save-dialog", dialog,
(GDestroyNotify) gtk_widget_destroy);
g_signal_connect (dialog, "destroy",
G_CALLBACK (file_dialog_destroyed),
gdisp->gimage);
}
}
file_save_a_copy_dialog_show (gdisp->gimage, gdisp->shell);
if (dialog)
{
gtk_window_set_title (GTK_WINDOW (dialog), _("Save a Copy of the Image"));
gimp_file_dialog_set_image (GIMP_FILE_DIALOG (dialog), gdisp->gimage,
FALSE, FALSE);
gtk_window_present (GTK_WINDOW (dialog));
}
}
void
......
......@@ -15,8 +15,6 @@ libappdialogs_a_SOURCES = \
color-dialog.h \
convert-dialog.c \
convert-dialog.h \
file-dialog-utils.c \
file-dialog-utils.h \
file-open-dialog.c \
file-open-dialog.h \
file-open-location-dialog.c \
......
......@@ -82,6 +82,7 @@
#include "dialogs-constructors.h"
#include "file-open-dialog.h"
#include "file-open-location-dialog.h"
#include "file-save-dialog.h"
#include "image-new-dialog.h"
#include "module-dialog.h"
#include "preferences-dialog.h"
......@@ -131,6 +132,14 @@ dialogs_file_open_location_new (GimpDialogFactory *factory,
return file_open_location_dialog_new (context->gimp);
}
GtkWidget *
dialogs_file_save_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
return file_save_dialog_new (context->gimp);
}
GtkWidget *
dialogs_preferences_get (GimpDialogFactory *factory,
GimpContext *context,
......
......@@ -31,6 +31,9 @@ GtkWidget * dialogs_file_open_new (GimpDialogFactory *factory,
GtkWidget * dialogs_file_open_location_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_file_save_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_preferences_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
......
......@@ -41,9 +41,6 @@ GimpDialogFactory *global_toolbox_factory = NULL;
static const GimpDialogFactoryEntry toplevel_entries[] =
{
/* foreign toplevels without constructor */
{ "gimp-file-save-dialog",
NULL, 0, TRUE, TRUE, TRUE, FALSE },
{ "gimp-brightness-contrast-tool-dialog",
NULL, 0, TRUE, TRUE, FALSE, FALSE },
{ "gimp-color-picker-tool-dialog",
......@@ -94,6 +91,8 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
0, TRUE, TRUE, TRUE, FALSE },
{ "gimp-file-open-location-dialog", dialogs_file_open_location_new,
0, FALSE, TRUE, FALSE, FALSE },
{ "gimp-file-save-dialog", dialogs_file_save_new,
0, FALSE, TRUE, TRUE, FALSE },
/* singleton toplevels */
{ "gimp-preferences-dialog", dialogs_preferences_get,
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995, 1996, 1997 Spencer Kimball and Peter Mattis
* Copyright (C) 1997 Josh MacDonald
*
* 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.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "dialogs-types.h"
#include "widgets/gimpactiongroup.h"
#include "file-dialog-utils.h"
void
file_dialog_show (GtkWidget *dialog,
GtkWidget *parent)
{
GList *list;
for (list = gimp_action_groups_from_name ("file");
list;
list = g_list_next (list))
{
GimpActionGroup *group = list->data;
gimp_action_group_set_action_sensitive (group, "file-save", FALSE);
gimp_action_group_set_action_sensitive (group, "file-save-as", FALSE);
gimp_action_group_set_action_sensitive (group, "file-save-a-copy", FALSE);
}
gtk_window_set_screen (GTK_WINDOW (dialog), gtk_widget_get_screen (parent));
gtk_window_present (GTK_WINDOW (dialog));
}
void
file_dialog_hide (GtkWidget *dialog)
{
GList *list;
gtk_widget_hide (dialog);
for (list = gimp_action_groups_from_name ("file");
list;
list = g_list_next (list))
{
GimpActionGroup *group = list->data;
gimp_action_group_set_action_sensitive (group, "file-save", TRUE);
gimp_action_group_set_action_sensitive (group, "file-save-as", TRUE);
gimp_action_group_set_action_sensitive (group, "file-save-a-copy", TRUE);
}
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 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.
*/
#ifndef __FILE_DIALOG_UTILS_H__
#define __FILE_DIALOG_UTILS_H__
void file_dialog_show (GtkWidget *dialog,
GtkWidget *parent);
void file_dialog_hide (GtkWidget *dialog);
#endif /* __FILE_DIALOG_UTILS_H__ */
......@@ -61,6 +61,8 @@ file_open_dialog_new (Gimp *gimp)
{
GtkWidget *dialog;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
dialog = gimp_file_dialog_new (gimp,
GTK_FILE_CHOOSER_ACTION_OPEN,
_("Open Image"), "gimp-file-open",
......
......@@ -34,13 +34,9 @@
#include "file/file-save.h"
#include "file/file-utils.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpfiledialog.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmenufactory.h"
#include "dialogs.h"
#include "file-dialog-utils.h"
#include "file-save-dialog.h"
#include "gimp-intl.h"
......@@ -48,106 +44,39 @@
/* local function prototypes */
static GtkWidget * file_save_dialog_create (Gimp *gimp);
static void file_save_dialog_response (GtkWidget *save_dialog,
gint response_id,
Gimp *gimp);
static void file_save_overwrite (GtkWidget *save_dialog,
const gchar *uri,
const gchar *raw_filename);
static void file_save_overwrite_callback (GtkWidget *widget,
gboolean overwrite,
gpointer data);
static gboolean file_save_dialog_save_image (GtkWidget *save_dialog,
GimpImage *gimage,
const gchar *uri,
const gchar *raw_filename,
PlugInProcDef *save_proc,
gboolean set_uri_and_proc,
gboolean set_image_clean);
/* private variables */
static GtkWidget *filesave = NULL;
static void file_save_dialog_response (GtkWidget *save_dialog,
gint response_id,
Gimp *gimp);
static void file_save_overwrite (GtkWidget *save_dialog,
const gchar *uri,
const gchar *raw_filename);
static void file_save_overwrite_callback (GtkWidget *widget,
gboolean overwrite,
gpointer data);
static gboolean file_save_dialog_save_image (GtkWidget *save_dialog,
GimpImage *gimage,
const gchar *uri,
const gchar *raw_filename,
PlugInProcDef *save_proc,
gboolean set_uri_and_proc,
gboolean set_image_clean);
/* public functions */
void
file_save_dialog_show (GimpImage *gimage,
GtkWidget *parent)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent));
if (! gimp_image_active_drawable (gimage))
return;
if (! filesave)
filesave = file_save_dialog_create (gimage->gimp);
gimp_file_dialog_set_sensitive (GIMP_FILE_DIALOG (filesave), TRUE);
if (GTK_WIDGET_VISIBLE (filesave))
{
gtk_window_present (GTK_WINDOW (filesave));
return;
}
gtk_window_set_title (GTK_WINDOW (filesave), _("Save Image"));
gimp_file_dialog_set_image (GIMP_FILE_DIALOG (filesave), gimage, TRUE, TRUE);
file_dialog_show (filesave, parent);
}
void
file_save_a_copy_dialog_show (GimpImage *gimage,
GtkWidget *parent)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent));
if (! gimp_image_active_drawable (gimage))
return;
if (! filesave)
filesave = file_save_dialog_create (gimage->gimp);
gimp_file_dialog_set_sensitive (GIMP_FILE_DIALOG (filesave), TRUE);
if (GTK_WIDGET_VISIBLE (filesave))
{
gtk_window_present (GTK_WINDOW (filesave));
return;
}
gtk_window_set_title (GTK_WINDOW (filesave), _("Save a Copy of the Image"));
gimp_file_dialog_set_image (GIMP_FILE_DIALOG (filesave),
gimage, FALSE, FALSE);
file_dialog_show (filesave, parent);
}
/* private functions */
static GtkWidget *
file_save_dialog_create (Gimp *gimp)
GtkWidget *
file_save_dialog_new (Gimp *gimp)
{
GtkWidget *dialog;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
dialog = gimp_file_dialog_new (gimp,
GTK_FILE_CHOOSER_ACTION_SAVE,
_("Save Image"), "gimp-file-save",
GTK_STOCK_SAVE,
GIMP_HELP_FILE_SAVE);
gimp_dialog_factory_add_foreign (global_dialog_factory,
"gimp-file-save-dialog", dialog);
g_signal_connect (dialog, "response",
G_CALLBACK (file_save_dialog_response),
gimp);
......@@ -155,6 +84,9 @@ file_save_dialog_create (Gimp *gimp)
return dialog;
}
/* private functions */
static void
file_save_dialog_response (GtkWidget *save_dialog,
gint response_id,
......@@ -167,7 +99,7 @@ file_save_dialog_response (GtkWidget *save_dialog,
if (response_id != GTK_RESPONSE_OK)
{
if (! dialog->busy)
file_dialog_hide (save_dialog);
gtk_widget_hide (save_dialog);
return;
}
......@@ -192,7 +124,7 @@ file_save_dialog_response (GtkWidget *save_dialog,
dialog->set_uri_and_proc,
dialog->set_image_clean))
{
file_dialog_hide (save_dialog);
gtk_widget_hide (save_dialog);
}
gimp_file_dialog_set_sensitive (dialog, TRUE);
......@@ -279,7 +211,7 @@ file_save_overwrite_callback (GtkWidget *widget,
dialog->set_uri_and_proc,
dialog->set_image_clean))
{
file_dialog_hide (overwrite_data->save_dialog);
gtk_widget_hide (overwrite_data->save_dialog);
}
}
......
......@@ -20,10 +20,7 @@
#define __FILE_SAVE_DIALOG_H__
void file_save_dialog_show (GimpImage *gimage,
GtkWidget *parent);
void file_save_a_copy_dialog_show (GimpImage *gimage,
GtkWidget *parent);
GtkWidget * file_save_dialog_new (Gimp *gimp);
#endif /* __FILE_SAVE_DIALOG_H__ */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment