<commit_before>#include <seed.h>
#include <gtk/gtk.h>

typedef struct _builder_ud {
  SeedContext ctx;
  SeedObject obj;
  SeedObject user_data;
} builder_ud;

// Need to support connect object.
static void
seed_builder_connect_func (GtkBuilder *builder,
			   GObject *object,
			   const gchar *signal_name,
			   const gchar *handler_name,
			   GObject *connect_object,
			   GConnectFlags flags,
			   gpointer user_data)
{
  SeedContext ctx;
  SeedObject obj, func;
  builder_ud *priv = (builder_ud *)user_data;
  GClosure *closure;

  ctx = priv->ctx;
  obj = priv->obj;

  func = seed_object_get_property (ctx, obj, handler_name);
  if (!seed_value_is_object (ctx, func) || !seed_value_is_function (ctx, func))
    return;
  
  closure = seed_closure_new (ctx, func, priv->user_data, "signal handler (GtkBuilder)");
  
  g_signal_connect_closure (object, signal_name, closure, FALSE);
}

SeedValue
seed_gtk_builder_connect_signals(SeedContext ctx,
				 SeedObject function,
				 SeedObject this_object,
				 gsize argument_count,
				 const SeedValue arguments[],
				 SeedException *exception)
{
  builder_ud ud;
  GtkBuilder *b;
  
  if (!seed_value_is_object (ctx, arguments[0]))<commit_msg>gtkbuilder: If connect_object is passed to the connect func, use g_object_watch_closure to ensure lifetime<commit_after>#include <seed.h>
#include <gtk/gtk.h>

typedef struct _builder_ud {
  SeedContext ctx;
  SeedObject obj;
  SeedObject user_data;
} builder_ud;

static void
seed_builder_connect_func (GtkBuilder *builder,
			   GObject *object,
			   const gchar *signal_name,
			   const gchar *handler_name,
			   GObject *connect_object,
			   GConnectFlags flags,
			   gpointer user_data)
{
  SeedContext ctx;
  SeedObject obj, func;
  builder_ud *priv = (builder_ud *)user_data;
  GClosure *closure;

  ctx = priv->ctx;
  obj = priv->obj;

  func = seed_object_get_property (ctx, obj, handler_name);
  if (!seed_value_is_object (ctx, func) || !seed_value_is_function (ctx, func))
    return;
  
  closure = seed_closure_new (ctx, func, priv->user_data, "signal handler (GtkBuilder)");
  if (connect_object != NULL)
    g_object_watch_closure (connect_object, closure);
  
  g_signal_connect_closure (object, signal_name, closure, FALSE);
}

SeedValue
seed_gtk_builder_connect_signals(SeedContext ctx,
				 SeedObject function,
				 SeedObject this_object,
				 gsize argument_count,
				 const SeedValue arguments[],
				 SeedException *exception)
{
  builder_ud ud;
  GtkBuilder *b;
  
  if (!seed_value_is_object (ctx, arguments[0]))
{'fraction_non_alphanumeric': 0.09308719560094265, 'fraction_numerical': 0.0007855459544383347, 'mean_word_length': 4.284232365145228, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '4017042', 'n_tokens_mistral': 940, 'n_tokens_neox': 842, 'n_words': 215}