<commit_before>// Copyright (c) 2014 <NAME>.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

#ifndef _GTK_H
#define _GTK_H

#include <string>
#include <utility>

#include <gtk/gtk.h>

namespace gtk {

template <class T>
struct destroy_delete {
	void operator()(T *ptr) const {
		ptr->destroy();
	}
};

template <class T, class Deleter = destroy_delete<T>>
using unique_ptr = std::unique_ptr<T, Deleter>;

template <class T, class ...Args>
T * make_sunk(Args ...args) {
	auto ptr = T::create(std::forward<Args>(args)...);
	ptr->ref_sink();
	return ptr;
}

struct connection {
	GObject *object;
	unsigned long handler_id;

	void disconnect() {
		g_signal_handler_disconnect(object, handler_id);
	}
};

struct style_context;
struct widget;

namespace methods {

template <class T, class Derived>
struct gobject : T {
	using c_type = GObject;

	// This struct and derived structs are only used for the method
	// interface (by reinterpret_cast'ing T pointers to gobject<T>
	// pointers).  They cannot be constructed, copied, or moved.  See
	// the make_unique function to construct an object that is destroyed
	// after going out of scope, or use the static create member function
	// to return a raw pointer with a floating reference.
	gobject() = delete;
	~gobject() = delete;
	gobject(const gobject&) = delete;
	gobject& operator=(const gobject&) = delete;
	gobject(gobject&&) = delete;
	gobject& operator=(gobject&&) = delete;

	void ref() {
		g_object_ref(ptr());
	}
	void ref_sink() {
		g_object_ref_sink(ptr());
	}
	void unref() {
		g_object_unref(ptr());
	}

	connection connect(const char *detailed_signal, GCallback handler, gpointer data) {
		auto id = g_signal_connect(ptr(), detailed_signal, handler, data);
		return {ptr(), id};
	}
	void disconnect(unsigned long handler_id) {
		g_signal_handler_disconnect(ptr(), handler_id);
	}<commit_msg>Correct a comment.<commit_after>// Copyright (c) 2014 <NAME>.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

#ifndef _GTK_H
#define _GTK_H

#include <string>
#include <utility>

#include <gtk/gtk.h>

namespace gtk {

template <class T>
struct destroy_delete {
	void operator()(T *ptr) const {
		ptr->destroy();
	}
};

template <class T, class Deleter = destroy_delete<T>>
using unique_ptr = std::unique_ptr<T, Deleter>;

template <class T, class ...Args>
T * make_sunk(Args ...args) {
	auto ptr = T::create(std::forward<Args>(args)...);
	ptr->ref_sink();
	return ptr;
}

struct connection {
	GObject *object;
	unsigned long handler_id;

	void disconnect() {
		g_signal_handler_disconnect(object, handler_id);
	}
};

struct style_context;
struct widget;

namespace methods {

template <class T, class Derived>
struct gobject : T {
	using c_type = GObject;

	// This struct and derived structs are only used for the method
	// interface (by reinterpret_cast'ing T pointers to gobject<T>
	// pointers).  They cannot be constructed, copied, or moved.  See
	// the make_sunk free function and the gtk::unique_ptr class to
	// construct an object that is destroyed after going out of scope,
	// or use the static create member function to return a raw pointer
	// with a floating reference.
	gobject() = delete;
	~gobject() = delete;
	gobject(const gobject&) = delete;
	gobject& operator=(const gobject&) = delete;
	gobject(gobject&&) = delete;
	gobject& operator=(gobject&&) = delete;

	void ref() {
		g_object_ref(ptr());
	}
	void ref_sink() {
		g_object_ref_sink(ptr());
	}
	void unref() {
		g_object_unref(ptr());
	}

	connection connect(const char *detailed_signal, GCallback handler, gpointer data) {
		auto id = g_signal_connect(ptr(), detailed_signal, handler, data);
		return {ptr(), id};
	}
	void disconnect(unsigned long handler_id) {
		g_signal_handler_disconnect(ptr(), handler_id);
	}
{'fraction_non_alphanumeric': 0.12344074844074844, 'fraction_numerical': 0.002079002079002079, 'mean_word_length': 4.428772919605078, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 31, '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': '6102564', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1277, 'n_words': 417}