progress_dialog

A simple progress dialog for the D programming language

Discussion

It should work without requiring any 3rd party GUI toolkits. But will work with what it can find on your OS at runtime.

Tries to make a progress dialog with:

* DlangUI (win32 on Windows or SDL2 on Linux)

* Zenity (Gtk/Gnome)

* Kdialog (KDE)

Home page: https://github.com/workhorsy/d-progress-dialog

Version

0.3.0

License

Boost Software License - Version 1.0

Examples

  1. import std.stdio : stdout, stderr; import progress_dialog : ProgressDialog, RUN_MAIN; mixin RUN_MAIN; extern (C) int UIAppMain(string[] args) { import core.thread; // Create the dialog auto dialog = new ProgressDialog("It's waitin' time!", "Waiting ..."); // Set the error handler dialog.onError((Throwable err) { stderr.writefln("Failed to show progress dialog: %s", err); dialog.close(); }); // Show the progress dialog dialog.show({ // Update the progress for 5 seconds int percent = 0; while (percent < 100) { dialog.setPercent(percent); percent += 20; Thread.sleep(1.seconds); stdout.writefln("percent: %s", percent); stdout.flush(); } // Close the dialog dialog.close(); }); return 0; }

  • Declaration

    template RUN_MAIN()

    This should be called once at the start of a program. It generates the proper main function for your environment (win32/posix/dmain) and boot straps the main loop for the GUI. This will call your UIAppMain function when ready.

  • Declaration

    void setUseLog(bool is_logging);

    If true will print output of external program to console.

    Parameters

    bool is_logging

    If true will print to output

  • Declaration

    bool getUseLog();

    Returns if external program logging is on or off.

  • Declaration

    class ProgressDialog;

    The ProgressDialog class

    • Declaration

      this(string title, string message);

      Sets up the progress dialog with the desired title, and message. Does not show it until the show method is called.

      Parameters

      string title

      The string to show in the progress dialog title

      string message

      The string to show in the progress dialog body

      Throws

      If it fails to find any programs or libraries to make a progress dialog with.

    • Declaration

      void onError(void delegate(Throwable err) cb);

      This method is called if there is an error when showing the progress dialog.

      Parameters

      void delegate(Throwable err) cb

      The call back to fire when there is an error.

    • Declaration

      void show(void delegate() cb);

      Shows the progress dialog. Will run the callback in a thread and block until it is closed or percent reaches 100.

    • Declaration

      void setPercent(int percent);

      Set the percent of the progess bar. Will close on 100.

      Parameters

      int percent

      from 0 to 100

    • Declaration

      void close();

      Close the dialog.