~ubuntu-branches/debian/sid/frama-c/sid

« back to all changes in this revision

Viewing changes to src/gui/source_viewer.ml

  • Committer: Bazaar Package Importer
  • Author(s): Mehdi Dogguy
  • Date: 2009-06-03 08:19:25 UTC
  • Revision ID: james.westby@ubuntu.com-20090603081925-kihvxvt0wy3zc4ar
Tags: upstream-20081201.dfsg
Import upstream version 20081201.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(**************************************************************************)
 
2
(*                                                                        *)
 
3
(*  This file is part of Frama-C.                                         *)
 
4
(*                                                                        *)
 
5
(*  Copyright (C) 2007-2008                                               *)
 
6
(*    CEA (Commissariat � l'�nergie Atomique)                             *)
 
7
(*                                                                        *)
 
8
(*  you can redistribute it and/or modify it under the terms of the GNU   *)
 
9
(*  Lesser General Public License as published by the Free Software       *)
 
10
(*  Foundation, version 2.1.                                              *)
 
11
(*                                                                        *)
 
12
(*  It 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         *)
 
15
(*  GNU Lesser General Public License for more details.                   *)
 
16
(*                                                                        *)
 
17
(*  See the GNU Lesser General Public License version 2.1                 *)
 
18
(*  for more details (enclosed in the file licenses/LGPLv2.1).            *)
 
19
(*                                                                        *)
 
20
(**************************************************************************)
 
21
 
 
22
 
 
23
 
 
24
 
 
25
(* Build a read only text view for C source code. *)
 
26
 
 
27
let set_language_to_C (buffer:GSourceView.source_buffer)  = 
 
28
  let original_source_language_manager = GSourceView.source_languages_manager () in
 
29
  let original_lang =
 
30
    original_source_language_manager#get_language_from_mime_type "text/x-csrc"
 
31
  in
 
32
  begin match original_lang with
 
33
  | Some lang -> buffer#set_language lang
 
34
  | None -> Format.printf "No such mime type@."
 
35
  end;
 
36
  buffer#set_highlight true
 
37
  
 
38
let make ~packing =
 
39
(*  let d = GWindow.font_selection_dialog ~title:"tutu" ~show:true () in
 
40
  d#selection#set_preview_text 
 
41
    (Format.sprintf "%s %s %s %s" 
 
42
       Utf8_logic.forall Utf8_logic.exists Utf8_logic.eq Utf8_logic.neq) ;
 
43
*)
 
44
  let original_source_window = 
 
45
    GSourceView.source_view
 
46
      ~show_line_numbers:true
 
47
      ~show_line_markers:true
 
48
      ~editable:false
 
49
      ~packing
 
50
      ()
 
51
  in
 
52
  (*    let pixbuf = 
 
53
        original_source_window#misc#render_icon ~size:`MENU `DIALOG_WARNING 
 
54
        in 
 
55
        original_source_window#set_marker_pixbuf "warning" pixbuf;*)
 
56
  let original_source_buffer = original_source_window#source_buffer in
 
57
  set_language_to_C original_source_buffer;
 
58
  (*      ignore (original_source_buffer#create_marker ~typ:"warning" original_source_buffer#start_iter ) ;*)
 
59
  begin try
 
60
    original_source_window#set_highlight_current_line true
 
61
  with Not_found -> ()
 
62
    (* very old gtksourceview do not have this property. *)
 
63
  end;
 
64
  original_source_window
 
65
  
 
66
    
 
67
let buffer () =
 
68
  let original_source_buffer = GSourceView.source_buffer ()  in
 
69
  set_language_to_C original_source_buffer;
 
70
  original_source_buffer
 
71
 
 
72