Commit 71cf9ee2 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Applied (slightly modified) patch from Sylvain Foret which adds "Close

2005-09-24  Michael Natterer  <mitch@gimp.org>

	Applied (slightly modified) patch from Sylvain Foret which adds
	"Close All" menu entries and dialog. Fixes bug #163532.

	* app/actions/file-actions.c
	* app/actions/file-commands.[ch]: added "file-close-all" action
	and callback.

	* app/dialogs/dialogs-constructors.[ch]
	* app/dialogs/dialogs.c
	* app/dialogs/quit-dialog.[ch]: added close all dialog which is a
	modified quit dialog.

	* app/widgets/gimphelp-ids.h: added help ID.

	* menus/image-menu.xml.in
	* menus/toolbox-menu.xml.in: add close all next to quit.
parent 871449b1
2005-09-24 Michael Natterer <mitch@gimp.org>
Applied (slightly modified) patch from Sylvain Foret which adds
"Close All" menu entries and dialog. Fixes bug #163532.
* app/actions/file-actions.c
* app/actions/file-commands.[ch]: added "file-close-all" action
and callback.
* app/dialogs/dialogs-constructors.[ch]
* app/dialogs/dialogs.c
* app/dialogs/quit-dialog.[ch]: added close all dialog which is a
modified quit dialog.
* app/widgets/gimphelp-ids.h: added help ID.
* menus/image-menu.xml.in
* menus/toolbox-menu.xml.in: add close all next to quit.
2005-09-24 Michael Natterer <mitch@gimp.org>
* app/display/gimpdisplayshell-scale.c
......
......@@ -107,6 +107,11 @@ static GimpActionEntry file_actions[] =
G_CALLBACK (file_revert_cmd_callback),
GIMP_HELP_FILE_REVERT },
{ "file-close-all", GTK_STOCK_CLOSE,
N_("Close all"), NULL, NULL,
G_CALLBACK (file_close_all_cmd_callback),
GIMP_HELP_FILE_CLOSE_ALL },
{ "file-quit", GTK_STOCK_QUIT,
N_("_Quit"), "<control>Q", NULL,
G_CALLBACK (file_quit_cmd_callback),
......
......@@ -358,6 +358,28 @@ file_revert_cmd_callback (GtkAction *action,
}
}
void
file_close_all_cmd_callback (GtkAction *action,
gpointer data)
{
Gimp *gimp;
return_if_no_gimp (gimp, data);
if (! gimp_displays_dirty (gimp))
{
gimp_displays_delete (gimp);
}
else
{
GtkWidget *widget;
return_if_no_widget (widget, data);
gimp_dialog_factory_dialog_raise (global_dialog_factory,
gtk_widget_get_screen (widget),
"gimp-close-all-dialog", -1);
}
}
void
file_quit_cmd_callback (GtkAction *action,
gpointer data)
......
......@@ -43,6 +43,8 @@ void file_save_template_cmd_callback (GtkAction *action,
void file_revert_cmd_callback (GtkAction *action,
gpointer data);
void file_close_all_cmd_callback (GtkAction *action,
gpointer data);
void file_quit_cmd_callback (GtkAction *action,
gpointer data);
......
......@@ -166,6 +166,14 @@ dialogs_error_get (GimpDialogFactory *factory,
return gimp_error_dialog_new (_("GIMP Message"));
}
GtkWidget *
dialogs_close_all_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
return close_all_dialog_new (context->gimp);
}
GtkWidget *
dialogs_quit_get (GimpDialogFactory *factory,
GimpContext *context,
......
......@@ -49,6 +49,9 @@ GtkWidget * dialogs_about_get (GimpDialogFactory *factory,
GtkWidget * dialogs_error_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_close_all_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
GtkWidget * dialogs_quit_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
......
......@@ -103,6 +103,8 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
dialogs_about_get, TRUE, FALSE, FALSE),
TOPLEVEL ("gimp-error-dialog",
dialogs_error_get, TRUE, FALSE, FALSE),
TOPLEVEL ("gimp-close-all-dialog",
dialogs_close_all_get, TRUE, FALSE, FALSE),
TOPLEVEL ("gimp-quit-dialog",
dialogs_quit_get, TRUE, FALSE, FALSE)
};
......
......@@ -45,23 +45,37 @@
#include "gimp-intl.h"
static void quit_dialog_response (GtkWidget *dialog,
gint response_id,
Gimp *gimp);
static void quit_dialog_container_changed (GimpContainer *images,
GimpObject *image,
GimpMessageBox *box);
static void quit_dialog_image_activated (GimpContainerView *view,
GimpImage *image,
gpointer insert_data,
Gimp *gimp);
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;
GimpMessageBox *box;
......@@ -96,7 +110,7 @@ quit_dialog_new (Gimp *gimp)
images, (GDestroyNotify) g_object_unref);
g_signal_connect (dialog, "response",
G_CALLBACK (quit_dialog_response),
G_CALLBACK (quit_close_all_dialog_response),
gimp);
box = GIMP_MESSAGE_DIALOG (dialog)->box;
......@@ -104,12 +118,13 @@ quit_dialog_new (Gimp *gimp)
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_dialog_container_changed),
G_CALLBACK (quit_close_all_dialog_container_changed),
box, 0);
g_signal_connect_object (images, "remove",
G_CALLBACK (quit_dialog_container_changed),
G_CALLBACK (quit_close_all_dialog_container_changed),
box, 0);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
......@@ -128,7 +143,7 @@ quit_dialog_new (Gimp *gimp)
gtk_widget_show (view);
g_signal_connect (view, "activate-item",
G_CALLBACK (quit_dialog_image_activated),
G_CALLBACK (quit_close_all_dialog_image_activated),
gimp);
dnd_widget = gimp_container_view_get_dnd_widget (GIMP_CONTAINER_VIEW (view));
......@@ -136,8 +151,12 @@ quit_dialog_new (Gimp *gimp)
(GimpDndDragViewableFunc) gimp_dnd_get_drag_data,
NULL);
label = gtk_label_new (_("If you quit GIMP now, "
"these changes will be lost."));
if (do_quit)
label = gtk_label_new (_("If you quit GIMP now, "
"these changes will be lost."));
else
label = gtk_label_new (_("If close these files 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);
......@@ -145,32 +164,43 @@ quit_dialog_new (Gimp *gimp)
g_object_set_data (G_OBJECT (box), "lost-label", label);
quit_dialog_container_changed (images, NULL,
GIMP_MESSAGE_DIALOG (dialog)->box);
quit_close_all_dialog_container_changed (images, NULL,
GIMP_MESSAGE_DIALOG (dialog)->box);
return dialog;
}
static void
quit_dialog_response (GtkWidget *dialog,
gint response_id,
Gimp *gimp)
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)
gimp_exit (gimp, TRUE);
{
if (do_quit)
gimp_exit (gimp, TRUE);
else
gimp_displays_delete (gimp);
}
}
static void
quit_dialog_container_changed (GimpContainer *images,
GimpObject *image,
GimpMessageBox *box)
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"));
gchar *text;
text = g_strdup_printf (ngettext ("There is one image with unsaved changes:",
......@@ -183,7 +213,7 @@ quit_dialog_container_changed (GimpContainer *images,
{
gtk_widget_hide (label);
g_object_set (button,
"label", GTK_STOCK_QUIT,
"label", do_quit ? GTK_STOCK_QUIT : GTK_STOCK_CLOSE,
"use-stock", TRUE,
"image", NULL,
NULL);
......@@ -204,10 +234,10 @@ quit_dialog_container_changed (GimpContainer *images,
}
static void
quit_dialog_image_activated (GimpContainerView *view,
GimpImage *image,
gpointer insert_data,
Gimp *gimp)
quit_close_all_dialog_image_activated (GimpContainerView *view,
GimpImage *image,
gpointer insert_data,
Gimp *gimp)
{
GList *list;
......
......@@ -22,7 +22,8 @@
#define __QUIT_DIALOG_H__
GtkWidget * quit_dialog_new (Gimp *gimp);
GtkWidget * quit_dialog_new (Gimp *gimp);
GtkWidget * close_all_dialog_new (Gimp *gimp);
#endif /* __QUIT_DIALOG_H__ */
......@@ -38,6 +38,7 @@
#define GIMP_HELP_FILE_SAVE_BY_EXTENSION "gimp-file-save-by-extension"
#define GIMP_HELP_FILE_REVERT "gimp-file-revert"
#define GIMP_HELP_FILE_CLOSE "gimp-file-close"
#define GIMP_HELP_FILE_CLOSE_ALL "gimp-file-close-all"
#define GIMP_HELP_FILE_QUIT "gimp-file-quit"
#define GIMP_HELP_EDIT_UNDO "gimp-edit-undo"
......
......@@ -33,6 +33,7 @@
<placeholder name="Info" />
<separator />
<menuitem action="view-close" />
<menuitem action="file-close-all" />
<menuitem action="file-quit" />
</menu>
......
......@@ -39,6 +39,7 @@
</menu>
<separator />
<menuitem action="file-close-all" />
<menuitem action="file-quit" />
</menu>
......
Markdown is supported
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