Develop and Download Open Source Software

Browse CVS Repository

Annotation of /shiki/shiki/buffer.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.11 - (hide annotations) (download) (as text)
Wed Nov 29 14:58:27 2006 UTC (17 years, 4 months ago) by aloha
Branch: MAIN
Changes since 1.10: +11 -15 lines
File MIME type: text/x-csrc
add customization feature of modeline (and add related some API)

1 aloha 1.1 /* vim: set encoding=utf8:
2     *
3     * buffer.c
4     *
5     * This file is part of Shiki.
6     *
7     * Copyright(C)2006 WAKATSUKI toshihiro
8     *
9     * Permission is hereby granted, free of charge, to any person obtaining a
10     * copy of this software and associated documentation files (the "Software"),
11     * to deal in the Software without restriction, including without limitation
12     * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13     * and/or sell copies of the Software, and to permit persons to whom the
14     * Software is furnished to do so, subject to the following conditions:
15     *
16     * The above copyright notice and this permission notice shall be included in
17     * all copies or substantial portions of the Software.
18     *
19     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25     * SOFTWARE.
26     *
27 aloha 1.11 * $Id: buffer.c,v 1.10 2006/11/29 05:08:46 aloha Exp $
28 aloha 1.1 */
29     #include"shiki.h"
30 aloha 1.2
31 aloha 1.9 ScmClass *ShikiBufferClass;
32     extern void Scm_Init_xyzzylisp(ScmModule *module);
33    
34 aloha 1.7 /* GtkTextBuffer ��������������������� ShikiBuffer ��������������������� */
35     static gint compBuffer(gconstpointer a, gconstpointer b) {
36     return ((ShikiBuffer *)a)->text_buffer == b ? 0 : b - a;
37     }
38 aloha 1.3
39 aloha 1.7 static GList *get_ShikiBufferListElement_By_GtkTextBuffer(GtkTextBuffer *b) {
40     return g_list_find_custom(Shiki_EDITOR_BUFFER_LIST, b, compBuffer);
41 aloha 1.3 }
42 aloha 1.4
43 aloha 1.9 static void buffer_print(ScmObj obj, ScmPort *out, ScmWriteContext *ctx) {
44     GtkTextBuffer *b = SHIKI_BUFFER_UNBOX(obj);
45     GList *l = g_list_find_custom(Shiki_EDITOR_BUFFER_LIST, b, compBuffer);
46     if(l)
47     Scm_Printf(out, "#<buffer: %s>", ((ShikiBuffer *)(l->data))->name);
48     else
49     Scm_Printf(out, "#<deleted buffer: %p>", b);
50     }
51    
52     static void buffer_cleanup(ScmObj obj)
53     {
54     g_object_unref(SHIKI_BUFFER_UNBOX(obj));
55     }
56    
57     /* ������������������������������������������������������������������������������������������ */
58     static gboolean delete_event_handler(GtkWidget *widget, GdkEvent *event, GtkTextBuffer *buffer){
59     /* delete-event ������������������������FALSE ��������������������������������������������� */
60     return Shiki_need_buffer_save_p(buffer) && !Shiki_yes_or_no_p("��������������������������������������������������������������������������� ?");
61     }
62    
63     /* ��������������������������������������������� */
64     static void insert_text_handler(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *str, gint len) {
65     /* Undo ��������������������������� */
66     ShikiUndoInfo *undoInfo = g_malloc(sizeof(ShikiUndoInfo));
67     g_return_if_fail(undoInfo != NULL);
68     undoInfo->action = SHIKI_UNDO_INSERT;
69     undoInfo->str = g_strdup(str);
70     undoInfo->strlen = len;
71     undoInfo->start = gtk_text_iter_get_offset(iter);
72     undoInfo->end = undoInfo->start + undoInfo->strlen;
73     Shiki_CURRENT_UNDO_INFO_LIST = g_list_prepend(Shiki_CURRENT_UNDO_INFO_LIST, undoInfo);
74     }
75    
76     /* ��������������������������������������������������������������� */
77 aloha 1.11 void Shiki_update_modeline(GtkTextBuffer *buffer) {
78     gtk_label_set_text(GTK_LABEL(Shiki_EDITOR_MODELINE_LABEL), Scm_GetString(SCM_STRING(Scm_EvalCString("(if *mode-line-format* (*mode-line-format*) \"\")", Shiki_CURRENT_BUFFER_ENV))));
79 aloha 1.9 }
80    
81     /* ������������������������������������������������ */
82     static void delete_range_handler(GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end) {
83     /* Undo ��������������������������� */
84     ShikiUndoInfo *undoInfo = g_malloc(sizeof(ShikiUndoInfo));
85     g_return_if_fail(undoInfo != NULL);
86     undoInfo->action = SHIKI_UNDO_DELETE;
87     undoInfo->str = gtk_text_buffer_get_text(buffer, start, end, FALSE);
88     undoInfo->start = gtk_text_iter_get_offset(start);
89     undoInfo->end = gtk_text_iter_get_offset(end);
90     undoInfo->strlen = end - start;
91     Shiki_CURRENT_UNDO_INFO_LIST = g_list_prepend(Shiki_CURRENT_UNDO_INFO_LIST, undoInfo);
92     }
93    
94 aloha 1.11 static void cursor_moved_handler() {
95     Shiki_update_modeline(Shiki_CURRENT_TEXT_BUFFER);
96     }
97    
98 aloha 1.9 /* ��������������������������������������� (������������) ��������� */
99     GtkTextBuffer *Shiki_new_buffer_create(gchar *filename) {
100     /*-------------------- ������������������������ ----------------------------------*/
101     /* ShikiBuffer ������������������������������������������������������������������ */
102     ShikiBuffer *tabinfo = g_malloc(sizeof(ShikiBuffer));
103     tabinfo->locale = "Gtk Default (utf8)";
104     tabinfo->undoInfoList = NULL;
105     tabinfo->filename = filename;
106     tabinfo->name = g_path_get_basename(filename);
107 aloha 1.10 tabinfo->tabpage_label = g_strndup(tabinfo->name, 10);
108 aloha 1.9 tabinfo->env = Scm_MakeModule(NULL, FALSE);
109    
110     ShikiBufferClass = Scm_MakeForeignPointerClass(SCM_MODULE(tabinfo->env),
111     "<buffer>", buffer_print, buffer_cleanup,
112     SCM_FOREIGN_POINTER_KEEP_IDENTITY
113     |
114     SCM_FOREIGN_POINTER_MAP_NULL);
115    
116     /* xyzzy lisp ��������������� */
117     Scm_Init_xyzzylisp(SCM_MODULE(tabinfo->env));
118    
119     /* ������������������������������ (������������������������) ��������� */
120     tabinfo->tabpage = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL));
121     gtk_scrolled_window_set_policy (tabinfo->tabpage, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
122    
123     /* ��������������������������������������������������������������������������������������� */
124     tabinfo->text_view = GTK_TEXT_VIEW(gtk_text_view_new());
125     gtk_text_view_set_wrap_mode(tabinfo->text_view, GTK_WRAP_WORD);
126     tabinfo->text_buffer = gtk_text_view_get_buffer(tabinfo->text_view);
127     gtk_widget_set_size_request(GTK_WIDGET(tabinfo->text_view), 680, 700);
128    
129     gtk_container_add(GTK_CONTAINER(tabinfo->tabpage), GTK_WIDGET(tabinfo->text_view));
130 aloha 1.11 g_signal_connect(tabinfo->text_buffer, "mark_set", G_CALLBACK(cursor_moved_handler), tabinfo->text_view);
131 aloha 1.9 g_signal_connect(tabinfo->text_buffer, "insert-text", G_CALLBACK(insert_text_handler), NULL);
132     g_signal_connect(tabinfo->text_buffer, "delete-range", G_CALLBACK(delete_range_handler), NULL);
133    
134     /* ������������������������������������������������������������������������������������������������������ */
135     tabinfo->delete_handler_id = g_signal_connect(Shiki_EDITOR_WINDOW, "delete_event", G_CALLBACK(delete_event_handler), tabinfo->text_buffer);
136    
137     /* ������������������������ */
138    
139     /* ������������������������������������������������ */
140     gtk_text_buffer_create_tag(tabinfo->text_buffer, "parent_emphasis_background", "background", "green", NULL);
141    
142     /* ������������������������������������������ */
143     gtk_text_buffer_create_tag(tabinfo->text_buffer, "keyword_highlighting", "foreground", "blue", NULL);
144     /* ������ */
145     gtk_text_buffer_create_tag(tabinfo->text_buffer, "function_highlighting", "foreground", "red", NULL);
146     /* ������������ */
147     gtk_text_buffer_create_tag (tabinfo->text_buffer, "comment_highlighting", "foreground", "purple", NULL);
148     /* ��������� */
149     gtk_text_buffer_create_tag (tabinfo->text_buffer, "string_highlighting", "foreground", "orange", NULL);
150     /* ������������������������������������������ */
151     gtk_notebook_append_page(Shiki_EDITOR_NOTEBOOK, GTK_WIDGET(tabinfo->tabpage), gtk_label_new(tabinfo->tabpage_label));
152     /* ������������������������������������������������������������������ */
153     Shiki_EDITOR_BUFFER_LIST = g_list_append(Shiki_EDITOR_BUFFER_LIST, tabinfo);
154    
155     gtk_widget_show_all(GTK_WIDGET(Shiki_EDITOR_NOTEBOOK));
156     /* ��������������������������������� */
157     gtk_notebook_set_current_page(Shiki_EDITOR_NOTEBOOK, g_list_length(Shiki_EDITOR_BUFFER_LIST) - 1);
158     //Shiki_CURRENT_TAB_INFO = tabinfo;
159 aloha 1.11
160     Scm_EvalCString("(set! *mode-line-format* (lambda () (format #f \"--~A- ~A (Gauche Interaction) [GtkDefault (utf8)] L~S:~S \" (if (buffer-modified-p) \"--\" \"**\") (buffer-name (selected-buffer)) (current-line-number) (current-column))))", tabinfo->env);
161 aloha 1.9 return tabinfo->text_buffer;
162     }
163    
164 aloha 1.10 void Shiki_create_file_buffer(const gchar *filename) {
165     gchar *text;
166     gchar *utf8filename = g_locale_to_utf8(filename, -1, NULL, NULL, NULL);
167     GtkTextIter p;
168     ScmObj s;
169    
170     /* g_file_get_contents(filename, &contents, &len, NULL); */
171    
172     /* ������������������������������ */
173     Shiki_new_buffer_create(g_strdup(filename));
174     gtk_window_set_title (GTK_WINDOW (Shiki_EDITOR_WINDOW), filename);
175    
176     Scm_Define(SCM_MODULE(Shiki_CURRENT_BUFFER_ENV), SCM_SYMBOL(SCM_INTERN("*filename*")), SCM_MAKE_STR_COPYING(utf8filename));
177     g_free(utf8filename);
178    
179     Scm_EvalCString("(use gauche.charconv)", Shiki_CURRENT_BUFFER_ENV);
180    
181     /* ������������������������������������������������������������������������������ */
182     s = Scm_EvalCString("(port->string (open-input-conversion-port (open-input-file *filename*) \"*jp\" :owner? #t))", Shiki_CURRENT_BUFFER_ENV);
183     text = Scm_GetString(SCM_STRING(s));
184     if(text)
185     gtk_text_buffer_set_text(Shiki_CURRENT_TEXT_BUFFER, text, -1);
186     else {
187     /* open-input-conversion-port ������������������������������������������������������
188     * ��������������������������������������������������������������������������� UTF8
189     */
190     gchar *contents;
191     gsize br, bw, len;
192     GError *err = NULL;
193    
194     if(g_file_get_contents(filename, &contents, &len, NULL)) {
195     if(!(text = g_locale_to_utf8(contents, -1, &br, &bw, &err)))
196     gtk_text_buffer_insert(Shiki_CURRENT_TEXT_BUFFER, &p, text, -1);
197     else
198     gtk_text_buffer_insert(Shiki_CURRENT_TEXT_BUFFER, &p, contents, -1);
199     g_free(contents);
200     }
201     }
202    
203     /* ������������������������ */
204     gtk_text_buffer_set_modified(Shiki_CURRENT_TEXT_BUFFER, FALSE);
205     /* ������������������������������ */
206     gtk_text_buffer_get_start_iter(Shiki_CURRENT_TEXT_BUFFER, &p);
207     gtk_text_buffer_place_cursor(Shiki_CURRENT_TEXT_BUFFER, &p);
208 aloha 1.11 Shiki_update_modeline(Shiki_CURRENT_TEXT_BUFFER);
209 aloha 1.10 gtk_widget_show_all(GTK_WIDGET(Shiki_EDITOR_NOTEBOOK));
210     }
211    
212     void Shiki_open_file_dialog() {
213     const gchar *filename = Shiki_file_name_dialog("���������������������");
214    
215     if(!filename) return;
216     Shiki_create_file_buffer(filename);
217     }
218    
219 aloha 1.7 void Shiki_delete_buffer(GtkTextBuffer *buffer) {
220     /* ��������������������������������������������������������������������������������������������������� */
221     /* ���������������������Scheme ������������������������ Gtk ������������������������������������������������ */
222     GList *bufListElem = get_ShikiBufferListElement_By_GtkTextBuffer(buffer);
223     ShikiBuffer *tabInfo = bufListElem->data;
224     gint bufNum = g_list_position(Shiki_EDITOR_BUFFER_LIST, bufListElem);
225    
226     /* ��������� 1 ��������������������������������������������������� */
227     if(g_list_length(Shiki_EDITOR_BUFFER_LIST) == 1)
228 aloha 1.4 return;
229 aloha 1.7 /* ��������������������������������������������������������������������������������������������� */
230     g_signal_handler_disconnect(Shiki_EDITOR_WINDOW, tabInfo->delete_handler_id);
231     Shiki_EDITOR_BUFFER_LIST = g_list_delete_link(Shiki_EDITOR_BUFFER_LIST, bufListElem);
232     gtk_widget_destroy(GTK_WIDGET(tabInfo->tabpage));
233     g_free(tabInfo->tabpage_label);
234     g_free(tabInfo->name);
235     g_free(tabInfo->filename);
236     g_free(tabInfo);
237     gtk_notebook_remove_page(Shiki_EDITOR_NOTEBOOK, bufNum);
238     /* ��������������� */
239     gtk_widget_queue_draw(GTK_WIDGET(Shiki_EDITOR_NOTEBOOK));
240     }
241    
242     GtkTextBuffer *Shiki_find_buffer(const gchar *name) {
243     GList *l;
244     for(l = Shiki_EDITOR_BUFFER_LIST; l != NULL; l = l->next)
245     if(strcmp(((ShikiBuffer *)l->data)->name, name) == 0)
246     return ((ShikiBuffer *)l->data)->text_buffer;
247     return NULL;
248     }
249    
250     gchar *Shiki_buffer_substring(gint start, gint end) {
251     if(start >= end)
252     return NULL;
253     else {
254     GtkTextIter s, e;
255     gtk_text_buffer_get_iter_at_offset(Shiki_CURRENT_TEXT_BUFFER, &s, start);
256     gtk_text_buffer_get_iter_at_offset(Shiki_CURRENT_TEXT_BUFFER, &e, end);
257    
258     return gtk_text_buffer_get_text(Shiki_CURRENT_TEXT_BUFFER, &s, &e, FALSE);
259     }
260     }
261    
262     void Shiki_delete_region(gint start, gint end) {
263     if(start >= end)
264     return;
265     else {
266     GtkTextIter s, e;
267     gtk_text_buffer_get_iter_at_offset(Shiki_CURRENT_TEXT_BUFFER, &s, start);
268     gtk_text_buffer_get_iter_at_offset(Shiki_CURRENT_TEXT_BUFFER, &e, end);
269 aloha 1.4
270 aloha 1.7 return gtk_text_buffer_delete(Shiki_CURRENT_TEXT_BUFFER, &s, &e);
271     }
272 aloha 1.4 }
273    
274     gint Shiki_point() {
275     GtkTextIter p;
276     gtk_text_buffer_get_iter_at_mark(Shiki_CURRENT_TEXT_BUFFER,&p, gtk_text_buffer_get_insert(Shiki_CURRENT_TEXT_BUFFER));
277     return gtk_text_iter_get_offset(&p);
278     }
279    
280     gint Shiki_point_max() {
281     GtkTextIter p;
282     gtk_text_buffer_get_end_iter(Shiki_CURRENT_TEXT_BUFFER, &p);
283     return gtk_text_iter_get_offset(&p);
284     }
285    
286     gint Shiki_point_min() {
287     return 0;
288     }
289    
290     void Shiki_goto_char(gint offset) {
291     GtkTextIter p;
292     gtk_text_buffer_get_iter_at_offset(Shiki_CURRENT_TEXT_BUFFER, &p, offset);
293     gtk_text_buffer_place_cursor(Shiki_CURRENT_TEXT_BUFFER, &p);
294     }
295    
296     void Shiki_forward_char() {
297     GtkTextIter p;
298     gtk_text_buffer_get_iter_at_mark(Shiki_CURRENT_TEXT_BUFFER,&p, gtk_text_buffer_get_insert(Shiki_CURRENT_TEXT_BUFFER));
299     gtk_text_iter_forward_char(&p);
300     gtk_text_buffer_place_cursor(Shiki_CURRENT_TEXT_BUFFER, &p);
301     }
302    
303     void Shiki_backward_char() {
304     GtkTextIter p;
305     gtk_text_buffer_get_iter_at_mark(Shiki_CURRENT_TEXT_BUFFER,&p, gtk_text_buffer_get_insert(Shiki_CURRENT_TEXT_BUFFER));
306     gtk_text_iter_backward_char(&p);
307     gtk_text_buffer_place_cursor(Shiki_CURRENT_TEXT_BUFFER, &p);
308     }
309    
310     void Shiki_goto_line(gint line) {
311     GtkTextIter p;
312     gtk_text_buffer_get_iter_at_line(Shiki_CURRENT_TEXT_BUFFER, &p, line);
313     gtk_text_buffer_place_cursor(Shiki_CURRENT_TEXT_BUFFER, &p);
314     }
315    
316     void Shiki_goto_bol() {
317     GtkTextIter p;
318     gtk_text_buffer_get_iter_at_mark(Shiki_CURRENT_TEXT_BUFFER,&p, gtk_text_buffer_get_insert(Shiki_CURRENT_TEXT_BUFFER));
319     gtk_text_buffer_get_iter_at_line_offset(Shiki_CURRENT_TEXT_BUFFER, &p, gtk_text_iter_get_line(&p), 0);
320     gtk_text_buffer_place_cursor(Shiki_CURRENT_TEXT_BUFFER, &p);
321     }
322    
323     void Shiki_goto_eol() {
324     GtkTextIter p;
325     gtk_text_buffer_get_iter_at_mark(Shiki_CURRENT_TEXT_BUFFER,&p, gtk_text_buffer_get_insert(Shiki_CURRENT_TEXT_BUFFER));
326     gtk_text_iter_forward_to_line_end(&p);
327     gtk_text_iter_backward_char(&p);
328     gtk_text_buffer_place_cursor(Shiki_CURRENT_TEXT_BUFFER, &p);
329     }
330 aloha 1.5
331 aloha 1.7 void Shiki_forward_line(gint count) {
332     GtkTextIter p;
333     gint i;
334     gtk_text_buffer_get_iter_at_mark(Shiki_CURRENT_TEXT_BUFFER,&p, gtk_text_buffer_get_insert(Shiki_CURRENT_TEXT_BUFFER));
335    
336     if(count >= 0) {
337     for(i = count; i != 0; i--)
338     gtk_text_view_forward_display_line(Shiki_CURRENT_TEXT_VIEW, &p);
339     } else {
340     for(i = count; i != 0; i++)
341     gtk_text_view_backward_display_line(Shiki_CURRENT_TEXT_VIEW, &p);
342     }
343     gtk_text_buffer_place_cursor(Shiki_CURRENT_TEXT_BUFFER, &p);
344 aloha 1.5 }
345    
346     const char *Shiki_buffer_name(GtkTextBuffer *buffer) {
347     GList *l = get_ShikiBufferListElement_By_GtkTextBuffer(buffer);
348     if(l)
349     return ((ShikiBuffer *)(l->data))->name;
350     else
351     return NULL;
352     }
353    
354 aloha 1.6 gboolean Shiki_deleted_buffer_p(GtkTextBuffer *buffer) {
355     GList *l = get_ShikiBufferListElement_By_GtkTextBuffer(buffer);
356     if(l)
357     return FALSE;
358     else
359     return TRUE;
360     }
361    
362 aloha 1.5 GtkTextBuffer *Shiki_get_next_buffer(GtkTextBuffer *buffer) {
363     GList *l = get_ShikiBufferListElement_By_GtkTextBuffer(buffer);
364     if(l && l->next)
365     return ((ShikiBuffer *)(l->next->data))->text_buffer;
366     else
367     return NULL;
368     }
369    
370     GtkTextBuffer *Shiki_get_previous_buffer(GtkTextBuffer *buffer) {
371     GList *l = get_ShikiBufferListElement_By_GtkTextBuffer(buffer);
372     if(l && l->prev)
373     return ((ShikiBuffer *)(l->prev->data))->text_buffer;
374     else
375     return NULL;
376     }
377    
378     ScmObj Shiki_buffer_list() {
379     GList *l;
380     GtkTextBuffer *b;
381     ScmObj bl = SCM_NIL;
382    
383     for(l = Shiki_EDITOR_BUFFER_LIST; l != NULL; l = l->next) {
384     b= ((ShikiBuffer *)(l->data))->text_buffer;
385     bl = Scm_Cons(SHIKI_BUFFER_BOX(g_object_ref(b)), bl);
386     }
387     return bl;
388     }
389 aloha 1.7
390     void Shiki_erase_buffer(GtkTextBuffer *buffer) {
391     GtkTextIter start, end;
392     gtk_text_buffer_get_start_iter(buffer, &start);
393     gtk_text_buffer_get_end_iter(buffer, &end);
394     gtk_text_buffer_delete(buffer, &start, &end);
395     }
396    
397     const gchar *Shiki_file_name_dialog(const gchar *msg) {
398    
399     GtkWidget *dialog = gtk_file_selection_new(msg);
400     gint resp = gtk_dialog_run(GTK_DIALOG(dialog));
401     const gchar *filename = NULL;
402    
403     if(resp == GTK_RESPONSE_OK)
404     filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog));
405    
406     gtk_widget_destroy(dialog);
407     return filename;
408     }
409    
410     gboolean Shiki_yes_or_no_p(const gchar *msg) {
411     GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(Shiki_EDITOR_WINDOW),
412     GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION,
413     GTK_BUTTONS_YES_NO, msg);
414 aloha 1.9 gint resp;
415     gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES);
416     resp = gtk_dialog_run(GTK_DIALOG(dialog));
417     gtk_widget_destroy(dialog);
418     if(GTK_RESPONSE_YES == resp)
419     return TRUE;
420     return FALSE;
421     }
422    
423     gboolean Shiki_no_or_yes_p(const gchar *msg) {
424     GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(Shiki_EDITOR_WINDOW),
425     GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION,
426     GTK_BUTTONS_YES_NO, msg);
427     gint resp;
428     gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_NO);
429     resp = gtk_dialog_run(GTK_DIALOG(dialog));
430 aloha 1.7 gtk_widget_destroy(dialog);
431     if(GTK_RESPONSE_YES == resp)
432     return TRUE;
433     return FALSE;
434     }
435 aloha 1.8
436     gboolean Shiki_need_buffer_save_p(GtkTextBuffer *buffer) {
437     return gtk_text_buffer_get_modified(buffer);
438     }
439    
440     /* ������������ */
441     void Shiki_kill_buffer(GtkTextBuffer *buffer) {
442     if(!Shiki_need_buffer_save_p(buffer) || Shiki_yes_or_no_p("��������������������������������������������������������������������������� ?"))
443     Shiki_delete_buffer(buffer);
444     }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26