Commit 5e950b55 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Cleaned up and improved the message system:

2003-06-13  Michael Natterer  <mitch@gimp.org>

	Cleaned up and improved the message system:

	* app/core/gimp.[ch]: added "const gchar *domain" to
	GimpMessageFunc (a NULL domain means the message is from the GIMP
	core, everything else is a plug-in).

	* app/errors.c: pass "domain == NULL" to gimp_message().

	* tools/pdbgen/pdb/message.pdb: derive the message domain from the
	current plug-in's menu_path (evil hack but works reasonably well).

	* app/pdb/message_cmds.c: regenerated.

	* app/widgets/gimpwidgets-utils.[ch] (gimp_message_box): added a
	header showing the message domain and changed the dialog layout to
	follow the HIG more closely.

	* app/gui/error-console-dialog.[ch]: removed.

	* app/widgets/gimperrorconsole.[ch]
	* app/gui/error-console-commands.[ch]
	* app/gui/error-console-menu.[ch]: new files containing a
	re-implementation of the error console dialog.

	* app/gui/Makefile.am
	* app/gui/dialogs-constructors.c
	* app/gui/gui.c
	* app/gui/menus.c
	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h: changed accordingly.

	* app/display/gimpprogress.c: added more spacing and removed the
	separator (more HIG compliant).

	* plug-ins/[most plug-ins].c: Changed lots of messages and
	progress strings:

	- Removed plug-in names from messages since that's automatically
	  covered by "domain" now.
	- Put all filenames in ''.
	- Changed "Loading" to "Opening".
	- Added "..." to all progress messages.
	- Cleaned up all file open/save error messages to look the
	  same and include g_strerror(errno).
	- Removed special casing for progress bars and *always* show them,
	  not only if run_mode != GIMP_RUN_NONINTERACTIVE (we can't expect
	  all plug-ins to do this correctly but need to hack the core to
	  sort out unwanted progress bars).

	Unrelated:

	- Cleaned up indentation, spacing, #includes, coding style and
	  other stuff while I was at all these files.
