You are not logged in.

#1 2009-05-17 20:38:12

caelestis
Member
Registered: 2009-04-04
Posts: 88

Embeding a web browser?

How would I go about embedding a web browser into my applications? Would I use something like gtkmozembed or some other thing? I want it to be able to handle flash as well. Is using webkit or gecko getting to low to the ground? Or is it easy to use these libraries to make a small browser? I just want something similar to the browser control in .NET/VC++

Offline

#2 2009-05-17 20:44:21

Wra!th
Member
Registered: 2009-03-31
Posts: 342

Re: Embeding a web browser?

caelestis wrote:

How would I go about embedding a web browser into my applications? Would I use something like gtkmozembed or some other thing? I want it to be able to handle flash as well. Is using webkit or gecko getting to low to the ground? Or is it easy to use these libraries to make a small browser? I just want something similar to the browser control in .NET/VC++

webkit is dead easy to embed (look at uzbl...) not sure if there's a QT wrapper for webkit too but with gtk it's really simple..


MacGregor DESPITE THEM!
7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00

Offline

#3 2009-05-17 21:18:36

caelestis
Member
Registered: 2009-04-04
Posts: 88

Re: Embeding a web browser?

Thanks, do you have an example maybe? I can't seem to find any on the net. If you don't I understand though.

Offline

#4 2009-05-17 21:21:26

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: Embeding a web browser?

This is probably (definitely) a bit overkill for an example, but have a look at the Uzbl source: http://github.com/Dieterbe/uzbl/tree/master

Offline

#5 2009-05-17 21:38:23

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: Embeding a web browser?

I was playing around with this yesterday and happened to pastebin it for a mate, again it uses gtk but should show you how simple it is to get Webkit up and running. You more or less just create the WebkitWebView control, hook up some callbacks (if you want), add it to a GTK container, and load a url. Waaay simple smile

http://pastebin.com/m287d1f03

Offline

#6 2009-05-18 00:41:37

caelestis
Member
Registered: 2009-04-04
Posts: 88

Re: Embeding a web browser?

Hmm, so to install the libraries I need, I use this port? http://live.gnome.org/WebKitGtk

Offline

#7 2009-05-18 00:50:13

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: Embeding a web browser?

Even easier than that, just run "pacman -S libwebkit"
To compile you use something like:

gcc -o main -Wall -W `pkg-config --cflags --libs gtk+-2.0 webkit-1.0` main.c

Offline

#8 2009-05-18 00:58:02

caelestis
Member
Registered: 2009-04-04
Posts: 88

Re: Embeding a web browser?

Oh the agony, does anyone know how to include all the necessary directories in eclipse? I can't use pkg-config on it... or could I?

Last edited by caelestis (2009-05-18 00:58:35)

Offline

#9 2009-05-18 01:45:27

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: Embeding a web browser?

Well this is the output from pkg-config:

-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/webkit-1.0 -I/usr/include/libsoup-2.4 -I/usr/include/libxml2  -lwebkit-1.0 -lgtk-x11-2.0 -lsoup-2.4 -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0

You might be able to add all of those by hand, I don't have much experience with Eclipse so I can't help you there, maybe someone else will have a better idea smile

Offline

#10 2009-05-18 21:08:11

caelestis
Member
Registered: 2009-04-04
Posts: 88

Re: Embeding a web browser?

Alright, I'll just use code::blocks.

How would you access a text/input box displayed in the browser to get/insert text?

Offline

#11 2009-05-19 00:46:21

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: Embeding a web browser?

Unfortunately I'm not too sure if the webkit api allows for that kind of stuff, although it must in some way, I know you can tell webkit to execute some javascript code, but you can't retrieve the result. I think you have to use JavascriptCore for that, and I'm not sure how that works, sorry!

Offline

#12 2009-05-21 16:02:48

bavardage
Member
Registered: 2008-02-17
Posts: 160

Re: Embeding a web browser?

There is a hackish way to send info from the browser back to the app:
Call javascript in the page with exectute_script and then make that script set the title of the page (with document.title or w/e) and then add an event handler for the on title change event.

Does it have to be C++? There is a nice python tutorial here
http://www.aclevername.com/articles/python-webgui/

Offline

#13 2009-05-21 16:03:32

bavardage
Member
Registered: 2008-02-17
Posts: 160

Re: Embeding a web browser?

Oh I see it does have to be C++, but anyway, you can use the above tutorial as a reference - since it uses PyWebkitGTK the method calls'll be similar if not the same.

Offline

#14 2009-05-21 18:27:38

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: Embeding a web browser?

bavardage wrote:

There is a hackish way to send info from the browser back to the app:
Call javascript in the page with exectute_script and then make that script set the title of the page (with document.title or w/e) and then add an event handler for the on title change event.

heh, that is indeed quite hackish tongue


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#15 2009-05-21 19:42:31

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: Embeding a web browser?

It's also the way I was using in my pastebinned code, but I cringe everytime I fire it up. Still it does work so I guess I should be greatful tongue

Offline

Board footer

Powered by FluxBB