Skip navigation.

Log in | Sign up

Linux for Designers

a blog by Eckhard M. Jäger

gEdit Browser Preview plugin

, , , , , ,

On my way bringing SweeTS - delicious TypoScript development to Linux, i wrote another plugin called "Browser Preview". This plugin showing the current webpage you are editing in gEdit directly in Firefox, Opera, Midori or Konquerer and the Internet Explorer 6. This plugin is completely localized in german and english.

How it works:
* you have to install all the browsers on your system
* Internet Explorer 6 support is done by IEs4Linux in standard configuration and includes path converting
* Copy the files browser.gedit-plugin and browser.py into ~/.gnome2/gedit/plugins
* Start gEdit and enable the plugin "Browser Preview" in the preferences
* After a restart the plugin appears in the View menu
* Assign the typical shortcuts "F12", "Ctrl+F12" etc. to the different Browsers in the menu

Download:
http://files.myopera.com/area42/files/gedit_browser_plugin.zip

gEdit plugins i wrote too:
http://my.opera.com/area42/blog/gedit-language-reference-plugin
http://my.opera.com/area42/blog/gedit-template-plugin
A lot of other gEdit plugins can be found here.

^Web development with gEdit in detail

Comments

Anonymous 17. April 2008, 10:33

luther writes:

Thanks, usefull plugin!

But...
...is not possible realtime preview like textmate?

area42 17. April 2008, 11:01

@luther
Nice idea but then i have to add a panel and there i have to integrate webkit or gecko and then i have to build a pip for realtime changes - huh man that's very hard ro code :frown:

Anonymous 20. May 2008, 01:44

alxarch writes:

the link is broken, it points to the reference plugin

area42 20. May 2008, 07:59

Oh,

thanx, fixed.

Anonymous 23. May 2008, 17:32

bmartin writes:

How do I set up shortcuts for each browser?

Thanks

area42 23. May 2008, 17:54

Well if dynamic shortcuts enabled on your gnome desktop than hover over the menu entry and press Ctrl+F12 or whatever you like prefer :smile:

Anonymous 24. May 2008, 20:05

bmartin writes:

How do I enable dynamic shortcuts? I can't seem to get it to work?

area42 25. May 2008, 11:07

Anonymous 25. May 2008, 15:13

bmartin writes:

very good thank you. works great

Anonymous 15. June 2008, 00:46

angelys writes:

Thank you so much for your great plugin.



Under firefox, i refresh automatically the tabs with "tab mix plus,
and if gedit was able of having an autosave feature for each modification to the document (gedit would be like the excellent textmate with its best feature "autopreview function".

Or maybe is it possible to choose an autosave period much shorter (because 1 minute... is not like real time :) )

Do you know a way for this?

Thank you


area42 15. June 2008, 08:59

Thanks.

About Autosave, there is no way using secounds. I tried modify it using gconf but its defined as an integer. May something for the bug tracker > Feature request :smile:
Here are two other tips about gEdit:

add to "/apps/gedit-2/preferences/editor/save" at the key "writable_vfs_schemes" the entry "ftp" to allow ftp connection from gEdit.

set "max_recents" at "/apps/gedit-2/preferences/ui/recents" up 15 to get a longer list of rescent opened files.

Happy computing :smile:

Anonymous 15. June 2008, 16:15

angelys writes:

Thank you for the tips.

My .gconf/apps/gedit-2/preferences/editor/save/%gconf.xml

Is now like that :





ssh


sftp


smb


dav


davs


ftp










And... It's greeat :)

Anonymous 23. September 2008, 01:54

Fevrin writes:

So you have to install all of the browsers, even if you won't use all of them? I followed the instructions (except for installing all of the browsers), but nothing happens when I click View > View in > Firefox or when I press F9 (the shortcut I assigned to Firefox). Also, does this plugin display the given file within a browser embedded in Gedit, or does it simply display the given file in a regular, separate browser window?

area42 23. September 2008, 20:37

Hello Fevrin,

thanks for your feedback. First of all you must not have all these browsers installed. The plugins calls a browser and did not embed it in the bottom panel. There is another plugin that tried that (but just one browser).
What is the output when you start gEdit via the shell? Is there any error message?

Anonymous 27. September 2008, 00:12

Fevrin writes:

Sorry for the late reply--yes, the following is output when I try to view in Firefox (I do not have the other browsers installed):

Traceback (most recent call last):
File "/home/chris/.gnome2/gedit/plugins/browser.py", line 93, in
lambda a: self._plugin.on_browser_activate(self._window)),
File "/home/chris/.gnome2/gedit/plugins/browser.py", line 151, in on_browser_activate
parts = string.split(url,"//")
File "/usr/lib/python2.5/string.py", line 290, in split
return s.split(sep, maxsplit)
AttributeError: 'NoneType' object has no attribute 'split'

area42 27. September 2008, 19:35

Hi,

thanks for the trace, i will try to debug it.

Anonymous 5. January 2009, 18:25

Kurt writes:

I have the same problem that Fervin does. Nothing happens when I try to view a html file with Firefox. I get exactly the same output when I start gedit in a bash shell.

Anonymous 5. January 2009, 18:26

Kurt writes:

This is the output:

kurt@kurt-desktop:~$ gedit
Traceback (most recent call last):
File "/home/kurt/.gnome2/gedit/plugins/browser.py", line 93, in
lambda a: self._plugin.on_browser_activate(self._window)),
File "/home/kurt/.gnome2/gedit/plugins/browser.py", line 151, in on_browser_activate
parts = string.split(url,"//")
File "/usr/lib/python2.5/string.py", line 290, in split
return s.split(sep, maxsplit)
AttributeError: 'NoneType' object has no attribute 'split'
kurt@kurt-desktop:~$

Anonymous 5. January 2009, 19:09

Kurt writes:

For some reason, it is now working. I did #rm -rf .gnome2/gedit/plugins, then recreated the plugins dir and reinstalled the plugin. It seems to work now. Thanks.

Is there a way to have it display the current document without first having to save it?

Anonymous 5. January 2009, 20:58

Richard writes:

Hi

useful plugin but please add Epiphany!
It might uses Webkit just like Firefox but I actually prefer this browser on my netbook.

Anonymous 12. June 2009, 20:43

Anonymous writes:

Broken download links?

Anonymous 22. July 2009, 10:13

hameau writes:

It's straightforward to modify the browser.py file to launch a specific Webkit browser. The defaults are Midori and Kfmclient, which I had never heard of before today. ;-)

Open browser.py (in the gedit plugins directory) and go to line 173. It should start with 'command = "midori " ...'.

Replace the single word 'midori' with the command to start your preferred browser. (For Debian, I use 'epiphany-webkit', which has to be installed, of course.)

Be careful not to change anything else, especially the indenting of the file and the single space after the browser command. Save the modified file with the same name.

It's necessary to restart gedit for changes to take effect.

area42 25. July 2009, 20:00

@hameau:
This is a dirty patch :wink: Let me fix this in a much better way.

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies