gdk_pixbuf2 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,19 @@
1
+ 2011-09-16 Nikolai Weibull <now@bitwi.se>
2
+
3
+ * lib/gdk_pixbuf2.rb: Remove unused variable.
4
+
5
+ 2011-09-12 Nikolai Weibull <now@bitwi.se>
6
+
7
+ * ext/gdk_pixbuf2/*.c: Remove methods that implement methods already
8
+ implemented with properties.
9
+ * ext/gdk_pixbuf2/*.c: call StringValue before calling
10
+ RSTRING_PTR()/RSTRING_LEN().
11
+
12
+ 2011-09-09 Nikolai Weibull <now@bitwi.se>
13
+
14
+ * ext/gdk_pixbuf2/*.c: Fix all warnings generated with gcc 4.4.5.
15
+ * ext/gdk_pixbuf2/*.c: Fix all RVAL2CSTR calls.
16
+
1
17
  2011-02-05 Masaaki Aoyagi
2
18
 
3
19
  * ext/gdk_pixbuf2/*.c: change to ANSI C style.
@@ -60,31 +60,33 @@ static VALUE
60
60
  loader_write(VALUE self, VALUE data)
61
61
  {
62
62
  GError *error = NULL;
63
- gboolean res;
64
63
 
65
- res = gdk_pixbuf_loader_write(_SELF(self), (const guchar*)RVAL2CSTR(data),
66
- RSTRING_LEN(data), &error);
67
- if (error)
64
+ StringValue(data);
65
+ if (!gdk_pixbuf_loader_write(_SELF(self),
66
+ (const guchar *)RSTRING_PTR(data),
67
+ RSTRING_LEN(data),
68
+ &error))
68
69
  RAISE_GERROR(error);
69
- return CBOOL2RVAL(res);
70
+
71
+ return Qtrue;
70
72
  }
71
73
 
72
74
  static VALUE
73
75
  last_write(VALUE self, VALUE data)
74
76
  {
75
77
  GError *error = NULL;
76
- gboolean res;
77
78
 
78
- res = gdk_pixbuf_loader_write(_SELF(self), (const guchar*)RVAL2CSTR(data),
79
- RSTRING_LEN(data), &error);
80
- if (error)
79
+ StringValue(data);
80
+ if (!gdk_pixbuf_loader_write(_SELF(self),
81
+ (const guchar *)RSTRING_PTR(data),
82
+ RSTRING_LEN(data),
83
+ &error))
81
84
  RAISE_GERROR(error);
82
85
 
83
- res = gdk_pixbuf_loader_close(_SELF(self), &error);
84
- if (error)
86
+ if (!gdk_pixbuf_loader_close(_SELF(self), &error))
85
87
  RAISE_GERROR(error);
86
88
 
87
- return CBOOL2RVAL(res);
89
+ return Qtrue;
88
90
  }
89
91
 
90
92
  #if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
@@ -29,30 +29,6 @@ static ID id_pixdata;
29
29
 
30
30
  /****************************************************/
31
31
  /* The GdkPixbuf Structure */
32
- static VALUE
33
- get_colorspace(VALUE self)
34
- {
35
- return GENUM2RVAL(gdk_pixbuf_get_colorspace(_SELF(self)), GDK_TYPE_COLORSPACE);
36
- }
37
-
38
- static VALUE
39
- get_n_channels(VALUE self)
40
- {
41
- return INT2FIX(gdk_pixbuf_get_n_channels(_SELF(self)));
42
- }
43
-
44
- static VALUE
45
- get_has_alpha(VALUE self)
46
- {
47
- return CBOOL2RVAL(gdk_pixbuf_get_has_alpha(_SELF(self)));
48
- }
49
-
50
- static VALUE
51
- get_bits_per_sample(VALUE self)
52
- {
53
- return INT2FIX(gdk_pixbuf_get_bits_per_sample(_SELF(self)));
54
- }
55
-
56
32
  static int
57
33
  pixels_size(GdkPixbuf *pixbuf)
58
34
  {
@@ -75,7 +51,7 @@ get_pixels(VALUE self)
75
51
  int size;
76
52
 
77
53
  size = pixels_size(pixbuf);
78
- return rb_str_new((const char*)gdk_pixbuf_get_pixels(pixbuf), size);
54
+ return rb_str_new((const char *)gdk_pixbuf_get_pixels(pixbuf), size);
79
55
  }
80
56
 
81
57
  static VALUE
@@ -87,7 +63,7 @@ set_pixels(VALUE self, VALUE pixels)
87
63
 
88
64
  size = pixels_size(pixbuf);
89
65
 
90
- Check_Type(pixels, T_STRING);
66
+ StringValue(pixels);
91
67
  arg_size = RSTRING_LEN(pixels);
92
68
  if (arg_size != size)
93
69
  rb_raise(rb_eRangeError,
@@ -99,25 +75,7 @@ set_pixels(VALUE self, VALUE pixels)
99
75
  memcpy(gdk_pixbuf_get_pixels(pixbuf),
100
76
  RSTRING_PTR(pixels), MIN(RSTRING_LEN(pixels), size));
101
77
 
102
- return pixels;
103
- }
104
-
105
- static VALUE
106
- get_width(VALUE self)
107
- {
108
- return INT2FIX(gdk_pixbuf_get_width(_SELF(self)));
109
- }
110
-
111
- static VALUE
112
- get_height(VALUE self)
113
- {
114
- return INT2FIX(gdk_pixbuf_get_height(_SELF(self)));
115
- }
116
-
117
- static VALUE
118
- get_rowstride(VALUE self)
119
- {
120
- return INT2FIX(gdk_pixbuf_get_rowstride(_SELF(self)));
78
+ return pixels;
121
79
  }
