gtksourceview2 0.90.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/ChangeLog +57 -0
  2. data/README +29 -0
  3. data/Rakefile +14 -0
  4. data/ext/gtksourceview2/Makefile +162 -0
  5. data/ext/gtksourceview2/depend +5 -0
  6. data/ext/gtksourceview2/extconf.rb +73 -0
  7. data/ext/gtksourceview2/gtksourceview2.def +2 -0
  8. data/ext/gtksourceview2/gtksourceview2.so +0 -0
  9. data/ext/gtksourceview2/rbgtksourcebuffer.c +401 -0
  10. data/ext/gtksourceview2/rbgtksourcebuffer.o +0 -0
  11. data/ext/gtksourceview2/rbgtksourceiter.c +110 -0
  12. data/ext/gtksourceview2/rbgtksourceiter.o +0 -0
  13. data/ext/gtksourceview2/rbgtksourcelanguage.c +126 -0
  14. data/ext/gtksourceview2/rbgtksourcelanguage.o +0 -0
  15. data/ext/gtksourceview2/rbgtksourcelanguagemanager.c +188 -0
  16. data/ext/gtksourceview2/rbgtksourcelanguagemanager.o +0 -0
  17. data/ext/gtksourceview2/rbgtksourcemain.c +38 -0
  18. data/ext/gtksourceview2/rbgtksourcemain.h +32 -0
  19. data/ext/gtksourceview2/rbgtksourcemain.o +0 -0
  20. data/ext/gtksourceview2/rbgtksourcemark.c +90 -0
  21. data/ext/gtksourceview2/rbgtksourcemark.o +0 -0
  22. data/ext/gtksourceview2/rbgtksourceprintcompositor.c +249 -0
  23. data/ext/gtksourceview2/rbgtksourceprintcompositor.o +0 -0
  24. data/ext/gtksourceview2/rbgtksourcestyle.c +48 -0
  25. data/ext/gtksourceview2/rbgtksourcestyle.o +0 -0
  26. data/ext/gtksourceview2/rbgtksourcestylescheme.c +71 -0
  27. data/ext/gtksourceview2/rbgtksourcestylescheme.o +0 -0
  28. data/ext/gtksourceview2/rbgtksourcestyleschememanager.c +211 -0
  29. data/ext/gtksourceview2/rbgtksourcestyleschememanager.o +0 -0
  30. data/ext/gtksourceview2/rbgtksourceview.c +239 -0
  31. data/ext/gtksourceview2/rbgtksourceview.o +0 -0
  32. data/ext/gtksourceview2/rbgtksourceview2version.h +25 -0
  33. data/ext/gtksourceview2/ruby-gtksourceview2.pc +3 -0
  34. data/extconf.rb +49 -0
  35. data/lib/gtksourceview2.rb +2 -0
  36. data/sample/sourcelanguagemanager.rb +21 -0
  37. data/sample/test.rb +32 -0
  38. data/test/run-test.rb +33 -0
  39. data/test/test_source_view.rb +17 -0
  40. metadata +122 -0
