User talk:Santhoshvkumar

Create plugin with Python for gedit

import gconf

import gedit

import apertium

class ExamplePyWindowHelper:

def __init__(self, plugin, window):

self._window = window

self._plugin = plugin

# Insert menu items

self._insert_menu

def deactivate(self):

# Remove any installed menu items

self._remove_menu

self._window = None

self._plugin = None

self._action_group = None

def _insert_menu(self):

# Get the GtkUIManager

manager = self._window.get_ui_manager

# Create a new action group

self._action_group = gtk.ActionGroup("ExamplePyPluginActions")

"""Specifying the name that will apper in menu"""

self._action_group.add_actions([("ExamplePy", None, _("Language Transulator"),

None, _("Clear the document"),

self.on_clear_document_activate)])

# Insert the action group

manager.insert_action_group(self._action_group, -1)

# Merge the UI

self._ui_id = manager.add_ui_from_string(ui_str)

def _remove_menu(self):

# Get the GtkUIManager

manager = self._window.get_ui_manager

#doc = self.window.get_active_document

# Remove the ui

manager.remove_ui(self._ui_id)

# Remove the action group

manager.remove_action_group(self._action_group)

# Make sure the manager updates

manager.ensure_update

def update_ui(self):

self._action_group.set_sensitive(self._window.get_active_document != None)

# Menu activate handlers and doc is the active gedit document

def on_clear_document_activate(self, action):

document = self._window.get_active_document