2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 14:05:25 -08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
2006-04-28 12:39:21 -07:00
|
|
|
*
|
|
|
|
|
* user-install-dialog.c
|
|
|
|
|
* Copyright (C) 2000-2006 Michael Natterer and Sven Neumann
|
1997-11-24 14:05:25 -08:00
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 14:05:25 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 14:05:25 -08: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
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 14:05:25 -08:00
|
|
|
*/
|
2000-12-16 13:37:03 -08:00
|
|
|
|
1999-03-07 04:56:03 -08:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2013-11-01 14:28:18 -07:00
|
|
|
#include <gegl.h>
|
2001-02-03 20:51:17 -08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
2001-01-24 14:36:18 -08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-23 15:56:18 -08:00
|
|
|
|
2004-09-13 08:15:23 -07:00
|
|
|
#include "dialogs-types.h"
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2006-04-28 17:24:48 -07:00
|
|
|
#include "core/gimp-user-install.h"
|
2004-11-23 13:00:15 -08:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
#include "widgets/gimpmessagebox.h"
|
|
|
|
|
#include "widgets/gimpmessagedialog.h"
|
|
|
|
|
|
2001-11-10 11:35:21 -08:00
|
|
|
#include "user-install-dialog.h"
|
2001-05-22 14:12:43 -07:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
2000-03-14 15:06:21 -08:00
|
|
|
|
2002-12-30 09:27:58 -08:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
static GtkWidget * user_install_dialog_new (GimpUserInstall *install);
|
|
|
|
|
static void user_install_dialog_log (const gchar *message,
|
2016-12-20 19:05:32 -08:00
|
|
|
gboolean error,
|
|
|
|
|
gpointer data);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
|
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
gboolean
|
|
|
|
|
user_install_dialog_run (GimpUserInstall *install)
|
2000-03-15 08:00:24 -08:00
|
|
|
{
|
2006-06-05 06:48:57 -07:00
|
|
|
GtkWidget *dialog;
|
|
|
|
|
gboolean success;
|
2000-03-15 08:00:24 -08:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
g_return_val_if_fail (install != NULL, FALSE);
|
2006-04-21 04:07:25 -07:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
dialog = user_install_dialog_new (install);
|
2000-03-14 15:06:21 -08:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
success = gimp_user_install_run (install);
|
2000-03-14 15:06:21 -08:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
if (! success)
|
2000-03-14 15:06:21 -08:00
|
|
|
{
|
2006-06-05 06:48:57 -07:00
|
|
|
g_signal_connect (dialog, "response",
|
2016-12-20 19:05:32 -08:00
|
|
|
G_CALLBACK (gtk_main_quit),
|
|
|
|
|
NULL);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
gtk_widget_show (dialog);
|
2006-04-21 04:07:25 -07:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
gtk_main ();
|
|
|
|
|
}
|
2000-03-14 15:06:21 -08:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
gtk_widget_destroy (dialog);
|
2006-04-28 12:39:21 -07:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
return success;
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2006-04-28 12:39:21 -07:00
|
|
|
static GtkWidget *
|
2006-06-05 06:48:57 -07:00
|
|
|
user_install_dialog_new (GimpUserInstall *install)
|
2006-04-24 08:26:08 -07:00
|
|
|
{
|
2006-06-05 06:48:57 -07:00
|
|
|
GtkWidget *dialog;
|
|
|
|
|
GtkWidget *frame;
|
|
|
|
|
GtkWidget *scrolled;
|
|
|
|
|
GtkTextBuffer *buffer;
|
|
|
|
|
GtkWidget *view;
|
|
|
|
|
|
2015-12-13 11:03:52 -08:00
|
|
|
gimp_icons_init ();
|
2006-06-05 06:48:57 -07:00
|
|
|
|
|
|
|
|
dialog = gimp_message_dialog_new (_("GIMP User Installation"),
|
2017-03-05 07:01:59 -08:00
|
|
|
GIMP_ICON_WILBER_EEK,
|
2016-12-20 19:05:32 -08:00
|
|
|
NULL, 0, NULL, NULL,
|
2006-06-05 06:48:57 -07:00
|
|
|
|
2017-02-12 07:06:34 -08:00
|
|
|
_("_Quit"), GTK_RESPONSE_OK,
|
2006-06-05 06:48:57 -07:00
|
|
|
|
2016-12-20 19:05:32 -08:00
|
|
|
NULL);
|
2006-06-05 06:48:57 -07:00
|
|
|
|
|
|
|
|
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
2016-12-20 19:05:32 -08:00
|
|
|
_("User installation failed!"));
|
2006-06-05 06:48:57 -07:00
|
|
|
gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
2016-12-20 19:05:32 -08:00
|
|
|
_("The GIMP user installation failed; "
|
|
|
|
|
"see the log for details."));
|
2007-10-09 01:04:31 -07:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
frame = gimp_frame_new (_("Installation Log"));
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (frame), 12);
|
2009-07-15 07:19:32 -07:00
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
|
|
|
|
frame, TRUE, TRUE, 0);
|
2006-06-05 06:48:57 -07:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
|
|
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
|
2006-04-28 12:39:21 -07:00
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
2006-06-05 06:48:57 -07:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), scrolled);
|
|
|
|
|
gtk_widget_show (scrolled);
|
2007-10-09 01:04:31 -07:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
buffer = gtk_text_buffer_new (NULL);
|
2006-04-28 12:39:21 -07:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
gtk_text_buffer_create_tag (buffer, "bold",
|
2006-04-28 12:39:21 -07:00
|
|
|
"weight", PANGO_WEIGHT_BOLD,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
view = gtk_text_view_new_with_buffer (buffer);
|
|
|
|
|
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
|
|
|
|
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
|
|
|
|
|
gtk_widget_set_size_request (view, -1, 200);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled), view);
|
|
|
|
|
gtk_widget_show (view);
|
2006-04-28 12:39:21 -07:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
g_object_unref (buffer);
|
2006-04-28 12:39:21 -07:00
|
|
|
|
2006-06-05 06:51:34 -07:00
|
|
|
gimp_user_install_set_log_handler (install, user_install_dialog_log, buffer);
|
2006-04-28 12:39:21 -07:00
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
return dialog;
|
2006-04-28 12:39:21 -07:00
|
|
|
}
|
|
|
|
|
|
2006-04-28 17:24:48 -07:00
|
|
|
static void
|
|
|
|
|
user_install_dialog_log (const gchar *message,
|
|
|
|
|
gboolean error,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
2006-06-05 06:51:34 -07:00
|
|
|
GtkTextBuffer *buffer = GTK_TEXT_BUFFER (data);
|
2006-04-28 17:24:48 -07:00
|
|
|
GtkTextIter cursor;
|
|
|
|
|
|
|
|
|
|
gtk_text_buffer_get_end_iter (buffer, &cursor);
|
|
|
|
|
|
2006-06-05 06:48:57 -07:00
|
|
|
if (error && message)
|
2006-04-28 17:24:48 -07:00
|
|
|
{
|
2006-06-05 06:48:57 -07:00
|
|
|
gtk_text_buffer_insert_with_tags_by_name (buffer, &cursor, message, -1,
|
|
|
|
|
"bold", NULL);
|
2006-04-28 17:24:48 -07:00
|
|
|
}
|
2006-06-05 06:48:57 -07:00
|
|
|
else if (message)
|
2006-04-28 17:24:48 -07:00
|
|
|
{
|
|
|
|
|
gtk_text_buffer_insert (buffer, &cursor, message, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_text_buffer_insert (buffer, &cursor, "\n", -1);
|
2004-10-31 09:51:00 -08:00
|
|
|
}
|