Callback functions in libdar

Michael Rasmussen <[email protected]> Mon, 08 Aug 2005 19:54:32 +0000
Newsgroups gmane.comp.sysutils.backup.dar.libdar
Message-ID <1123530872l.3713l.2l@loke>
Hi all,

I have a question I hope on of you can help me with:

First a piece of the source code:
/*
** Display a warning to the user in a GtkMessageDialog
** Input:
**    void *: Gpointer to the main window
**    GtkMessageType: The type of message dialog
**    const gchar *: The message to display in the dialog
**
** Output:
**    Cancel clicked: GTK_RESPONSE_CANCEL
**    Ok clicked: GTK_RESPONSE_OK
*/
GtkResponseType ok_cancel_message(
	void *mainwindow, GtkMessageType type, const gchar *msg)
{
	GtkWidget		*dialog;
	GtkResponseType    result;
	 
	dialog = gtk_message_dialog_new (
		(GtkWindow *) mainwindow,
         (GtkDialogFlags) (GTK_DIALOG_DESTROY_WITH_PARENT |
GTK_DIALOG_MODAL),
         type,
         GTK_BUTTONS_OK_CANCEL,
	msg);
	result = (GtkResponseType) gtk_dialog_run(GTK_DIALOG (dialog));
	gtk_widget_destroy(dialog);
	return result;
}

bool answer_callback(const string &message, void *context)
{
	GtkResponseType  result;
	 
	result = ok_cancel_message(context, GTK_MESSAGE_WARNING,
message.c_str());
	if (result == GTK_RESPONSE_OK)
		return true;
	else
		throw Euser_abort(NULL);
}

The answer call back is called when slices exists and the
user has choosen to create a new backup set. The
ok_cancel_message is shown and if the user hits Ok the
creating of the backup set begin. Now comes the problem: all
though the gtk_widget_destroy(dialog) is called before
returning the call it is blocked until the creation of the
archive is finished. Does anyone have an idea how I can bypass
this state?

-- 
Hilsen/Regards
Michael Rasmussen

Get my public GnuPG keys:
michael <at> rasmussen <dot> cc
http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xD3C9A00E
mir <at> datanom <dot> net
http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE501F51C
mir <at> miras <dot> org
http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917
--------------------------------------------------------------
Tonight's the night: Sleep in a eucalyptus tree.
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBC97h4QQOPluUB9RwRArlNAJ9m1CiENqN0ZVXAX25VoinqspOuygCgxgA3
cYTN4Lv0EOhxIEPSDnkKXG4=
=6mS7
-----END PGP SIGNATURE-----