From 0f7616a007edaa1d19c4672a4fd390c072b1eba6 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 13 Dec 2009 14:32:58 +0100 Subject: Error system transformation to GError Note that most coreworkers are broken at the moment. --- UError.pas | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'UError.pas') diff --git a/UError.pas b/UError.pas index cf722e3..57250a8 100644 --- a/UError.pas +++ b/UError.pas @@ -21,7 +21,7 @@ unit UError; interface -uses glib2, gdk2, Classes, ULibc; +uses glib2, gtk2, Classes, ULibc, GTKForms; // Ported from gioerror.h @@ -68,6 +68,8 @@ function G_IO_ERROR: TGQuark; function g_io_error_from_errno(err_no: gint): GIOErrorEnum; +procedure ShowError(Parent: TCustomGTKForm; const Text: string; Error: PGError); + implementation uses SysUtils, UCoreUtils, UGnome; @@ -111,5 +113,26 @@ begin end; end; + +(********************************************************************************************************************************) +procedure ShowError(Parent: TCustomGTKForm; const Text: string; Error: PGError); +var Dialog: PGtkWidget; + error_str: PChar; +begin + if Error <> nil then error_str := Error^.message + else error_str := ''; + if @gtk_message_dialog_new_with_markup <> nil + then dialog := gtk_message_dialog_new_with_markup (PGtkWindow(Parent.FWidget), GTK_DIALOG_MODAL or GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + '%s'#10#10'%s', + PChar(Text), error_str) + else dialog := gtk_message_dialog_new (PGtkWindow(Parent.FWidget), GTK_DIALOG_MODAL or GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + '%s'#10#10'%s', PChar(Text), error_str); + gtk_window_set_title (PGtkWindow(dialog), ''); + gtk_dialog_run (PGtkDialog(Dialog)); + gtk_widget_destroy (PGtkWidget(Dialog)); +end; + end. -- cgit v1.2.3