app/widgets/Makefile.am app/widgets/widgets-types.h added a simple message

2004-10-13  Sven Neumann  <sven@gimp.org>

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpmessagedialog.[ch]: added a simple message
	dialog to avoid code duplication.

	* app/widgets/gimpmessagebox.c: set the border width to 12 pixels.

	* app/dialogs/file-save-dialog.c
	* app/dialogs/quit-dialog.c
	* app/display/gimpdisplayshell-close.c
	* app/widgets/gimperrordialog.c
	* app/widgets/gimphelp.c
	* app/widgets/gimpactionview.c: use the new GimpMessageDialog.
This commit is contained in:
Sven Neumann 2004-10-13 14:35:28 +00:00 committed by Sven Neumann
parent e122a3c3de
commit 8300c550e3
12 changed files with 334 additions and 140 deletions

View File

@ -1,3 +1,19 @@
2004-10-13 Sven Neumann <sven@gimp.org>
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpmessagedialog.[ch]: added a simple message
dialog to avoid code duplication.
* app/widgets/gimpmessagebox.c: set the border width to 12 pixels.
* app/dialogs/file-save-dialog.c
* app/dialogs/quit-dialog.c
* app/display/gimpdisplayshell-close.c
* app/widgets/gimperrordialog.c
* app/widgets/gimphelp.c
* app/widgets/gimpactionview.c: use the new GimpMessageDialog.
2004-10-13 Michael Natterer <mitch@gimp.org>
* app/actions/image-actions.c

View File

@ -37,6 +37,7 @@
#include "widgets/gimpfiledialog.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmessagebox.h"
#include "widgets/gimpmessagedialog.h"
#include "file-save-dialog.h"
@ -151,38 +152,33 @@ file_save_overwrite (GtkWidget *save_dialog,
{
OverwriteData *overwrite_data = g_new0 (OverwriteData, 1);
GtkWidget *dialog;
GtkWidget *box;
gchar *filename;
overwrite_data->save_dialog = save_dialog;
overwrite_data->uri = g_strdup (uri);
overwrite_data->raw_filename = g_strdup (raw_filename);
dialog = gimp_dialog_new (_("File exists"), "gimp-file-overwrite",
save_dialog, 0,
gimp_standard_help_func, NULL,
dialog =
gimp_message_dialog_new (_("File exists"), GIMP_STOCK_WARNING,
save_dialog, 0,
gimp_standard_help_func, NULL,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Replace"), GTK_RESPONSE_OK,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Replace"), GTK_RESPONSE_OK,
NULL);
NULL);
g_signal_connect (dialog, "response",
G_CALLBACK (file_save_overwrite_response),
overwrite_data);
box = gimp_message_box_new (GIMP_STOCK_WARNING);
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box);
gtk_widget_show (box);
filename = file_utils_uri_to_utf8_filename (uri);
gimp_message_box_set_primary_text (GIMP_MESSAGE_BOX (box),
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
_("A file named '%s' already exists."),
filename);
g_free (filename);
gimp_message_box_set_text (GIMP_MESSAGE_BOX (box),
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
_("Do you want to replace it with the image "
"you are saving?"));

View File

@ -36,6 +36,7 @@
#include "widgets/gimpcontainertreeview.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmessagebox.h"
#include "widgets/gimpmessagedialog.h"
#include "quit-dialog.h"
@ -53,13 +54,13 @@ static void quit_dialog_container_changed (GimpContainer *images,
GtkWidget *
quit_dialog_new (Gimp *gimp)
{
GimpContainer *images;
GtkWidget *dialog;
GtkWidget *box;
GtkWidget *label;
GtkWidget *view;
gint rows;
gint preview_size;
GimpContainer *images;
GimpMessageBox *box;
GtkWidget *dialog;
GtkWidget *label;
GtkWidget *view;
gint rows;
gint preview_size;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
@ -71,23 +72,21 @@ quit_dialog_new (Gimp *gimp)
g_return_val_if_fail (images != NULL, NULL);
dialog = gimp_dialog_new (_("Quit The GIMP"), "gimp-quit",
NULL, 0,
gimp_standard_help_func, NULL,
dialog =
gimp_message_dialog_new (_("Quit The GIMP"), GIMP_STOCK_WILBER_EEK,
NULL, 0,
gimp_standard_help_func, NULL,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Discard Changes"), GTK_RESPONSE_OK,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Discard Changes"), GTK_RESPONSE_OK,
NULL);
NULL);
g_signal_connect (dialog, "response",
G_CALLBACK (quit_dialog_response),
gimp);
box = gimp_message_box_new (GIMP_STOCK_WILBER_EEK);
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box);
gtk_widget_show (box);
box = GIMP_MESSAGE_DIALOG (dialog)->box;
g_signal_connect_object (images, "add",
G_CALLBACK (quit_dialog_container_changed),
@ -116,7 +115,8 @@ quit_dialog_new (Gimp *gimp)
g_object_set_data (G_OBJECT (box), "lost-label", label);
quit_dialog_container_changed (images, NULL, GIMP_MESSAGE_BOX (box));
quit_dialog_container_changed (images, NULL,
GIMP_MESSAGE_DIALOG (dialog)->box);
return dialog;
}

View File

@ -35,6 +35,7 @@
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmessagebox.h"
#include "widgets/gimpmessagedialog.h"
#include "widgets/gimpuimanager.h"
#include "gimpdisplay.h"
@ -103,12 +104,12 @@ static void
gimp_display_shell_close_dialog (GimpDisplayShell *shell,
GimpImage *gimage)
{
GtkWidget *dialog;
GtkWidget *box;
GClosure *closure;
GSource *source;
gchar *name;
gchar *title;
GtkWidget *dialog;
GimpMessageBox *box;
GClosure *closure;
GSource *source;
gchar *name;
gchar *title;
if (shell->close_dialog)
{
@ -122,18 +123,16 @@ gimp_display_shell_close_dialog (GimpDisplayShell *shell,
g_free (name);
shell->close_dialog =
dialog = gimp_dialog_new (title,
"gimp-display-shell-close",
GTK_WIDGET (shell),
GTK_DIALOG_DESTROY_WITH_PARENT,
gimp_standard_help_func, NULL,
dialog = gimp_message_dialog_new (title, GIMP_STOCK_WARNING,
GTK_WIDGET (shell),
GTK_DIALOG_DESTROY_WITH_PARENT,
gimp_standard_help_func, NULL,
_("Do_n't save"), GTK_RESPONSE_CLOSE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, RESPONSE_SAVE,
NULL);
_("Do_n't save"), GTK_RESPONSE_CLOSE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, RESPONSE_SAVE,
NULL);
g_free (title);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), RESPONSE_SAVE);
@ -146,10 +145,7 @@ gimp_display_shell_close_dialog (GimpDisplayShell *shell,
G_CALLBACK (gimp_display_shell_close_response),
shell);
box = gimp_message_box_new (GIMP_STOCK_WARNING);
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box);
gtk_widget_show (box);
box = GIMP_MESSAGE_DIALOG (dialog)->box;
g_signal_connect_object (gimage, "name_changed",
G_CALLBACK (gimp_display_shell_close_name_changed),

View File

@ -174,6 +174,8 @@ libappwidgets_a_sources = \
gimpmenufactory.h \
gimpmessagebox.c \
gimpmessagebox.h \
gimpmessagedialog.c \
gimpmessagedialog.h \
gimpnavigationview.c \
gimpnavigationview.h \
gimppaletteeditor.c \

View File

@ -34,6 +34,8 @@
#include "gimpactiongroup.h"
#include "gimpactionview.h"
#include "gimpcellrendereraccel.h"
#include "gimpmessagebox.h"
#include "gimpmessagedialog.h"
#include "gimpuimanager.h"
#include "gimpwidgets-utils.h"
@ -441,14 +443,14 @@ typedef struct
} ConfirmData;
static void
gimp_action_view_accel_confirm (GtkWidget *query_box,
gboolean value,
gpointer data)
gimp_action_view_conflict_response (GtkWidget *dialog,
gint response_id,
ConfirmData *confirm_data)
{
if (value)
{
ConfirmData *confirm_data = data;
gtk_widget_destroy (dialog);
if (response_id == GTK_RESPONSE_OK)
{
if (! gtk_accel_map_change_entry (confirm_data->accel_path,
confirm_data->accel_key,
confirm_data->accel_mask,
@ -457,6 +459,74 @@ gimp_action_view_accel_confirm (GtkWidget *query_box,
g_message (_("Changing shortcut failed."));
}
}
g_free (confirm_data->accel_path);
g_free (confirm_data);
}
static void
gimp_action_view_conflict_confirm (GimpActionView *view,
GtkAction *action,
guint accel_key,
GdkModifierType accel_mask,
const gchar *accel_path)
{
GimpActionGroup *group;
GimpMessageBox *box;
gchar *label;
gchar *stripped;
gchar *accel_string;
ConfirmData *confirm_data;
GtkWidget *dialog;
g_object_get (action,
"action-group", &group,
"label", &label,
NULL);
stripped = gimp_strip_uline (label);
g_free (label);
accel_string = gimp_get_accel_string (accel_key, accel_mask);
confirm_data = g_new0 (ConfirmData, 1);
confirm_data->accel_path = g_strdup (accel_path);
confirm_data->accel_key = accel_key;
confirm_data->accel_mask = accel_mask;
dialog =
gimp_message_dialog_new (_("Conflicting Shortcuts"),
GIMP_STOCK_WARNING,
gtk_widget_get_toplevel (GTK_WIDGET (view)), 0,
gimp_standard_help_func, NULL,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Resassign shortcut"), GTK_RESPONSE_OK,
NULL);
g_signal_connect (dialog, "response",
G_CALLBACK (gimp_action_view_conflict_response),
confirm_data);
box = GIMP_MESSAGE_DIALOG (dialog)->box;
gimp_message_box_set_primary_text (box,
_("Shortcut \"%s\" is already taken "
"by \"%s\" from the \"%s\" group."),
accel_string, stripped, group->label);
gimp_message_box_set_text (box,
_("Reassigning the shortcut will cause it "
"to be removed from \"%s\"."),
stripped);
g_free (stripped);
g_free (accel_string);
g_object_unref (group);
gtk_widget_show (dialog);
}
static void
@ -568,69 +638,11 @@ gimp_action_view_accel_edited (GimpCellRendererAccel *accel,
if (conflict_action && conflict_action != action)
{
GimpActionGroup *conflict_group;
gchar *label;
gchar *stripped;
gchar *accel_string;
gchar *message;
ConfirmData *confirm_data;
GtkWidget *query_box;
g_object_get (conflict_action,
"action-group", &conflict_group,
"label", &label,
NULL);
stripped = gimp_strip_uline (label);
accel_string = gimp_get_accel_string (accel_key, accel_mask);
message =
g_strdup_printf ("Shortcut \"%s\" is already taken by "
"\"%s\" from the \"%s\" group.\n"
"\n"
"Choose \"Reassign Shortcut\" to "
"reassign the shortcut, thereby removing "
"the shortcut from %s.",
accel_string,
stripped,
conflict_group->label,
stripped);
confirm_data = g_new0 (ConfirmData, 1);
confirm_data->accel_path = g_strdup (accel_path);
confirm_data->accel_key = accel_key;
confirm_data->accel_mask = accel_mask;
query_box =
gimp_query_boolean_box (_("Conflicting Shortcuts"),
gtk_widget_get_toplevel (GTK_WIDGET (view)),
gimp_standard_help_func,
NULL,
GIMP_STOCK_WARNING,
message,
_("_Resassign Shortcut"),
GTK_STOCK_CANCEL,
G_OBJECT (view), "destroy",
gimp_action_view_accel_confirm,
confirm_data);
g_object_weak_ref (G_OBJECT (query_box),
(GWeakNotify) g_free,
confirm_data);
g_object_weak_ref (G_OBJECT (query_box),
(GWeakNotify) g_free,
confirm_data->accel_path);
g_free (label);
g_free (stripped);
g_free (accel_string);
g_free (message);
gimp_action_view_conflict_confirm (view, conflict_action,
accel_key,
accel_mask,
accel_path);
g_object_unref (conflict_action);
g_object_unref (conflict_group);
gtk_widget_show (query_box);
}
else if (conflict_action != action)
{

View File

@ -240,8 +240,7 @@ gimp_error_dialog_add (GimpErrorDialog *dialog,
}
box = g_object_new (GIMP_TYPE_MESSAGE_BOX,
"stock_id", stock_id,
"border_width", 12,
"stock_id", stock_id,
NULL);
dialog->num_messages++;

View File

@ -44,6 +44,7 @@
#include "gimphelp.h"
#include "gimphelp-ids.h"
#include "gimpmessagebox.h"
#include "gimpmessagedialog.h"
#include "gimp-intl.h"
@ -229,24 +230,19 @@ gimp_help_browser_error (Gimp *gimp,
const gchar *text)
{
GtkWidget *dialog;
GtkWidget *box;
dialog = gimp_dialog_new (title, "gimp-help-error",
NULL, 0,
NULL, NULL,
dialog =
gimp_message_dialog_new (title, GIMP_STOCK_WARNING,
NULL, 0,
NULL, NULL,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("Use _web browser instead"), GTK_RESPONSE_OK,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("Use _web browser instead"), GTK_RESPONSE_OK,
NULL);
NULL);
box = gimp_message_box_new (GIMP_STOCK_WARNING);
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box);
gtk_widget_show (box);
gimp_message_box_set_primary_text (GIMP_MESSAGE_BOX (box), primary);
gimp_message_box_set_text (GIMP_MESSAGE_BOX (box), text);
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box, primary);
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box, text);
if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK)
g_object_set (gimp->config,

View File

@ -41,11 +41,11 @@ enum
};
static void gimp_message_box_class_init (GimpMessageBoxClass *klass);
static void gimp_message_box_class_init (GimpMessageBoxClass *klass);
static GObject * gimp_message_box_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static GObject * gimp_message_box_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_message_box_init (GimpMessageBox *box);
static void gimp_message_box_finalize (GObject *object);
@ -136,6 +136,7 @@ gimp_message_box_init (GimpMessageBox *box)
gint i;
gtk_box_set_spacing (GTK_BOX (box), 12);
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
for (i = 0; i < 2; i++)
{

View File

@ -0,0 +1,111 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpmessagedialog.c
* 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 "widgets-types.h"
#include "gimpmessagebox.h"
#include "gimpmessagedialog.h"
GType
gimp_message_dialog_get_type (void)
{
static GType dialog_type = 0;
if (! dialog_type)
{
static const GTypeInfo dialog_info =
{
sizeof (GimpMessageDialogClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
NULL, /* class_init */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpMessageDialog),
0, /* n_preallocs */
NULL /* instance_init */
};
dialog_type = g_type_register_static (GIMP_TYPE_DIALOG,
"GimpMessageDialog",
&dialog_info, 0);
}
return dialog_type;
}
/* public functions */
GtkWidget *
gimp_message_dialog_new (const gchar *title,
const gchar *stock_id,
GtkWidget *parent,
GtkDialogFlags flags,
GimpHelpFunc help_func,
const gchar *help_id,
...)
{
GimpMessageDialog *dialog;
va_list args;
g_return_val_if_fail (title != NULL, NULL);
g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
dialog = g_object_new (GIMP_TYPE_MESSAGE_DIALOG,
"title", title,
"role", "gimp-message-dialog",
"modal", (flags & GTK_DIALOG_MODAL),
"help-func", help_func,
"help-id", help_id,
NULL);
if (parent)
{
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
}
va_start (args, help_id);
gimp_dialog_add_buttons_valist (GIMP_DIALOG (dialog), args);
va_end (args);
dialog->box = g_object_new (GIMP_TYPE_MESSAGE_BOX,
"stock_id", stock_id,
NULL);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
dialog->box, FALSE, FALSE, 0);
gtk_widget_show (dialog->box);
return GTK_WIDGET (dialog);
}

View File

@ -0,0 +1,64 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpmessagedialog.h
* 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.
*/
#ifndef __GIMP_MESSAGE_DIALOG_H__
#define __GIMP_MESSAGE_DIALOG_H__
G_BEGIN_DECLS
#define GIMP_TYPE_MESSAGE_DIALOG (gimp_message_dialog_get_type ())
#define GIMP_MESSAGE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_MESSAGE_DIALOG, GimpMessageDialog))
#define GIMP_MESSAGE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_MESSAGE_DIALOG, GimpMessageDialogClass))
#define GIMP_IS_MESSAGE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_MESSAGE_DIALOG))
#define GIMP_IS_MESSAGE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_MESSAGE_DIALOG))
#define GIMP_MESSAGE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_MESSAGE_DIALOG, GimpMessageDialogClass))
typedef struct _GimpMessageDialogClass GimpMessageDialogClass;
struct _GimpMessageDialog
{
GimpDialog parent_instance;
GimpMessageBox *box;
};
struct _GimpMessageDialogClass
{
GimpDialogClass parent_class;
};
GType gimp_message_dialog_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_message_dialog_new (const gchar *title,
const gchar *stock_id,
GtkWidget *parent,
GtkDialogFlags flags,
GimpHelpFunc help_func,
const gchar *help_id,
...);
G_END_DECLS
#endif /* __GIMP_MESSAGE_DIALOG_H__ */

View File

@ -125,6 +125,7 @@ typedef struct _GimpUIManager GimpUIManager;
typedef struct _GimpColorDialog GimpColorDialog;
typedef struct _GimpErrorDialog GimpErrorDialog;
typedef struct _GimpFileDialog GimpFileDialog;
typedef struct _GimpMessageDialog GimpMessageDialog;
typedef struct _GimpProgressDialog GimpProgressDialog;
typedef struct _GimpTextEditor GimpTextEditor;
typedef struct _GimpViewableDialog GimpToolDialog;