gedit IDE hack

Contribute code & patches
Forum rules
No support questions here please

gedit IDE hack

Postby mr bob on Thu Aug 11, 2011 6:30 am


Recently I decided to review which IDE I wished to use. I prefer lightweights IDE with plugins and so my choice ended up between Geany (which I have been using for a couple of years) and Gedit which I now prefer because of its snippets and the ability to write plugins in python.

However, I also want to use gedit as a simple text editor too. So I have hacked gedit to create a separate application that:

a) runs as a separate instance of gedit (called geditIDE).
b) has it's own profile (using a sub-directory in gconf) - therefore opening with and remembering different preferences.
c) has a separate menu place.

Here is the quick hack. It works for me but I can't guarantee it will work for others. I recommend you only try this if you know what you are doing

1) Download the source of the version of gedit you wish to hack from here:

I'm using the stable version of gedit on Ubuntu and Mint - 2.30.4

2) Make the changes to the files.

2.1) First replace all references to the application menu file "gedit.desktop" with "geditIDE.desktop".

You need to find and replace these in ./configure and data/

2.2) I have listed all other file changes in the diff file below:
Code: Select all
diff -r gedit-2.30.4/configure geditIDE-2.30.4/configure
< PACKAGE_NAME='gedit'
< PACKAGE_STRING='gedit 2.30.4'
> PACKAGE_STRING='geditIDE 2.30.4'
diff -r gedit-2.30.4/gedit/gedit.c geditIDE-2.30.4/gedit/gedit.c
<    connection = bacon_message_connection_new ("gedit");
>    connection = bacon_message_connection_new ("geditIDE");
diff -r gedit-2.30.4/gedit/gedit-prefs-manager.h geditIDE-2.30.4/gedit/gedit-prefs-manager.h
< #define GEDIT_BASE_KEY   "/apps/gedit-2"
> #define GEDIT_BASE_KEY   "/apps/gedit-2/IDE"
diff -r gedit-2.30.4/gedit/gedit-window.c geditIDE-2.30.4/gedit/gedit-window.c
<       gedit_osx_set_window_title (window, "gedit", NULL);
>       gedit_osx_set_window_title (window, "geditIDE", NULL);
<       gtk_window_set_title (GTK_WINDOW (window), "gedit");
>       gtk_window_set_title (GTK_WINDOW (window), "geditIDE");
<          title = g_strdup_printf ("%s [%s] (%s) - gedit",
>          title = g_strdup_printf ("%s [%s] (%s) - geditIDE",
<          title = g_strdup_printf ("%s [%s] - gedit",
>          title = g_strdup_printf ("%s [%s] - geditIDE",
<          title = g_strdup_printf ("%s (%s) - gedit",
>          title = g_strdup_printf ("%s (%s) - geditIDE",
<          title = g_strdup_printf ("%s - gedit",
>          title = g_strdup_printf ("%s - geditIDE",
diff -r gedit-2.30.4/gedit/ geditIDE-2.30.4/gedit/
< bin_PROGRAMS = gedit
> bin_PROGRAMS = geditIDE
diff -r gedit-2.30.4/gedit/ geditIDE-2.30.4/gedit/
< bin_PROGRAMS = gedit$(EXEEXT)
> bin_PROGRAMS = geditIDE$(EXEEXT)
< gedit$(EXEEXT): $(gedit_OBJECTS) $(gedit_DEPENDENCIES)
<    @rm -f gedit$(EXEEXT)
> geditIDE$(EXEEXT): $(gedit_OBJECTS) $(gedit_DEPENDENCIES)
>    @rm -f geditIDE$(EXEEXT)

It is probably worth copying and pasting the above diff file into your own diff file.

3) Now create and in the data folder and copy and paste the text below:

Code: Select all
[Desktop Entry]
_GenericName=Integrated Development Environment
_Comment=gedit IDE hack
Exec=geditIDE %U
_X-GNOME-FullName=gedit IDE
X-GNOME-Bugzilla-Product=gedit IDE

4) Then perform the usual process to install from the source:
Code: Select all
sudo make install

4.1) The configuration may fail if other packages are needed. You may need to install these required packages before configuring.

Code: Select all
sudo apt-get install intltool
sudo apt-get install libenchant-dev
sudo apt-get install libxml2-dev
sudo apt-get install libgtk2.0-dev
sudo apt-get install libgtksourceview2.0-dev
sudo apt-get install libgconf2-dev

This should have installed geditIDE.

5) The application is likely to be installed into /usr/local/bin.

To be able to use the gedit plugins already installed, it is necessary to create links to the current gedit plugin directory:

Code: Select all
cd /usr/local/share/gedit-2
sudo rm -rf plugins
sudo ln -s /usr/share/gedit-2/plugins
cd /usr/local/lib/gedit-2
sudo rm -rf plugin*
sudo ln -s /usr/lib/gedit-2/plugin-loaders
sudo ln -s /usr/lib/gedit-2/plugins

6) If the menu doesn't display geditIDE, you may have to copy the .desktop file:

Code: Select all
sudo cp /usr/local/share/applications/geditIDE.desktop /usr/share/applications/


Explanation of the code changes:

1) Replacing "gedit.desktop" with "geditIDE.desktop" in ./configure and data/

This will to point to new application menu files that will be installed as geditIDE.desktop. This file will contain the change in name and comment and will reside in the "Development" or "Programming" sub menu.

2) Changing the application name in configuration and make

in ./configure
Code: Select all
PACKAGE_STRING='geditIDE 2.30.4'

in gedit/
Code: Select all
bin_PROGRAMS = geditIDE

in gedit/
Code: Select all
geditIDE$(EXEEXT): $(gedit_OBJECTS) $(gedit_DEPENDENCIES)
   @rm -f geditIDE$(EXEEXT)

3) Creating a separate instance for geditIDE, so that gedit and geditIDE can run simultaneously

in gedit.c:main()
Code: Select all
connection = bacon_message_connection_new ("geditIDE");

4) Creating a separate "profile" for geditIDE, by creating the gconf subdirectory /apps/gedit-2/IDE

in gedit-prefs-manager.h
Code: Select all
#define GEDIT_BASE_KEY   "/apps/gedit-2/IDE"

5) Changing the main window name from gedit to geditIDE

in gedit-window.c:set_title() change all occurrences of "gedit" to "geditIDE"


If anybody wishes to create a proper patch that would be great but I don't have the time unfortunately.

Hope this helps though, regards Mr Bob
mr bob
Level 1
Level 1
Posts: 5
Joined: Wed Jan 06, 2010 5:23 pm

Linux Mint is funded by ads and donations.

Return to Code & Patches

Who is online

Users browsing this forum: No registered users and 1 guest