Sha256: 08419f5256273a027345f6838b0280b4ba8be152df7af2842889575dc6c3b26d

Contents?: true

Size: 1.45 KB

Versions: 6

Compression:

Stored size: 1.45 KB

Contents

/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/************************************************

  rbgtklinkbutton.c -

  $Author: sakai $
  $Date: 2007/07/08 03:00:49 $

  Copyright (C) 2006 Masao Mutoh
************************************************/

#include "global.h"

#if GTK_CHECK_VERSION(2,10,0)

#define _SELF(self) (GTK_LINK_BUTTON(RVAL2GOBJ(self)))

static VALUE
lb_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE uri, label;
    GtkWidget *widget = NULL;

    rb_scan_args(argc, argv, "11", &uri, &label);
    if (NIL_P(label)){
        widget = gtk_link_button_new(RVAL2CSTR(uri));
    } else {
        widget = gtk_link_button_new_with_label(RVAL2CSTR(uri), RVAL2CSTR(label));
    }
    RBGTK_INITIALIZE(self, widget); 
    return Qnil;
}

static void
link_func(GtkLinkButton *button, const gchar *link, gpointer func)
{
    rb_funcall((VALUE)func, id_call, 2, GOBJ2RVAL(button), CSTR2RVAL(link));
}

static VALUE
lb_set_uri_hook(VALUE self)
{
    VALUE func = rb_block_proc();
    G_RELATIVE(self, func);
    gtk_link_button_set_uri_hook((GtkLinkButtonUriFunc)link_func, (gpointer)func, (GDestroyNotify)NULL);
    return self;
}
#endif 

void 
Init_gtk_link_button()
{
#if GTK_CHECK_VERSION(2,10,0)
    VALUE button = G_DEF_CLASS(GTK_TYPE_LINK_BUTTON, "LinkButton", mGtk);

    rb_define_method(button, "initialize", lb_initialize, -1);
    rb_define_singleton_method(button, "set_uri_hook", lb_set_uri_hook, 0);

    G_DEF_SETTERS(button);
#endif
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gtk2-1.0.0-x86-mingw32 ext/gtk2/rbgtklinkbutton.c
gtk2-1.0.0 ext/gtk2/rbgtklinkbutton.c
gtk2-0.90.9 ext/gtk2/rbgtklinkbutton.c
gtk2-0.90.9-x86-mingw32 ext/gtk2/rbgtklinkbutton.c
gtk2-0.90.8-x86-mingw32 ext/gtk2/rbgtklinkbutton.c
gtk2-0.90.8 ext/gtk2/rbgtklinkbutton.c