gtksourceview2 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,29 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbgtksourcebuffer.c -
5
-
6
- $Author: sakai $
7
- $Date: 2007/07/08 03:02:28 $
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2004,2005 Ruby-GNOME2 Project Team
5
+ * Copyright (C) 2003 Geoff Youngs, based on gtktextview.c by Masao Mutoh
6
+ *
7
+ * This library is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * This library is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with this library; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
+ * MA 02110-1301 USA
21
+ */
8
22
 
9
- Copyright (C) 2004,2005 Ruby-GNOME2 Project Team
10
- Copyright (C) 2003 Geoff Youngs, based on gtktextview.c by Masao Mutoh
11
- ************************************************/
12
23
  #include "rbgtksourcemain.h"
13
24
 
25
+ #define RG_TARGET_NAMESPACE cSourceBuffer
26
+
14
27
  /* Class: Gtk::SourceBuffer
15
28
  * Text buffer object for Gtk::SourceView.
16
29
  */
@@ -33,60 +46,33 @@
33
46
  * Returns: a newly created Gtk::SourceBuffer object.
34
47
  */
35
48
  static VALUE
36
- sourcebuffer_new(int argc, VALUE *argv, VALUE self)
49
+ rg_initialize(int argc, VALUE *argv, VALUE self)
37
50
  {
38
- VALUE val;
39
-
40
- rb_scan_args (argc, argv, "01", &val);
41
- if (NIL_P (val)) {
42
- G_INITIALIZE (self, gtk_source_buffer_new (NULL));
43
- } else
44
- if (rb_obj_is_kind_of
45
- (val, GTYPE2CLASS (GTK_TYPE_TEXT_TAG_TABLE))) {
46
- G_INITIALIZE (self,
47
- gtk_source_buffer_new (GTK_TEXT_TAG_TABLE
48
- (RVAL2GOBJ (val))));
49
- } else
50
- if (rb_obj_is_kind_of
51
- (val, GTYPE2CLASS (GTK_TYPE_SOURCE_LANGUAGE))) {
52
- G_INITIALIZE (self,
53
- gtk_source_buffer_new_with_language
54
- (GTK_SOURCE_LANGUAGE (RVAL2GOBJ (val))));
55
- } else {
56
- rb_raise (rb_eArgError,
57
- "invalid argument %s (expect nil, Gtk::TextTagTable or Gtk::SourceLanguage)",
58
- rb_class2name (CLASS_OF (val)));
59
- }
60
- return Qnil;
51
+ VALUE val;
52
+
53
+ rb_scan_args (argc, argv, "01", &val);
54
+ if (NIL_P (val)) {
55
+ G_INITIALIZE (self, gtk_source_buffer_new (NULL));
56
+ } else
57
+ if (rb_obj_is_kind_of
58
+ (val, GTYPE2CLASS (GTK_TYPE_TEXT_TAG_TABLE))) {
59
+ G_INITIALIZE (self,
60
+ gtk_source_buffer_new (GTK_TEXT_TAG_TABLE
61
+ (RVAL2GOBJ (val))));
62
+ } else
63
+ if (rb_obj_is_kind_of
64
+ (val, GTYPE2CLASS (GTK_TYPE_SOURCE_LANGUAGE))) {
65
+ G_INITIALIZE (self,
66
+ gtk_source_buffer_new_with_language
67
+ (GTK_SOURCE_LANGUAGE (RVAL2GOBJ (val))));
68
+ } else {
69
+ rb_raise (rb_eArgError,
70
+ "invalid argument %s (expect nil, Gtk::TextTagTable or Gtk::SourceLanguage)",
71
+ rb_class2name (CLASS_OF (val)));
72
+ }
73
+ return Qnil;
61
74
  }
62
75
 
