gdk_pixbuf2 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,24 +1,33 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbgdk-pixbuf.h -
5
-
6
- $Author: ggc $
7
- $Date: 2005/09/23 22:02:07 $
8
-
9
- Copyright (C) 2002-2004 Masao Mutoh
10
- ************************************************/
11
-
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002-2004 Masao Mutoh
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
21
+
22
+ #ifndef __RBGDK_PIXBUF_H__
23
+ #define __RBGDK_PIXBUF_H__
12
24
 
13
25
  #define GDK_PIXBUF_ENABLE_BACKEND
14
26
  #include <gdk-pixbuf/gdk-pixbuf.h>
15
27
  #include <gdk-pixbuf/gdk-pixdata.h>
16
28
  #include "rbgobject.h"
29
+ #include "rbgdk-pixbuf2conversions.h"
17
30
 
18
- extern void Init_gdk_pixbuf_animation(VALUE mGLib);
19
- extern void Init_gdk_pixdata(VALUE mGLib);
20
- extern void Init_gdk_pixbuf_loader(VALUE mGLib);
21
- extern void Init_gdk_pixbuf_format(VALUE mGLib);
22
31
  extern GType gdk_pixbuf_format_get_type(void);
23
32
 
24
33
  #define RBGDK_PIXBUF_CHECK_VERSION(major,minor,micro) \
@@ -27,8 +36,6 @@ extern GType gdk_pixbuf_format_get_type(void);
27
36
  (GDK_PIXBUF_MAJOR == (major) && GDK_PIXBUF_MINOR == (minor) && \
28
37
  GDK_PIXBUF_MICRO >= (micro)))
29
38
 
30
- #if RBGDK_PIXBUF_CHECK_VERSION(2,8,0)
31
- extern void Init_gdk_pixbuf_simpleanim(VALUE mGLib);
32
- #endif
33
-
34
39
  #define GDK_TYPE_PIXBUF_FORMAT (gdk_pixbuf_format_get_type())
40
+
41
+ #endif /* __RBGDK_PIXBUF_H__ */
@@ -0,0 +1,42 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #ifndef __RBGDK_PIXBUF2CONVERSIONS_H__
22
+ #define __RBGDK_PIXBUF2CONVERSIONS_H__
23
+
24
+ #define RVAL2GDKPIXBUF(o) (GDK_PIXBUF(RVAL2GOBJ(o)))
25
+ #define RVAL2GDKPIXBUFANIMATION(o) (GDK_PIXBUF_ANIMATION(RVAL2GOBJ(o)))
26
+ #define RVAL2GDKPIXBUFANIMATIONITER(o) (GDK_PIXBUF_ANIMATION_ITER(RVAL2GOBJ(o)))
27
+ #define RVAL2GDKPIXBUFLOADER(o) (GDK_PIXBUF_LOADER(RVAL2GOBJ(o)))
28
+ #define RVAL2GDKPIXBUFSIMPLEANIM(o) (GDK_PIXBUF_SIMPLE_ANIM(RVAL2GOBJ(o)))
29
+
30
+ #define RVAL2GDKPIXBUFFORMAT(o) ((GdkPixbufFormat*)RVAL2BOXED(o, GDK_TYPE_PIXBUF_FORMAT))
31
+ #define GDKPIXBUFFORMAT2RVAL(o) (BOXED2RVAL(o, GDK_TYPE_PIXBUF_FORMAT))
32
+ #define RVAL2GDKPIXDATA(o) ((GdkPixdata*)RVAL2BOXED(o, GDK_TYPE_PIXDATA))
33
+ #define GDKPIXDATA2RVAL(o) (BOXED2RVAL(o, GDK_TYPE_PIXDATA))
34
+
35
+ #define RVAL2GDKCOLORSPACE(o) (RVAL2GENUM(o, GDK_TYPE_COLORSPACE))
36
+ #define GDKCOLORSPACE2RVAL(o) (GENUM2RVAL(o, GDK_TYPE_COLORSPACE))
37
+ #define RVAL2GDKINTERPTYPE(o) (RVAL2GENUM(o, GDK_TYPE_INTERP_TYPE))
38
+ #define GDKINTERPTYPE2RVAL(o) (GENUM2RVAL(o, GDK_TYPE_INTERP_TYPE))
39
+ #define RVAL2GDKPIXBUFROTATION(o) (RVAL2GENUM(o, GDK_TYPE_PIXBUF_ROTATION))
40
+ #define GDKPIXBUFROTATION2RVAL(o) (GENUM2RVAL(o, GDK_TYPE_PIXBUF_ROTATION))
41
+
42
+ #endif /* __RBGDK_PIXBUF2CONVERSIONS_H__ */
@@ -0,0 +1,35 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #ifndef __RBGDK_PIXBUF2PRIVATE_H__
22
+ #define __RBGDK_PIXBUF2PRIVATE_H__
23
+
24
+ #include "rbgdk-pixbuf.h"
25
+
26
+ G_GNUC_INTERNAL void Init_gdk_pixbuf_animation(VALUE mGLib);
27
+ G_GNUC_INTERNAL void Init_gdk_pixbuf_animation_iter(VALUE mGLib);
28
+ G_GNUC_INTERNAL void Init_gdk_pixbuf_format(VALUE mGLib);
29
+ G_GNUC_INTERNAL void Init_gdk_pixbuf_loader(VALUE mGLib);
30
+ #if RBGDK_PIXBUF_CHECK_VERSION(2,8,0)
31
+ G_GNUC_INTERNAL void Init_gdk_pixbuf_simpleanim(VALUE mGLib);
32
+ #endif
33
+ G_GNUC_INTERNAL void Init_gdk_pixdata(VALUE mGLib);
34
+
35
+ #endif /* __RBGDK_PIXBUF2PRIVATE_H__ */
@@ -1,20 +1,31 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbgdk-pixbufanimation.c -
5
-
6
- $Author: mutoh $
7
- $Date: 2004/11/30 16:23:13 $
8
-
9
- Copyright (C) 2002,2003 Masao Mutoh
10
- ************************************************/
11
- #include "rbgdk-pixbuf.h"
12
-
13
- #define _SELF(s) (GDK_PIXBUF_ANIMATION(RVAL2GOBJ(s)))
14
- #define RVAL2ITR(i) (GDK_PIXBUF_ANIMATION_ITER(RVAL2GOBJ(i)))
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002,2003 Masao Mutoh
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
21
+
22
+ #include "rbgdk-pixbuf2private.h"
23
+
24
+ #define RG_TARGET_NAMESPACE cPixbufAnimation
25
+ #define _SELF(s) (RVAL2GDKPIXBUFANIMATION(s))
15
26
 