parent 9aa41cec
2003-06-13 Michael Natterer <mitch@gimp.org>
Cleaned up and improved the message system:
* app/core/gimp.[ch]: added "const gchar *domain" to
GimpMessageFunc (a NULL domain means the message is from the GIMP
core, everything else is a plug-in).
* app/errors.c: pass "domain == NULL" to gimp_message().
* tools/pdbgen/pdb/message.pdb: derive the message domain from the
current plug-in's menu_path (evil hack but works reasonably well).
* app/pdb/message_cmds.c: regenerated.
* app/widgets/gimpwidgets-utils.[ch] (gimp_message_box): added a
header showing the message domain and changed the dialog layout to
follow the HIG more closely.
* app/gui/error-console-dialog.[ch]: removed.
* app/widgets/gimperrorconsole.[ch]
* app/gui/error-console-commands.[ch]
* app/gui/error-console-menu.[ch]: new files containing a
re-implementation of the error console dialog.
* app/gui/Makefile.am
* app/gui/dialogs-constructors.c
* app/gui/gui.c
* app/gui/menus.c
* app/widgets/Makefile.am
* app/widgets/widgets-types.h: changed accordingly.
* app/display/gimpprogress.c: added more spacing and removed the
separator (more HIG compliant).
* plug-ins/[most plug-ins].c: Changed lots of messages and
progress strings:
- Removed plug-in names from messages since that's automatically
covered by "domain" now.
- Put all filenames in ''.
- Changed "Loading" to "Opening".
- Added "..." to all progress messages.
- Cleaned up all file open/save error messages to look the
same and include g_strerror(errno).
- Removed special casing for progress bars and *always* show them,
not only if run_mode != GIMP_RUN_NONINTERACTIVE (we can't expect
all plug-ins to do this correctly but need to hack the core to
sort out unwanted progress bars).
Unrelated:
- Cleaned up indentation, spacing, #includes, coding style and
other stuff while I was at all these files.
2003-06-13 Sven Neumann <sven@gimp.org>
* app/gui/file-save-dialog.c (file_save_ok_callback): removed
/* 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.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "widgets/gimperrorconsole.h"
#include "error-console-commands.h"
/* public functions */
void
error_console_clear_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
if (GTK_WIDGET_IS_SENSITIVE (console->clear_button))
gtk_button_clicked (GTK_BUTTON (console->clear_button));
}
void
error_console_save_all_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
if (GTK_WIDGET_IS_SENSITIVE (console->save_button))
gtk_button_clicked (GTK_BUTTON (console->save_button));
}
void
error_console_save_selection_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
if (GTK_WIDGET_IS_SENSITIVE (console->save_button))
gimp_button_extended_clicked (GIMP_BUTTON (console->save_button),
GDK_SHIFT_MASK);
}
/* 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 __ERROR_CONSOLE_COMMANDS_H__
#define __ERROR_CONSOLE_COMMANDS_H__
void error_console_clear_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void error_console_save_all_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void error_console_save_selection_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
#endif /* __ERROR_CONSOLE_COMMANDS_H__ */
......@@ -885,6 +885,7 @@ gimp_unset_busy (Gimp *gimp)
void
gimp_message (Gimp *gimp,
const gchar *domain,
const gchar *message)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
......@@ -895,7 +896,7 @@ gimp_message (Gimp *gimp,
case GIMP_ERROR_CONSOLE:
if (gimp->gui_message_func)
{
gimp->gui_message_func (gimp, message);
gimp->gui_message_func (gimp, domain, message);
return;
}
break;
......@@ -904,7 +905,7 @@ gimp_message (Gimp *gimp,
break;
}
g_printerr ("%s: %s\n", GIMP_OBJECT (gimp)->name, message);
g_printerr ("%s: %s\n", domain ? domain : GIMP_OBJECT (gimp)->name, message);
}
GimpImage *
......
......@@ -30,6 +30,7 @@ typedef GimpObject * (* GimpCreateDisplayFunc) (GimpImage *gimage,
typedef void (* GimpSetBusyFunc) (Gimp *gimp);
typedef void (* GimpUnsetBusyFunc) (Gimp *gimp);
typedef void (* GimpMessageFunc) (Gimp *gimp,
const gchar *domain,
const gchar *message);
......@@ -184,6 +185,7 @@ void gimp_set_busy_until_idle (Gimp *gimp);
void gimp_unset_busy (Gimp *gimp);
void gimp_message (Gimp *gimp,
const gchar *domain,
const gchar *message);
GimpImage * gimp_create_image (Gimp *gimp,
......
......@@ -52,6 +52,7 @@
#include "widgets/gimpdataeditor.h"
#include "widgets/gimpdatafactoryview.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimperrorconsole.h"
#include "widgets/gimpimagedock.h"
#include "widgets/gimpimageview.h"
#include "widgets/gimpitemtreeview.h"
......@@ -78,7 +79,6 @@
#include "device-status-dialog.h"
#include "dialogs.h"
#include "dialogs-constructors.h"
#include "error-console-dialog.h"
#include "file-commands.h"
#include "file-new-dialog.h"
#include "layers-commands.h"
......@@ -284,7 +284,7 @@ dialogs_error_console_get (GimpDialogFactory *factory,
if (view)
return NULL;
view = error_console_create (context->gimp);
view = gimp_error_console_new (context->gimp, factory->menu_factory);
g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view);
......
......@@ -144,8 +144,11 @@ gimp_progress_start (GimpDisplay *gdisp,
NULL);
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
gtk_window_set_resizable (GTK_WINDOW (progress->dialog), FALSE);
gtk_dialog_set_has_separator (GTK_DIALOG (progress->dialog), FALSE);
vbox = gtk_vbox_new (FALSE, 10);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (progress->dialog)->vbox),
vbox);
gtk_widget_show (vbox);
......@@ -154,12 +157,13 @@ gimp_progress_start (GimpDisplay *gdisp,
_("Please wait..."));
gtk_misc_set_alignment (GTK_MISC (progress->dialog_label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), progress->dialog_label,
FALSE, TRUE, 0);
FALSE, FALSE, 0);
gtk_widget_show (progress->dialog_label);
progress->progressbar = gtk_progress_bar_new ();
gtk_widget_set_size_request (progress->progressbar, 150, 20);
gtk_box_pack_start (GTK_BOX (vbox), progress->progressbar, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), progress->progressbar,
FALSE, FALSE, 0);
gtk_widget_show (progress->progressbar);
gtk_widget_show (progress->dialog);
......
......@@ -60,7 +60,7 @@ gimp_message_log_func (const gchar *log_domain,
if (! console_messages && GIMP_IS_GIMP (gimp))
{
gimp_message (gimp, message);
gimp_message (gimp, NULL, message);
return;
}
......
......@@ -17,8 +17,6 @@ dialogs_sources = \
dialogs.h \
dialogs-constructors.c \
dialogs-constructors.h \
error-console-dialog.c \
error-console-dialog.h \
file-dialog-utils.c \
file-dialog-utils.h \
file-new-dialog.c \
......@@ -95,6 +93,10 @@ menus_sources = \
drawable-commands.h \
edit-commands.c \
edit-commands.h \
error-console-commands.c \
error-console-commands.h \
error-console-menu.c \
error-console-menu.h \
file-commands.c \
file-commands.h \
file-open-menu.c \
......
......@@ -52,6 +52,7 @@
#include "widgets/gimpdataeditor.h"
#include "widgets/gimpdatafactoryview.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimperrorconsole.h"
#include "widgets/gimpimagedock.h"
#include "widgets/gimpimageview.h"
#include "widgets/gimpitemtreeview.h"
......@@ -78,7 +79,6 @@
#include "device-status-dialog.h"
#include "dialogs.h"
#include "dialogs-constructors.h"
#include "error-console-dialog.h"
#include "file-commands.h"
#include "file-new-dialog.h"
#include "layers-commands.h"
......@@ -284,7 +284,7 @@ dialogs_error_console_get (GimpDialogFactory *factory,
if (view)
return NULL;
view = error_console_create (context->gimp);
view = gimp_error_console_new (context->gimp, factory->menu_factory);
g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view);
......
/* 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.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "widgets/gimperrorconsole.h"
#include "error-console-commands.h"
/* public functions */
void
error_console_clear_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
if (GTK_WIDGET_IS_SENSITIVE (console->clear_button))
gtk_button_clicked (GTK_BUTTON (console->clear_button));
}
void
error_console_save_all_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
if (GTK_WIDGET_IS_SENSITIVE (console->save_button))
gtk_button_clicked (GTK_BUTTON (console->save_button));
}
void
error_console_save_selection_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
if (GTK_WIDGET_IS_SENSITIVE (console->save_button))
gimp_button_extended_clicked (GIMP_BUTTON (console->save_button),
GDK_SHIFT_MASK);
}
/* 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 __ERROR_CONSOLE_COMMANDS_H__
#define __ERROR_CONSOLE_COMMANDS_H__
void error_console_clear_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void error_console_save_all_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void error_console_save_selection_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
#endif /* __ERROR_CONSOLE_COMMANDS_H__ */
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* errorconsole.c - text window for collecting error messages
* Copyright (C) 1998 Nick Fetchak <nuke@bayside.net>
*
* 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 <glib.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#ifdef G_OS_WIN32
#include <io.h>
#ifndef S_IRUSR
#define S_IRUSR _S_IREAD
#endif
#ifndef S_IWUSR
#define S_IWUSR _S_IWRITE
#endif
#endif
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "error-console-dialog.h"
#include "gimp-intl.h"
typedef enum
{
ERRORS_ALL,
ERRORS_SELECTION
} ErrorScope;
/* local function prototypes */
static void error_console_destroy_callback (gpointer data);
static gboolean text_clicked_callback (GtkWidget *widget,
GdkEventButton *event,
GtkMenu *menu);
static void error_console_clear_callback (GtkWidget *widget,
GtkTextBuffer *buffer);
static void error_console_write_all_callback (GtkWidget *widget,
GtkTextBuffer *buffer);
static void error_console_write_selection_callback (GtkWidget *widget,
GtkTextBuffer *buffer);
static void error_console_create_file_dialog (GtkTextBuffer *buffer,
ErrorScope textscope);
static void error_console_file_ok_callback (GtkWidget *widget,
gpointer data);
static gboolean error_console_write_file (GtkTextBuffer *text_buffer,
const gchar *path,
ErrorScope textscope);
/* private variables */
static GtkWidget *error_console = NULL;
/* public functions */
GtkWidget *
error_console_create (Gimp *gimp)
{
GtkTextBuffer *text_buffer;
GtkWidget *text_view;
GtkWidget *scrolled_window;
GtkWidget *menu;
GtkWidget *menuitem;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
if (error_console)
return error_console;
text_buffer = gtk_text_buffer_new (NULL);
error_console = gtk_vbox_new (FALSE, 0);
g_object_set_data (G_OBJECT (error_console), "text-buffer", text_buffer);
g_object_weak_ref (G_OBJECT (error_console),
(GWeakNotify) error_console_destroy_callback,
gimp);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (error_console), scrolled_window);
gtk_widget_show (scrolled_window);
menu = gtk_menu_new ();
menuitem = gtk_menu_item_new_with_label (_("Clear Console"));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (error_console_clear_callback),
text_buffer);
menuitem = gtk_menu_item_new ();
gtk_widget_set_sensitive (menuitem, FALSE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
menuitem = gtk_menu_item_new_with_label (_("Write all errors to file..."));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (error_console_write_all_callback),
text_buffer);
menuitem = gtk_menu_item_new_with_label (_("Write selection to file..."));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (error_console_write_selection_callback),
text_buffer);
/* The output text widget */
text_view = gtk_text_view_new_with_buffer (text_buffer);
g_object_unref (text_buffer);
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
gtk_widget_show (text_view);
g_signal_connect (text_view, "button_press_event",
G_CALLBACK (text_clicked_callback),
menu);