63
- /* Defined as properties.
64
- void gtk_source_buffer_set_highlight_syntax
65
- (GtkSourceBuffer *buffer,
66
- gboolean highlight);
67
- gboolean gtk_source_buffer_get_highlight_syntax
68
- (GtkSourceBuffer *buffer);
69
- void gtk_source_buffer_set_language (GtkSourceBuffer *buffer,
70
- GtkSourceLanguage *language);
71
- GtkSourceLanguage* gtk_source_buffer_get_language (GtkSourceBuffer *buffer);
72
- void gtk_source_buffer_set_highlight_matching_brackets
73
- (GtkSourceBuffer *buffer,
74
- gboolean highlight);
75
- gboolean gtk_source_buffer_get_highlight_matching_brackets
76
- (GtkSourceBuffer *buffer);
77
- void gtk_source_buffer_set_style_scheme (GtkSourceBuffer *buffer,
78
- GtkSourceStyleScheme *scheme);
79
- GtkSourceStyleScheme* gtk_source_buffer_get_style_scheme
80
- (GtkSourceBuffer *buffer);
81
- gint gtk_source_buffer_get_max_undo_levels
82
- (GtkSourceBuffer *buffer);
83
- void gtk_source_buffer_set_max_undo_levels
84
- (GtkSourceBuffer *buffer,
85
- gint max_undo_levels);
86
- gboolean gtk_source_buffer_can_redo (GtkSourceBuffer *buffer);
87
- gboolean gtk_source_buffer_can_undo (GtkSourceBuffer *buffer);
88
- */
89
-
90
76
  /*
91
77
  * Method: redo!
92
78
  *
@@ -96,10 +82,10 @@ gboolean gtk_source_buffer_can_undo (GtkSourceBuffer *buffer
96
82
  * Returns: self.
97
83
  */
98
84
  static VALUE
99
- sourcebuffer_redo(VALUE self)
85
+ rg_redo_bang(VALUE self)
100
86
  {
101
- gtk_source_buffer_redo (_SELF (self));
102
- return self;
87
+ gtk_source_buffer_redo (_SELF (self));
88
+ return self;
103
89
  }
104
90
 
105
91
  /*
@@ -116,10 +102,10 @@ sourcebuffer_redo(VALUE self)
116
102
  * Returns: self.
117
103
  */
118
104
  static VALUE
119
- sourcebuffer_undo(VALUE self)
105
+ rg_undo_bang(VALUE self)
120
106
  {
121
- gtk_source_buffer_undo (_SELF (self));
122
- return self;
107
+ gtk_source_buffer_undo (_SELF (self));
108
+ return self;
123
109
  }
124
110
 
125
111
  /*
@@ -138,14 +124,14 @@ sourcebuffer_undo(VALUE self)
138
124
  * Returns: self
139
125
  */
140
126
  static VALUE
141
- sourcebuffer_begin_not_undoable_action(VALUE self)
127
+ rg_begin_not_undoable_action(VALUE self)
142
128
  {
143
129
  gtk_source_buffer_begin_not_undoable_action (_SELF (self));
144
130
 
145
131
  if (rb_block_given_p()) {
146
- VALUE block = rb_block_proc ();
147
- rb_funcall (block, rb_intern ("call"), 0);
148
- gtk_source_buffer_end_not_undoable_action (_SELF (self));
132
+ VALUE block = rb_block_proc ();
133
+ rb_funcall (block, rb_intern ("call"), 0);
134
+ gtk_source_buffer_end_not_undoable_action (_SELF (self));
149
135
  }
150
136
  return self;
151
137
  }
@@ -160,13 +146,12 @@ sourcebuffer_begin_not_undoable_action(VALUE self)
160
146
  * Returns: self
161
147
  */
162
148
  static VALUE
163
- sourcebuffer_end_not_undoable_action(VALUE self)
149
+ rg_end_not_undoable_action(VALUE self)
164
150
  {
165
151
  gtk_source_buffer_end_not_undoable_action (_SELF (self));
166
152
  return self;
167
153
  }
168
154
 
169
-
170
155
  /*
171
156
  * Method: not_undoable_action { ... }
172
157
  *
@@ -182,15 +167,15 @@ sourcebuffer_end_not_undoable_action(VALUE self)
182
167
  * Returns: the return value of the provided block.
183
168
  */
184
169
  static VALUE
