2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-06-13 14:37:00 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-06-13 14:37:00 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-06-13 14:37:00 +00:00
|
|
|
* (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
|
2009-01-17 22:28:01 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-06-13 14:37:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2013-11-01 22:28:18 +01:00
|
|
|
#include <gegl.h>
|
2003-06-13 14:37:00 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2004-10-24 22:26:11 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2003-06-13 14:37:00 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-20 13:25:55 +00:00
|
|
|
#include "actions-types.h"
|
2003-06-13 14:37:00 +00:00
|
|
|
|
2006-10-09 08:17:22 +00:00
|
|
|
#include "core/gimp.h"
|
|
|
|
|
2003-06-13 14:37:00 +00:00
|
|
|
#include "widgets/gimperrorconsole.h"
|
2004-10-24 22:26:11 +00:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2010-02-25 17:41:10 +01:00
|
|
|
#include "widgets/gimptextbuffer.h"
|
2003-06-13 14:37:00 +00:00
|
|
|
|
|
|
|
#include "error-console-commands.h"
|
|
|
|
|
2004-10-24 22:26:11 +00:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
static void error_console_save_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
GimpErrorConsole *console);
|
|
|
|
|
2003-06-13 14:37:00 +00:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2004-04-29 12:52:29 +00:00
|
|
|
error_console_clear_cmd_callback (GtkAction *action,
|
2004-04-19 16:00:54 +00:00
|
|
|
gpointer data)
|
2003-06-13 14:37:00 +00:00
|
|
|
{
|
|
|
|
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
|
2004-10-24 22:26:11 +00:00
|
|
|
GtkTextIter start_iter;
|
|
|
|
GtkTextIter end_iter;
|
2003-06-13 14:37:00 +00:00
|
|
|
|
2004-10-24 22:26:11 +00:00
|
|
|
gtk_text_buffer_get_bounds (console->text_buffer, &start_iter, &end_iter);
|
|
|
|
gtk_text_buffer_delete (console->text_buffer, &start_iter, &end_iter);
|
2003-06-13 14:37:00 +00:00
|
|
|
}
|
|
|
|
|
2006-06-07 13:47:55 +00:00
|
|
|
void
|
|
|
|
error_console_select_all_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
|
|
|
|
GtkTextIter start_iter;
|
|
|
|
GtkTextIter end_iter;
|
|
|
|
|
|
|
|
gtk_text_buffer_get_bounds (console->text_buffer, &start_iter, &end_iter);
|
|
|
|
gtk_text_buffer_select_range (console->text_buffer, &start_iter, &end_iter);
|
|
|
|
}
|
|
|
|
|
2003-06-13 14:37:00 +00:00
|
|
|
void
|
2004-10-24 22:26:11 +00:00
|
|
|
error_console_save_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2003-06-13 14:37:00 +00:00
|
|
|
{
|
|
|
|
GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
|
2004-10-24 22:26:11 +00:00
|
|
|
|
|
|
|
if (value && ! gtk_text_buffer_get_selection_bounds (console->text_buffer,
|
|
|
|
NULL, NULL))
|
|
|
|
{
|
2008-11-04 12:33:09 +00:00
|
|
|
gimp_message_literal (console->gimp,
|
2013-09-15 04:59:20 +12:00
|
|
|
G_OBJECT (console), GIMP_MESSAGE_WARNING,
|
|
|
|
_("Cannot save. Nothing is selected."));
|
2004-10-24 22:26:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-25 22:18:37 +02:00
|
|
|
if (! console->file_dialog)
|
2004-10-24 22:26:11 +00:00
|
|
|
{
|
2016-09-25 22:18:37 +02:00
|
|
|
GtkWidget *dialog;
|
2004-10-24 22:26:11 +00:00
|
|
|
|
2016-09-25 22:18:37 +02:00
|
|
|
dialog = console->file_dialog =
|
|
|
|
gtk_file_chooser_dialog_new (_("Save Error Log to File"), NULL,
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
2004-10-24 22:26:11 +00:00
|
|
|
|
2017-02-12 16:06:34 +01:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("_Save"), GTK_RESPONSE_OK,
|
2004-10-24 22:26:11 +00:00
|
|
|
|
2016-09-25 22:18:37 +02:00
|
|
|
NULL);
|
2005-02-10 11:00:46 +00:00
|
|
|
|
2016-09-25 22:18:37 +02:00
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2004-10-24 22:26:11 +00:00
|
|
|
|
2016-09-25 22:18:37 +02:00
|
|
|
console->save_selection = value;
|
2004-10-24 22:26:11 +00:00
|
|
|
|
2016-09-25 22:18:37 +02:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (dialog),
|
|
|
|
(gpointer) &console->file_dialog);
|
2003-06-13 14:37:00 +00:00
|
|
|
|
2016-09-25 22:18:37 +02:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (dialog),
|
|
|
|
gtk_widget_get_screen (GTK_WIDGET (console)));
|
|
|
|
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
|
|
|
|
gtk_window_set_role (GTK_WINDOW (dialog), "gimp-save-errors");
|
2004-10-24 22:26:11 +00:00
|
|
|
|
2016-09-25 22:18:37 +02:00
|
|
|
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
|
|
|
|
TRUE);
|
2004-10-24 22:26:11 +00:00
|
|
|
|
2016-09-25 22:18:37 +02:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (error_console_save_response),
|
|
|
|
console);
|
|
|
|
g_signal_connect (dialog, "delete-event",
|
|
|
|
G_CALLBACK (gtk_true),
|
|
|
|
NULL);
|
2007-02-02 07:50:36 +00:00
|
|
|
|
2016-09-25 22:18:37 +02:00
|
|
|
gimp_help_connect (dialog, gimp_standard_help_func,
|
|
|
|
GIMP_HELP_ERRORS_DIALOG, NULL);
|
|
|
|
}
|
2004-10-24 22:26:11 +00:00
|
|
|
|
2016-09-25 22:18:37 +02:00
|
|
|
gtk_window_present (GTK_WINDOW (console->file_dialog));
|
2003-06-13 14:37:00 +00:00
|
|
|
}
|
|
|
|
|
2004-10-24 22:26:11 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
error_console_save_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
GimpErrorConsole *console)
|
2003-06-13 14:37:00 +00:00
|
|
|
{
|
2004-10-24 22:26:11 +00:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
2016-09-25 22:18:37 +02:00
|
|
|
GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
2004-10-24 22:26:11 +00:00
|
|
|
GError *error = NULL;
|
|
|
|
|
2010-02-25 17:41:10 +01:00
|
|
|
if (! gimp_text_buffer_save (GIMP_TEXT_BUFFER (console->text_buffer),
|
2014-07-02 15:10:53 +02:00
|
|
|
file,
|
2004-10-24 22:26:11 +00:00
|
|
|
console->save_selection, &error))
|
|
|
|
{
|
2006-10-09 08:17:22 +00:00
|
|
|
gimp_message (console->gimp, G_OBJECT (dialog), GIMP_MESSAGE_ERROR,
|
|
|
|
_("Error writing file '%s':\n%s"),
|
2014-07-02 15:10:53 +02:00
|
|
|
gimp_file_get_utf8_name (file),
|
2006-10-09 08:17:22 +00:00
|
|
|
error->message);
|
2004-10-24 22:26:11 +00:00
|
|
|
g_clear_error (&error);
|
2014-07-02 15:10:53 +02:00
|
|
|
g_object_unref (file);
|
2004-10-24 22:26:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-02 15:10:53 +02:00
|
|
|
g_object_unref (file);
|
2004-10-24 22:26:11 +00:00
|
|
|
}
|
2003-06-13 14:37:00 +00:00
|
|
|
|
2004-10-24 22:26:11 +00:00
|
|
|
gtk_widget_destroy (dialog);
|
2003-06-13 14:37:00 +00:00
|
|
|
}
|