[yast-devel] Package callbacks - turning off
Hi all, I have added these new functions into PackageCallbacks.ycp (yast2-2.16.52): RegisterEmptyProgressCallbacks() - registers empty callbacks RestorePreviousProgressCallbacks() - restores the previous registered callbacks (Pkg-bindings have a stack of registered functions for each callback, unregistering a callback means removing the function from the top of the stack.) If you need to temporarily turn off the callbacks then use the functions in a wrapper to ensure that the restoring function is always called: //disable callbacks PackageCallbacks::RegisterEmptyProgressCallbacks(); // Start the requested operation here DoActionWithoutCallbacks(); // restore the previous callbacks PackageCallbacks::RestorePreviousProgressCallbacks(); RegisterEmptyProgressCallbacks() sets empty callbacks for all progress callbacks, if you need to disable just a particular type of callback then use PackageCallbacks::SetDummy*Callbacks() and PackageCallbacks::Restore*Callbacks() functions. The new functionality is used to fix bug #377919, but it might be useful in other modules/scripts. -- Best Regards Ladislav Slezák Yast Developer ------------------------------------------------------------------------ SUSE LINUX, s.r.o. e-mail: lslezak@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/ -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Ladislav Slezak napsal(a):
Hi all,
I have added these new functions into PackageCallbacks.ycp (yast2-2.16.52):
RegisterEmptyProgressCallbacks() - registers empty callbacks RestorePreviousProgressCallbacks() - restores the previous registered callbacks ... The new functionality is used to fix bug #377919, but it might be useful in other modules/scripts.
Thanks a lot! :) I've just used these functions in installation scripts so I can handle installation progresses as I want. I hope it will also remove the unneeded second progress bar that appears for a very short time when initializing the installation repository. Hmm, anyway, how can I re-register another function for downloading a file? Image deployment downloads images if needed (Pkg::SourceProvideOptionalFile?) and I don't want pop-ups to appear there. Will is work to RegisterEmptyProgressCallbacks, RegisterMySpecialCallback and then RestorePreviousProgressCallbacks? Doesn't the RestorePreviousProgressCallbacks function have a bit confusing name :), previous? Bye Lukas
Lukas Ocilka wrote:
I've just used these functions in installation scripts so I can handle installation progresses as I want. I hope it will also remove the unneeded second progress bar that appears for a very short time when initializing the installation repository.
It should be also disabled by the new function.
Hmm, anyway, how can I re-register another function for downloading a file? Image deployment downloads images if needed (Pkg::SourceProvideOptionalFile?) and I don't want pop-ups to appear there.
Will is work to RegisterEmptyProgressCallbacks, RegisterMySpecialCallback and then RestorePreviousProgressCallbacks? Doesn't the RestorePreviousProgressCallbacks function have a bit confusing name :), previous?
The previous are the standard callbacks in this case (the standard callbacks are registered in PackageCallbacks constructor.) But it shouldn't break if there is no previous callback registered :-) In the case above you should do: - RegisterEmptyProgressCallbacks - RegisterMySpecialCallback - UnregisterMySpecialCallback - RestorePreviousProgressCallbacks The new functions: void RegisterMySpecialCallback() { Pkg::CallbackProgressDownload (MyProgressHandler); } void UnregisterMySpecialCallback() { Pkg::CallbackProgressDownload (nil); } The most important thing it to register/unregister the same callbacks in RegisterMySpecialCallback() and UnregisterMySpecialCallback() functions. Otherwise RestorePreviousProgressCallbacks() won't restore the previous state correctly. -- Best Regards Ladislav Slezák Yast Developer ------------------------------------------------------------------------ SUSE LINUX, s.r.o. e-mail: lslezak@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/ -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (2)
-
Ladislav Slezak
-
Lukas Ocilka