GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to display an html page in gtk

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
iswariak
Familiar Face


Joined: 28 Jun 2006
Posts: 8

PostPosted: Wed Jun 28, 2006 5:13 am    Post subject: How to display an html page in gtk Reply with quote

Hi all
I am a novice programmer in GTK.

Can anyone tell how to display an html page in GTK. I have tried GTKHtml and there few dependancy issues.

Any suggestions will help me.

Iswaria.
Back to top
iswariak
Familiar Face


Joined: 28 Jun 2006
Posts: 8

PostPosted: Thu Jun 29, 2006 6:01 am    Post subject: Launch browser window when selecting list box entry. Reply with quote

Hi

Now I am able to launch browser window when I click the GNOME href new button. But I want to launch the browser when I select something in the GTK list box.

Code for GNOME href button
----------------------------------------------------------------------------------------------------------
#include <gnome.h>
GtkWidget * href1, *fixed1;

href1 = gnome_href_new ("http://www.ifpindia.org/", _("Visit IFP"));
gtk_widget_show (href1);
gtk_fixed_put (GTK_FIXED (fixed1), href1, 56, 152);
gtk_widget_set_size_request (href1, 216, 32);
-------------------------------------------------------------------------------------------------------
Suggestions will be very helpful.

Thanks
Iswaria.
Back to top
iswariak
Familiar Face


Joined: 28 Jun 2006
Posts: 8

PostPosted: Fri Jun 30, 2006 5:46 am    Post subject: Gtkmozembed widget Reply with quote

Hi all
Gtkmozembed widget helps to embed browser in GTK.

Have anyone worked with gtkmozembed widget?

If so, please give the sample code.

Thanks
Iswaria.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 481
Location: Portland, OR USA

PostPosted: Sun Jul 02, 2006 10:01 pm    Post subject: Reply with quote

As for GtkMozEmbed, i couldn't find and RPM and don't want to take the time to figure it out just right now, however, the API documentation is here: http://www.mozilla.org/unix/gtk-embedding.html

I was able to use gtkhtml3. I first had to install the development libraries which I did using yum:
Code: (Plaintext)
1
yum install gtkhtml3-devel


And then there is a tutorial on using the GtkHTML library here: http://primates.ximian.com/~rodo/programing_with_gtkhtml_tutorial/guadec.html
Back to top
iswariak
Familiar Face


Joined: 28 Jun 2006
Posts: 8

PostPosted: Tue Jul 04, 2006 6:30 am    Post subject: Reply with quote

Hi
when I use the following code it is working fine.

Code for GNOME href button
----------------------------------------------------------------------------------------------------------
#include <gnome.h>
GtkWidget * href1, *fixed1;

href1 = gnome_href_new ("http://www.ifpindia.org/", _("Visit IFP"));
gtk_widget_show (href1);
gtk_fixed_put (GTK_FIXED (fixed1), href1, 56, 152);
gtk_widget_set_size_request (href1, 216, 32);
----------------------------------------------------------------------------------------------------------

When I change the website address to local address "file:///home/OscarDesktop/Images/especes/b/brare/brare.html" the following error occurs:

An error has occurred while trying to launch the default web browser.
Please check your settings in the 'Preferred Applications' preference
tool.
Please suggest.

Thanks
Iswaria.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 481
Location: Portland, OR USA

PostPosted: Tue Jul 04, 2006 3:16 pm    Post subject: Reply with quote

It looks as though it's not using the file:/// to mean web browser. Perhaps you can use a call to something like system("firefox file:///blablabla") or perhaps there is a way to get the default web browser and then call it using system or one of the exec functions?
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 481
Location: Portland, OR USA

PostPosted: Tue Jul 04, 2006 3:27 pm    Post subject: Reply with quote

Better yet, use GConf to add a handler for "file:". You can copy the one for http and just replace the http: with file:
Code: (Plaintext)
1
2
3
4
/desktop/gnome/url-handlers/http:
   needs_terminal = false
   command = firefox %s
   enabled = true


See http://www.gnome.org/projects/gconf/ for information on GConf. The API library for GConf is at http://developer.gnome.org/doc/API/2.0/gconf/index.html
Back to top
iswariak
Familiar Face


Joined: 28 Jun 2006
Posts: 8

PostPosted: Wed Jul 05, 2006 4:07 am    Post subject: System command is working Reply with quote

Hi Micah Carrick
Thanks a lot.

System command is working to launch the browser.

system ("firefox file:///home/OscarDesktop/Images/especes/b/brare/brare.html");

Thanks
Iswaria.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 481
Location: Portland, OR USA

PostPosted: Wed Jul 05, 2006 5:11 pm    Post subject: Reply with quote

Great... the only problem is that your users will have to have firefox in order for that to work. But if you're just using it for yourself... that'll work just fine.
Back to top
iswariak
Familiar Face


Joined: 28 Jun 2006
Posts: 8

PostPosted: Thu Jul 06, 2006 5:16 am    Post subject: System command and browser Reply with quote

Hi
Is it possible to say the default browser in the user computer instead of specifying firefox? We can't assume all the users will have firefox.

Thanks
Iswaria.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 481
Location: Portland, OR USA

PostPosted: Thu Jul 06, 2006 5:23 am    Post subject: Reply with quote

If it's a gnome application, then you can use GConf to determine which is application "handles" firefox. I don't know how it would work with KDE or other environments. You may also want to have a preferences dialog in you application in which the user specifies their browser... or programatically check for several of the more well known browsers.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP