~ubuntu-branches/ubuntu/lucid/gedit/lucid-updates

« back to all changes in this revision

Viewing changes to plugins/pythonconsole/pythonconsole/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2009-07-28 10:11:53 UTC
  • mfrom: (1.1.64 upstream)
  • Revision ID: james.westby@ubuntu.com-20090728101153-tx96qv2r25psmldd
Tags: 2.27.3-0ubuntu1
* New upstream release (LP: #405550)
  - Misc bugfixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
from console import PythonConsole
31
31
from config import PythonConsoleConfigDialog
32
32
 
 
33
PYTHON_ICON = 'gnome-mime-text-x-python'
 
34
 
33
35
class PythonConsolePlugin(gedit.Plugin):
34
 
        def __init__(self):
35
 
                gedit.Plugin.__init__(self)
36
 
                self.dlg = None
37
 
                
38
 
        def activate(self, window):
39
 
                console = PythonConsole(namespace = {'__builtins__' : __builtins__,
40
 
                                                     'gedit' : gedit,
41
 
                                                     'window' : window})
42
 
                console.eval('print "You can access the main window through ' \
43
 
                             '\'window\' :\\n%s" % window', False)
44
 
                bottom = window.get_bottom_panel()
45
 
                image = gtk.Image()
46
 
                image.set_from_icon_name('gnome-mime-text-x-python',
47
 
                                         gtk.ICON_SIZE_MENU)
48
 
                bottom.add_item(console, _('Python Console'), image)
49
 
                window.set_data('PythonConsolePluginInfo', console)
50
 
 
51
 
        def deactivate(self, window):
52
 
                console = window.get_data("PythonConsolePluginInfo")
53
 
                console.stop()
54
 
                window.set_data("PythonConsolePluginInfo", None)
55
 
                bottom = window.get_bottom_panel()
56
 
                bottom.remove_item(console)
57
 
 
58
 
        def is_configurable(self):
59
 
                return True
60
 
 
61
 
        def create_configure_dialog(self):
62
 
                if not self.dlg:
63
 
                        self.dlg = PythonConsoleConfigDialog(self.get_data_dir())
64
 
                
65
 
                dialog = self.dlg.dialog()
66
 
                window = gedit.app_get_default().get_active_window()
67
 
                if window:
68
 
                        dialog.set_transient_for(window)
69
 
 
70
 
                return dialog
71
 
 
 
36
    def __init__(self):
 
37
        gedit.Plugin.__init__(self)
 
38
        self.dlg = None
 
39
 
 
40
    def activate(self, window):
 
41
        console = PythonConsole(namespace = {'__builtins__' : __builtins__,
 
42
                                             'gedit' : gedit,
 
43
                                             'window' : window})
 
44
        console.eval('print "You can access the main window through ' \
 
45
                     '\'window\' :\\n%s" % window', False)
 
46
        bottom = window.get_bottom_panel()
 
47
        image = gtk.Image()
 
48
        image.set_from_icon_name(PYTHON_ICON, gtk.ICON_SIZE_MENU)
 
49
        bottom.add_item(console, _('Python Console'), image)
 
50
        window.set_data('PythonConsolePluginInfo', console)
 
51
 
 
52
    def deactivate(self, window):
 
53
        console = window.get_data("PythonConsolePluginInfo")
 
54
        console.stop()
 
55
        window.set_data("PythonConsolePluginInfo", None)
 
56
        bottom = window.get_bottom_panel()
 
57
        bottom.remove_item(console)
 
58
 
 
59
    def is_configurable(self):
 
60
        return True
 
61
 
 
62
    def create_configure_dialog(self):
 
63
        if not self.dlg:
 
64
            self.dlg = PythonConsoleConfigDialog(self.get_data_dir())
 
65
 
 
66
        dialog = self.dlg.dialog()
 
67
        window = gedit.app_get_default().get_active_window()
 
68
        if window:
 
69
            dialog.set_transient_for(window)
 
70
 
 
71
        return dialog
 
72
 
 
73
# ex:et:ts=4: