NvDialog 0.10.1
A cross-platform modal dialogs library for C/C++ that uses the native OS theme.
Loading...
Searching...
No Matches
nvdialog_core.h File Reference
#include "nvdialog_types.h"
#include "nvdialog_platform.h"

Go to the source code of this file.

Macros

#define __nvdialog_core_h__   1

Typedefs

typedef void * NvdParentWindow
 An opaque representation of a window object.

Functions

NVD_API int nvd_init ()
 Initializes NvDialog.
NVD_API void nvd_set_application_name (const char *application_name)
 Sets the application name to use inside NvDialog.
NVD_API const char * nvd_get_application_name ()
 Returns the application name set inside NvDialog.
NVD_API const char * nvd_get_argv (void)
 Returns the argv[0] given to nvdialog.
NVD_API int nvd_set_parent (NvdParentWindow parent)
 Sets a window as the parent of all dialogs created from NvDialog.
NVD_API NvdParentWindow nvd_get_parent (void)
 Returns the window attached as the parent of all dialogs of NvDialog.
NVD_API void nvd_delete_parent (void)
 Unmarks the window set from nvd_set_parent as the parent window.
NVD_API void nvd_free_object (void *object)
 Deletes an object creates by NvDialog.

Macro Definition Documentation

◆ __nvdialog_core_h__

#define __nvdialog_core_h__   1

Typedef Documentation

◆ NvdParentWindow

typedef void* NvdParentWindow

An opaque representation of a window object.

Warning
This is not cross platform nor portable. It can be set to almost anything and nvdialog will accept it. Only use this if you're sure that what you're giving the library is valid.

Function Documentation

◆ nvd_delete_parent()

NVD_API void nvd_delete_parent ( void )

Unmarks the window set from nvd_set_parent as the parent window.

This will reset the changes made by nvd_set_parent, by unmarking the window that is given as the parent from NvDialog.

◆ nvd_free_object()

NVD_API void nvd_free_object ( void * object)

Deletes an object creates by NvDialog.

Call this function when you are no longer interested in using the parameter passed anymore, to free up any resources occupied by the object. Note that calling this in the middle of an operation will cause use after free.

Parameters
objectThe object to be deleted.
Note
object may be NULL, although this will print a small warning on the command line.
Examples
/home/acs/Projects/nvdialog/include/dialogs/nvdialog_file_dialog.h.

◆ nvd_get_application_name()

NVD_API const char * nvd_get_application_name ( )

Returns the application name set inside NvDialog.

Returns
The application name.
Since
v0.5.0

◆ nvd_get_argv()

NVD_API const char * nvd_get_argv ( void )

Returns the argv[0] given to nvdialog.

This function returns the parameter passed to nvdialog during nvd_init. It is mainly intended to be used internally.

Deprecated
This function is deprecated as of v0.8.1 and will only return NULL
Returns
The argv[0] given to nvdialog on success, otherwise NULL.

◆ nvd_get_parent()

NVD_API NvdParentWindow nvd_get_parent ( void )

Returns the window attached as the parent of all dialogs of NvDialog.

Returns
The currently set parent window, or NULL if no parent window is currently set.

◆ nvd_init()

NVD_API int nvd_init ( )

Initializes NvDialog.

This function initializes NvDialog. It's the first function that should be called when you create your program as without it, you cannot create any dialogs or use the library at all.

Depending on the platform, this function does a series of things (in random order):

  • If any optional libraries are to be loaded, they're detected and loaded at this stage.
  • All function pointers for each platform are initialized now.
  • It initializes some internal state for future use.
  • Any backends that need special setup are also initialized now.
Note
You should call this function to the same thread you're creating your dialogs from. If you also happen to use a library used by NvDialog as the backend, make sure that the two libraries stay in the same thread to avoid race conditions.
Since
v0.1.0
Returns
0 on success, else a negative error code indicating failure.

◆ nvd_set_application_name()

NVD_API void nvd_set_application_name ( const char * application_name)

Sets the application name to use inside NvDialog.

This function sets the application name that NvDialog will use if an application name is needed. By default, the application name is set to "NvDialog Application". The application name is used in notifications, so it is important to set the actual application name if you wish to use them.

Note
Make sure the given string will not be mutated during the lifetime of the program.
Parameters
application_nameThe application name to use.
Since
v0.5.0

◆ nvd_set_parent()

NVD_API int nvd_set_parent ( NvdParentWindow parent)

Sets a window as the parent of all dialogs created from NvDialog.

Using the parameter given, a window will be set as the parent of all dialogs that are created from within the library. The window has to match the window type used by the backend.

Warning
This is a very dangerous operation, and may not work as expected. There are a series of guarantees you must have to make sure things don't go bad:
  • You handle the pointer given so that it matches the backend's expectation. For example, you'll use an HWND pointer on Windows, GtkWindow on Linux, and so on.
  • The window lives as long as any dialog will be displayed.
  • The window is allowed to be used by the backend at any arbitrary time during the dialog's lifetime, since no guarantees can be made.
Parameters
parentThe window to set as the parent.
Returns
0 on success, otherwise -1, call nvd_get_error() for more.