Skip to content

Commit

Permalink
examples: Fix extra parameter on nvd_init
Browse files Browse the repository at this point in the history
  • Loading branch information
tseli0s committed Feb 2, 2024
1 parent 54972d7 commit f2552d5
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/about-dialog/about_dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(int argc, char** argv) {
* on Linux to avoid undefined behaviour.
* Call this function before any other.
*/
int result = nvd_init(argv[0]);
int result = nvd_init();
if (result != 0) {
/* Initialization failed, exit now. */
puts("Error: Couldn't initialize NvDialog.");
Expand Down
2 changes: 1 addition & 1 deletion examples/file-dialog/file_dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(int argc, char** argv) {
* on Linux to avoid undefined behaviour.
* Call this function before any other.
*/
int result = nvd_init(argv[0]);
int result = nvd_init();
if (result != 0) {
/* Initialization failed, exit now. */
puts("Error: Couldn't initialize NvDialog.");
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-world/hello_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(int argc, char** argv) {
* on Linux to avoid undefined behaviour.
* Call this function before any other.
*/
int result = nvd_init(argv[0]);
int result = nvd_init();
if (result != 0) {
/* Initialization failed, exit now. */
puts("Error: Couldn't initialize NvDialog.");
Expand Down
2 changes: 1 addition & 1 deletion examples/notification/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <unistd.h>

int main(int argc, char** argv) {
if (nvd_init(argv[0]) != 0) {
if (nvd_init() != 0) {
printf("NvDialog couldn't initialize: %s", nvd_stringify_error(nvd_get_error()));
exit(EXIT_FAILURE);
}
Expand Down
5 changes: 5 additions & 0 deletions examples/question-dialog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.22)
project(nvdialog-question-dialog VERSION 1.0 LANGUAGES C)

add_executable(question-dialog question_dialog.c)
target_link_libraries(question-dialog nvdialog)
34 changes: 34 additions & 0 deletions examples/question-dialog/question_dialog.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <stdio.h>
#include <errno.h>
#include <nvdialog/nvdialog.h>
#include <stdlib.h>

int main(int argc, char** argv) {
int result = nvd_init();
if (result != 0) {
puts("Error: Couldn't initialize NvDialog.");
exit(EXIT_FAILURE);
}

NvdQuestionBox *dialog = nvd_dialog_question_new("Question dialog", "Press Yes, No or Cancel. Your choice will be printed in stdout.", NVD_YES_NO_CANCEL);
if (!dialog) {
puts("Error: Could not construct the dialog.");
return -ENOMEM;
}

NvdReply reply = nvd_get_reply(dialog);
switch (reply) {
case NVD_REPLY_OK:
printf("You chose yes.\n");
break;
case NVD_REPLY_NO:
printf("You chose no.\n");
break;
case NVD_REPLY_CANCEL:
printf("You cancelled.\n");
break;
}
nvd_free_object(dialog);

return 0;
}

0 comments on commit f2552d5

Please sign in to comment.