185
- sourcebuffer_not_undoable_action(VALUE self)
170
+ rg_not_undoable_action(VALUE self)
186
171
  {
187
- VALUE block, ret;
172
+ VALUE block, ret;
188
173
 
189
- block = rb_block_proc ();
190
- gtk_source_buffer_begin_not_undoable_action (_SELF (self));
191
- ret = rb_funcall (block, rb_intern ("call"), 0);
192
- gtk_source_buffer_end_not_undoable_action (_SELF (self));
193
- return ret;
174
+ block = rb_block_proc ();
175
+ gtk_source_buffer_begin_not_undoable_action (_SELF (self));
176
+ ret = rb_funcall (block, rb_intern ("call"), 0);
177
+ gtk_source_buffer_end_not_undoable_action (_SELF (self));
178
+ return ret;
194
179
  }
195
180
 
196
181
  #ifdef HAVE_GTK_SOURCE_MARK_GET_TYPE
@@ -224,23 +209,23 @@ sourcebuffer_not_undoable_action(VALUE self)
224
209
  * Returns: a new Gtk::SourceMark object, owned by the buffer.
225
210
  */
226
211
  static VALUE
227
- sourcebuffer_create_source_mark(int argc, VALUE *argv, VALUE self)
212
+ rg_create_source_mark(int argc, VALUE *argv, VALUE self)
228
213
  {
229
- VALUE name, category, where;
214
+ VALUE name, category, where;
230
215
 
231
- if (argc == 2)
232
- rb_scan_args (argc, argv, "21", &where, &category, &name);
233
- else
234
- rb_scan_args (argc, argv, "30", &name, &category, &where);
216
+ if (argc == 2)
217
+ rb_scan_args (argc, argv, "21", &where, &category, &name);
218
+ else
219
+ rb_scan_args (argc, argv, "30", &name, &category, &where);
235
220
 
236
- return GOBJ2RVAL (gtk_source_buffer_create_source_mark (_SELF (self),
237
- RVAL2CSTR (name),
238
- RVAL2CSTR (category),
239
- RVAL2ITR (where)));
221
+ return GOBJ2RVAL (gtk_source_buffer_create_source_mark (_SELF (self),
222
+ RVAL2CSTR (name),
223
+ RVAL2CSTR (category),
224
+ RVAL2ITR (where)));
240
225
  }
241
226
 
242
227
  static VALUE
243
- sourcebuffer_get_source_marks_at_line(int argc, VALUE *argv, VALUE self)
228
+ rg_get_source_marks_at_line(int argc, VALUE *argv, VALUE self)
244
229
  {
245
230
  GSList *list, *p;
246
231
  VALUE line, category;
@@ -264,7 +249,7 @@ sourcebuffer_get_source_marks_at_line(int argc, VALUE *argv, VALUE self)
264
249
  }
265
250
 
266
251
  static VALUE
267
- sourcebuffer_get_source_marks_at_iter(int argc, VALUE *argv, VALUE self)
252
+ rg_get_source_marks_at_iter(int argc, VALUE *argv, VALUE self)
268
253
  {
269
254
  GSList *list, *p;
270
255
  VALUE iter, category;
@@ -288,7 +273,7 @@ sourcebuffer_get_source_marks_at_iter(int argc, VALUE *argv, VALUE self)
288
273
  }
289
274
 
290
275
  static VALUE
291
- sourcebuffer_remove_source_marks(int argc, VALUE *argv, VALUE self)
276
+ rg_remove_source_marks(int argc, VALUE *argv, VALUE self)
292
277
  {
293
278
  VALUE start, end, category;
294
279
 
@@ -303,7 +288,7 @@ sourcebuffer_remove_source_marks(int argc, VALUE *argv, VALUE self)
303
288
  }
304
289
 
305
290
  static VALUE
306
- sourcebuffer_forward_iter_to_source_mark(int argc, VALUE *argv, VALUE self)
291
+ rg_forward_iter_to_source_mark(int argc, VALUE *argv, VALUE self)
307
292
  {
308
293
  VALUE iter, category;
309
294
 
@@ -316,7 +301,7 @@ sourcebuffer_forward_iter_to_source_mark(int argc, VALUE *argv, VALUE self)
316
301
  }
