-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: Fix extra parameter on
nvd_init
- Loading branch information
Showing
6 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |