Thursday, August 07, 2008

Gedit Web Browser Plugin

If you've ever been typing away on Gedit and needed to look for some obscure Gtk reference, then this plugin might be for you. It adds an address bar between the toolbar and main Gedit pane, along with buttons for back, forward, new tab, and, of course, go. If you are currently editing a text file and hit the go button, it'll open a new tab with the page in the address bar. The plugin makes it look like it's integrated, so that one tab could be a text document, another a web page, the next a text document, etc.

Screenshot

Download
Current version: 0.1.0.0.1rc2
You can download the plugin here. Unpack it in ~/.gnome2/gedit/plugins (the directory might not exist, so create it if neccessary) or /usr/share/gedit-2/plugins. It will show up in Gedit's list of plugins as "Web Browser."

Problems
It's not really integrated, and could conflict with other plugins that do things certain things like adding other widgets to Gedit's main VBox. Also, doing things like saving and printing the "current document" when it is actually a web page will do so to a blank document, because Gedit itself doesn't actually know about the web page.

25 comments:

haTem said...

This plugin sounds like it would be very useful, thanks!

However, I'm having trouble getting it to work. I get a segmentation fault when I click the new-tab button or the go arrow.

Here is some information about my system.

Distribution: Arch Linux
Gnome Release: 2.22.3 2008-07-02 (Archlinux)
BugBuddy Version: 2.22.0

System: Linux 2.6.26-ARCH #1 SMP PREEMPT Tue Aug 26 21:15:43 UTC 2008 i686
X Vendor: The X.Org Foundation
X Vendor Release: 10402000
Selinux: No
Accessibility: Disabled
GTK+ Theme: Nodoka Wise
Icon Theme: gnome-wise

Memory status: size: 0 vsize: 0 resident: 0 share: 0 rss: 0 rss_rlim: 0
CPU usage: start_time: 0 rtime: 0 utime: 0 stime: 0 cutime:0 cstime: 0 timeout: 0 it_real_value: 0 frequency: 0

Output of custom script "/usr/libexec/gedit-2/gedit-bugreport.sh":
Active plugins:
- webbrowser

Plugins in $HOME:
- template
- webbrowser

Module versions:
- glib 2.16.5
- gtk+ 2.12.11
- gtksourceview 1.8.5
- libgnomeui 2.22.1
- libglade 2.6.2
- libgnomeprintui 2.18.2
- gnome-vfs 2.22.0
- pygobject 2.14.2
- pygtk 2.12.1
- gnome-python 2.22.1
- gnome-python-desktop 2.22.0
- enchant 1.4.2
- iso-codes 2.0

Python module versions:
- python 2.5.2
- pygtk 2.12.1 (GTK+ 2.12.11)
- gnome-python 2.22.1

Any idea what may be causing this?

Sharkbaitbobby said...

Sorry, I didn't see your comment until now.
Please install `gdb` if it isn't installed. Then, run `gdb gedit`, type `run` and hit enter, and once it crashes, type `bt` and hit enter, and post the output here or on a pastebin. Thanks.

haTem said...

Here's the backtrace from gdb:

http://pastebin.com/m57595f74

It seems like I am missing the debugging symbols though, so I'm not sure how useful it will be. I'm trying to figure out how to install the debugging symbols on arch, I'll post again if I manage to do it.

Thanks!

Chris said...

I followed the directions to install this plugin, but it doesn't seem to be working correctly; the URL bar and buttons show up as they should, but when I press the go button, a mere blank document opens up. The same results when I type in a URL into the address bar and press the go button. Am I doing something wrong?

Anonymous said...

404

Pooja said...

Great Idea. And it works for me.

The only difference from your screen shot is, it doesn't show the icons for back and forward. Clicking the place where these icons are supposed to be works all right, so the functionality is all right. In the downloaded archive, only one icon is available under webbrowser directory - internet-web-browser - Is that expected? Or is the archive incomplete? Thanks.

Pooja said...

On another thought, I've customized my ubuntu to look as Mac - this includes customization for basic icon sets as well - could this be the reason for non appearance of your icons?

Anonymous said...

Pooja, the plugin gets the icons for all but the web icon from your current icon theme. This is done so it better fits within your desktop environment (f.e. KDE icons look out of place in GNOME), and this is what most applications do. However, from my research, most icon themes don't have a web icon, (though it could just be the few that I tested,) so I included it with the plugin so that it shows for any icon theme. AFAIK, icon themes that don't have standard icons like left, right, etc. aren't following the general standard.

To others who are having problems, making sure the libgtkmozembed library and Python bindings are installed. It's still a new library that doesn't always work, unfortunately.

mdgrech said...

Hey when I click go or press enter a new tab opens up and just says loading. Please please please help :)

mdgrech said...

well whatever the prob was it work in 9.04...love this plugin...my development as sped up so much now!!!

Unknown said...

Hi!
I don't know where to get libgtkmozembed... I am running fedora, can you help me?

Bryan said...

Hi there, when I enter an url and press enter, I get a blank page.

This plugin would be great if I could get it to work ..

Any Ideas ?

Anonymous said...

It was rather interesting for me to read that post. Thanx for it. I like such topics and anything connected to this matter. I would like to read more on that blog soon.

ryanpage said...

really useful,

works fine but the buttons!

thanks !!

Anonymous said...

Good Afternoon!!! sharkbaitbobby.blogspot.com is one of the most outstanding informational websites of its kind. I enjoy reading it every day. All the best.

Unknown said...

Hello!

GDB backtrace for a segfault in Fedora 12.

http://pastebin.com/m75936fff

Name : gedit
Arch : x86_64
Epoch : 1
Version : 2.28.3

Name : gnome-python2-gtkmozembed
Arch : x86_64
Version : 2.25.3
Release : 14.fc12

Name : firefox
Arch : x86_64
Version : 3.5.6

Good plugin idea though! Might be an upstream problem.

bheklilr said...

I am unable to get it to work in Ubuntu 9.10. I disabled every plugin other than the Web Browser, and made sure to install python-gtkmozembed. I know I already have the python bindings for gEdit.

When I try to open a web page, all I get is a blank new document.

Also, is there a way to add custom back/forward buttons? Would I need to just drop them in the correct directory and give them the proper names?

bheklilr said...

Also, when I open up gEdit, the plugin will sometimes crash and display this error: http://pastebin.com/V4P9ZtAN

Unknown said...

Those having problems get it running, you need to install the package python-libgtkmozembed first!

bheklilr said...

I have tried installing the python library, but I still get errors when it attempts to execute the code.

Again, the traceback is:


Traceback (most recent call last):
File "/home/aarons/.gnome2/gedit/plugins/webbrowser.py", line 214, in new_tab
self.goto_url('about:blank', True)
File "/home/aarons/.gnome2/gedit/plugins/webbrowser.py", line 126, in goto_url
notebook = self._window.get_children()[0].get_children()[3].get_children()[1].get_children()[1]
IndexError: list index out of range

xMonty said...

Hi I have the solution for: arrows show, close tab

homepage = 'http://localhost/'

#Back button (just the arrow)
back_button = gtk.Button()
back_button.set_relief(gtk.RELIEF_NONE)
back_image = gtk.Image()
back_image.set_from_stock(gtk.STOCK_GO_BACK, gtk.ICON_SIZE_MENU)
back_image.set_pixel_size(16)
back_button.add(back_image)

back_button.connect('clicked', self.go_back)

#Forward button (just the arrow)
forward_button = gtk.Button()
forward_button.set_relief(gtk.RELIEF_NONE)
forward_image = gtk.Image()
forward_image.set_from_stock(gtk.STOCK_GO_FORWARD, gtk.ICON_SIZE_MENU)
forward_image.set_pixel_size(16)
forward_button.add(forward_image)

forward_button.connect('clicked', self.go_forward)

#New tab button
tab_button = gtk.Button()
try:
icon = self.icon_theme.load_icon('tab-new', 16, 0)
except:
icon = self.icon_theme.load_icon('list-add', 16, 0)
tab_button.set_image(gtk.image_new_from_pixbuf(icon))
tab_button.set_relief(gtk.RELIEF_NONE)
tab_button.connect('clicked', self.new_tab)

#Create the tab label
label = gtk.Label('Loading')
image = gtk.image_new_from_pixbuf(icon)
button = notebook.get_tab_label(tab).get_children()[1]
button.parent.remove(button)
button.connect('clicked', lambda b: self._window.close_tab(tab))

Al said...

it dosent works, i have installed python-gtkmozembed but all the way i only see a blank page.

Al said...

it dosent works, i have installed python-gtkmozembed but all the way i only see a blank page.

bheklilr said...

I think it's a problem with getting the child elements of the window. It errors trying to call a child object inside the window, so it may just be any toolbars that are present are getting in the way, or something like that. Unfortunately, I'm not the best python programmer, so I can't really say more after that.

Unknown said...

The plugin appears in my preferences dialog box, but it is greyed out. I've installed "gdb" and "gtkmozembed" but it is still greyed.

Would you have any clues to what else could help?

Thanks