317
302
 
318
303
  static VALUE
319
- sourcebuffer_backward_iter_to_source_mark(int argc, VALUE *argv, VALUE self)
304
+ rg_backward_iter_to_source_mark(int argc, VALUE *argv, VALUE self)
320
305
  {
321
306
  VALUE iter, category;
322
307
 
@@ -331,7 +316,7 @@ sourcebuffer_backward_iter_to_source_mark(int argc, VALUE *argv, VALUE self)
331
316
  #endif /* HAVE_GTK_SOURCE_MARK_GET_TYPE */
332
317
 
333
318
  static VALUE
334
- sourcebuffer_ensure_highlight(VALUE self, VALUE start, VALUE end)
319
+ rg_ensure_highlight(VALUE self, VALUE start, VALUE end)
335
320
  {
336
321
  gtk_source_buffer_ensure_highlight (_SELF (self), RVAL2ITR (start), RVAL2ITR (end));
337
322
 
@@ -339,37 +324,27 @@ sourcebuffer_ensure_highlight(VALUE self, VALUE start, VALUE end)
339
324
  }
340
325
 
341
326
  void
342
- Init_gtk_sourcebuffer ()
327
+ Init_gtk_sourcebuffer (VALUE mGtk)
343
328
  {
344
- VALUE cbuffer =
345
- G_DEF_CLASS (GTK_TYPE_SOURCE_BUFFER, "SourceBuffer", mGtk);
346
-
347
- rb_define_method (cbuffer, "initialize", sourcebuffer_new, -1);
348
- rb_define_method (cbuffer, "redo!", sourcebuffer_redo, 0);
349
- rb_define_method (cbuffer, "undo!", sourcebuffer_undo, 0);
350
- rb_define_method (cbuffer, "begin_not_undoable_action",
351
- sourcebuffer_begin_not_undoable_action, 0);
352
- rb_define_method (cbuffer, "end_not_undoable_action",
353
- sourcebuffer_end_not_undoable_action, 0);
354
- rb_define_method (cbuffer, "not_undoable_action",
355
- sourcebuffer_not_undoable_action, 0);
356
- rb_define_alias (cbuffer, "non_undoable_action", "not_undoable_action");
329
+ VALUE RG_TARGET_NAMESPACE =
330
+ G_DEF_CLASS (GTK_TYPE_SOURCE_BUFFER, "SourceBuffer", mGtk);
331
+
332
+ RG_DEF_METHOD(initialize, -1);
333
+ RG_DEF_METHOD_BANG(redo, 0);
334
+ RG_DEF_METHOD_BANG(undo, 0);
335
+ RG_DEF_METHOD(begin_not_undoable_action, 0);
336
+ RG_DEF_METHOD(end_not_undoable_action, 0);
337
+ RG_DEF_METHOD(not_undoable_action, 0);
338
+ RG_DEF_ALIAS("non_undoable_action", "not_undoable_action");
357
339
  #ifdef HAVE_GTK_SOURCE_MARK_GET_TYPE
358
- rb_define_method (cbuffer, "create_source_mark",
359
- sourcebuffer_create_source_mark, -1);
360
- rb_define_method (cbuffer, "get_source_marks_at_line",
361
- sourcebuffer_get_source_marks_at_line, -1);
362
- rb_define_method (cbuffer, "get_source_marks_at_iter",
363
- sourcebuffer_get_source_marks_at_iter, -1);
364
- rb_define_method (cbuffer, "remove_source_marks",
365
- sourcebuffer_remove_source_marks, -1);
366
- rb_define_method (cbuffer, "forward_iter_to_source_mark",
367
- sourcebuffer_forward_iter_to_source_mark, -1);
368
- rb_define_method (cbuffer, "backward_iter_to_source_mark",
369
- sourcebuffer_backward_iter_to_source_mark, -1);
340
+ RG_DEF_METHOD(create_source_mark, -1);
341
+ RG_DEF_METHOD(get_source_marks_at_line, -1);
342
+ RG_DEF_METHOD(get_source_marks_at_iter, -1);
343
+ RG_DEF_METHOD(remove_source_marks, -1);
344
+ RG_DEF_METHOD(forward_iter_to_source_mark, -1);
345
+ RG_DEF_METHOD(backward_iter_to_source_mark, -1);
370
346
  #endif
371
- rb_define_method (cbuffer, "ensure_highlight",
372
- sourcebuffer_ensure_highlight, 2);
347
+ RG_DEF_METHOD(ensure_highlight, 2);
373
348
 
374
- G_DEF_SETTERS (cbuffer);
349
+ G_DEF_SETTERS (RG_TARGET_NAMESPACE);
375
350
  }
@@ -1,15 +1,27 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbgtksourceiter.c -
5
-
6
- $Author: mutoh $
7
- $Date: 2005/01/03 15:33:56 $
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2004 Ruby-GNOME2 Project Team
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
+ */
8
21
 
9
- Copyright (C) 2004 Ruby-GNOME2 Project Team
10
- ************************************************/
11
22
  #include "rbgtksourcemain.h"
12
23
 
24
+ #define RG_TARGET_NAMESPACE cTextIter
13
25
  #define _SELF(s) ((GtkTextIter*)RVAL2BOXED(s, GTK_TYPE_TEXT_ITER))
14
26
  #define ITR2RVAL(i) (BOXED2RVAL(i, GTK_TYPE_TEXT_ITER))
15
27
 
@@ -20,35 +32,35 @@
20
32
  * Returns: locations of start and end of match.
21
33
  */
22
34
  static VALUE
23
- forward_search(int argc, VALUE *argv, VALUE self)
35
+ rg_forward_search(int argc, VALUE *argv, VALUE self)
24
36
  {
25
- GtkTextIter m_start, m_end;
26
- VALUE str, flags, limit;
27
- VALUE ret = Qnil;
37
+ GtkTextIter m_start, m_end;
38
+ VALUE str, flags, limit;
39
+ VALUE ret = Qnil;
28
40
 
29
- rb_scan_args (argc, argv, "21", &str, &flags, &limit);
41
+ rb_scan_args (argc, argv, "21", &str, &flags, &limit);
30
42
 
31
- if (rb_obj_is_kind_of
32
- (flags, GTYPE2CLASS (GTK_TYPE_SOURCE_SEARCH_FLAGS))) {
33
- if (gtk_source_iter_forward_search
34
- (_SELF (self), RVAL2CSTR (str),
35
- RVAL2GFLAGS (flags, GTK_TYPE_SOURCE_SEARCH_FLAGS),
36
- &m_start, &m_end, NIL_P (limit) ? NULL : _SELF (limit)))
37
- ret =
38
- rb_ary_new3 (2, ITR2RVAL (&m_start),
39
- ITR2RVAL (&m_end));
40
- } else
41
- if (rb_obj_is_kind_of
42
- (flags, GTYPE2CLASS (GTK_TYPE_TEXT_SEARCH_FLAGS))) {
43
- if (gtk_text_iter_forward_search
44
- (_SELF (self), RVAL2CSTR (str),
45
- RVAL2GFLAGS (flags, GTK_TYPE_TEXT_SEARCH_FLAGS), &m_start,
46
- &m_end, NIL_P (limit) ? NULL : _SELF (limit)))
47
- ret =
48
- rb_ary_new3 (2, ITR2RVAL (&m_start),
49
- ITR2RVAL (&m_end));
50
- }
51
- return ret;
43
+ if (rb_obj_is_kind_of
44
+ (flags, GTYPE2CLASS (GTK_TYPE_SOURCE_SEARCH_FLAGS))) {
45
+ if (gtk_source_iter_forward_search
46
+ (_SELF (self), RVAL2CSTR (str),
47
+ RVAL2GFLAGS (flags, GTK_TYPE_SOURCE_SEARCH_FLAGS),
48
+ &m_start, &m_end, NIL_P (limit) ? NULL : _SELF (limit)))
49
+ ret =
50
+ rb_ary_new3 (2, ITR2RVAL (&m_start),
51
+ ITR2RVAL (&m_end));
52
+ } else
53
+ if (rb_obj_is_kind_of
54
+ (flags, GTYPE2CLASS (GTK_TYPE_TEXT_SEARCH_FLAGS))) {
55
+ if (gtk_text_iter_forward_search
56
+ (_SELF (self), RVAL2CSTR (str),
57
+ RVAL2GFLAGS (flags, GTK_TYPE_TEXT_SEARCH_FLAGS), &m_start,
58
+ &m_end, NIL_P (limit) ? NULL : _SELF (limit)))
59
+ ret =
60
+ rb_ary_new3 (2, ITR2RVAL (&m_start),
61
+ ITR2RVAL (&m_end));
62
+ }
63
+ return ret;
52
64
  }
53
65
 
54
66
  /* Method: backward_search(str, flags, limit)
@@ -58,47 +70,47 @@ forward_search(int argc, VALUE *argv, VALUE self)
58
70
  * Returns: locations of start and end of match.
59
71
  */
60
72
  static VALUE
61
- backward_search(int argc, VALUE *argv, VALUE self)
73
+ rg_backward_search(int argc, VALUE *argv, VALUE self)
62
74
  {
63
- GtkTextIter m_start, m_end;
64
- VALUE str, flags, limit;
65
- VALUE ret = Qnil;
75
+ GtkTextIter m_start, m_end;
76
+ VALUE str, flags, limit;
77
+ VALUE ret = Qnil;
66
78
 
67
- rb_scan_args (argc, argv, "21", &str, &flags, &limit);
68
- if (rb_obj_is_kind_of
69
- (flags, GTYPE2CLASS (GTK_TYPE_SOURCE_SEARCH_FLAGS))) {
70
- if (gtk_source_iter_backward_search
71
- (_SELF (self), RVAL2CSTR (str),
72
- RVAL2GFLAGS (flags, GTK_TYPE_SOURCE_SEARCH_FLAGS),
73
- &m_start, &m_end, NIL_P (limit) ? NULL : _SELF (limit)))
74
- ret =
75
- rb_ary_new3 (2, ITR2RVAL (&m_start),
76
- ITR2RVAL (&m_end));
77
- } else
78
- if (rb_obj_is_kind_of
79
- (flags, GTYPE2CLASS (GTK_TYPE_TEXT_SEARCH_FLAGS))) {
80
- if (gtk_text_iter_backward_search
81
- (_SELF (self), RVAL2CSTR (str),
82
- RVAL2GFLAGS (flags, GTK_TYPE_TEXT_SEARCH_FLAGS), &m_start,
83
- &m_end, NIL_P (limit) ? NULL : _SELF (limit)))
84
- ret =
85
- rb_ary_new3 (2, ITR2RVAL (&m_start),
86
- ITR2RVAL (&m_end));
87
- }
88
- return ret;
79
+ rb_scan_args (argc, argv, "21", &str, &flags, &limit);
80
+ if (rb_obj_is_kind_of
81
+ (flags, GTYPE2CLASS (GTK_TYPE_SOURCE_SEARCH_FLAGS))) {
82
+ if (gtk_source_iter_backward_search
83
+ (_SELF (self), RVAL2CSTR (str),
84
+ RVAL2GFLAGS (flags, GTK_TYPE_SOURCE_SEARCH_FLAGS),
85
+ &m_start, &m_end, NIL_P (limit) ? NULL : _SELF (limit)))
86
+ ret =
87
+ rb_ary_new3 (2, ITR2RVAL (&m_start),
88
+ ITR2RVAL (&m_end));
89
+ } else
90
+ if (rb_obj_is_kind_of
91
+ (flags, GTYPE2CLASS (GTK_TYPE_TEXT_SEARCH_FLAGS))) {
92
+ if (gtk_text_iter_backward_search
93
+ (_SELF (self), RVAL2CSTR (str),
94
+ RVAL2GFLAGS (flags, GTK_TYPE_TEXT_SEARCH_FLAGS), &m_start,
95
+ &m_end, NIL_P (limit) ? NULL : _SELF (limit)))
96
+ ret =
97
+ rb_ary_new3 (2, ITR2RVAL (&m_start),
98
+ ITR2RVAL (&m_end));
99
+ }
100
+ return ret;
89
101
  }
90
102
 
91
103
  void
92
- Init_gtk_sourceiter ()
104
+ Init_gtk_sourceiter (VALUE mGtk)
93
105
  {
94
- VALUE cTextIter = GTYPE2CLASS (GTK_TYPE_TEXT_ITER);
106
+ VALUE RG_TARGET_NAMESPACE = GTYPE2CLASS (GTK_TYPE_TEXT_ITER);
95
107
 
96
- /*
97
- * They are override original Gtk::TextIter#[for|back]ward_search
98
- */
99
- rb_define_method (cTextIter, "forward_search", forward_search, -1);
100
- rb_define_method (cTextIter, "backward_search", backward_search, -1);
108
+ /*
109
+ * They are override original Gtk::TextIter#[for|back]ward_search
110
+ */
111
+ RG_DEF_METHOD(forward_search, -1);
112
+ RG_DEF_METHOD(backward_search, -1);
101
113
 
102
- G_DEF_CLASS(GTK_TYPE_SOURCE_SEARCH_FLAGS, "SourceSearchFlags", cTextIter);
103
- G_DEF_CONSTANTS(cTextIter, GTK_TYPE_SOURCE_SEARCH_FLAGS, "GTK_");
114
+ G_DEF_CLASS(GTK_TYPE_SOURCE_SEARCH_FLAGS, "SourceSearchFlags", RG_TARGET_NAMESPACE);
115
+ G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GTK_TYPE_SOURCE_SEARCH_FLAGS, "GTK_");
104
116
  }
