Syntax Highlight and Autocomplete in Geany for GTK+ (C)

1

2

I have just started GTK+ coding in C. I was curious whether i can get syntax highlight and auto-completion working for my GTK code... because as a beginner it would be helpful.

I was completely convinced that it was not possible until i came across this video on youtube:

https://www.youtube.com/watch?v=AyeQrO1VDFM&feature=plcp I asked the uploader for help, but turns out his last activity on youtube was in Septembeer :(

I also tried opening the gtk.h file with geany as i had read somewhere that it worked, but unfortunately it didn't work too.

Any help? :'(

Prasanna Choudhari

Posted 2012-11-01T16:16:47.277

Reputation: 13

Is this what you meant by opening gtk.h?

– Louis – 2012-11-01T16:54:57.913

Umm..no...i thought opening means just browse the file and open it? isn't it like that? if not please enlighten me... i'm new to gtk+. – Prasanna Choudhari – 2012-11-01T17:00:58.720

almost, but you have do do a couple of things first. See my answer. – Louis – 2012-11-02T00:35:26.560

Answers

1

First create a file called gtk_headers.c. Add this line and save it #include <gtk/gtk.h>

Now run one of the following based on which version of GTK+ you are using.

GTK+2:

gcc -E gtk_headers.c `pkg-config gtk+-2.0 --cflags --libs` -o
gtk_headers.h

GTK+3:

gcc -E gtk_headers.c `pkg-config gtk+-3.0 --cflags --libs` -o
gtk_headers.h


Finally, open the output file (gtk_headers.h) in Geany while your project is open. After a few seconds syntax highlighting and autocompletion will begin to work.

Louis

Posted 2012-11-01T16:16:47.277

Reputation: 18 859

Thanks @Louis! That Worked....

I also found an alternative method which is generating gtk3.c.tags file through geany...and then load it..so that it learns the synatxes.. Thanks a lot!
Btw, your method can be easily incorporated in a script..so im going with it.. – Prasanna Choudhari – 2012-11-02T08:08:38.927

3

Download this package and extract it to ~/.config/geany/tags.

Restart Geany and you're done!

Simon

Posted 2012-11-01T16:16:47.277

Reputation: 31