<commit_before>//
//  MessageDialog.swift
//  SwiftGtk
//
//  Created by <NAME> on 4/8/19.
//  Copyright © 2019 <NAME>.  All rights reserved.
//
import CGtk
import GtkCHelpers

public extension MessageDialog {
    /// Creates a new message dialog,
    /// which is a simple dialog with some text the user may want to see.
    /// When the user clicks a button a “response” signal is emitted
    /// with response IDs from `GtkResponseType` corresponding to the buttons.
    /// See `Dialog` for more details.
    /// - Parameter title: Title of the dialog
    /// - Parameter flags: flags to use such as `.modal` (default) or `.destroy_with_parent`
    /// - Parameter type: dialog type such as `.info`, `.warning`, `.error`, etc.
    /// - Parameter buttons: buttons to display, e.g. `.ok_cancel`, `.yes_no`, `.ok`
    /// - Parameter text: text to display in the dialog box
    /// - Parameter secondaryText: optional secondary text to display
    convenience init(flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, text: String, secondaryText: String? = nil) {
        self.init(cPointer: gtk_c_helper_message_dialog_new_with_button(nil, flags, type, buttons, text))
        guard let secondaryText = secondaryText else { return }
        gtk_c_helper_message_dialog_set_secondary_text(cast(ptr), secondaryText)
    }

    /// Creates a new message dialog,
    /// which is a simple dialog with some text the user may want to see.
    /// When the user clicks a button a “response” signal is emitted
    /// with response IDs from `GtkResponseType` corresponding to the buttons.
    /// See `Dialog` for more details.
    /// - Parameter parent: parent window
    /// - Parameter flags: flags to use such as `.modal` (default) or `.destroy_with_parent`
    /// - Parameter type: dialog type such as `.info`, `.warning`, `.error`, etc.
    /// - Parameter buttons: buttons to display, e.g. `.ok_cancel`, `.yes_no`, `.ok`
    /// - Parameter text: text to display in the dialog box
    /// - Parameter secondaryText: optional secondary text to display
    convenience init<W: WindowProtocol>(parent: W, flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, text: String, secondaryText: String? = nil) {
        let dialog = parent.window_ptr.withMemoryRebound(to: GtkWindow.self, capacity: 1) {
            gtk_c_helper_message_dialog_new_with_button($0, flags, type, buttons, text)!
        }
        self.init(cPointer: dialog)
        guard let secondaryText = secondaryText else { return }
        gtk_c_helper_message_dialog_set_secondary_text(cast(ptr), secondaryText)
    }

    /// Creates a new message dialog,
    /// which is a simple dialog with some markup the user may want to see.
    /// When the user clicks a button a “response” signal is emitted
    /// with response IDs from `GtkResponseType` corresponding to the buttons.
    /// See `Dialog` for more details.
    /// - Parameter title: Title of the dialog
    /// - Parameter flags: flags to use such as `.modal` (default) or `.destroy_with_parent`
    /// - Parameter type: dialog type such as `.info`, `.warning`, `.error`, etc.
    /// - Parameter buttons: buttons to display, e.g. `.ok_cancel`, `.yes_no`, `.ok`
    /// - Parameter markup: markup text to display in the dialog box
    /// - Parameter secondaryMarkup: optional secondary markup to display
    convenience init(flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, markup: String, secondaryMarkup: String? = nil) {
        self.init(cPointer: gtk_c_helper_message_dialog_new_with_button(nil, flags, type, buttons, markup))
        guard let markup = secondaryMarkup else { return }
        gtk_c_helper_message_dialog_set_secondary_markup(cast(ptr), markup)
    }

    /// Creates a new message dialog,
    /// which is a simple dialog with some text the user may want to see.
    /// When the user clicks a button a “response” signal is emitted
    /// with response IDs from `GtkResponseType` corresponding to the buttons.
    /// See `Dialog` for more details.
    /// - Parameter title: Title of the dialog
    /// - Parameter parent: parent window
    /// - Parameter flags: flags to use such as `.modal` (default) or `.destroy_with_parent`
    /// - Parameter type: dialog type such as `.info`, `.warning`, `.error`, etc.
    /// - Parameter buttons: buttons to display, e.g. `.ok_cancel`, `.yes_no`, `.ok`
    /// - Parameter markup: markup text to display in the dialog box
    /// - Parameter secondaryMarkup: optional secondary text to display
    convenience init<W: WindowProtocol>(parent: W, flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, markup: String, secondaryMarkup: String? = nil) {
        let dialog = parent.window_ptr.withMemoryRebound(to: GtkWindow.self, capacity: 1) {
            gtk_c_helper_message_dialog_new_with_button($0, flags, type, buttons, markup)!
        }
        self.init(cPointer: dialog)
        guard let markup = secondaryMarkup else { return }
        gtk_c_helper_message_dialog_set_secondary_markup(cast(ptr), markup)
    }
}

public extension MessageDialogProtocol {
    /// Convenience method to set the secondary text of a message dialog
    /// - Parameter secondaryText: string to set the secondary text to
    func set(secondaryText: String) {
        gtk_c_helper_message_dialog_set_secondary_text(cast(ptr), secondaryText)
    }

    /// Convenience method to set markup for the secondary text of of a message dialog
    /// - Parameter secondaryText: string to set the secondary text to
    func set(secondaryMarkup: String) {
        gtk_c_helper_message_dialog_set_secondary_markup(cast(ptr), secondaryMarkup)
    }
}<commit_msg>s/cPointer/retainingCPointer/ Fixes test crash reported in issue #18<commit_after>//
//  MessageDialog.swift
//  SwiftGtk
//
//  Created by <NAME> on 4/8/19.
//  Copyright © 2019, 2020 <NAME>.  All rights reserved.
//
import CGtk
import GtkCHelpers