@@ -1,49 +1,54 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbgtksourcelanguage.c -
5
-
6
- $Author: mutoh $
7
- $Date: 2005/10/02 18:40:34 $
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2004 Ruby-GNOME2 Project Team
5
+ * Copyright (C) 2003 Geoff Youngs, based on gtktextview.c by Masao Mutoh
6
+ *
7
+ * This library is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * This library is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with this library; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
+ * MA 02110-1301 USA
21
+ */
8
22
 
9
- Copyright (C) 2004 Ruby-GNOME2 Project Team
10
- Copyright (C) 2003 Geoff Youngs, based on gtktextview.c by Masao Mutoh
11
- ************************************************/
12
23
  #include "rbgtksourcemain.h"
13
24
 
14
25
  /* Class: Gtk::SourceLanguage
15
26
  * Source language.
16
27
  */
17
28
 
29
+ #define RG_TARGET_NAMESPACE cSourceLanguage
18
30
  #define _SELF(self) (GTK_SOURCE_LANGUAGE(RVAL2GOBJ(self)))
19
31
 
20
- /* Defined as properties.
21
- const gchar* gtk_source_language_get_id (GtkSourceLanguage *language);
22
- const gchar* gtk_source_language_get_name (GtkSourceLanguage *language);
23
- const gchar* gtk_source_language_get_section (GtkSourceLanguage *language);
24
- gboolean gtk_source_language_get_hidden (GtkSourceLanguage *language);
25
- */
26
-
27
32
  /* Method: get_metadata(name)
28
33
  * name: the metadata property name (string)
29
34
  * Returns: the localized metadata for the given name.
30
35
  */
