NvDialog is a C library that lets you create modal dialog boxes, file dialogs, notifications and other kinds of popups using the system's native API for user interfaces.
MIT License
gcc
, clang
and MSVC).Gtk3 Backend The most maintained backend, used mainly for GNU/Linux distributions (And FreeBSD). It is based off Gtk3 and has been the primary focus since this library was started.
Adwaita Backend The Adwaita backend is more experimental and overall you can expect some bugs with it. However it provides better integration with Linux distributions that are based on the GNOME ecosystem. Do note that sometimes this backend can break games on Wayland due to hardware acceleration.
Sandbox Backend The sandbox backend is used in place of the other backends when the process is under some kind of sandbox (Flatpak, AppImage, etc). It is mostly identical to the Gtk3 one but differs slightly in the implementation. This one is chosen automatically if enabled at compile time.
Cocoa Backend The Cocoa backend was recently added to NvDialog for MacOS X support. It is written in Objective-C for better integration with the OS, and is still in the experimental stage. Please report any bugs or features that need to be fixed / implemented.
Win32 Backend
Windows-specific backend, used only for Windows compatibility. This backend is mainly tested on GNU/Linux with wine
, and so some bugs may not be detected. Open an issue if that's the case.
This is a simple cross-platform example of a simple message box greeting the user:
#include <stdlib.h>
#include <nvdialog/nvdialog.h>
int main(int argc, char **argv)
{
if (nvd_init(argv[0]) != 0) {
puts("Failed to initialize NvDialog.\n");
exit(EXIT_FAILURE);
}
NvdDialogBox* dialog = nvd_dialog_box_new(
"Hello, world!", // Title of the dialog
"Hello world ! This is a dialog box created using libnvdialog!", // Message of the dialog
NVD_DIALOG_SIMPLE // What is the dialog representing? (Eg a warning). In this
// case, it represents a simple dialog with no context.
);
nvd_show_dialog(dialog);
nvd_free_object(dialog);
return 0;
}
Make sure you have installed CMake before doing anything else ! The library can only be installed using CMake. See CMake's website for more information.
master
branch directly, by cloning the source code.$ sudo apt update && sudo apt install libgtk-3-dev build-essential gcc
$ mkdir build/ && cd build/
$ cmake ..
$ cmake --build .
$ sudo cmake --install .
For Arch Linux and derivatives, a PKGBUILD
is provided to build the library as a package. It is recommended to use it this way to allow uninstalling the library easily.
To install the library as an Arch Linux package, enter the following commands:
Download git
(Required to download the source code)
$ sudo pacman -S git
Clone the repository (To download the source code)
$ git clone --depth=1 https://github.com/tseli0s/nvdialog.git
$ cd nvdialog/
Build the package:
$ makepkg --clean --install
The oldest OS NvDialog has ran on is Windows XP, although some calls did not produce any change / output (But did not fail either). The recommended minumum is Windows 8 / 8.1, and any later version should work as expected.
Only the very latest versions of macOS are supported. Older releases will at best throw a compiler error if compiling from source or a linking error otherwise.
Some deprecated functions are used here and there when building for macOS. This shouldn't worry you since Apple does give enough time for developers to switch away without enforcing it.
Since there are well over 1000 distributions, there is no specific distribution requirement. However, your system must have these installed:
libadwaita
+ Gtk4, the latest releases of each.Common distros officially supported:
Distro | Version |
---|---|
Arch Linux | (Rolling) |
Ubuntu and derivatives | >16.04 |
Debian and derivatives | >Debian 7 |
Slackware Linux | Latest |
Android support will not be implemented anytime soon (Neither iOS support). You are advised instead to use Android's AlertDialog
class or your UI library, which would achieve the same effect.
Other OSes are assumed to be supported. To make sure they do indeed work, you need to make sure the given OS supports all of the following features:
nvdialog
is licensed under the MIT license. See COPYING for more.
All contributions made to the library are assumed to be licensed under the MIT license as well. However, you may specify a different license if you wish.