<commit_before>//! Simple clipboard example
//!
//! From https://developer.gnome.org/gtkmm-tutorial/stable/sec-clipboard-examples.html.en
extern crate gdk;
extern crate gio;
extern crate gtk;

use std::cell::RefCell;
use std::env::args;

use gio::prelude::*;
use gtk::prelude::*;

// make moving clones into closures more convenient
macro_rules! clone {
    (@param _) => ( _ );
    (@param $x:ident) => ( $x );
    ($($n:ident),+ => move || $body:expr) => (
        {
            $( let $n = $n.clone(); )+
            move || $body
        }
    );
    ($($n:ident),+ => move |$($p:tt),+| $body:expr) => (
        {
            $( let $n = $n.clone(); )+
            move |$(clone!(@param $p),)+| $body
        }
    );
}

struct Ui {
    pub button_a1: gtk::ToggleButton,
    pub button_a2: gtk::ToggleButton,
    pub button_b1: gtk::ToggleButton,
    pub button_b2: gtk::ToggleButton,
}

// Declare a new thread local storage key
thread_local!(
    static GLOBAL: RefCell<Option<Ui>> = RefCell::new(None)
);

fn build_ui(application: &gtk::Application) {
    let window = gtk::ApplicationWindow::new(application);

    // Create the whole window
    window.set_title("gtk::Clipboard Simple Example");
    window.connect_delete_event(clone!(window => move |_, _| {
        window.destroy();
        Inhibit(false)
    }));

    // Create the button grid
    let grid = gtk::Grid::new();
    grid.set_row_homogeneous(true);
    grid.set_column_homogeneous(true);
    let button_a1 = gtk::ToggleButton::new_with_label("A1");
    grid.attach(&button_a1, 0, 0, 1, 1);
    let button_a2 = gtk::ToggleButton::new_with_label("A2");
    grid.attach(&button_a2, 1, 0, 1, 1);
    let button_b1 = gtk::ToggleButton::new_with_label("B1");
    grid.attach(&button_b1, 0, 1, 1, 1);
    let button_b2 = gtk::ToggleButton::new_with_label("B2");
    grid.attach(&button_b2, 1, 1, 1, 1);

    // Add in the action buttons
    let copy_button = gtk::Button::new_with_mnemonic("_Copy");
    let paste_button = gtk::Button::new_with_mnemonic("_Paste");
    let button_box = gtk::ButtonBox::new(gtk::Orientation::Horizontal);
    button_box.set_layout(gtk::ButtonBoxStyle::End);
    button_box.pack_start(&copy_button, false, false, 0);
    button_box.pack_start(&paste_button, false, false, 0);

    // Pack widgets into the window and display everything
    let vbox = gtk::Box::new(gtk::Orientation::Vertical, 0);
    vbox.set_spacing(6);
    let label = gtk::Label::new(Some(
        "Select cells in the grid, click Copy, then \
         open a second instance of this example to try \<commit_msg>remove useless clone macro usage<commit_after>//! Simple clipboard example
//!
//! From https://developer.gnome.org/gtkmm-tutorial/stable/sec-clipboard-examples.html.en
extern crate gdk;
extern crate gio;
extern crate gtk;

use std::cell::RefCell;
use std::env::args;

use gio::prelude::*;
use gtk::prelude::*;

struct Ui {
    pub button_a1: gtk::ToggleButton,
    pub button_a2: gtk::ToggleButton,
    pub button_b1: gtk::ToggleButton,
    pub button_b2: gtk::ToggleButton,
}

// Declare a new thread local storage key
thread_local!(
    static GLOBAL: RefCell<Option<Ui>> = RefCell::new(None)
);

fn build_ui(application: &gtk::Application) {
    let window = gtk::ApplicationWindow::new(application);

    // Create the whole window
    window.set_title("gtk::Clipboard Simple Example");
    window.connect_delete_event(|window, _| {
        window.destroy();
        Inhibit(false)
    });

    // Create the button grid
    let grid = gtk::Grid::new();
    grid.set_row_homogeneous(true);
    grid.set_column_homogeneous(true);
    let button_a1 = gtk::ToggleButton::new_with_label("A1");
    grid.attach(&button_a1, 0, 0, 1, 1);
    let button_a2 = gtk::ToggleButton::new_with_label("A2");
    grid.attach(&button_a2, 1, 0, 1, 1);
    let button_b1 = gtk::ToggleButton::new_with_label("B1");
    grid.attach(&button_b1, 0, 1, 1, 1);
    let button_b2 = gtk::ToggleButton::new_with_label("B2");
    grid.attach(&button_b2, 1, 1, 1, 1);

    // Add in the action buttons
    let copy_button = gtk::Button::new_with_mnemonic("_Copy");
    let paste_button = gtk::Button::new_with_mnemonic("_Paste");
    let button_box = gtk::ButtonBox::new(gtk::Orientation::Horizontal);
    button_box.set_layout(gtk::ButtonBoxStyle::End);
    button_box.pack_start(&copy_button, false, false, 0);
    button_box.pack_start(&paste_button, false, false, 0);

    // Pack widgets into the window and display everything
    let vbox = gtk::Box::new(gtk::Orientation::Vertical, 0);
    vbox.set_spacing(6);
    let label = gtk::Label::new(Some(
        "Select cells in the grid, click Copy, then \
         open a second instance of this example to try \
{'fraction_non_alphanumeric': 0.15498623756087232, 'fraction_numerical': 0.015244547956807113, 'mean_word_length': 3.7620967741935485, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, 'https://': 2, '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': '4982560', 'n_tokens_mistral': 1694, 'n_tokens_neox': 1603, 'n_words': 361}