public extension MessageDialog {
    /// Creates a new message dialog,
    /// which is a simple dialog with some text the user may want to see.
    /// When the user clicks a button a “response” signal is emitted
    /// with response IDs from `GtkResponseType` corresponding to the buttons.
    /// See `Dialog` for more details.
    /// - Parameter title: Title of the dialog
    /// - Parameter flags: flags to use such as `.modal` (default) or `.destroy_with_parent`
    /// - Parameter type: dialog type such as `.info`, `.warning`, `.error`, etc.
    /// - Parameter buttons: buttons to display, e.g. `.ok_cancel`, `.yes_no`, `.ok`
    /// - Parameter text: text to display in the dialog box
    /// - Parameter secondaryText: optional secondary text to display
    convenience init(flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, text: String, secondaryText: String? = nil) {
        self.init(retainingCPointer: gtk_c_helper_message_dialog_new_with_button(nil, flags, type, buttons, text))
        guard let secondaryText = secondaryText else { return }
        gtk_c_helper_message_dialog_set_secondary_text(cast(ptr), secondaryText)
    }

    /// Creates a new message dialog,
    /// which is a simple dialog with some text the user may want to see.
    /// When the user clicks a button a “response” signal is emitted
    /// with response IDs from `GtkResponseType` corresponding to the buttons.
    /// See `Dialog` for more details.
    /// - Parameter parent: parent window
    /// - Parameter flags: flags to use such as `.modal` (default) or `.destroy_with_parent`
    /// - Parameter type: dialog type such as `.info`, `.warning`, `.error`, etc.
    /// - Parameter buttons: buttons to display, e.g. `.ok_cancel`, `.yes_no`, `.ok`
    /// - Parameter text: text to display in the dialog box
    /// - Parameter secondaryText: optional secondary text to display
    convenience init<W: WindowProtocol>(parent: W, flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, text: String, secondaryText: String? = nil) {
        let dialog = parent.window_ptr.withMemoryRebound(to: GtkWindow.self, capacity: 1) {
            gtk_c_helper_message_dialog_new_with_button($0, flags, type, buttons, text)!
        }
        self.init(retainingCPointer: dialog)
        guard let secondaryText = secondaryText else { return }
        gtk_c_helper_message_dialog_set_secondary_text(cast(ptr), secondaryText)
    }

    /// Creates a new message dialog,
    /// which is a simple dialog with some markup the user may want to see.
    /// When the user clicks a button a “response” signal is emitted
    /// with response IDs from `GtkResponseType` corresponding to the buttons.
    /// See `Dialog` for more details.
    /// - Parameter title: Title of the dialog
    /// - Parameter flags: flags to use such as `.modal` (default) or `.destroy_with_parent`
    /// - Parameter type: dialog type such as `.info`, `.warning`, `.error`, etc.
    /// - Parameter buttons: buttons to display, e.g. `.ok_cancel`, `.yes_no`, `.ok`
    /// - Parameter markup: markup text to display in the dialog box
    /// - Parameter secondaryMarkup: optional secondary markup to display
    convenience init(flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, markup: String, secondaryMarkup: String? = nil) {
        self.init(retainingCPointer: gtk_c_helper_message_dialog_new_with_button(nil, flags, type, buttons, markup))
        guard let markup = secondaryMarkup else { return }
        gtk_c_helper_message_dialog_set_secondary_markup(cast(ptr), markup)
    }

    /// Creates a new message dialog,
    /// which is a simple dialog with some text the user may want to see.
    /// When the user clicks a button a “response” signal is emitted
    /// with response IDs from `GtkResponseType` corresponding to the buttons.
    /// See `Dialog` for more details.
    /// - Parameter title: Title of the dialog
    /// - Parameter parent: parent window
    /// - Parameter flags: flags to use such as `.modal` (default) or `.destroy_with_parent`
    /// - Parameter type: dialog type such as `.info`, `.warning`, `.error`, etc.
    /// - Parameter buttons: buttons to display, e.g. `.ok_cancel`, `.yes_no`, `.ok`
    /// - Parameter markup: markup text to display in the dialog box
    /// - Parameter secondaryMarkup: optional secondary text to display
    convenience init<W: WindowProtocol>(parent: W, flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, markup: String, secondaryMarkup: String? = nil) {
        let dialog = parent.window_ptr.withMemoryRebound(to: GtkWindow.self, capacity: 1) {
            gtk_c_helper_message_dialog_new_with_button($0, flags, type, buttons, markup)!
        }
        self.init(retainingCPointer: dialog)
        guard let markup = secondaryMarkup else { return }
        gtk_c_helper_message_dialog_set_secondary_markup(cast(ptr), markup)
    }
}

public extension MessageDialogProtocol {
    /// Convenience method to set the secondary text of a message dialog
    /// - Parameter secondaryText: string to set the secondary text to
    func set(secondaryText: String) {
        gtk_c_helper_message_dialog_set_secondary_text(cast(ptr), secondaryText)
    }

    /// Convenience method to set markup for the secondary text of of a message dialog
    /// - Parameter secondaryText: string to set the secondary text to
    func set(secondaryMarkup: String) {
        gtk_c_helper_message_dialog_set_secondary_markup(cast(ptr), secondaryMarkup)
    }
}
{'fraction_non_alphanumeric': 0.10799414852422339, 'fraction_numerical': 0.0025815334308579296, 'mean_word_length': 3.0523012552301254, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4914858', 'n_tokens_mistral': 3319, 'n_tokens_neox': 3224, 'n_words': 1212}