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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/*
* Copyright (C) 2011 Ruby-GNOME2 Project Team
* Copyright (C) 2006 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 cRecentInfo
#define _SELF(self) (RVAL2GTKRECENTINFO(self))
static VALUE
rg_uri(VALUE self)
{
return CSTR2RVAL(gtk_recent_info_get_uri(_SELF(self)));
}
static VALUE
rg_display_name(VALUE self)
{
return CSTR2RVAL(gtk_recent_info_get_display_name(_SELF(self)));
}
static VALUE
rg_description(VALUE self)
{
return CSTR2RVAL(gtk_recent_info_get_description(_SELF(self)));
}
static VALUE
rg_mime_type(VALUE self)
{
return CSTR2RVAL(gtk_recent_info_get_mime_type(_SELF(self)));
}
static VALUE
rg_added(VALUE self)
{
time_t t = gtk_recent_info_get_added(_SELF(self));
return rb_funcall(rb_cTime, rb_intern("at"), 1, INT2NUM(t));
}
static VALUE
rg_modified(VALUE self)
{
time_t t = gtk_recent_info_get_modified(_SELF(self));
return rb_funcall(rb_cTime, rb_intern("at"), 1, INT2NUM(t));
}
static VALUE
rg_visited(VALUE self)
{
time_t t = gtk_recent_info_get_visited(_SELF(self));
return rb_funcall(rb_cTime, rb_intern("at"), 1, INT2NUM(t));
}
static VALUE
rg_private_hint_p(VALUE self)
{
return CBOOL2RVAL(gtk_recent_info_get_private_hint(_SELF(self)));
}
static VALUE
rg_application_info(VALUE self, VALUE app_name)
{
const gchar *app_exec;
guint count;
time_t t;
gboolean ret = gtk_recent_info_get_application_info(_SELF(self),
RVAL2CSTR(app_name),
&app_exec,
&count,
&t);
VALUE ary = rb_ary_new();
if (ret){
rb_ary_push(ary, CSTR2RVAL(app_exec));
rb_ary_push(ary, UINT2NUM(count));
rb_ary_push(ary, rb_funcall(rb_cTime, rb_intern("at"), 1, INT2NUM(t)));
}
return ary;
}
static VALUE
rg_applications(VALUE self)
{
gsize i;
gsize length;
gchar** str = gtk_recent_info_get_applications(_SELF(self), &length);
VALUE ary = rb_ary_new();
for(i = 0; i < length; i++){
rb_ary_push(ary, CSTR2RVAL(str[i]));
}
g_strfreev(str);
return ary;
}
static VALUE
rg_last_application(VALUE self)
{
return CSTR2RVAL(gtk_recent_info_last_application(_SELF(self)));
}
static VALUE
rg_groups(VALUE self)
{
gsize i;
gsize length;
gchar** str = gtk_recent_info_get_groups(_SELF(self), &length);
VALUE ary = rb_ary_new();
for(i = 0; i < length; i++){
rb_ary_push(ary, CSTR2RVAL(str[i]));
}
g_strfreev(str);
return ary;
}
static VALUE
rg_has_group_p(VALUE self, VALUE group_name)
{
return CBOOL2RVAL(gtk_recent_info_has_group(_SELF(self),
RVAL2CSTR(group_name)));
}
static VALUE
rg_has_application_p(VALUE self, VALUE app_name)
{
return CBOOL2RVAL(gtk_recent_info_has_application(_SELF(self),
RVAL2CSTR(app_name)));
}
static VALUE
rg_get_icon(VALUE self, VALUE size)
{
return GOBJ2RVAL(gtk_recent_info_get_icon(_SELF(self), NUM2INT(size)));
}
static VALUE
rg_short_name(VALUE self)
{
return CSTR2RVAL(gtk_recent_info_get_short_name(_SELF(self)));
}
static VALUE
rg_uri_display(VALUE self)
{
return CSTR2RVAL(gtk_recent_info_get_uri_display(_SELF(self)));
}
static VALUE
rg_age(VALUE self)
{
return INT2NUM(gtk_recent_info_get_age(_SELF(self)));
}
static VALUE
rg_local_p(VALUE self)
{
return CBOOL2RVAL(gtk_recent_info_is_local(_SELF(self)));
}
static VALUE
rg_exist_p(VALUE self)
{
return CBOOL2RVAL(gtk_recent_info_exists(_SELF(self)));
}
static VALUE
rg_operator_ri_match(VALUE self, VALUE other)
{
return CBOOL2RVAL(gtk_recent_info_match(_SELF(self), _SELF(other)));
}
void
Init_gtk_recent_info(VALUE mGtk)
{
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_RECENT_INFO, "RecentInfo", mGtk);
RG_DEF_METHOD(uri, 0);
RG_DEF_METHOD(display_name, 0);
RG_DEF_METHOD(description, 0);
RG_DEF_METHOD(mime_type, 0);
RG_DEF_METHOD(added, 0);
RG_DEF_METHOD(modified, 0);
RG_DEF_METHOD(visited, 0);
RG_DEF_METHOD_P(private_hint, 0);
RG_DEF_METHOD(application_info, 1);
RG_DEF_METHOD(applications, 0);
RG_DEF_METHOD(last_application, 0);
RG_DEF_METHOD(groups, 0);
RG_DEF_METHOD_P(has_group, 1);
RG_DEF_METHOD_P(has_application, 1);
RG_DEF_METHOD(get_icon, 1);
RG_DEF_METHOD(short_name, 0);
RG_DEF_METHOD(uri_display, 0);
RG_DEF_METHOD(age, 0);
RG_DEF_METHOD_P(local, 0);
RG_DEF_METHOD_P(exist, 0);
RG_DEF_METHOD_OPERATOR("==", ri_match, 1);
}
|