Gimp/app/dialogs/quit-dialog.c
Sven Neumann 4762b73403 bumped minimum required version of GLib to 2.18.0.
2008-11-04  Sven Neumann  <sven@sven>

	* configure.in: bumped minimum required version of GLib to 
2.18.0.

	* INSTALL: document the updated dependency.

	* app/core/gimp.[ch]: introduced gimp_message_literal(), a 
variant
	of gimp_message() that takes a literal string.

	* app/errors.[ch]: removed format arguments from 
gimp_fatal_error()
	and gimp_terminate() and let them take a literal string instead.

	* app/tools/gimptool.[ch]: introduced 
gimp_tool_message_literal(),
	a variant of gimp_tool_message() that takes a literal string.

	* app/actions/documents-commands.c
	* app/actions/drawable-commands.c
	* app/actions/edit-commands.c
	* app/actions/error-console-commands.c
	* app/actions/file-commands.c
	* app/actions/gradients-commands.c
	* app/actions/image-commands.c
	* app/actions/layers-commands.c
	* app/actions/palettes-commands.c
	* app/actions/plug-in-commands.c
	* app/actions/select-commands.c
	* app/actions/vectors-commands.c
	* app/config/gimprc.c
	* app/core/gimp-modules.c
	* app/core/gimp-parasites.c
	* app/core/gimp-templates.c
	* app/core/gimp-units.c
	* app/core/gimpchannel.c
	* app/core/gimpcontainer-filter.c
	* app/core/gimpdrawable-bucket-fill.c
	* app/core/gimpimage-convert.c
	* app/core/gimpimage-merge.c
	* app/core/gimpimage.c
	* app/core/gimpimagefile.c
	* app/core/gimplayer-floating-sel.c
	* app/core/gimplayer.c
	* app/core/gimpselection.c
	* app/dialogs/convert-dialog.c
	* app/dialogs/dialogs.c
	* app/dialogs/palette-import-dialog.c
	* app/dialogs/preferences-dialog.c
	* app/dialogs/quit-dialog.c
	* app/dialogs/stroke-dialog.c
	* app/display/gimpdisplayshell-dnd.c
	* app/file/file-open.c
	* app/file/file-procedure.c
	* app/file/file-save.c
	* app/file/file-utils.c
	* app/gegl/gimpcurvesconfig.c
	* app/gegl/gimplevelsconfig.c
	* app/gui/gui-message.c
	* app/gui/gui.c
	* app/gui/session.c
	* app/paint/gimpbrushcore.c
	* app/paint/gimpclone.c
	* app/paint/gimpheal.c
	* app/paint/gimpperspectiveclone.c
	* app/paint/gimpsourcecore.c
	* app/pdb/gimppdb-utils.c
	* app/pdb/gimpprocedure.c
	* app/plug-in/gimpplugin-message.c
	* app/plug-in/gimpplugin.c
	* app/plug-in/gimppluginmanager-restore.c
	* app/plug-in/gimppluginprocedure.c
	* app/text/gimptextlayer.c
	* app/tools/gimp-tools.c
	* app/tools/gimpaligntool.c
	* app/tools/gimpblendtool.c
	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpbucketfilltool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcolorpickertool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimpdesaturatetool.c
	* app/tools/gimpeditselectiontool.c
	* app/tools/gimpforegroundselecttool.c
	* app/tools/gimpfreeselecttool.c
	* app/tools/gimpgegltool.c
	* app/tools/gimphuesaturationtool.c
	* app/tools/gimpimagemaptool-settings.c
	* app/tools/gimpiscissorstool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimppainttool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimpselectiontool.c
	* app/tools/gimpsourcetool.c
	* app/tools/gimpthresholdtool.c
	* app/tools/gimptransformtool.c
	* app/tools/gimpvectortool.c
	* app/widgets/gimpactionview.c
	* app/widgets/gimpcontrollerlist.c
	* app/widgets/gimpcontrollers.c
	* app/widgets/gimpdataeditor.c
	* app/widgets/gimpdevices.c
	* app/widgets/gimpdnd-xds.c
	* app/widgets/gimperrordialog.c
	* app/widgets/gimphelp.c
	* app/widgets/gimpitemtreeview.c
	* app/widgets/gimppdbdialog.c
	* app/widgets/gimpsettingsbox.c
	* app/widgets/gimpvectorstreeview.c
	* app/widgets/gimpwidgets-utils.c
	* app/xcf/xcf-load.c
	* tools/pdbgen/pdb/convert.pdb
	* tools/pdbgen/pdb/edit.pdb
	* tools/pdbgen/pdb/floating_sel.pdb
	* tools/pdbgen/pdb/image.pdb: use the _literal variants for
	g_set_error(), gimp_message() and gimp_tool_message().

	* app/pdb/convert-cmds.c
	* app/pdb/edit-cmds.c
	* app/pdb/floating-sel-cmds.c
	* app/pdb/image-cmds.c: regenerated.


svn path=/trunk/; revision=27548
2008-11-04 12:33:09 +00:00

263 lines
9.2 KiB
C