16
27
  static VALUE
17
- animation_initialize(VALUE self, VALUE filename)
28
+ rg_initialize(VALUE self, VALUE filename)
18
29
  {
19
30
  GdkPixbufAnimation* ret;
20
31
  GError* error = NULL;
@@ -28,103 +39,55 @@ animation_initialize(VALUE self, VALUE filename)
28
39
  }
29
40
 
30
41
  static VALUE
31
- animation_get_width(VALUE self)
42
+ rg_width(VALUE self)
32
43
  {
33
44
  return INT2NUM(gdk_pixbuf_animation_get_width(_SELF(self)));
34
45
  }
35
46
 
36
47
  static VALUE
37
- animation_get_height(VALUE self)
48
+ rg_height(VALUE self)
38
49
  {
39
50
  return INT2NUM(gdk_pixbuf_animation_get_height(_SELF(self)));
40
51
  }
41
52
 
42
53
  static VALUE
43
- animation_get_iter(int argc, VALUE *argv, VALUE self)
54
+ rg_get_iter(int argc, VALUE *argv, VALUE self)
44
55
  {
45
56
  VALUE start_time_sec, start_time_usec;
46
- GTimeVal* time = NULL;
57
+ GTimeVal start_time;
47
58
 
48
59
  rb_scan_args(argc, argv, "02", &start_time_sec, &start_time_usec);
49
60
 
50
- if (! NIL_P(start_time_sec)){
51
- time = g_new(GTimeVal, 1);
52
- time->tv_sec = NUM2LONG(start_time_sec);
53
- if (NIL_P(start_time_usec)){
54
- time->tv_usec = 0;
55
- } else {
56
- time->tv_usec = NUM2LONG(start_time_usec);
57
- }
58
- }
59
- return GOBJ2RVAL(gdk_pixbuf_animation_get_iter(_SELF(self), time));
60
- }
61
+ if (NIL_P(start_time_sec))
62
+ return GOBJ2RVAL(gdk_pixbuf_animation_get_iter(_SELF(self), NULL));
61
63
 
62
- static VALUE
63
- animation_is_static_image(VALUE self)
64
- {
65
- return CBOOL2RVAL(gdk_pixbuf_animation_is_static_image(_SELF(self)));
66
- }
64
+ start_time.tv_sec = NUM2LONG(start_time_sec);
65
+ start_time.tv_usec = NIL_P(start_time_usec) ? 0 : NUM2LONG(start_time_usec);
67
66
 
