usage of Gsv::LanguageManager::get_default from Gtksourceviewmm



Hello List

I don't understand well how to use Gsv::LanguageManager::get_default

Platform is Linux/Debian/AMD64/unstable using packages libgtksourceviewmm-3.0-dev 3.2.0-1
& libgtkmm-3.0-dev 3.2.0-1 

My source code (GPLv3 licensed) is inside the GCC MELT branch. See http://gcc-melt.org/
for more about MELT (MELT is a high-level domain specific language to extend GCC; it has
a lispy syntax and is translated to C; the melt.so plugin is a meta-plugin to GCC, etc..)

The source code is exactly in the file simplemelt-gtkmm-probe.cc of the contrib
directory of that branch. You can fetch it with

 svn co svn://gcc.gnu.org/svn/gcc/branches/melt-branch/contrib

which brings a few dozen of files and I am talking of the simplemelt-gtkmm-probe.cc file
there svn revision 185491 (which is "self contained" and has a comment at the end of the
file showing the compilation command; you need g++ 4.6 to compile it - since I am using
some C+ +11 things.

What does simplemelt-gtkmm-probe.cc will do? It will "interactively" interact with the
MELT plugin for GCC using simple textual protocols. You could compile it with

   g++ -std=gnu++0x -Wall -O -g \
     $(pkg-config --cflags --libs gtksourceviewmm-3.0 gtkmm-3.0  gtk+-3.0) \
     -o simplemelt-gtkmm-probe simplemelt-gtkmm-probe.cc

So far, my  simplemelt-gtkmm-probe.cc is very incomplete. I'm testing it by running it as

     simplemelt-gtkmm-probe -D -t -C 0 -R 1  

where -D shows a lot of debug prints, -t shows the trace window displaying the protocol
exchanges, -C 0 is the command channel, here file descriptor 0 ie stdin, and -R is the
reply channel (or channel for requests to MELT, when MELT will later run
simplemelt-gtkmm-probe), here the reply channel is file descriptor 1 for stdout.

Then you can send commands to  simplemelt-gtkmm-probe.cc; each command should be followed
by two newlines (a single one is not enough). I'm trying

     showfile_cmd "paranoia.cc" 1

followed by two new lines, which is supposed to show the file paranoia.cc in tab #1 of a
notebook. I'm getting a SIGSEGV

#0  Gsv::LanguageManager::guess_language (this=0x0, filename=..., 
    content_type=...) at languagemanager.cc:205
#1  0x000000000040e9ed in SmeltMainWindow::ShownFile::ShownFile (
    this=0x5ec9b0, mwin=0x7fffffffe1b8, filepath=..., num=1)
    at simplemelt-gtkmm-probe.cc:845
#2  0x000000000040f97d in SmeltMainWindow::show_file (this=0x7fffffffe1b8, 
    path=..., num=1) at simplemelt-gtkmm-probe.cc:886
#3  0x000000000040fb89 in SmeltAppl::showfile_cmd (this=0x7fffffffe1a0, v=...)
    at simplemelt-gtkmm-probe.cc:1233
#4  0x000000000040bc13 in SmeltCommandSymbol::call (this=<optimized out>, 
    app=<optimized out>, v=...) at simplemelt-gtkmm-probe.cc:1022
#5  0x000000000040e235 in SmeltAppl::process_command_from_melt (
    this=0x7fffffffe1a0, str=...) at simplemelt-gtkmm-probe.cc:1164
#6  0x000000000040e636 in SmeltAppl::cmdbuf_from_melt_cb (this=0x7fffffffe1a0, 
    incond=<optimized out>) at simplemelt-gtkmm-probe.cc:1109
#7  0x0000000000413db0 in operator() (_A_a1=<optimized out>, 
    this=<optimized out>)
    at /usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1851
#8  operator()<const Glib::IOCondition&> (_A_arg1=<optimized out>, 
    this=<optimized out>)
    at /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:84
#9  sigc::internal::slot_call1<sigc::bound_mem_functor1<bool, SmeltAppl, Glib::IOCondition>, bool, Glib::IOCondition>::call_it (rep=<optimized out>, 


And it is probably because, when executing  
   _app_langman = Gsv::LanguageManager::get_default();
line 619 of my simplemelt-gtkmm-probe.cc I am getting
(simplemelt-gtkmm-probe:14602): glibmm-WARNING **: Failed to wrap object of type
'GtkSourceLanguageManager'. Hint: this error is commonly caused by failing to call a
library init() function.

I don't understand why I am getting this warning. It is called inside the contructor of
SmeltAppl, a subclass of Gtk::Main, so gtk should be initialized then -since Gtk::Main
constructor has been called- (and I cannot figure if and how I have to explicitly
initialize the GtkSourceViewMM library).


A general question is how to display, with GtkSourceViewMM library, a given source file
(like e.g. paranoia.cc) with style (ie. syntax colorization). If someone has a simple
program doing that (e.g. display its own C++ source file using GtkSourceViewMM) I would be
grateful.

I also am not sure to understand how should Gsv::LanguageManager::guess_language should
be used.

Ideally, I would like to understand how to use GtkSourceViewMM to display the source code
-with syntax coloring- of any file compilable by GCC (eg a C, or C++, or Ada, or Fortran
file). An example application which takes as a single argument such a file and displays
it -with syntax colorization- would be interesting to many!

Any help would be grateful.

Regards.
-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]