gphoto4ruby 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,12 @@
1
+ == 0.3.2
2
+
3
+ * Added setting and getting of GP_WIDGET_DATE type configs. Behavior is strange
4
+ though. In nikon D80 config name "time":
5
+ * libgphoto 2.4.2 -- able to read, but unable to set
6
+ * libgphoto 2.4.6 -- able to set, but when reading keep getting value 3 hours
7
+ earlier. For any camera time zone. But the value set is
8
+ correctly applied to exif. So can be used somehow
9
+
1
10
  == 0.3.1
2
11
 
3
12
  * Added files_count function and parameter allowing to limit files function
data/ext/gphoto2camera.c CHANGED
@@ -531,6 +531,9 @@ VALUE camera_get_config(int argc, VALUE *argv, VALUE self) {
531
531
  case GP_WIDGET_TOGGLE:
532
532
  rb_hash_aset(cfg, RARRAY(arr)->ptr[i], getToggle(c->childConfig));
533
533
  break;
534
+ case GP_WIDGET_DATE:
535
+ rb_hash_aset(cfg, RARRAY(arr)->ptr[i], getDate(c->childConfig));
536
+ break;
534
537
  default:
535
538
  break;
536
539
  }
@@ -606,6 +609,10 @@ VALUE camera_config_merge(VALUE self, VALUE hash) {
606
609
  rb_ary_push(cfg_changed, rb_str_new2(key));
607
610
  setToggle(self, c, rb_hash_aref(hash, RARRAY(arr)->ptr[i]), 0);
608
611
  break;
612
+ case GP_WIDGET_DATE:
613
+ rb_ary_push(cfg_changed, rb_str_new2(key));
614
+ setDate(self, c, rb_hash_aref(hash, RARRAY(arr)->ptr[i]), 0);
615
+ break;
609
616
  default:
610
617
  break;
611
618
  }
@@ -738,6 +745,20 @@ VALUE camera_get_value(int argc, VALUE *argv, VALUE self) {
738
745
  return Qnil;
739
746
  }
740
747
  break;
748
+ case GP_WIDGET_DATE:
749
+ if (strcmp(rb_id2name(rb_to_id(dir)), "no_cache") == 0) {
750
+ val = getDate(c->childConfig);
751
+ rb_hash_aset(rb_iv_get(self, "@configuration"), rb_str_new2(name), val);
752
+ return val;
753
+ } else if (strcmp(rb_id2name(rb_to_id(dir)), "all") == 0) {
754
+ return rb_ary_new();
755
+ } else if (strcmp(rb_id2name(rb_to_id(dir)), "type") == 0) {
756
+ return INT2FIX(GP_WIDGET_DATE);
757
+ } else {
758
+ rb_raise(rb_cGPhoto2ConfigurationError, "Unknown directive '%s'", rb_id2name(rb_to_id(dir)));
759
+ return Qnil;
760
+ }
761
+ break;
741
762
  default:
742
763
  rb_raise(rb_cGPhoto2ConfigurationError, "Not supported yet");
743
764
  return Qnil;
@@ -806,6 +827,11 @@ VALUE camera_set_value(VALUE self, VALUE str, VALUE newVal) {
806
827
  rb_ary_push(cfg_changed, rb_str_new2(name));
807
828
  return setToggle(self, c, newVal, 1);
808
829
  break;
830
+ case GP_WIDGET_DATE:
831
+ cfg_changed = rb_iv_get(self, "@configs_changed");
832
+ rb_ary_push(cfg_changed, rb_str_new2(name));
833
+ return setDate(self, c, newVal, 1);
834
+ break;
809
835
  default:
810
836
  rb_raise(rb_cGPhoto2ConfigurationError, "Cannot access this setting");
811
837
  return Qnil;
@@ -39,7 +39,11 @@ VALUE getRadio(CameraWidget *cc) {
39
39
  const char *val;
40
40
 
41
41
  gp_result_check(gp_widget_get_value(cc, &val));
42
- return rb_str_new2(val);
42
+ if (val == NULL) {
43
+ return Qnil;
44
+ } else {
45
+ return rb_str_new2(val);
46
+ }
43
47
  }
44
48
 
45
49
  VALUE listRadio(CameraWidget *cc) {
@@ -71,7 +75,11 @@ VALUE getText(CameraWidget *cc) {
71
75
  const char *val;
72
76
 
73
77
  gp_result_check(gp_widget_get_value(cc, &val));
74
- return rb_str_new2(val);
78
+ if (val == NULL) {
79
+ return Qnil;
80
+ } else {
81
+ return rb_str_new2(val);
82
+ }
75
83
  }
76
84
 
77
85
  VALUE setText(VALUE self, GPhoto2Camera *c, VALUE newVal, int save) {
@@ -165,6 +173,28 @@ VALUE setToggle(VALUE self, GPhoto2Camera *c, VALUE newVal, int save) {
165
173
  }
166
174
  }
167
175
 
176
+ VALUE getDate(CameraWidget *cc) {
177
+ int val;
178
+ char str[25];
179
+ gp_result_check(gp_widget_get_value(cc, &val));
180
+ // printf("got: %d\n",val);
181
+ sprintf(str, "Time.at(%d).utc", val);
182
+ return rb_eval_string(str);
183
+ }
184
+
185
+ VALUE setDate(VALUE self, GPhoto2Camera *c, VALUE newNum, int save) {
186
+ int val;
187
+
188
+ val = NUM2INT(rb_funcall(newNum, rb_intern("to_i"), 0));
189
+
190
+ // printf("setting: %d\n", val);
191
+ gp_result_check(gp_widget_set_value(c->childConfig, &val));
192
+ if (save == 1) {
193
+ saveConfigs(self, c);
194
+ }
195
+ return newNum;
196
+ }
197
+
168
198
  void saveConfigs(VALUE self, GPhoto2Camera *c) {
169
199
  VALUE cfgs, cfg_changed, name;
170
200
  CameraWidgetType widgettype;
@@ -191,6 +221,9 @@ void saveConfigs(VALUE self, GPhoto2Camera *c) {
191
221
  case GP_WIDGET_TOGGLE:
192
222
  rb_hash_aset(cfgs, name, getToggle(c->childConfig));
193
223
  break;
224
+ case GP_WIDGET_DATE:
225
+ rb_hash_aset(cfgs, name, getDate(c->childConfig));
226
+ break;
194
227
  default:
195
228
  break;
196
229
  }
@@ -222,6 +255,10 @@ void populateWithConfigs(CameraWidget *cc, VALUE hash) {
222
255
  gp_result_check(gp_widget_get_name(cc, &name));
223
256
  rb_hash_aset(hash, rb_str_new2(name), getToggle(cc));
224
257
  break;
258
+ case GP_WIDGET_DATE:
259
+ gp_result_check(gp_widget_get_name(cc, &name));
260
+ rb_hash_aset(hash, rb_str_new2(name), getDate(cc));
261
+ break;
225
262
  case GP_WIDGET_WINDOW:
226
263
  case GP_WIDGET_SECTION:
227
264
  childrenTotal = gp_result_check(gp_widget_count_children(cc));
@@ -53,6 +53,8 @@ VALUE listRange(CameraWidget *cc);
53
53
  VALUE setRange(VALUE self, GPhoto2Camera *c, VALUE newNum, int save);
54
54
  VALUE getToggle(CameraWidget *cc);
55
55
  VALUE setToggle(VALUE self, GPhoto2Camera *c, VALUE newVal, int save);
56
+ VALUE getDate(CameraWidget *cc);
57
+ VALUE setDate(VALUE self, GPhoto2Camera *c, VALUE newNum, int save);
56
58
  void saveConfigs(VALUE self, GPhoto2Camera *c);
57
59
 
58
60
  void populateWithConfigs(CameraWidget *cc, VALUE arr);
data/ext/gphoto4ruby.c CHANGED
@@ -61,6 +61,7 @@ void Init_gphoto4ruby() {
61
61
  rb_define_const(rb_cGPhoto2Camera, "CONFIG_TYPE_TEXT", INT2FIX(GP_WIDGET_TEXT));
62
62
  rb_define_const(rb_cGPhoto2Camera, "CONFIG_TYPE_RANGE", INT2FIX(GP_WIDGET_RANGE));
63
63
  rb_define_const(rb_cGPhoto2Camera, "CONFIG_TYPE_TOGGLE", INT2FIX(GP_WIDGET_TOGGLE));
64
+ rb_define_const(rb_cGPhoto2Camera, "CONFIG_TYPE_DATE", INT2FIX(GP_WIDGET_DATE));
64
65
 
65
66
  rb_define_const(rb_cGPhoto2CameraEvent, "EVENT_TYPE_UNKNOWN", EVENT_UNKNOWN);
66
67
  rb_define_const(rb_cGPhoto2CameraEvent, "EVENT_TYPE_TIMEOUT", EVENT_TIMEOUT);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gphoto4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - heq4 company
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-11-07 00:00:00 +03:00
13
+ date: 2009-06-11 00:00:00 +04:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  requirements: []
75
75
 
76
76
  rubyforge_project: gphoto4ruby
77
- rubygems_version: 1.3.0
77
+ rubygems_version: 1.2.0
78
78
  signing_key:
79
79
  specification_version: 2
80
80
  summary: GPhoto4Ruby is Ruby wrapping around gphoto2 C library