68
- static VALUE
69
- animation_get_static_image(VALUE self)
70
- {
71
- return GOBJ2RVAL(gdk_pixbuf_animation_get_static_image(_SELF(self)));
67
+ return GOBJ2RVAL(gdk_pixbuf_animation_get_iter(_SELF(self), &start_time));
72
68
  }
73
69
 
74
70
  static VALUE
75
- animation_iter_advance(int argc, VALUE *argv, VALUE self)
71
+ rg_static_image_p(VALUE self)
76
72
  {
77
- VALUE current_time_sec, current_time_usec;
78
- GTimeVal* time = NULL;
79
-
80
- rb_scan_args(argc, argv, "02", &current_time_sec, &current_time_usec);
81
-
82
- if (! NIL_P(current_time_sec)){
83
- time = g_new(GTimeVal, 1);
84
- time->tv_sec = NUM2LONG(current_time_sec);
85
- if (NIL_P(current_time_usec)){
86
- time->tv_usec = 0;
87
- } else {
88
- time->tv_usec = NUM2LONG(current_time_usec);
89
- }
90
- }
91
-
92
- return CBOOL2RVAL(gdk_pixbuf_animation_iter_advance(RVAL2ITR(self), time));
93
- }
94
-
95
- static VALUE
96
- animation_iter_get_delay_time(VALUE self)
97
- {
98
- return INT2NUM(gdk_pixbuf_animation_iter_get_delay_time(RVAL2ITR(self)));
99
- }
100
-
101
- static VALUE
102
- animation_iter_on_currently_loading_frame(VALUE self)
103
- {
104
- return CBOOL2RVAL(gdk_pixbuf_animation_iter_on_currently_loading_frame(RVAL2ITR(self)));
73
+ return CBOOL2RVAL(gdk_pixbuf_animation_is_static_image(_SELF(self)));
105
74
  }
106
75
 
107
76
  static VALUE
108
- animation_iter_get_pixbuf(VALUE self)
77
+ rg_static_image(VALUE self)
109
78
  {
110
- return GOBJ2RVAL(gdk_pixbuf_animation_iter_get_pixbuf(RVAL2ITR(self)));
79
+ return GOBJ2RVAL(gdk_pixbuf_animation_get_static_image(_SELF(self)));
111
80
  }
112
81
 
113
82
  void
114
83
  Init_gdk_pixbuf_animation(VALUE mGdk)
115
84
  {
116
- VALUE anim = G_DEF_CLASS(GDK_TYPE_PIXBUF_ANIMATION, "PixbufAnimation", mGdk);
117
- VALUE animiter = G_DEF_CLASS(GDK_TYPE_PIXBUF_ANIMATION_ITER, "PixbufAnimationIter", mGdk);
118
-
119
- rb_define_method(anim, "initialize", animation_initialize, 1);
120
- rb_define_method(anim, "width", animation_get_width, 0);
121
- rb_define_method(anim, "height", animation_get_height, 0);
122
- rb_define_method(anim, "get_iter", animation_get_iter, -1);
123
- rb_define_method(anim, "static_image?", animation_is_static_image, 0);
124
- rb_define_method(anim, "static_image", animation_get_static_image, 0);
125
- rb_define_method(animiter, "advance", animation_iter_advance, -1);
126
- rb_define_method(animiter, "delay_time", animation_iter_get_delay_time, 0);
127
- rb_define_method(animiter, "on_currently_loading_frame?", animation_iter_on_currently_loading_frame, 0);
128
- rb_define_method(animiter, "pixbuf", animation_iter_get_pixbuf, 0);
129
-
85
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF_ANIMATION, "PixbufAnimation", mGdk);
86
+
87
+ RG_DEF_METHOD(initialize, 1);
88
+ RG_DEF_METHOD(width, 0);
89
+ RG_DEF_METHOD(height, 0);
90
+ RG_DEF_METHOD(get_iter, -1);
91
+ RG_DEF_METHOD_P(static_image, 0);
92
+ RG_DEF_METHOD(static_image, 0);
130
93
  }
