| 3920 | } |
| 3921 | |
| 3922 | G_GNUC_PRINTF(6, 0) static GtkMessageDialog * |
| 3923 | question_dialog_va (GtkWindow *parent, GhbActionStyle accept_style, |
| 3924 | const char *accept_button, const char *cancel_button, |
| 3925 | const char *title, const char *format, va_list va_args) |
| 3926 | { |
| 3927 | GtkWidget *dialog, *button; |
| 3928 | |
| 3929 | if (parent == NULL) |
| 3930 | { |
| 3931 | GtkApplication *app = GTK_APPLICATION(g_application_get_default()); |
| 3932 | parent = gtk_application_get_active_window(app); |
| 3933 | } |
| 3934 | |
| 3935 | // Toss up a warning dialog |
| 3936 | dialog = gtk_message_dialog_new(parent, GTK_DIALOG_MODAL, |
| 3937 | GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, |
| 3938 | "%s", title); |
| 3939 | if (format) |
| 3940 | { |
| 3941 | char *message; |
| 3942 | |
| 3943 | message = g_strdup_vprintf(format, va_args); |
| 3944 | gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", message); |
| 3945 | g_free(message); |
| 3946 | } |
| 3947 | |
| 3948 | if (cancel_button != NULL) |
| 3949 | { |
| 3950 | gtk_dialog_add_button(GTK_DIALOG(dialog), cancel_button, |
| 3951 | GTK_RESPONSE_CANCEL); |
| 3952 | } |
| 3953 | |
| 3954 | if (accept_button != NULL) |
| 3955 | { |
| 3956 | button = gtk_dialog_add_button(GTK_DIALOG(dialog), accept_button, |
| 3957 | GTK_RESPONSE_ACCEPT); |
| 3958 | |
| 3959 | switch (accept_style) |
| 3960 | { |
| 3961 | case GHB_ACTION_SUGGESTED: |
| 3962 | gtk_widget_add_css_class(button, "suggested-action"); |
| 3963 | break; |
| 3964 | case GHB_ACTION_DESTRUCTIVE: |
| 3965 | gtk_widget_add_css_class(button, "destructive-action"); |
| 3966 | default: |
| 3967 | break; |
| 3968 | } |
| 3969 | } |
| 3970 | return GTK_MESSAGE_DIALOG(dialog); |
| 3971 | } |
| 3972 | |
| 3973 | GtkMessageDialog * |
| 3974 | ghb_question_dialog_new (GtkWindow *parent, GhbActionStyle accept_style, |
no outgoing calls
no test coverage detected