31
36
  static VALUE
32
- sourcelanguage_get_metadata(VALUE self, VALUE name)
37
+ rg_get_metadata(VALUE self, VALUE name)
33
38
  {
34
- return
35
- CSTR2RVAL (gtk_source_language_get_metadata
36
- (_SELF (self), RVAL2CSTR(name)));
39
+ return
40
+ CSTR2RVAL (gtk_source_language_get_metadata
41
+ (_SELF (self), RVAL2CSTR(name)));
37
42
  }
38
43
 
39
44
  /* Method: mime_types
40
45
  * Returns: a list of mime types for the given language, as an array of strings.
41
46
  */
42
47
  static VALUE
43
- sourcelanguage_get_mime_types(VALUE self)
48
+ rg_mime_types(VALUE self)
44
49
  {
45
- VALUE ary;
46
- char **types = gtk_source_language_get_mime_types (_SELF (self));
50
+ VALUE ary;
51
+ char **types = gtk_source_language_get_mime_types (_SELF (self));
47
52
  if (!types)
48
53
  return Qnil;
49
54
 
@@ -59,10 +64,10 @@ sourcelanguage_get_mime_types(VALUE self)
59
64
  * Returns: a list of globs for the given language, as an array of strings.
60
65
  */
61
66
  static VALUE
62
- sourcelanguage_get_globs(VALUE self)
67
+ rg_globs(VALUE self)
63
68
  {
64
- VALUE ary;
65
- char **globs = gtk_source_language_get_globs (_SELF (self));
69
+ VALUE ary;
70
+ char **globs = gtk_source_language_get_globs (_SELF (self));
66
71
  if (!globs)
67
72
  return Qnil;
68
73
 
@@ -79,21 +84,21 @@ sourcelanguage_get_globs(VALUE self)
79
84
  * Returns: the localized style name of the given id.
80
85
  */
81
86
  static VALUE
82
- sourcelanguage_get_style_name(VALUE self, VALUE style_id)
87
+ rg_get_style_name(VALUE self, VALUE style_id)
83
88
  {
84
- return
85
- CSTR2RVAL (gtk_source_language_get_style_name
86
- (_SELF (self), RVAL2CSTR(style_id)));
89
+ return
90
+ CSTR2RVAL (gtk_source_language_get_style_name
91
+ (_SELF (self), RVAL2CSTR(style_id)));
87
92
  }
88
93
 
89
94
  /* Method: style_id
90
95
  * Returns: the styles defined by the language.
91
96
  */
92
97
  static VALUE
93
- sourcelanguage_get_style_ids(VALUE self)
98
+ rg_style_ids(VALUE self)
94
99
  {
95
- VALUE ary;
96
- gchar **ids = gtk_source_language_get_style_ids (_SELF (self));
100
+ VALUE ary;
101
+ gchar **ids = gtk_source_language_get_style_ids (_SELF (self));
97
102
  if (!ids)
98
103
  return Qnil;
99
104
 
@@ -106,16 +111,16 @@ sourcelanguage_get_style_ids(VALUE self)
106
111
  }
107
112
 
108
113
  void
109
- Init_gtk_sourcelanguage ()
114
+ Init_gtk_sourcelanguage (VALUE mGtk)
110
115
  {
111
- VALUE clang =
112
- G_DEF_CLASS (GTK_TYPE_SOURCE_LANGUAGE, "SourceLanguage", mGtk);
116
+ VALUE RG_TARGET_NAMESPACE =
117
+ G_DEF_CLASS (GTK_TYPE_SOURCE_LANGUAGE, "SourceLanguage", mGtk);
113
118
 
114
- rb_define_method (clang, "get_metadata", sourcelanguage_get_metadata, 1);
115
- rb_define_method (clang, "mime_types", sourcelanguage_get_mime_types, 0);
116
- rb_define_method (clang, "globs", sourcelanguage_get_globs, 0);
117
- rb_define_method (clang, "get_style_name", sourcelanguage_get_style_name, 1);
118
- rb_define_method (clang, "style_ids", sourcelanguage_get_style_ids, 0);
119
+ RG_DEF_METHOD(get_metadata, 1);
120
+ RG_DEF_METHOD(mime_types, 0);
121
+ RG_DEF_METHOD(globs, 0);
122
+ RG_DEF_METHOD(get_style_name, 1);
123
+ RG_DEF_METHOD(style_ids, 0);
119
124
 
120
- G_DEF_SETTERS (clang);
125
+ G_DEF_SETTERS (RG_TARGET_NAMESPACE);
121
126
  }