Пример #1
0
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);
}
Пример #2
0
static gboolean
gui_message_error_dialog (Gimp                *gimp,
                          GObject             *handler,
                          GimpMessageSeverity  severity,
                          const gchar         *domain,
                          const gchar         *message)
{
  GtkWidget *dialog;

  if (GIMP_IS_PROGRESS (handler))
    {
      /* If there's already an error dialog associated with this
       * progress, then continue without trying gimp_progress_message().
       */
      if (! g_object_get_data (handler, "gimp-error-dialog") &&
          gimp_progress_message (GIMP_PROGRESS (handler), gimp,
                                 severity, domain, message))
        {
          return TRUE;
        }
    }
  else if (GTK_IS_WIDGET (handler))
    {
      GtkWidget      *parent = GTK_WIDGET (handler);
      GtkMessageType  type   = GTK_MESSAGE_ERROR;

      switch (severity)
        {
        case GIMP_MESSAGE_INFO:    type = GTK_MESSAGE_INFO;    break;
        case GIMP_MESSAGE_WARNING: type = GTK_MESSAGE_WARNING; break;
        case GIMP_MESSAGE_ERROR:   type = GTK_MESSAGE_ERROR;   break;
        }

      dialog =
        gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (parent)),
                                GTK_DIALOG_DESTROY_WITH_PARENT,
                                type, GTK_BUTTONS_OK,
                                "%s", message);

      g_signal_connect (dialog, "response",
                        G_CALLBACK (gtk_widget_destroy),
                        NULL);

      gtk_widget_show (dialog);

      return TRUE;
    }

  if (GIMP_IS_PROGRESS (handler) && ! GIMP_IS_PROGRESS_DIALOG (handler))
    dialog = progress_error_dialog (GIMP_PROGRESS (handler));
  else
    dialog = global_error_dialog ();

  if (dialog)
    {
      gimp_error_dialog_add (GIMP_ERROR_DIALOG (dialog),
                             gimp_get_message_stock_id (severity),
                             domain, message);
      gtk_window_present (GTK_WINDOW (dialog));

      return TRUE;
    }

  return FALSE;
}