122
80
 
123
81
  static VALUE
@@ -252,17 +210,15 @@ initialize(int argc, VALUE *argv, VALUE self)
252
210
  buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1), &error);
253
211
  }
254
212
  } else if (TYPE(arg1) == T_ARRAY) {
255
- int i;
256
- gchar** data = ALLOCA_N(gchar*, RARRAY_LEN(arg1));
257
- for (i=0; i < RARRAY_LEN(arg1); i++) {
258
- data[i] = RVAL2CSTR(RARRAY_PTR(arg1)[i]);
259
- }
260
- buf = gdk_pixbuf_new_from_xpm_data((const gchar**)data);
261
- if (buf == NULL){
213
+ const gchar **data = RVAL2STRV(arg1);
214
+ buf = gdk_pixbuf_new_from_xpm_data(data);
215
+ if (buf == NULL) {
262
216
  rb_gc();
263
- buf = gdk_pixbuf_new_from_xpm_data((const gchar**)data);
264
- if (buf == NULL) NOMEM_ERROR(&error);
217
+ buf = gdk_pixbuf_new_from_xpm_data(data);
265
218
  }
219
+ g_free(data);
220
+ if (buf == NULL)
221
+ NOMEM_ERROR(&error);
266
222
  } else {
267
223
  rb_raise(rb_eArgError, "Wrong type of 1st argument or wrong number of arguments");
268
224
  }
@@ -302,7 +258,7 @@ get_file_info(VALUE self, VALUE filename)
302
258
  #endif
303
259
 
304
260
  static VALUE
305
- save_to(VALUE self, gchar *filename, gchar *type, VALUE options)
261
+ save_to(VALUE self, const gchar *filename, const gchar *type, VALUE options)
306
262
  {
307
263
  VALUE result = self;
308
264
  GError *error = NULL;
@@ -328,10 +284,10 @@ save_to(VALUE self, gchar *filename, gchar *type, VALUE options)
328
284
  const_key = rb_id2name(SYM2ID(key));
329
285
  keys[i] = (gchar *)const_key;
330
286
  } else {
331
- keys[i] = RVAL2CSTR(key);
287
+ keys[i] = (gchar *)RVAL2CSTR(key);
332
288
  }
333
289
  value = rb_funcall(RARRAY_PTR(RARRAY_PTR(ary)[i])[1], to_s, 0);
334
- values[i] = RVAL2CSTR(value);
290
+ values[i] = (gchar *)RVAL2CSTR(value);
335
291
  }
336
292
  keys[len] = NULL;
337
293
  values[len] = NULL;
@@ -625,15 +581,8 @@ Init_gdk_pixbuf2()
625
581
  /*
626
582
  * The GdkPixbuf Structure
627
583
  */
628
- rb_define_method(gdkPixbuf, "colorspace", get_colorspace, 0);
629
- rb_define_method(gdkPixbuf, "n_channels", get_n_channels, 0);
630
- rb_define_method(gdkPixbuf, "has_alpha?", get_has_alpha, 0);
631
- rb_define_method(gdkPixbuf, "bits_per_sample", get_bits_per_sample, 0);
632
- rb_define_method(gdkPixbuf, "pixels", get_pixels, 0);
584
+ G_REPLACE_GET_PROPERTY(gdkPixbuf, "pixels", get_pixels, 0);
633
585
  rb_define_method(gdkPixbuf, "pixels=", set_pixels, 1);
634
- rb_define_method(gdkPixbuf, "width", get_width, 0);
635
- rb_define_method(gdkPixbuf, "height", get_height, 0);
636
- rb_define_method(gdkPixbuf, "rowstride", get_rowstride, 0);
637
586
  rb_define_method(gdkPixbuf, "get_option", get_option, 1);
638
587
 
639
588
  /* GdkPixbufError */
@@ -65,7 +65,7 @@ static VALUE
65
65
  pixdata_serialize(VALUE self)
66
66
  {
67
67
  guint stream_length;
68
- gint i;
68
+ guint i;
69
69
  guint8* ret = gdk_pixdata_serialize(_SELF(self), &stream_length);
70
70
  VALUE ary = rb_ary_new2(stream_length);
71
71
  for (i = 0; i < stream_length; i++) {
@@ -5,7 +5,7 @@ vendor_dir = base_dir + "vendor" + "local"
5
5
  vendor_bin_dir = vendor_dir + "bin"
6
6
  GLib.prepend_environment_path(vendor_bin_dir)
7
7
  begin
8
- major, minor, micro, = RUBY_VERSION.split(/\./)
8
+ major, minor, _ = RUBY_VERSION.split(/\./)
9
9
  require "#{major}.#{minor}/gdk_pixbuf2.so"
10
10
  rescue LoadError
11
11
  require "gdk_pixbuf2.so"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gdk_pixbuf2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - The Ruby-GNOME2 Proejct Team
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-13 00:00:00 Z
18
+ date: 2011-09-18 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: glib2
@@ -25,12 +25,12 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- hash: 23
28
+ hash: 21
29
29
  segments:
30
30
  - 1
31
31
  - 0
32
- - 0
33
- version: 1.0.0
32
+ - 1
33
+ version: 1.0.1
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  description: Ruby/GdkPixbuf2 is a Ruby binding of GdkPixbuf-2.x.