/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
*
* 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 "libgimpwidgets/gimpwidgets.h"
#include "dialogs-types.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "widgets/gimpcontainertreeview.h"
#include "widgets/gimpcontainerview.h"
#include "widgets/gimpdnd.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmessagebox.h"
#include "widgets/gimpmessagedialog.h"
#include "quit-dialog.h"
#include "gimp-intl.h"
static GtkWidget * quit_close_all_dialog_new (Gimp *gimp,
gboolean do_quit);
static void quit_close_all_dialog_response (GtkWidget *dialog,
gint response_id,
Gimp *gimp);
static void quit_close_all_dialog_container_changed (GimpContainer *images,
GimpObject *image,
GimpMessageBox *box);
static void quit_close_all_dialog_image_activated (GimpContainerView *view,
GimpImage *image,
gpointer insert_data,
Gimp *gimp);
/* public functions */
GtkWidget *
quit_dialog_new (Gimp *gimp)
{
return quit_close_all_dialog_new (gimp, TRUE);
}
GtkWidget *
close_all_dialog_new (Gimp *gimp)
{
return quit_close_all_dialog_new (gimp, FALSE);
}
static GtkWidget *
quit_close_all_dialog_new (Gimp *gimp,
gboolean do_quit)
{
GimpContainer *images;
GimpContext *context;
GimpMessageBox *box;
GtkWidget *dialog;
GtkWidget *label;
GtkWidget *button;
GtkWidget *view;
GtkWidget *dnd_widget;
gint rows;
gint view_size;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
#ifdef __GNUC__
#warning FIXME: need container of dirty images
#endif
images = gimp_displays_get_dirty_images (gimp);
context = gimp_context_new (gimp, "close-all-dialog",
gimp_get_user_context (gimp));
g_return_val_if_fail (images != NULL, NULL);
dialog =
gimp_message_dialog_new (do_quit ? _("Quit GIMP") : _("Close All Images"),
GIMP_STOCK_WARNING,
NULL, 0,
gimp_standard_help_func,
do_quit ?
GIMP_HELP_FILE_QUIT : GIMP_HELP_FILE_CLOSE_ALL,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
g_object_set_data_full (G_OBJECT (dialog), "dirty-images",
images, (GDestroyNotify) g_object_unref);
g_object_set_data_full (G_OBJECT (dialog), "dirty-images-context",
context, (GDestroyNotify) g_object_unref);
g_signal_connect (dialog, "response",
G_CALLBACK (quit_close_all_dialog_response),
gimp);
box = GIMP_MESSAGE_DIALOG (dialog)->box;
button = gtk_dialog_add_button (GTK_DIALOG (dialog), "", GTK_RESPONSE_OK);
g_object_set_data (G_OBJECT (box), "ok-button", button);
g_object_set_data (G_OBJECT (box), "do-quit", GINT_TO_POINTER (do_quit));
g_signal_connect_object (images, "add",
G_CALLBACK (quit_close_all_dialog_container_changed),
box, 0);
g_signal_connect_object (images, "remove",
G_CALLBACK (quit_close_all_dialog_container_changed),
box, 0);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
view_size = gimp->config->layer_preview_size;
rows = CLAMP (gimp_container_num_children (images), 3, 6);
view = gimp_container_tree_view_new (images, context, view_size, 1);
gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (view),
-1,
rows * (view_size + 2));
gtk_box_pack_start (GTK_BOX (box), view, TRUE, TRUE, 0);
gtk_widget_show (view);
g_signal_connect (view, "activate-item",
G_CALLBACK (quit_close_all_dialog_image_activated),
gimp);
dnd_widget = gimp_container_view_get_dnd_widget (GIMP_CONTAINER_VIEW (view));
gimp_dnd_xds_source_add (dnd_widget,
(GimpDndDragViewableFunc) gimp_dnd_get_drag_data,
NULL);
if (do_quit)
label = gtk_label_new (_("If you quit GIMP now, "
"these changes will be lost."));
else
label = gtk_label_new (_("If you close these images now, "
"changes will be lost."));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_object_set_data (G_OBJECT (box), "lost-label", label);
quit_close_all_dialog_container_changed (images, NULL,
GIMP_MESSAGE_DIALOG (dialog)->box);
return dialog;
}
static void
quit_close_all_dialog_response (GtkWidget *dialog,
gint response_id,
Gimp *gimp)
{
GimpMessageBox *box = GIMP_MESSAGE_DIALOG (dialog)->box;
gboolean do_quit = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (box),
"do-quit"));
gtk_widget_destroy (dialog);
if (response_id == GTK_RESPONSE_OK)
{
if (do_quit)
gimp_exit (gimp, TRUE);
else
gimp_displays_close (gimp);
}
}
static void
quit_close_all_dialog_container_changed (GimpContainer *images,
GimpObject *image,
GimpMessageBox *box)
{
gint num_images = gimp_container_num_children (images);
GtkWidget *label = g_object_get_data (G_OBJECT (box), "lost-label");
GtkWidget *button = g_object_get_data (G_OBJECT (box), "ok-button");
GtkWidget *dialog = gtk_widget_get_toplevel (button);
gboolean do_quit = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (box),
"do-quit"));
gimp_message_box_set_primary_text (box,
ngettext ("There is one image with "
"unsaved changes:",
"There are %d images with "
"unsaved changes:",
num_images), num_images);
if (num_images == 0)
{
gtk_widget_hide (label);
g_object_set (button,
"label", do_quit ? GTK_STOCK_QUIT : GTK_STOCK_CLOSE,
"use-stock", TRUE,
"image", NULL,
NULL);
gtk_widget_grab_default (button);
}
else
{
GtkWidget *icon = gtk_image_new_from_stock (GTK_STOCK_DELETE,
GTK_ICON_SIZE_BUTTON);
gtk_widget_show (label);
g_object_set (button,
"label", _("_Discard Changes"),
"use-stock", FALSE,
"image", icon,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
GTK_RESPONSE_CANCEL);
}
}
static void
quit_close_all_dialog_image_activated (GimpContainerView *view,
GimpImage *image,
gpointer insert_data,
Gimp *gimp)
{
GList *list;
for (list = gimp_get_display_iter (gimp);
list;
list = g_list_next (list))
{
GimpDisplay *display = list->data;
if (display->image == image)
gtk_window_present (GTK_WINDOW (display->shell));
}
}