# Gio

**URL:** <https://www.ruby-forum.com/t/gio/189660>\
**Category:** Ruby-Gnome 2\
**Created:** [June 4, 2010, 4:28pm UTC](https://www.ruby-forum.com/t/gio/189660 "2010-06-04T16:28:21Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [June 4, 2010, 4:28pm UTC](https://www.ruby-forum.com/t/gio/189660/1 "2010-06-04T16:28:21Z")

</div>

Iâ€™m very disappointed to see that gio was removed.

What would it take to get it re-added?

> And please don’t use DECLARE\*, DEF\ __, SCAN\__ family  
> macros. Please keep coding style with other bindings.

I have now removed all DECLARE\* and DEF\__; four hours of work, even  
with automation. What exactly is the problem with SCAN\__? I can  
rename them to RBGIO2\_SCAN\_\*, but I have absolutely no desire to  
duplicate that kind of code for exactly the reasons I stated  
previously:

> â€¦ sometimes order is important and then we have a problem if it is done  
> in different ways

I can also make the argument and block variables name explicit, that  
is, instead of

```
    GCancellable *cancellable;
    VALUE block;

    SCAN_1_ARG_WITH_BLOCK("01", cancellable, RVAL2GCANCELLABLE);

    g_drive_poll_for_media(_SELF(self),
                           cancellable,
                           rbgio_async_ready_callback,
                           (gpointer)block);

    return self;

```

we can have

```
    GCancellable *cancellable;
    VALUE block;

    RBGIO2_SCAN_1_ARG_WITH_BLOCK(argc, argv, "01", cancellable,

```

RVAL2GCANCELLABLE, block);

```
    g_drive_poll_for_media(_SELF(self),
                           cancellable,
                           rbgio_async_ready_callback,
                           (gpointer)block);

    return self;

```

if that kind of â€œbehind the scenesâ€ action is confusing.