@@ -0,0 +1,401 @@
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 $
8
+
9
+ Copyright (C) 2004,2005 Ruby-GNOME2 Project Team
10
+ Copyright (C) 2003 Geoff Youngs, based on gtktextview.c by Masao Mutoh
11
+ ************************************************/
12
+ #include "rbgtksourcemain.h"
13
+
14
+ /* Class: Gtk::SourceBuffer
15
+ * Text buffer object for Gtk::SourceView.
16
+ */
17
+
18
+ #define _SELF(self) (GTK_SOURCE_BUFFER(RVAL2GOBJ(self)))
19
+ #define RVAL2ITR(i) ((GtkTextIter*)RVAL2BOXED(i, GTK_TYPE_TEXT_ITER))
20
+
21
+ /*
22
+ * Class method: new(obj=nil)
23
+ * obj: either a Gtk::TextTagTable, a Gtk::SourceLanguage, or nil.
24
+ *
25
+ * Creates a new source buffer. If a Gtk::SourceTagTable is provided, the
26
+ * buffer will use it, otherwise it will create a new one.
27
+ *
28
+ * If a Gtk::SourceLanguage object is given, the buffer will be created
29
+ * using highlightings patterns in this language. This is equivalent to
30
+ * creating a new source buffer with the default tag table and then setting
31
+ * the 'language' property.
32
+ *
33
+ * Returns: a newly created Gtk::SourceBuffer object.
34
+ */
35
+ static VALUE
36
+ sourcebuffer_new (argc, argv, self)
37
+ int argc;
38
+ VALUE *argv;
39
+ VALUE self;
40
+ {
41
+ VALUE val;
42
+
43
+ rb_scan_args (argc, argv, "01", &val);
44
+ if (NIL_P (val)) {
45
+ G_INITIALIZE (self, gtk_source_buffer_new (NULL));
46
+ } else
47
+ if (rb_obj_is_kind_of
48
+ (val, GTYPE2CLASS (GTK_TYPE_TEXT_TAG_TABLE))) {
49
+ G_INITIALIZE (self,
50
+ gtk_source_buffer_new (GTK_TEXT_TAG_TABLE
51
+ (RVAL2GOBJ (val))));
52
+ } else
53
+ if (rb_obj_is_kind_of
54
+ (val, GTYPE2CLASS (GTK_TYPE_SOURCE_LANGUAGE))) {
55
+ G_INITIALIZE (self,
56
+ gtk_source_buffer_new_with_language
57
+ (GTK_SOURCE_LANGUAGE (RVAL2GOBJ (val))));
58
+ } else {
59
+ rb_raise (rb_eArgError,
60
+ "invalid argument %s (expect nil, Gtk::TextTagTable or Gtk::SourceLanguage)",
61
+ rb_class2name (CLASS_OF (val)));
62
+ }
63
+ return Qnil;
64
+ }
65
+
66
+ /* Defined as properties.
67
+ void gtk_source_buffer_set_highlight_syntax
68
+ (GtkSourceBuffer *buffer,
69
+ gboolean highlight);
70
+ gboolean gtk_source_buffer_get_highlight_syntax
71
+ (GtkSourceBuffer *buffer);
72
+ void gtk_source_buffer_set_language (GtkSourceBuffer *buffer,
73
+ GtkSourceLanguage *language);
74
+ GtkSourceLanguage* gtk_source_buffer_get_language (GtkSourceBuffer *buffer);
75
+ void gtk_source_buffer_set_highlight_matching_brackets
76
+ (GtkSourceBuffer *buffer,
77
+ gboolean highlight);
78
+ gboolean gtk_source_buffer_get_highlight_matching_brackets
79
+ (GtkSourceBuffer *buffer);
80
+ void gtk_source_buffer_set_style_scheme (GtkSourceBuffer *buffer,
81
+ GtkSourceStyleScheme *scheme);
82
+ GtkSourceStyleScheme* gtk_source_buffer_get_style_scheme
83
+ (GtkSourceBuffer *buffer);
84
+ gint gtk_source_buffer_get_max_undo_levels
85
+ (GtkSourceBuffer *buffer);
86
+ void gtk_source_buffer_set_max_undo_levels
87
+ (GtkSourceBuffer *buffer,
88
+ gint max_undo_levels);
89
+ gboolean gtk_source_buffer_can_redo (GtkSourceBuffer *buffer);
90
+ gboolean gtk_source_buffer_can_undo (GtkSourceBuffer *buffer);
91
+ */
92
+
93
+ /*
94
+ * Method: redo!
95
+ *
96
+ * Redoes the last undo operation. Use Gtk::SourceBuffer#can_redo? to check
97
+ * whether a call to this function will have any effect.
98
+ *
99
+ * Returns: self.
100
+ */
101
+ static VALUE
102
+ sourcebuffer_redo (self)
103
+ VALUE self;
104
+ {
105
+ gtk_source_buffer_redo (_SELF (self));
106
+ return self;
107
+ }
108
+
109
+ /*
110
+ * Method: undo!
111
+ *
112
+ * Undoes the last user action which modified the buffer.
113
+ * Use Gtk::SourceBuffer#can_undo? to check whether a call to this function
114
+ * will have any effect.
115
+ *
116
+ * Actions are defined as groups of operations between a call to
117
+ * Gtk::TextBuffer#begin_user_action and Gtk::TextBuffer#end_user_action,
118
+ * or sequences of similar edits (inserts or deletes) on the same line.
119
+ *
120
+ * Returns: self.
121
+ */
122
+ static VALUE
123
+ sourcebuffer_undo (self)
124
+ VALUE self;
125
+ {
126
+ gtk_source_buffer_undo (_SELF (self));
127
+ return self;
128
+ }
129
+
130
+ /*
131
+ * Method: begin_not_undoable_action
132
+ * Method: begin_not_undoable_action { ... }
133
+ *
134
+ * Marks the beginning of a not undoable action on the buffer, disabling the
135
+ * undo manager.
136
+ *
137
+ * If a block is given, the block is called after marking the beginning
138
+ * of a not undoable action on the buffer.
139
+ * At the end of the block, marks the end of a not undoable action on the
140
+ * buffer. When the last not undoable block is finished, the list of undo
141
+ * actions is cleared and the undo manager is re-enabled.
142
+ *
143
+ * Returns: self
144
+ */
145
+ static VALUE
146
+ sourcebuffer_begin_not_undoable_action(self)
147
+ VALUE self;
148
+ {
149
+ gtk_source_buffer_begin_not_undoable_action (_SELF (self));
150
+
151
+ if (rb_block_given_p()) {
152
+ VALUE block = rb_block_proc ();
153
+ rb_funcall (block, rb_intern ("call"), 0);
154
+ gtk_source_buffer_end_not_undoable_action (_SELF (self));
155
+ }
156
+ return self;
157
+ }
158
+
159
+ /*
160
+ * Method: end_not_undoable_action
161
+ *
162
+ * Marks the end of a not undoable action on the buffer.
163
+ * When the last not undoable block is finished, the list of undo
164
+ * actions is cleared and the undo manager is re-enabled.
165
+ *
166
+ * Returns: self
167
+ */
168
+ static VALUE
169
+ sourcebuffer_end_not_undoable_action(self)
170
+ VALUE self;
171
+ {
172
+ gtk_source_buffer_end_not_undoable_action (_SELF (self));
173
+ return self;
174
+ }
175
+
176
+
177
+ /*
178
+ * Method: not_undoable_action { ... }
179
+ *
180
+ * Marks the beginning of a not undoable action on the buffer, disabling the
181
+ * undo manager, then calls the provided block of code.
182
+ *
183
+ * At the end of the block, marks the end of a not undoable action on the
184
+ * buffer. When the last not undoable block is finished, the list of undo
185
+ * actions is cleared and the undo manager is re-enabled.
186
+ *
187
+ * ((*Deprecated*)). Use Gtk::SourceView#begin_not_undoable_action{ ... } instead.
188
+ *
189
+ * Returns: the return value of the provided block.
190
+ */
191
+ static VALUE
192
+ sourcebuffer_not_undoable_action (self)
193
+ VALUE self;
194
+ {
195
+ VALUE block, ret;
196
+
197
+ block = rb_block_proc ();
198
+ gtk_source_buffer_begin_not_undoable_action (_SELF (self));
199
+ ret = rb_funcall (block, rb_intern ("call"), 0);
200
+ gtk_source_buffer_end_not_undoable_action (_SELF (self));
201
+ return ret;
202
+ }
203
+
204
+ #ifdef HAVE_GTK_SOURCE_MARK_GET_TYPE
205
+ /*
206
+ * Method: create_source_mark(name=nil, category, where)
207
+ * name: the name of the mark.
208
+ * type: a string defining the mark type.
209
+ * where: a location to place the mark, as a Gtk::TreeIter object.
210
+ *
211
+ * Creates a mark in the buffer of the given type. A mark is semantically
212
+ * very similar to a Gtk::TextMark, except it has a type which is used by the
213
+ * Gtk::SourceView object displaying the buffer to show a pixmap on the left
214
+ * margin, at the line the mark is in. Because of this, a mark is generally
215
+ * associated to a line and not a character position. Marks are also
216
+ * accessible through a position or range in the buffer.
217
+ *
218
+ * Marks are implemented using Gtk::TextMark, so all characteristics and
219
+ * restrictions to marks apply to marks too. These includes life cycle issues
220
+ * and "mark-set" and "mark-deleted" signal emissions.
221
+ *
222
+ * Like a Gtk::TextMark, a Gtk::SourceMark can be anonymous if the passed
223
+ * name is nil.
224
+ *
225
+ * Marks always have left gravity and are moved to the beginning of the line
226
+ * when the user deletes the line they were in. Also, if the user deletes a
227
+ * region of text which contained lines with marks, those are deleted.
228
+ *
229
+ * Typical uses for a mark are bookmarks, breakpoints, current executing
230
+ * instruction indication in a source file, etc..
231
+ *
232
+ * Returns: a new Gtk::SourceMark object, owned by the buffer.
233
+ */
234
+ static VALUE
235
+ sourcebuffer_create_source_mark (argc, argv, self)
236
+ int argc;
237
+ VALUE *argv, self;
238
+ {
239
+ VALUE name, category, where;
240
+
241
+ if (argc == 2)
242
+ rb_scan_args (argc, argv, "21", &where, &category, &name);
243
+ else
244
+ rb_scan_args (argc, argv, "30", &name, &category, &where);
245
+
246
+ return GOBJ2RVAL (gtk_source_buffer_create_source_mark (_SELF (self),
247
+ RVAL2CSTR (name),
248
+ RVAL2CSTR (category),
249
+ RVAL2ITR (where)));
250
+ }
251
+
252
+ static VALUE
253
+ sourcebuffer_get_source_marks_at_line (argc, argv, self)
254
+ int argc;
255
+ VALUE *argv;
256
+ VALUE self;
257
+ {
258
+ GSList *list, *p;
259
+ VALUE line, category;
260
+ VALUE ary;
261
+
262
+ rb_scan_args (argc, argv, "11", &line, &category);
263
+
264
+ list =
265
+ gtk_source_buffer_get_source_marks_at_line (_SELF (self),
266
+ NUM2INT (line),
267
+ NIL_P (category) ? NULL : RVAL2CSTR (category));
268
+ ary = rb_ary_new ();
269
+
270
+ p = (GSList *) list;
271
+ while (p) {
272
+ rb_ary_push (ary, GOBJ2RVAL (p->data));
273
+ p = g_slist_next (p);
274
+ }
275
+
276
+ return ary;
277
+ }
278
+
279
+ static VALUE
280
+ sourcebuffer_get_source_marks_at_iter (argc, argv, self)
281
+ int argc;
282
+ VALUE *argv;
283
+ VALUE self;
284
+ {
285
+ GSList *list, *p;
286
+ VALUE iter, category;
287
+ VALUE ary;
288
+
289
+ rb_scan_args (argc, argv, "11", &iter, &category);
290
+
291
+ list =
292
+ gtk_source_buffer_get_source_marks_at_iter (_SELF (self),
293
+ RVAL2ITR (iter),
294
+ NIL_P (category) ? NULL : RVAL2CSTR (category));
295
+ ary = rb_ary_new ();
296
+
297
+ p = (GSList *) list;
298
+ while (p) {
299
+ rb_ary_push (ary, GOBJ2RVAL (p->data));
300
+ p = g_slist_next (p);
301
+ }
302
+
303
+ return ary;
304
+ }
305
+
306
+ static VALUE
307
+ sourcebuffer_remove_source_marks (argc, argv, self)
308
+ int argc;
309
+ VALUE *argv;
310
+ VALUE self;
311
+ {
312
+ VALUE start, end, category;
313
+
314
+ rb_scan_args (argc, argv, "21", &start, &end, &category);
315
+
316
+ gtk_source_buffer_remove_source_marks (_SELF (self),
317
+ RVAL2ITR (start),
318
+ RVAL2ITR (end),
319
+ NIL_P (category) ? NULL : RVAL2CSTR (category));
320
+
321
+ return self;
322
+ }
323
+
324
+ static VALUE
325
+ sourcebuffer_forward_iter_to_source_mark (argc, argv, self)
326
+ int argc;
327
+ VALUE *argv;
328
+ VALUE self;
329
+ {
330
+ VALUE iter, category;
331
+
332
+ rb_scan_args (argc, argv, "11", &iter, &category);
333
+
334
+ return
335
+ CBOOL2RVAL (gtk_source_buffer_forward_iter_to_source_mark
336
+ (_SELF (self), RVAL2ITR (iter),
337
+ NIL_P (category) ? NULL : RVAL2CSTR (category)));
338
+ }
339
+
340
+ static VALUE
341
+ sourcebuffer_backward_iter_to_source_mark (argc, argv, self)
342
+ int argc;
343
+ VALUE *argv;
344
+ VALUE self;
345
+ {
346
+ VALUE iter, category;
347
+
348
+ rb_scan_args (argc, argv, "11", &iter, &category);
349
+
350
+ return
351
+ CBOOL2RVAL (gtk_source_buffer_backward_iter_to_source_mark
352
+ (_SELF (self), RVAL2ITR (iter),
353
+ NIL_P (category) ? NULL : RVAL2CSTR (category)));
354
+ }
355
+
356
+ #endif /* HAVE_GTK_SOURCE_MARK_GET_TYPE */
357
+
358
+ static VALUE
359
+ sourcebuffer_ensure_highlight (self, start, end)
360
+ VALUE self, start, end;
361
+ {
362
+ gtk_source_buffer_ensure_highlight (_SELF (self), RVAL2ITR (start), RVAL2ITR (end));
363
+
364
+ return self;
365
+ }
366
+
367
+ void
368
+ Init_gtk_sourcebuffer ()
369
+ {
370
+ VALUE cbuffer =
371
+ G_DEF_CLASS (GTK_TYPE_SOURCE_BUFFER, "SourceBuffer", mGtk);
372
+
373
+ rb_define_method (cbuffer, "initialize", sourcebuffer_new, -1);
374
+ rb_define_method (cbuffer, "redo!", sourcebuffer_redo, 0);
375
+ rb_define_method (cbuffer, "undo!", sourcebuffer_undo, 0);
376
+ rb_define_method (cbuffer, "begin_not_undoable_action",
377
+ sourcebuffer_begin_not_undoable_action, 0);
378
+ rb_define_method (cbuffer, "end_not_undoable_action",
379
+ sourcebuffer_end_not_undoable_action, 0);
380
+ rb_define_method (cbuffer, "not_undoable_action",
381
+ sourcebuffer_not_undoable_action, 0);
382
+ rb_define_alias (cbuffer, "non_undoable_action", "not_undoable_action");
383
+ #ifdef HAVE_GTK_SOURCE_MARK_GET_TYPE
384
+ rb_define_method (cbuffer, "create_source_mark",
385
+ sourcebuffer_create_source_mark, -1);
386
+ rb_define_method (cbuffer, "get_source_marks_at_line",
387
+ sourcebuffer_get_source_marks_at_line, -1);
388
+ rb_define_method (cbuffer, "get_source_marks_at_iter",
389
+ sourcebuffer_get_source_marks_at_iter, -1);
390
+ rb_define_method (cbuffer, "remove_source_marks",
391
+ sourcebuffer_remove_source_marks, -1);
392
+ rb_define_method (cbuffer, "forward_iter_to_source_mark",
393
+ sourcebuffer_forward_iter_to_source_mark, -1);
394
+ rb_define_method (cbuffer, "backward_iter_to_source_mark",
395
+ sourcebuffer_backward_iter_to_source_mark, -1);
396
+ #endif
397
+ rb_define_method (cbuffer, "ensure_highlight",
398
+ sourcebuffer_ensure_highlight, 2);
399
+
400
+ G_DEF_SETTERS (cbuffer);
401
+ }
@@ -0,0 +1,110 @@
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 $
8
+
9
+ Copyright (C) 2004 Ruby-GNOME2 Project Team
10
+ ************************************************/
11
+ #include "rbgtksourcemain.h"
12
+
13
+ #define _SELF(s) ((GtkTextIter*)RVAL2BOXED(s, GTK_TYPE_TEXT_ITER))
14
+ #define ITR2RVAL(i) (BOXED2RVAL(i, GTK_TYPE_TEXT_ITER))
15
+
16
+ /* Method: forward_search(str, flags, limit)
17
+ * str: the search string (string)
18
+ * flags: flags affecting the search (Gtk::SourceSearchFlags)
19
+ * limit: location of last possible match start, or NULL for start of buffer
20
+ * Returns: locations of start and end of match.
21
+ */
22
+ static VALUE
23
+ forward_search (argc, argv, self)
24
+ int argc;
25
+ VALUE *argv;
26
+ VALUE self;
27
+ {
28
+ GtkTextIter m_start, m_end;
29
+ VALUE str, flags, limit;
30
+ VALUE ret = Qnil;
31
+
32
+ rb_scan_args (argc, argv, "21", &str, &flags, &limit);
33
+
34
+ if (rb_obj_is_kind_of
35
+ (flags, GTYPE2CLASS (GTK_TYPE_SOURCE_SEARCH_FLAGS))) {
36
+ if (gtk_source_iter_forward_search
37
+ (_SELF (self), RVAL2CSTR (str),
38
+ RVAL2GFLAGS (flags, GTK_TYPE_SOURCE_SEARCH_FLAGS),
39
+ &m_start, &m_end, NIL_P (limit) ? NULL : _SELF (limit)))
40
+ ret =
41
+ rb_ary_new3 (2, ITR2RVAL (&m_start),
42
+ ITR2RVAL (&m_end));
43
+ } else
44
+ if (rb_obj_is_kind_of
45
+ (flags, GTYPE2CLASS (GTK_TYPE_TEXT_SEARCH_FLAGS))) {
46
+ if (gtk_text_iter_forward_search
47
+ (_SELF (self), RVAL2CSTR (str),
48
+ RVAL2GFLAGS (flags, GTK_TYPE_TEXT_SEARCH_FLAGS), &m_start,
49
+ &m_end, NIL_P (limit) ? NULL : _SELF (limit)))
50
+ ret =
51
+ rb_ary_new3 (2, ITR2RVAL (&m_start),
52
+ ITR2RVAL (&m_end));
53
+ }
54
+ return ret;
55
+ }
56
+
57
+ /* Method: backward_search(str, flags, limit)
58
+ * str: the search string (string)
59
+ * flags: flags affecting the search (Gtk::SourceSearchFlags)
60
+ * limit: location of last possible match end, or NULL for end of buffer
61
+ * Returns: locations of start and end of match.
62
+ */
63
+ static VALUE
64
+ backward_search (argc, argv, self)
65
+ int argc;
66
+ VALUE *argv;
67
+ VALUE self;
68
+ {
69
+ GtkTextIter m_start, m_end;
70
+ VALUE str, flags, limit;
71
+ VALUE ret = Qnil;
72
+
73
+ rb_scan_args (argc, argv, "21", &str, &flags, &limit);
74
+ if (rb_obj_is_kind_of
75
+ (flags, GTYPE2CLASS (GTK_TYPE_SOURCE_SEARCH_FLAGS))) {
76
+ if (gtk_source_iter_backward_search
77
+ (_SELF (self), RVAL2CSTR (str),
78
+ RVAL2GFLAGS (flags, GTK_TYPE_SOURCE_SEARCH_FLAGS),
79
+ &m_start, &m_end, NIL_P (limit) ? NULL : _SELF (limit)))
80
+ ret =
81
+ rb_ary_new3 (2, ITR2RVAL (&m_start),
82
+ ITR2RVAL (&m_end));
83
+ } else
84
+ if (rb_obj_is_kind_of
85
+ (flags, GTYPE2CLASS (GTK_TYPE_TEXT_SEARCH_FLAGS))) {
86
+ if (gtk_text_iter_backward_search
87
+ (_SELF (self), RVAL2CSTR (str),
88
+ RVAL2GFLAGS (flags, GTK_TYPE_TEXT_SEARCH_FLAGS), &m_start,
89
+ &m_end, NIL_P (limit) ? NULL : _SELF (limit)))
90
+ ret =
91
+ rb_ary_new3 (2, ITR2RVAL (&m_start),
92
+ ITR2RVAL (&m_end));
93
+ }
94
+ return ret;
95
+ }
96
+
97
+ void
98
+ Init_gtk_sourceiter ()
99
+ {
100
+ VALUE cTextIter = GTYPE2CLASS (GTK_TYPE_TEXT_ITER);
101
+
102
+ /*
103
+ * They are override original Gtk::TextIter#[for|back]ward_search
104
+ */
105
+ rb_define_method (cTextIter, "forward_search", forward_search, -1);
106
+ rb_define_method (cTextIter, "backward_search", backward_search, -1);
107
+
108
+ G_DEF_CLASS(GTK_TYPE_SOURCE_SEARCH_FLAGS, "SourceSearchFlags", cTextIter);
109
+ G_DEF_CONSTANTS(cTextIter, GTK_TYPE_SOURCE_SEARCH_FLAGS, "GTK_");
110
+ }
@@ -0,0 +1,126 @@
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 $
8
+
9
+ Copyright (C) 2004 Ruby-GNOME2 Project Team
10
+ Copyright (C) 2003 Geoff Youngs, based on gtktextview.c by Masao Mutoh
11
+ ************************************************/
12
+ #include "rbgtksourcemain.h"
13
+
14
+ /* Class: Gtk::SourceLanguage
15
+ * Source language.
16
+ */
17
+
18
+ #define _SELF(self) (GTK_SOURCE_LANGUAGE(RVAL2GOBJ(self)))
19
+
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
+ /* Method: get_metadata(name)
28
+ * name: the metadata property name (string)
29
+ * Returns: the localized metadata for the given name.
30
+ */
31
+ static VALUE
32
+ sourcelanguage_get_metadata (self, name)
33
+ VALUE self, name;
34
+ {
35
+ return
36
+ CSTR2RVAL (gtk_source_language_get_metadata
37
+ (_SELF (self), RVAL2CSTR(name)));
38
+ }
39
+
40
+ /* Method: mime_types
41
+ * Returns: a list of mime types for the given language, as an array of strings.
42
+ */
43
+ static VALUE
44
+ sourcelanguage_get_mime_types (self)
45
+ VALUE self;
46
+ {
47
+ VALUE ary;
48
+ char **types = gtk_source_language_get_mime_types (_SELF (self));
49
+ if (!types)
50
+ return Qnil;
51
+
52
+ ary = rb_ary_new();
53
+ while (*types){
54
+ rb_ary_push(ary, CSTR2RVAL(*types));
55
+ types++;
56
+ }
57
+ return ary;
58
+ }
59
+
60
+ /* Method: globs
61
+ * Returns: a list of globs for the given language, as an array of strings.
62
+ */
63
+ static VALUE
64
+ sourcelanguage_get_globs (self)
65
+ VALUE self;
66
+ {
67
+ VALUE ary;
68
+ char **globs = gtk_source_language_get_globs (_SELF (self));
69
+ if (!globs)
70
+ return Qnil;
71
+
72
+ ary = rb_ary_new();
73
+ while (*globs){
74
+ rb_ary_push(ary, CSTR2RVAL(*globs));
75
+ globs++;
76
+ }
77
+ return ary;
78
+ }
79
+
80
+ /* Method: get_style_name(style_id)
81
+ * style_id: the style id (string)
82
+ * Returns: the localized style name of the given id.
83
+ */
84
+ static VALUE
85
+ sourcelanguage_get_style_name (self, style_id)
86
+ VALUE self, style_id;
87
+ {
88
+ return
89
+ CSTR2RVAL (gtk_source_language_get_style_name
90
+ (_SELF (self), RVAL2CSTR(style_id)));
91
+ }
92
+
93
+ /* Method: style_id
94
+ * Returns: the styles defined by the language.
95
+ */
96
+ static VALUE
97
+ sourcelanguage_get_style_ids (self)
98
+ VALUE self;
99
+ {
100
+ VALUE ary;
101
+ gchar **ids = gtk_source_language_get_style_ids (_SELF (self));
102
+ if (!ids)
103
+ return Qnil;
104
+
105
+ ary = rb_ary_new();
106
+ while (*ids){
107
+ rb_ary_push(ary, CSTR2RVAL(*ids));
108
+ ids++;
109
+ }
110
+ return ary;
111
+ }
112
+
113
+ void
114
+ Init_gtk_sourcelanguage ()
115
+ {
116
+ VALUE clang =
117
+ G_DEF_CLASS (GTK_TYPE_SOURCE_LANGUAGE, "SourceLanguage", mGtk);
118
+
119
+ rb_define_method (clang, "get_metadata", sourcelanguage_get_metadata, 1);
120
+ rb_define_method (clang, "mime_types", sourcelanguage_get_mime_types, 0);
121
+ rb_define_method (clang, "globs", sourcelanguage_get_globs, 0);
122
+ rb_define_method (clang, "get_style_name", sourcelanguage_get_style_name, 1);
123
+ rb_define_method (clang, "style_ids", sourcelanguage_get_style_ids, 0);
124
+
125
+ G_DEF_SETTERS (clang);
126
+ }