1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/*
* Copyright (C) 2011-2013 Ruby-GNOME2 Project Team
* Copyright (C) 2004 Masao Mutoh
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
#include "rbgtk3private.h"
#define RG_TARGET_NAMESPACE cIconInfo
#define _SELF(i) (RVAL2GTKICONINFO(i))
static VALUE
rg_base_size(VALUE self)
{
return INT2NUM(gtk_icon_info_get_base_size(_SELF(self)));
}
static VALUE
rg_filename(VALUE self)
{
return CSTR2RVAL(gtk_icon_info_get_filename(_SELF(self)));
}
static VALUE
rg_builtin_pixbuf(VALUE self)
{
return GOBJ2RVAL(gtk_icon_info_get_builtin_pixbuf(_SELF(self)));
}
static VALUE
rg_load_icon(VALUE self)
{
GError* error = NULL;
GdkPixbuf* pixbuf = gtk_icon_info_load_icon(_SELF(self), &error);
VALUE ret;
if (error) RAISE_GERROR(error);
ret = GOBJ2RVAL(pixbuf);
g_object_unref(pixbuf);
return ret;
}
static VALUE
rg_set_raw_coordinates(VALUE self, VALUE raw_coordinates)
{
gtk_icon_info_set_raw_coordinates(_SELF(self), RVAL2CBOOL(raw_coordinates));
return self;
}
static VALUE
rg_embedded_rect(VALUE self)
{
GdkRectangle rectangle;
gboolean ret = gtk_icon_info_get_embedded_rect(_SELF(self), &rectangle);
if (ret)
return GDKRECTANGLE2RVAL(&rectangle);
else
return Qnil;
}
static VALUE
rg_attach_points(VALUE self)
{
GdkPoint* points;
gint n_points, i;
gboolean ret = gtk_icon_info_get_attach_points(_SELF(self), &points, &n_points);
VALUE ary = Qnil;
if (ret){
ary = rb_ary_new();
for (i = 0; i < n_points; i++){
rb_ary_push(ary, rb_assoc_new(INT2NUM(points[i].x), INT2NUM(points[i].y)));
}
g_free(points);
}
return ary;
}
static VALUE
rg_display_name(VALUE self)
{
return CSTR2RVAL(gtk_icon_info_get_display_name(_SELF(self)));
}
void
Init_gtk_icon_info(VALUE mGtk)
{
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ICON_INFO, "IconInfo", mGtk);
RG_DEF_METHOD(base_size, 0);
RG_DEF_METHOD(filename, 0);
RG_DEF_METHOD(builtin_pixbuf, 0);
RG_DEF_METHOD(load_icon, 0);
RG_DEF_METHOD(set_raw_coordinates, 1);
RG_DEF_METHOD(embedded_rect, 0);
RG_DEF_METHOD(attach_points, 0);
RG_DEF_METHOD(display_name, 0);
}
|