Is this an acceptable compromise?

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [June 11, 2010, 7:54pm UTC](https://www.ruby-forum.com/t/gio/189660/2 "2010-06-11T19:54:31Z")

</div>

On Fri, Jun 4, 2010 at 16:27, Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Iâ€™m very disappointed to see that gio was removed.

Bump. Whatâ€™s going on?

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [June 12, 2010, 12:47pm UTC](https://www.ruby-forum.com/t/gio/189660/3 "2010-06-12T12:47:35Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] gio” on Fri, 4 Jun 2010 16:27:42 +0200,  
Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> What would it take to get it re-added?

If Ruby/GIO uses Ruby-GNOME2 style, we are welcome to re-add  
Ruby/GIO.

> > And please don’t use DECLARE\*, DEF\ __, SCAN\__ family  
> > macros. Please keep coding style with other bindings.
> 
> I have now removed all DECLARE\* and DEF\_\*; four hours of work, even  
> with automation.

Thanks!!!

> ```
> What exactly is the problem with SCAN_*? I can
> 
> ```
> 
> rename them to RBGIO2\_SCAN\_\*, but I have absolutely no desire to  
> duplicate that kind of code for exactly the reasons I stated  
> previously:

Please don’t use the macros too.

> ```
> VALUE block;
> 
> ```
> 
> if that kind of $B!H(Bbehind the scenes$B!I(B action is confusing.
> 
> Is this an acceptable compromise?

Uhm… I can’t accept it.

If we need to change 1 argument to 2 arguments, we need to  
change XXX\_SCAN\_1\_XXX to XXX\_SCAN\_2\_XXX and “01” to “02”.  
We also can’t handle selectable argument. For example, we  
write like the following when we want to accept ID or NAME  
as an argument:

VALUE id\_or\_name, id = Qnil, name = Qnil;  
rb\_scan\_args(argc, argv, “10”, &id\_or\_name);  
if (TYPE(id\_or\_name) == T\_STRING) {  
name = id\_or\_name;  
} else {  
id = id\_or\_name;  
}

If we accept the such argument, we need to define a macro  
for the case.

So I don’t think the XXX\_SCAN\_N\_XXX approach is a good idea  
for readability, writability and extensibility in the  
Ruby-GNOME2 project.

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [June 12, 2010, 1:01pm UTC](https://www.ruby-forum.com/t/gio/189660/4 "2010-06-12T13:01:03Z")

</div>

2010/6/12 Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> So I don’t think the XXX\_SCAN\_N\_XXX approach is a good idea  
> for readability, writability and extensibility in the  
> Ruby-GNOME2 project.

OK. Iâ€™ll remove them.

May I then re-add it, or do you want a patch instead?

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [June 12, 2010, 1:09pm UTC](https://www.ruby-forum.com/t/gio/189660/5 "2010-06-12T13:09:15Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] gio” on Sat, 12 Jun 2010 13:00:32 +0200,  
Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > So I don’t think the XXX\_SCAN\_N\_XXX approach is a good idea  
> > for readability, writability and extensibility in the  
> > Ruby-GNOME2 project.
> 
> OK. I¢ll remove them.

Thanks!

> May I then re-add it, or do you want a patch instead?

You can re-add it. But if there are some problems, we will  
comment them. In the case, please fix them.

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [June 12, 2010, 1:23pm UTC](https://www.ruby-forum.com/t/gio/189660/6 "2010-06-12T13:23:18Z")

</div>

2010/6/12 Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > OK. Â Iâ€™ll remove them.
> 
> Thanks!
> 
> > May I then re-add it, or do you want a patch instead?
> 
> You can re-add it. But if there are some problems, we will  
> comment them. In the case, please fix them.

OK, great!

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [June 17, 2010, 4:26pm UTC](https://www.ruby-forum.com/t/gio/189660/7 "2010-06-17T16:26:21Z")

</div>

On Tue, Jun 15, 2010 at 15:59, Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> block you have to convert all the parameters first, as any errors have  
> to be raised before you save the blockâ€¦this is so boring.

OK, so this is now done.

Can we perhaps consider moving to Git in the future. Subversion is  
seriously a pain to work with.

There are still a bunch of TODOs that remain of the â€œI need input from  
others on how to resolve themâ€ kind, so please search for TODO in \*.c  
and see if you have any suggestions.

Enjoy.

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/gio/189660/8 "2010-06-17T16:22:44Z")

</div>

On Sat, Jun 12, 2010 at 13:22, Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 2010/6/12 Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > > > So I don’t think the XXX\_SCAN\_N\_XXX approach is a good idea  
> > > > for readability, writability and extensibility in the  
> > > > Ruby-GNOME2 project.

> > > OK. Â Iâ€™ll remove them.

OK, now I remember why I created the SCAN\_\* macros. When you take a  
block you have to convert all the parameters first, as any errors have  
to be raised before you save the blockâ€¦this is so boring.

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [June 20, 2010, 12:34pm UTC](https://www.ruby-forum.com/t/gio/189660/9 "2010-06-20T12:34:07Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] gio” on Wed, 16 Jun 2010 16:17:04 +0200,  
Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> OK, so this is now done.  
> Thanks!

> There are still a bunch of TODOs that remain of the â€œI need input from  
> others on how to resolve themâ€ kind, so please search for TODO in \*.c  
> and see if you have any suggestions.

Please also check the bug?  
[https://sourceforge.net/tracker/?func=detail&atid=470969&aid=3018618&group\_id=53614](https://sourceforge.net/tracker/?func=detail&atid=470969&aid=3018618&group_id=53614)

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [July 3, 2010, 11:32am UTC](https://www.ruby-forum.com/t/gio/189660/10 "2010-07-03T11:32:39Z")

</div>

On Sun, Jun 20, 2010 at 14:30, Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Also, what is the current target for Ruby-GNOME2? Â 2.22? Â 2.24?

Iâ€™ve brought the bindings up to 2.24 compatibility and implemented  
many missing classes and the unix interface as well.

I have some questions, though.

How do I know when to use rbgobj\_boxed\_not\_copy\_obj?

What name do we prefer, GLib::File::Enumerator or GLib::FileEnumerator?

Same for GLib::File::Info versus GLib::FileInfo? (Ruby has File::Stat.)

When should I be using G\_PROTECT\_CALLBACK?

Thanks!

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [June 20, 2010, 2:31pm UTC](https://www.ruby-forum.com/t/gio/189660/11 "2010-06-20T14:31:10Z")

</div>

On Sun, Jun 20, 2010 at 12:33, Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Â Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > There are still a bunch of TODOs that remain of the â€œI need input from  
> > others on how to resolve themâ€ kind, so please search for TODO in \*.c  
> > and see if you have any suggestions.

> Please also check the bug?  
> Â [https://sourceforge.net/tracker/?func=detail&atid=470969&aid=3018618&group\_id=53614](https://sourceforge.net/tracker/?func=detail&atid=470969&aid=3018618&group_id=53614)

I’ll fix it tomorrow.

Also, what is the current target for Ruby-GNOME2? 2.22? 2.24?

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [July 4, 2010, 10:35am UTC](https://www.ruby-forum.com/t/gio/189660/12 "2010-07-04T10:35:37Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] gio” on Sat, 3 Jul 2010 11:31:49 +0200,  
Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> How do I know when to use rbgobj\_boxed\_not\_copy\_obj?

It’s a time to use rbgobj\_boxed\_not\_copy\_obj() when a boxed  
object cannot be created by user. (If you don’t provide  
BoxedClass.new, you need to use  
rbgobj\_boxed\_not\_copy\_obj().)

> What name do we prefer, GLib::File::Enumerator or GLib::FileEnumerator?
> 
> Same for GLib::File::Info versus GLib::FileInfo? (Ruby has File::Stat.)

GLib::FileEnumerator and GLib::FileInfo.  
See also:  
[http://ruby-gnome2.sourceforge.jp/hiki.cgi?Naming+and+Conversion+Rules](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Naming+and+Conversion+Rules)

> When should I be using G\_PROTECT\_CALLBACK?

When you allow user to use callback block.

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [July 8, 2010, 11:21pm UTC](https://www.ruby-forum.com/t/gio/189660/13 "2010-07-08T23:21:45Z")

</div>

OK, almost done. Quite a few to-dos, but Iâ€™m quite happy with it now.

Another question, though:

How do I know when to use GOBJ2RVAL\_UNREF? Should I use it as soon as  
a new, freshly allocated, GObject \* is returned? It seems that quite  
a few uses of GOBJ2RVAL may be incorrect in, for example, gtk/src/\*.c,  
if thatâ€™s the case.

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [July 12, 2010, 11:06am UTC](https://www.ruby-forum.com/t/gio/189660/14 "2010-07-12T11:06:49Z")

</div>

On Thu, Jul 8, 2010 at 23:21, Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> OK, almost done. Â Quite a few to-dos, but Iâ€™m quite happy with it now.

OK, done. GIO has been updated to 2.24.1, should compile under Ruby  
1.9.\* and has a lot fewer to-dos.

Implementing GConverter remains to be done. Thereâ€™s code in the  
repository for it, but it doesnâ€™t work. I donâ€™t exactly know how to  
solve it, actually, as it seems that the API more or less requires  
that you keep auxiliary data around between calls (like ext/iconv/\*  
does as well), but I canâ€™t figure out a good way of doing so.

> Another question, though:
> 
> How do I know when to use GOBJ2RVAL\_UNREF? Â Should I use it as soon as  
> a new, freshly allocated, GObject \* is returned? Â It seems that quite  
> a few uses of GOBJ2RVAL may be incorrect in, for example, gtk/src/\*.c,  
> if thatâ€™s the case.

I really would like this question answered.

Also, I think that rbg\_cstr2rval\_with\_free should be rewritten,  
wrapping it in a rb\_ensure that ensures that that g\_free is called  
even if rb\_str\_new2 throws an error. What do you think?

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [July 12, 2010, 2:44pm UTC](https://www.ruby-forum.com/t/gio/189660/15 "2010-07-12T14:44:02Z")

</div>

Hi,

Sorry for my late response.

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] gio” on Mon, 12 Jul 2010 11:06:12 +0200,  
Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> OK, done. GIO has been updated to 2.24.1, should compile under Ruby  
> 1.9.\* and has a lot fewer to-dos.

Great!

> > How do I know when to use GOBJ2RVAL\_UNREF? Should I use it as soon as  
> > a new, freshly allocated, GObject \* is returned?

GOBJ2RVAL\_UNREF is a convenience macro. It meens that the  
following:

ruby\_object = GOBJE2RVAL(g\_object);  
g\_object\_unref(g\_object);

You can use GOBJ2RVAL\_UNREF when you need to unref converted  
GObject.

> > ```
> > It seems that quite
> > 
> > ```
> > 
> > a few uses of GOBJ2RVAL may be incorrect in, for example, gtk/src/\*.c,  
> > if that¢s the case.

Please give us a patch.

> Also, I think that rbg\_cstr2rval\_with\_free should be rewritten,  
> wrapping it in a rb\_ensure that ensures that that g\_free is called  
> even if rb\_str\_new2 throws an error. What do you think?

I agree with you.

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [July 12, 2010, 6:37pm UTC](https://www.ruby-forum.com/t/gio/189660/16 "2010-07-12T18:37:40Z")

</div>

2010/7/12 Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Sorry for my late response.

No problem!

> In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> Â “Re: [ruby-gnome2-devel-en] gio” on Mon, 12 Jul 2010 11:06:12 +0200,  
> Â Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> GObject.
> 
> > > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â It seems that quite  
> > > a few uses of GOBJ2RVAL may be incorrect in, for example, gtk/src/\*.c,  
> > > if thatâ€™s the case.

So, use GOBJ2RVAL\_UNREF whenever a function returns a freshly  
allocated/new GObject \*?

Also, I noticed quite a few uses of G\_CHILD\_ADD that I donâ€™t  
understand. For example, in gtk/src/rbgdkdraw.c we have  
gdkdraw\_set\_colormap that does G\_CHILD\_REMOVE/G\_CHILD\_ADD for the  
colormap that weâ€™re setting. Why? I mean, if the colormap goes out  
of Ruby scope itâ€™ll still be referenced by the GdkDrawable, right? So  
why all the fuss with managing it as a child with G\_CHILD\_\*?
