summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthieu Gautier <starmad@pegase.localdomain>2009-03-28 11:31:04 +0100
committerMatthieu Gautier <starmad@pegase.localdomain>2009-03-28 11:31:04 +0100
commitb4cb78b1c6b9a05a5dba9f85fc831d8249fc72f4 (patch)
tree10b7b025cae0f7949a4adf49c5265b50efe0709c
parentb47c39a0fcf6501706d8e2fb5b8064a8b5fd3600 (diff)
downloadg-ed-it-b4cb78b1c6b9a05a5dba9f85fc831d8249fc72f4.zip
g-ed-it-b4cb78b1c6b9a05a5dba9f85fc831d8249fc72f4.tar.gz
g-ed-it-b4cb78b1c6b9a05a5dba9f85fc831d8249fc72f4.tar.xz
Add a document bar.
Signed-off-by: Matthieu Gautier <starmad@pegase.localdomain>
-rw-r--r--g-ed-it/__init__.py3
-rw-r--r--g-ed-it/docBar.py42
-rw-r--r--g-ed-it/g_ed_it.py40
3 files changed, 81 insertions, 4 deletions
diff --git a/g-ed-it/__init__.py b/g-ed-it/__init__.py
index d57f401..870eb32 100644
--- a/g-ed-it/__init__.py
+++ b/g-ed-it/__init__.py
@@ -5,14 +5,13 @@ import os.path
import g_ed_it
-
class G_ed_it(gedit.Plugin):
def __init__(self):
gedit.Plugin.__init__(self)
self.instances = {}
def activate(self, window):
- self.instances[window] = g_ed_it.PluginHelper(self, window)
+ self.instances[window] = g_ed_it.G_ed_itHelper(self, window)
def deactivate(self, window):
self.instances[window].deactivate()
diff --git a/g-ed-it/docBar.py b/g-ed-it/docBar.py
new file mode 100644
index 0000000..a0d049e
--- /dev/null
+++ b/g-ed-it/docBar.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+
+import gedit
+import gtk
+
+class DocBar (object):
+
+ def __init__(self, tab):
+ self.tab = tab
+ self.child = self.tab.get_children()[0]
+ self.tab.remove(self.child)
+ self.vbox = gtk.VBox()
+ hbox = gtk.HBox()
+
+ self.btn_cancel = gtk.Button("End Splitview")
+ self.btn_cancel.connect("clicked", self.end_split_view)
+
+
+ hbox.pack_start(self.btn_cancel, False, False)
+
+ self.vbox.pack_start(hbox, False, False)
+ self.vbox.pack_start(self.child)
+
+ self.tab.add(self.vbox)
+
+ self.tab.show_all()
+
+ print "bar inserted"
+
+ def deactivate(self):
+ self.tab.remove(self.vbox)
+ self.vbox.remove(self.child)
+ self.tab.add(self.child)
+
+ self.vbox = None
+ self.child = None
+ self.tab = None
+ print "bar removed"
+
+ def end_split_view(self):
+ pass
diff --git a/g-ed-it/g_ed_it.py b/g-ed-it/g_ed_it.py
index e5cd15e..f02a3f8 100644
--- a/g-ed-it/g_ed_it.py
+++ b/g-ed-it/g_ed_it.py
@@ -10,10 +10,14 @@ import time
import menuManager
import commitDialog
+import docBar
GLADE_FILE = os.path.join(os.path.dirname(__file__), "g-ed-it.glade")
-class PluginHelper:
+class G_ed_itHelper:
+ G_ED_IT_VIEW_DATA_KEY = "G-ed-itPluginTabData"
+ G_ED_IT_WINDOW_DATA_KEY = "G-ed-itPluginWindowData"
+
def __init__(self, plugin, window):
self.window = window
self.plugin = plugin
@@ -24,6 +28,10 @@ class PluginHelper:
self.menuManager = menuManager.MenuManager(self.window)
self.commitDialog = commitDialog.CommitDialog(self.window,self.glade_xml)
+
+ self.setCallBack()
+
+
# I hardly even know how this works, but it gets our encoding.
try: self.encoding = gedit.encoding_get_current()
@@ -33,6 +41,14 @@ class PluginHelper:
self.menuManager.deactivate()
self.manager.remove_action_group(self.action_group)
+ handlers = self.window.get_data(self.G_ED_IT_WINDOW_DATA_KEY)
+ for handler in handlers:
+ self.window.disconnect(handler)
+ self.window.set_data(self.G_ED_IT_WINDOW_DATA_KEY, None)
+
+ for view in self.window.get_views():
+ view.get_data(self.G_ED_IT_VIEW_DATA_KEY).deactivate()
+
self.window = None
self.plugin = None
@@ -75,5 +91,25 @@ class PluginHelper:
# Add the action group.
self.manager.insert_action_group(self.action_group, -1)
pass
+
+ def setCallBack(self):
+ for view in self.window.get_views():
+ tab = view
+ while (tab.__class__ != gedit.Tab):
+ tab = tab.get_parent()
+ self.createDocBar(tab)
-
+ added_hid = self.window.connect("tab-added",
+ lambda w, t: self.createDocBar(t))
+ removed_hid = self.window.connect("tab-removed",
+ lambda w, t: self.removeDocBar(t))
+ self.window.set_data(self.G_ED_IT_WINDOW_DATA_KEY, (added_hid, removed_hid))
+ pass
+
+ def createDocBar(self, tab):
+ docBar_ = docBar.DocBar(tab)
+ tab.get_view().set_data(self.G_ED_IT_VIEW_DATA_KEY, docBar_)
+
+ def removeDocBar(self, tab):
+ tab.get_view().get_data(self.G_ED_IT_VIEW_DATA_KEY).deactivate()
+ tab.get_view().set_data(self.G_ED_IT_VIEW_DATA_KEY, None)