mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 03:52:33 +00:00
added gimp_message_box_repeat().
2004-08-25 Sven Neumann <sven@gimp.org> * app/widgets/gimpmessagebox.[ch]: added gimp_message_box_repeat(). * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimperrordialog.[ch]: added new dialog that adds a new GimpMessageBox for each message added. Fixes bug #92604. * app/widgets/gimpwidgets-utils.[ch]: removed old gimp_message_box() functionality. * app/gui/gui.c (gui_abort): use a GimpMessageBox in a GimpDialog. * app/gui/dialogs-constructors.[ch] * app/gui/dialogs.c: manage GimpErrorDialog as singleton. * app/gui/gui-vtable.c (gui_message): use the new error dialog. * app/core/gimp-gui.c (gimp_message): substitue "GIMP" for a NULL domain. * app/widgets/gimperrorconsole.c (gimp_error_console_add): fail when being called with a NULL domain.
This commit is contained in:
parent
54fa5a0af9
commit
80531ec936
32
ChangeLog
32
ChangeLog
|
@ -1,17 +1,39 @@
|
|||
2004-08-25 Bill Skaggs <weskaggs@primate.ucdavis.edu>
|
||||
2004-08-25 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* devel-docs/Makefile.am: added ggr.txt to list.
|
||||
* app/widgets/gimpmessagebox.[ch]: added gimp_message_box_repeat().
|
||||
|
||||
2004-08-25 Bill Skaggs <weskaggs@primate.ucdavis.edu>
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimperrordialog.[ch]: added new dialog that adds a new
|
||||
GimpMessageBox for each message added. Fixes bug #92604.
|
||||
|
||||
* devel-docs/ggr.txt: added new file decribing the ggr
|
||||
(Gimp gradient) file format.
|
||||
* app/widgets/gimpwidgets-utils.[ch]: removed old gimp_message_box()
|
||||
functionality.
|
||||
|
||||
* app/gui/gui.c (gui_abort): use a GimpMessageBox in a GimpDialog.
|
||||
|
||||
* app/gui/dialogs-constructors.[ch]
|
||||
* app/gui/dialogs.c: manage GimpErrorDialog as singleton.
|
||||
|
||||
* app/gui/gui-vtable.c (gui_message): use the new error dialog.
|
||||
|
||||
* app/core/gimp-gui.c (gimp_message): substitue "GIMP" for a NULL
|
||||
domain.
|
||||
|
||||
* app/widgets/gimperrorconsole.c (gimp_error_console_add): fail
|
||||
when being called with a NULL domain.
|
||||
|
||||
2004-08-25 DindinX <david@dindinx.org>
|
||||
|
||||
* app/display/gimpnavigationeditor.[ch]: eradicate some more previews
|
||||
in favor of views.
|
||||
|
||||
2004-08-25 Bill Skaggs <weskaggs@primate.ucdavis.edu>
|
||||
|
||||
* devel-docs/Makefile.am
|
||||
* devel-docs/ggr.txt: added new file decribing the ggr (Gimp
|
||||
gradient) file format.
|
||||
|
||||
2004-08-25 DindinX <david@dindinx.org>
|
||||
|
||||
* app/display/gimpnavigationview.c
|
||||
|
|
|
@ -144,25 +144,13 @@ gimp_message (Gimp *gimp,
|
|||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
if (! gimp->console_messages)
|
||||
{
|
||||
switch (gimp->message_handler)
|
||||
{
|
||||
case GIMP_MESSAGE_BOX:
|
||||
case GIMP_ERROR_CONSOLE:
|
||||
if (gimp->gui.message)
|
||||
{
|
||||
gimp->gui.message (gimp, domain, message);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
if (! domain)
|
||||
domain = _("GIMP");
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_printerr ("%s: %s\n\n", domain ? domain : _("GIMP"), message);
|
||||
if (! gimp->console_messages && gimp->gui.message)
|
||||
gimp->gui.message (gimp, domain, message);
|
||||
else
|
||||
g_printerr ("%s: %s\n\n", domain, message);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "widgets/gimpdockable.h"
|
||||
#include "widgets/gimpdocumentview.h"
|
||||
#include "widgets/gimperrorconsole.h"
|
||||
#include "widgets/gimperrordialog.h"
|
||||
#include "widgets/gimpfontview.h"
|
||||
#include "widgets/gimpgradienteditor.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
@ -144,6 +145,13 @@ dialogs_about_get (GimpDialogFactory *factory,
|
|||
return about_dialog_create ();
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
dialogs_error_get (GimpDialogFactory *factory,
|
||||
GimpContext *context,
|
||||
gint preview_size)
|
||||
{
|
||||
return gimp_error_dialog_new (_("GIMP Message"), GIMP_STOCK_WARNING);
|
||||
}
|
||||
|
||||
/***********/
|
||||
/* docks */
|
||||
|
|
|
@ -37,6 +37,9 @@ GtkWidget * dialogs_tips_get (GimpDialogFactory *factory,
|
|||
GtkWidget * dialogs_about_get (GimpDialogFactory *factory,
|
||||
GimpContext *context,
|
||||
gint preview_size);
|
||||
GtkWidget * dialogs_error_get (GimpDialogFactory *factory,
|
||||
GimpContext *context,
|
||||
gint preview_size);
|
||||
|
||||
|
||||
/* docks */
|
||||
|
|
|
@ -101,6 +101,8 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
|
|||
{ "gimp-tips-dialog", dialogs_tips_get,
|
||||
0, TRUE, FALSE, FALSE, FALSE },
|
||||
{ "gimp-about-dialog", dialogs_about_get,
|
||||
0, TRUE, FALSE, FALSE, FALSE },
|
||||
{ "gimp-error-dialog", dialogs_error_get,
|
||||
0, TRUE, FALSE, FALSE, FALSE }
|
||||
};
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "widgets/gimpdockable.h"
|
||||
#include "widgets/gimpdocumentview.h"
|
||||
#include "widgets/gimperrorconsole.h"
|
||||
#include "widgets/gimperrordialog.h"
|
||||
#include "widgets/gimpfontview.h"
|
||||
#include "widgets/gimpgradienteditor.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
@ -144,6 +145,13 @@ dialogs_about_get (GimpDialogFactory *factory,
|
|||
return about_dialog_create ();
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
dialogs_error_get (GimpDialogFactory *factory,
|
||||
GimpContext *context,
|
||||
gint preview_size)
|
||||
{
|
||||
return gimp_error_dialog_new (_("GIMP Message"), GIMP_STOCK_WARNING);
|
||||
}
|
||||
|
||||
/***********/
|
||||
/* docks */
|
||||
|
|
|
@ -37,6 +37,9 @@ GtkWidget * dialogs_tips_get (GimpDialogFactory *factory,
|
|||
GtkWidget * dialogs_about_get (GimpDialogFactory *factory,
|
||||
GimpContext *context,
|
||||
gint preview_size);
|
||||
GtkWidget * dialogs_error_get (GimpDialogFactory *factory,
|
||||
GimpContext *context,
|
||||
gint preview_size);
|
||||
|
||||
|
||||
/* docks */
|
||||
|
|
|
@ -101,6 +101,8 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
|
|||
{ "gimp-tips-dialog", dialogs_tips_get,
|
||||
0, TRUE, FALSE, FALSE, FALSE },
|
||||
{ "gimp-about-dialog", dialogs_about_get,
|
||||
0, TRUE, FALSE, FALSE, FALSE },
|
||||
{ "gimp-error-dialog", dialogs_error_get,
|
||||
0, TRUE, FALSE, FALSE, FALSE }
|
||||
};
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "widgets/gimpbrushselect.h"
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
#include "widgets/gimperrorconsole.h"
|
||||
#include "widgets/gimperrordialog.h"
|
||||
#include "widgets/gimpfontselect.h"
|
||||
#include "widgets/gimpgradientselect.h"
|
||||
#include "widgets/gimphelp.h"
|
||||
|
@ -57,7 +58,6 @@
|
|||
#include "widgets/gimppatternselect.h"
|
||||
#include "widgets/gimpprogressdialog.h"
|
||||
#include "widgets/gimpuimanager.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplay-foreach.h"
|
||||
|
@ -199,29 +199,55 @@ gui_message (Gimp *gimp,
|
|||
const gchar *domain,
|
||||
const gchar *message)
|
||||
{
|
||||
if (gimp->message_handler == GIMP_ERROR_CONSOLE)
|
||||
switch (gimp->message_handler)
|
||||
{
|
||||
GtkWidget *dockable;
|
||||
case GIMP_ERROR_CONSOLE:
|
||||
{
|
||||
GtkWidget *dockable;
|
||||
|
||||
dockable = gimp_dialog_factory_dialog_raise (global_dock_factory,
|
||||
dockable = gimp_dialog_factory_dialog_raise (global_dock_factory,
|
||||
gdk_screen_get_default (),
|
||||
"gimp-error-console", -1);
|
||||
|
||||
if (dockable)
|
||||
{
|
||||
GimpErrorConsole *console;
|
||||
|
||||
console = GIMP_ERROR_CONSOLE (GTK_BIN (dockable)->child);
|
||||
|
||||
gimp_error_console_add (console,
|
||||
GIMP_STOCK_WARNING, domain, message);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gimp->message_handler = GIMP_MESSAGE_BOX;
|
||||
}
|
||||
/* fallthru */
|
||||
|
||||
case GIMP_MESSAGE_BOX:
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gimp_dialog_factory_dialog_raise (global_dialog_factory,
|
||||
gdk_screen_get_default (),
|
||||
"gimp-error-console", -1);
|
||||
"gimp-error-dialog", -1);
|
||||
if (dialog)
|
||||
{
|
||||
gimp_error_dialog_add (GIMP_ERROR_DIALOG (dialog),
|
||||
GIMP_STOCK_WARNING, domain, message);
|
||||
|
||||
if (dockable)
|
||||
{
|
||||
GimpErrorConsole *console;
|
||||
return;
|
||||
}
|
||||
|
||||
console = GIMP_ERROR_CONSOLE (GTK_BIN (dockable)->child);
|
||||
gimp->message_handler = GIMP_CONSOLE;
|
||||
}
|
||||
/* fallthru */
|
||||
|
||||
gimp_error_console_add (console, GIMP_STOCK_WARNING, domain, message);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gimp->message_handler = GIMP_MESSAGE_BOX;
|
||||
case GIMP_CONSOLE:
|
||||
g_printerr ("%s: %s\n\n", domain, message);
|
||||
break;
|
||||
}
|
||||
|
||||
gimp_message_box (GIMP_STOCK_WARNING, domain, message, NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "widgets/gimphelp.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpmenufactory.h"
|
||||
#include "widgets/gimpmessagebox.h"
|
||||
#include "widgets/gimpsessioninfo.h"
|
||||
#include "widgets/gimpuimanager.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
@ -149,11 +150,30 @@ gui_libs_init (gint *argc,
|
|||
void
|
||||
gui_abort (const gchar *abort_message)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *box;
|
||||
|
||||
g_return_if_fail (abort_message != NULL);
|
||||
|
||||
gimp_message_box (GIMP_STOCK_WILBER_EEK, NULL, abort_message,
|
||||
(GtkCallback) gtk_main_quit, NULL);
|
||||
gtk_main ();
|
||||
dialog = gimp_dialog_new (_("GIMP Message"), "gimp-abort",
|
||||
NULL, GTK_DIALOG_MODAL, NULL, NULL,
|
||||
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
|
||||
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
||||
|
||||
box = g_object_new (GIMP_TYPE_MESSAGE_BOX,
|
||||
"stock_id", GIMP_STOCK_WILBER_EEK,
|
||||
"border_width", 12,
|
||||
NULL);
|
||||
|
||||
gimp_message_box_set_text (GIMP_MESSAGE_BOX (box), abort_message);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box);
|
||||
gtk_widget_show (box);
|
||||
|
||||
gimp_dialog_run (GIMP_DIALOG (dialog));
|
||||
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,6 +131,8 @@ libappwidgets_a_sources = \
|
|||
gimpenumwidgets.h \
|
||||
gimperrorconsole.c \
|
||||
gimperrorconsole.h \
|
||||
gimperrordialog.c \
|
||||
gimperrordialog.h \
|
||||
gimpfgbgeditor.c \
|
||||
gimpfgbgeditor.h \
|
||||
gimpfiledialog.c \
|
||||
|
|
|
@ -254,11 +254,9 @@ gimp_error_console_add (GimpErrorConsole *console,
|
|||
|
||||
g_return_if_fail (GIMP_IS_ERROR_CONSOLE (console));
|
||||
g_return_if_fail (stock_id != NULL);
|
||||
g_return_if_fail (domain != NULL);
|
||||
g_return_if_fail (message != NULL);
|
||||
|
||||
if (! domain)
|
||||
domain = _("GIMP");
|
||||
|
||||
gtk_text_buffer_get_end_iter (console->text_buffer, &end);
|
||||
|
||||
pixbuf = gtk_widget_render_icon (console->text_view, stock_id,
|
||||
|
|
235
app/widgets/gimperrordialog.c
Normal file
235
app/widgets/gimperrordialog.c
Normal file
|
@ -0,0 +1,235 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimperrordialog.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 <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "gimperrordialog.h"
|
||||
#include "gimpmessagebox.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void gimp_error_dialog_class_init (GimpErrorDialogClass *klass);
|
||||
static void gimp_error_dialog_init (GimpErrorDialog *dialog);
|
||||
static void gimp_error_dialog_finalize (GObject *object);
|
||||
static void gimp_error_dialog_response (GtkDialog *dialog,
|
||||
gint response_id);
|
||||
|
||||
|
||||
static GimpDialogClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_error_dialog_get_type (void)
|
||||
{
|
||||
static GType dialog_type = 0;
|
||||
|
||||
if (! dialog_type)
|
||||
{
|
||||
static const GTypeInfo dialog_info =
|
||||
{
|
||||
sizeof (GimpErrorDialogClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_error_dialog_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpErrorDialog),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_error_dialog_init
|
||||
};
|
||||
|
||||
dialog_type = g_type_register_static (GIMP_TYPE_DIALOG,
|
||||
"GimpErrorDialog",
|
||||
&dialog_info, 0);
|
||||
}
|
||||
|
||||
return dialog_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_error_dialog_class_init (GimpErrorDialogClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gimp_error_dialog_finalize;
|
||||
|
||||
dialog_class->response = gimp_error_dialog_response;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_error_dialog_init (GimpErrorDialog *dialog)
|
||||
{
|
||||
gtk_window_set_role (GTK_WINDOW (dialog), "gimp-message");
|
||||
|
||||
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
||||
GTK_STOCK_OK, GTK_RESPONSE_CLOSE,
|
||||
NULL);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
|
||||
|
||||
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
||||
|
||||
dialog->vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
|
||||
dialog->vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (dialog->vbox);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_error_dialog_finalize (GObject *object)
|
||||
{
|
||||
GimpErrorDialog *dialog = GIMP_ERROR_DIALOG (object);
|
||||
|
||||
if (dialog->last_domain)
|
||||
{
|
||||
g_free (dialog->last_domain);
|
||||
dialog->last_domain = NULL;
|
||||
}
|
||||
if (dialog->last_message)
|
||||
{
|
||||
g_free (dialog->last_message);
|
||||
dialog->last_message = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_error_dialog_response (GtkDialog *dialog,
|
||||
gint response_id)
|
||||
{
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_error_dialog_set_icon (GtkWidget *dialog,
|
||||
const gchar *stock_id)
|
||||
{
|
||||
GtkIconSet *icon_set;
|
||||
|
||||
gtk_widget_ensure_style (dialog);
|
||||
|
||||
icon_set = gtk_style_lookup_icon_set (dialog->style, stock_id);
|
||||
|
||||
if (icon_set)
|
||||
{
|
||||
GtkIconSize *sizes;
|
||||
GList *icons = NULL;
|
||||
gint i, n_sizes;
|
||||
|
||||
gtk_icon_set_get_sizes (icon_set, &sizes, &n_sizes);
|
||||
|
||||
for (i = 0; i < n_sizes; i++)
|
||||
{
|
||||
if (sizes[i] < GTK_ICON_SIZE_DIALOG) /* skip the large version */
|
||||
icons = g_list_prepend (icons,
|
||||
gtk_widget_render_icon (dialog,
|
||||
stock_id, sizes[i],
|
||||
NULL));
|
||||
}
|
||||
|
||||
g_free (sizes);
|
||||
|
||||
if (icons)
|
||||
{
|
||||
gtk_window_set_icon_list (GTK_WINDOW (dialog), icons);
|
||||
|
||||
g_list_foreach (icons, (GFunc) g_object_unref, NULL);
|
||||
g_list_free (icons);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GtkWidget *
|
||||
gimp_error_dialog_new (const gchar *title,
|
||||
const gchar *stock_id)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
g_return_val_if_fail (title != NULL, NULL);
|
||||
|
||||
dialog = g_object_new (GIMP_TYPE_ERROR_DIALOG,
|
||||
"title", title,
|
||||
NULL);
|
||||
|
||||
if (stock_id)
|
||||
gimp_error_dialog_set_icon (dialog, stock_id);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_error_dialog_add (GimpErrorDialog *dialog,
|
||||
const gchar *stock_id,
|
||||
const gchar *domain,
|
||||
const gchar *message)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_ERROR_DIALOG (dialog), FALSE);
|
||||
g_return_val_if_fail (domain != NULL, FALSE);
|
||||
g_return_val_if_fail (message != NULL, FALSE);
|
||||
|
||||
if (dialog->last_box &&
|
||||
dialog->last_domain && strcmp (dialog->last_domain, domain) == 0 &&
|
||||
dialog->last_message && strcmp (dialog->last_message, message) == 0)
|
||||
{
|
||||
gimp_message_box_repeat (GIMP_MESSAGE_BOX (dialog->last_box));
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *box = g_object_new (GIMP_TYPE_MESSAGE_BOX,
|
||||
"stock_id", GIMP_STOCK_WARNING,
|
||||
"border_width", 12,
|
||||
NULL);
|
||||
|
||||
gimp_message_box_set_primary_text (GIMP_MESSAGE_BOX (box),
|
||||
_("%s Message"), domain);
|
||||
gimp_message_box_set_text (GIMP_MESSAGE_BOX (box), message);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (dialog->vbox), box);
|
||||
gtk_widget_show (box);
|
||||
|
||||
dialog->last_box = box;
|
||||
|
||||
g_free (dialog->last_domain);
|
||||
dialog->last_domain = g_strdup (domain);
|
||||
|
||||
g_free (dialog->last_message);
|
||||
dialog->last_message = g_strdup (message);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
68
app/widgets/gimperrordialog.h
Normal file
68
app/widgets/gimperrordialog.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimperrordialog.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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_ERROR_DIALOG_H__
|
||||
#define __GIMP_ERROR_DIALOG_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GIMP_TYPE_ERROR_DIALOG (gimp_error_dialog_get_type ())
|
||||
#define GIMP_ERROR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ERROR_DIALOG, GimpErrorDialog))
|
||||
#define GIMP_ERROR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ERROR_DIALOG, GimpErrorDialogClass))
|
||||
#define GIMP_IS_ERROR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ERROR_DIALOG))
|
||||
#define GIMP_IS_ERROR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ERROR_DIALOG))
|
||||
#define GIMP_ERROR_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_ERROR_DIALOG, GimpErrorDialogClass))
|
||||
|
||||
|
||||
typedef struct _GimpErrorDialogClass GimpErrorDialogClass;
|
||||
|
||||
struct _GimpErrorDialog
|
||||
{
|
||||
GimpDialog parent_instance;
|
||||
|
||||
GtkWidget *vbox;
|
||||
|
||||
GtkWidget *last_box;
|
||||
gchar *last_domain;
|
||||
gchar *last_message;
|
||||
};
|
||||
|
||||
struct _GimpErrorDialogClass
|
||||
{
|
||||
GimpDialogClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_error_dialog_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_error_dialog_new (const gchar *title,
|
||||
const gchar *stock_id);
|
||||
gboolean gimp_error_dialog_add (GimpErrorDialog *dialog,
|
||||
const gchar *stock_id,
|
||||
const gchar *domain,
|
||||
const gchar *message);
|
||||
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_ERROR_DIALOG_H__ */
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include "gimpmessagebox.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define GIMP_MESSAGE_BOX_SPACING 12
|
||||
|
||||
|
@ -154,6 +156,9 @@ gimp_message_box_init (GimpMessageBox *box)
|
|||
|
||||
box->label[i] = label;
|
||||
}
|
||||
|
||||
box->repeat = 0;
|
||||
box->label[2] = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -438,3 +443,38 @@ gimp_message_box_set_markup (GimpMessageBox *box,
|
|||
gimp_message_box_set_label_markup (box, 1,format, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_message_box_repeat (GimpMessageBox *box)
|
||||
{
|
||||
gchar *message;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_MESSAGE_BOX (box), 0);
|
||||
|
||||
box->repeat++;
|
||||
|
||||
if (box->repeat > 1)
|
||||
message = g_strdup_printf (_("Message repeated %d times."), box->repeat);
|
||||
else
|
||||
message = g_strdup (_("Message repeated once."));
|
||||
|
||||
if (box->label[2])
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (box->label[2]), message);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *label = box->label[2] = gtk_label_new (message);
|
||||
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0);
|
||||
gimp_label_set_attributes (GTK_LABEL (label),
|
||||
PANGO_ATTR_STYLE, PANGO_STYLE_OBLIQUE,
|
||||
-1);
|
||||
gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
}
|
||||
|
||||
g_free (message);
|
||||
|
||||
return box->repeat;
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ struct _GimpMessageBox
|
|||
GtkVBox parent_instance;
|
||||
|
||||
gchar *stock_id;
|
||||
|
||||
GtkWidget *label[2];
|
||||
gint repeat;
|
||||
GtkWidget *label[3];
|
||||
GtkWidget *image;
|
||||
};
|
||||
|
||||
|
@ -63,6 +63,7 @@ void gimp_message_box_set_text (GimpMessageBox *box,
|
|||
void gimp_message_box_set_markup (GimpMessageBox *box,
|
||||
const gchar *format,
|
||||
...);
|
||||
gint gimp_message_box_repeat (GimpMessageBox *box);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -31,209 +31,12 @@
|
|||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "gimpmessagebox.h"
|
||||
#include "gimperrordialog.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
/*
|
||||
* Message Boxes...
|
||||
*/
|
||||
|
||||
typedef struct _MessageBox MessageBox;
|
||||
|
||||
struct _MessageBox
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *box;
|
||||
GtkWidget *repeat_label;
|
||||
gchar *domain;
|
||||
gchar *message;
|
||||
gint repeat_count;
|
||||
GtkCallback callback;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
/* the maximum number of concurrent dialog boxes */
|
||||
#define MESSAGE_BOX_MAXIMUM 4
|
||||
|
||||
|
||||
static void gimp_message_box_set_icons (GtkWidget *dialog,
|
||||
const gchar *stock_id);
|
||||
static void gimp_message_box_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
MessageBox *msg_box);
|
||||
|
||||
|
||||
static GList *message_boxes = NULL;
|
||||
|
||||
|
||||
void
|
||||
gimp_message_box (const gchar *stock_id,
|
||||
const gchar *domain,
|
||||
const gchar *message,
|
||||
GtkCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
MessageBox *msg_box;
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *box;
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (stock_id != NULL);
|
||||
g_return_if_fail (message != NULL);
|
||||
|
||||
if (! domain)
|
||||
domain = _("GIMP");
|
||||
|
||||
if (g_list_length (message_boxes) > MESSAGE_BOX_MAXIMUM)
|
||||
{
|
||||
g_printerr ("%s: %s\n\n", domain, message);
|
||||
return;
|
||||
}
|
||||
|
||||
for (list = message_boxes; list; list = list->next)
|
||||
{
|
||||
msg_box = list->data;
|
||||
|
||||
if (strcmp (msg_box->message, message) == 0 &&
|
||||
strcmp (msg_box->domain, domain) == 0)
|
||||
{
|
||||
msg_box->repeat_count++;
|
||||
|
||||
if (msg_box->repeat_count > 1)
|
||||
{
|
||||
gchar *text = g_strdup_printf (_("Message repeated %d times."),
|
||||
msg_box->repeat_count);
|
||||
gtk_label_set_text (GTK_LABEL (msg_box->repeat_label), text);
|
||||
g_free (text);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *label;
|
||||
|
||||
label = gtk_label_new (_("Message repeated once."));
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
gimp_label_set_attributes (GTK_LABEL (label),
|
||||
PANGO_ATTR_STYLE, PANGO_STYLE_OBLIQUE,
|
||||
-1);
|
||||
gtk_box_pack_end (GTK_BOX (msg_box->box), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
msg_box->repeat_label = label;
|
||||
}
|
||||
|
||||
gtk_window_present (GTK_WINDOW (msg_box->dialog));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_list_length (message_boxes) == MESSAGE_BOX_MAXIMUM)
|
||||
{
|
||||
g_printerr ("%s: %s\n\n", domain, message);
|
||||
message = _("WARNING:\n"
|
||||
"Too many open message dialogs.\n"
|
||||
"Messages are redirected to stderr.");
|
||||
}
|
||||
|
||||
msg_box = g_new0 (MessageBox, 1);
|
||||
|
||||
dialog = gimp_dialog_new (_("GIMP Message"), "gimp-message",
|
||||
NULL, 0,
|
||||
NULL, NULL,
|
||||
|
||||
GTK_STOCK_OK, GTK_RESPONSE_CLOSE,
|
||||
|
||||
NULL);
|
||||
|
||||
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
||||
|
||||
gimp_message_box_set_icons (dialog, stock_id);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gimp_message_box_response),
|
||||
msg_box);
|
||||
|
||||
box = gimp_message_box_new (stock_id);
|
||||
gimp_message_box_set_primary_text (GIMP_MESSAGE_BOX (box),
|
||||
_("%s Message"), domain);
|
||||
gimp_message_box_set_text (GIMP_MESSAGE_BOX (box), message);
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box);
|
||||
gtk_widget_show (box);
|
||||
|
||||
msg_box->dialog = dialog;
|
||||
msg_box->box = box;
|
||||
msg_box->domain = g_strdup (domain);
|
||||
msg_box->message = g_strdup (message);
|
||||
msg_box->callback = callback;
|
||||
msg_box->data = data;
|
||||
|
||||
message_boxes = g_list_prepend (message_boxes, msg_box);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_message_box_set_icons (GtkWidget *dialog,
|
||||
const gchar *stock_id)
|
||||
{
|
||||
GtkIconSet *icon_set;
|
||||
GtkIconSize *sizes;
|
||||
GList *icons = NULL;
|
||||
gint i, n_sizes;
|
||||
|
||||
gtk_widget_ensure_style (dialog);
|
||||
|
||||
icon_set = gtk_style_lookup_icon_set (dialog->style, stock_id);
|
||||
|
||||
if (icon_set == NULL)
|
||||
return;
|
||||
|
||||
gtk_icon_set_get_sizes (icon_set, &sizes, &n_sizes);
|
||||
|
||||
for (i = 0; i < n_sizes; i++)
|
||||
{
|
||||
if (sizes[i] < GTK_ICON_SIZE_DIALOG) /* skip the large version */
|
||||
icons = g_list_prepend (icons,
|
||||
gtk_widget_render_icon (dialog,
|
||||
stock_id, sizes[i],
|
||||
NULL));
|
||||
}
|
||||
|
||||
g_free (sizes);
|
||||
|
||||
if (icons)
|
||||
{
|
||||
gtk_window_set_icon_list (GTK_WINDOW (dialog), icons);
|
||||
|
||||
g_list_foreach (icons, (GFunc) g_object_unref, NULL);
|
||||
g_list_free (icons);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_message_box_response (GtkWidget *widget,
|
||||
gint resonse_id,
|
||||
MessageBox *msg_box)
|
||||
{
|
||||
/* If there is a valid callback, invoke it */
|
||||
if (msg_box->callback)
|
||||
(* msg_box->callback) (widget, msg_box->data);
|
||||
|
||||
/* Destroy the box */
|
||||
gtk_widget_destroy (msg_box->dialog);
|
||||
|
||||
/* make this box available again */
|
||||
message_boxes = g_list_remove (message_boxes, msg_box);
|
||||
|
||||
g_free (msg_box->domain);
|
||||
g_free (msg_box->message);
|
||||
g_free (msg_box);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_menu_position:
|
||||
* @menu: a #GtkMenu widget
|
||||
|
|
|
@ -23,12 +23,6 @@
|
|||
#define __GIMP_WIDGETS_UTILS_H__
|
||||
|
||||
|
||||
void gimp_message_box (const gchar *stock_id,
|
||||
const gchar *domain,
|
||||
const gchar *message,
|
||||
GtkCallback callback,
|
||||
gpointer data);
|
||||
|
||||
void gimp_menu_position (GtkMenu *menu,
|
||||
gint *x,
|
||||
gint *y);
|
||||
|
|
|
@ -122,6 +122,7 @@ typedef struct _GimpUIManager GimpUIManager;
|
|||
|
||||
/* misc dialogs */
|
||||
|
||||
typedef struct _GimpErrorDialog GimpErrorDialog;
|
||||
typedef struct _GimpFileDialog GimpFileDialog;
|
||||
typedef struct _GimpProgressDialog GimpProgressDialog;
|
||||
typedef struct _GimpTextEditor GimpTextEditor;
|
||||
|
|
Loading…
Reference in a new issue