@@ -0,0 +1,71 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002,2003 Masao Mutoh
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
21
+
22
+ #include "rbgdk-pixbuf2private.h"
23
+
24
+ #define RG_TARGET_NAMESPACE cPixbufAnimationIter
25
+ #define _SELF(i) (RVAL2GDKPIXBUFANIMATIONITER(i))
26
+
27
+ static VALUE
28
+ rg_advance(int argc, VALUE *argv, VALUE self)
29
+ {
30
+ VALUE current_time_sec, current_time_usec;
31
+ GTimeVal current_time;
32
+
33
+ rb_scan_args(argc, argv, "02", &current_time_sec, &current_time_usec);
34
+
35
+ if (NIL_P(current_time_sec))
36
+ return CBOOL2RVAL(gdk_pixbuf_animation_iter_advance(_SELF(self), NULL));
37
+
38
+ current_time.tv_sec = NUM2LONG(current_time_sec);
39
+ current_time.tv_usec = NIL_P(current_time_usec) ? 0 : NUM2LONG(current_time_usec);
40
+
41
+ return CBOOL2RVAL(gdk_pixbuf_animation_iter_advance(_SELF(self), &current_time));
42
+ }
43
+
44
+ static VALUE
45
+ rg_delay_time(VALUE self)
46
+ {
47
+ return INT2NUM(gdk_pixbuf_animation_iter_get_delay_time(_SELF(self)));
48
+ }
49
+
50
+ static VALUE
51
+ rg_on_currently_loading_frame_p(VALUE self)
52
+ {
53
+ return CBOOL2RVAL(gdk_pixbuf_animation_iter_on_currently_loading_frame(_SELF(self)));
54
+ }
55
+
56
+ static VALUE
57
+ rg_pixbuf(VALUE self)
58
+ {
59
+ return GOBJ2RVAL(gdk_pixbuf_animation_iter_get_pixbuf(_SELF(self)));
60
+ }
61
+
62
+ void
63
+ Init_gdk_pixbuf_animation_iter(VALUE mGdk)
64
+ {
65
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF_ANIMATION_ITER, "PixbufAnimationIter", mGdk);
66
+
67
+ RG_DEF_METHOD(advance, -1);
68
+ RG_DEF_METHOD(delay_time, 0);
69
+ RG_DEF_METHOD_P(on_currently_loading_frame, 0);
70
+ RG_DEF_METHOD(pixbuf, 0);
71
+ }
@@ -1,20 +1,32 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbgdk-pixbufanimation.c -
5
-
6
- $Author: ggc $
7
- $Date: 2005/09/23 22:02:07 $
8
-
9
- Copyright (C) 2002,2003 the ruby-gnome2 project
10
- ************************************************/
11
- #include "rbgdk-pixbuf.h"
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002,2003 the ruby-gnome2 project
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
21
+
22
+ #include "rbgdk-pixbuf2private.h"
12
23
 
13
24
  #if RBGDK_PIXBUF_CHECK_VERSION(2,8,0)
14
- #define _SELF(s) (GDK_PIXBUF_SIMPLE_ANIM(RVAL2GOBJ(s)))
25
+ #define RG_TARGET_NAMESPACE cPixbufSimpleAnim
26
+ #define _SELF(s) (RVAL2GDKPIXBUFSIMPLEANIM(s))
15
27
 
16
28
  static VALUE
17
- simpleanim_initialize(VALUE self, VALUE width, VALUE height, VALUE rate)
29
+ rg_initialize(VALUE self, VALUE width, VALUE height, VALUE rate)
18
30
  {
19
31
  GdkPixbufSimpleAnim* ret = gdk_pixbuf_simple_anim_new(NUM2INT(width), NUM2INT(height), NUM2DBL(rate));
20
32
  G_INITIALIZE(self, ret);
@@ -22,9 +34,9 @@ simpleanim_initialize(VALUE self, VALUE width, VALUE height, VALUE rate)
22
34
  }
23
35
 
24
36
  static VALUE
25
- simpleanim_add_frame(VALUE self, VALUE pixbuf)
37
+ rg_add_frame(VALUE self, VALUE pixbuf)
26
38
  {
27
- gdk_pixbuf_simple_anim_add_frame(_SELF(self), RVAL2GOBJ(pixbuf));
39
+ gdk_pixbuf_simple_anim_add_frame(_SELF(self), RVAL2GDKPIXBUF(pixbuf));
28
40
  return self;
29
41
  }
30
42
  #endif
@@ -33,9 +45,9 @@ void
33
45
  Init_gdk_pixbuf_simpleanim(VALUE mGdk)
34
46
  {
35
47
  #if RBGDK_PIXBUF_CHECK_VERSION(2,8,0)
36
- VALUE anim = G_DEF_CLASS(GDK_TYPE_PIXBUF_SIMPLE_ANIM, "PixbufSimpleAnim", mGdk);
48
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF_SIMPLE_ANIM, "PixbufSimpleAnim", mGdk);
37
49
 
38
- rb_define_method(anim, "initialize", simpleanim_initialize, 3);
39
- rb_define_method(anim, "add_frame", simpleanim_add_frame, 1);
50
+ RG_DEF_METHOD(initialize, 3);
51
+ RG_DEF_METHOD(add_frame, 1);
40
52
  #endif
41
53
  }