[gedit-latex] Remove WindowScopeViews



commit da104f1d27ca99f7457634a7d9113c53eb5c8613
Author: John Stowers <john stowers gmail com>
Date:   Mon Aug 22 21:35:01 2011 +1200

    Remove WindowScopeViews
    
    LaTeXSymbolBrowser was the only user

 latex/base/__init__.py          |   14 +-----
 latex/base/config.py            |   12 -----
 latex/base/windowactivatable.py |   95 +--------------------------------------
 3 files changed, 2 insertions(+), 119 deletions(-)
---
diff --git a/latex/base/__init__.py b/latex/base/__init__.py
index c299de2..9412d0b 100644
--- a/latex/base/__init__.py
+++ b/latex/base/__init__.py
@@ -38,7 +38,6 @@ class PanelView(Gtk.Box):
 
     _log = getLogger("PanelView")
 
-    SCOPE_WINDOW = 0
     SCOPE_EDITOR = 1
 
     def __init__(self, context):
@@ -55,16 +54,6 @@ class PanelView(Gtk.Box):
     def get_icon(self):
         return None
 
-    # FIXME: this doesn't seems to be used, should we remove it?
-    # the scope of this PanelView:
-    #    SCOPE_WINDOW: the View is created with the window and the same instance is passed to every Editor
-    #    SCOPE_EDITOR: the View is created with the Editor and destroyed with it
-    def get_scope(self):
-        return self.SCOPE_WINDOW
-
-    def __del__(self):
-        self._log.debug("Properly destroyed %s" % self)
-
 class Template(object):
     """
     This one is exposed and should be used by the 'real' plugin code
@@ -103,7 +92,6 @@ class WindowContext(object):
         self._window_decorator = window_decorator
         self._editor_scope_view_classes = editor_scope_view_classes
 
-        self.window_scope_views = {}    # maps view ids to View objects
         self.editor_scope_views = {}    # maps Editor object to a map from ID to View object
 
         self._log.debug("init")
@@ -155,7 +143,7 @@ class WindowContext(object):
         try:
             return self.editor_scope_views[editor][view_id]
         except KeyError:
-            return self.window_scope_views[view_id]
+            self._log.critical("Unknown view id: %s" % view_id)
 
     def set_action_enabled(self, action_id, enabled):
         """
diff --git a/latex/base/config.py b/latex/base/config.py
index d6a0fed..74bbf51 100644
--- a/latex/base/config.py
+++ b/latex/base/config.py
@@ -23,7 +23,6 @@ base.config
 """
 
 # actions
-
 from ..latex.actions import LaTeXMenuAction, LaTeXNewAction, LaTeXChooseMasterAction, \
         LaTeXListMenuAction, LaTeXListActionDefault, \
         LaTeXItemizeAction, LaTeXEnumerateAction, LaTeXFontFamilyAction, LaTeXFontFamilyMenuAction, LaTeXBoldAction, \
@@ -54,25 +53,15 @@ ACTIONS = [LaTeXMenuAction, LaTeXNewAction, LaTeXChooseMasterAction,
         BibTeXMenuAction, BibTeXNewEntryAction]
 
 # views
-
 from ..views import IssueView
 from ..latex.views import LaTeXSymbolMapView, LaTeXOutlineView
 from ..bibtex.views import BibTeXOutlineView
 
 
-#WINDOW_SCOPE_VIEWS = {".tex": {"LaTeXSymbolMapView": LaTeXSymbolMapView}}
-#
-#EDITOR_SCOPE_VIEWS = {".tex": {"IssueView": IssueView,
-#                                 "LaTeXOutlineView": LaTeXOutlineView},
-#
-#                       ".bib": {"IssueView": IssueView,
-#                                 "BibTeXOutlineView": BibTeXOutlineView}}
-
 from ..preferences import Preferences
 LATEX_EXTENSIONS = Preferences().get("latex-extensions").split(",")
 BIBTEX_EXTENSIONS = [".bib"]
 
-WINDOW_SCOPE_VIEWS = {}
 EDITOR_SCOPE_VIEWS = {}
 
 for e in LATEX_EXTENSIONS:
@@ -83,7 +72,6 @@ for e in BIBTEX_EXTENSIONS:
 
 
 # editors
-
 from ..latex.editor import LaTeXEditor
 from ..bibtex.editor import BibTeXEditor
 
diff --git a/latex/base/windowactivatable.py b/latex/base/windowactivatable.py
index 7fa5c32..5864c6d 100644
--- a/latex/base/windowactivatable.py
+++ b/latex/base/windowactivatable.py
@@ -33,7 +33,7 @@ from ..preferences.dialog import PreferencesDialog
 from ..preferences.tools import ToolPreferences
 from ..tools import ToolAction
 from ..tools.views import ToolView
-from .config import WINDOW_SCOPE_VIEWS, EDITOR_SCOPE_VIEWS, ACTIONS
+from .config import EDITOR_SCOPE_VIEWS, ACTIONS
 from .decorators import GeditTabDecorator
 from .resources import Resources
 from . import PanelView, WindowContext
@@ -123,12 +123,6 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
         # remove all views
         self.disable()
 
-        # destroy all window scope views
-        # (the editor scope views are destroyed by the editor)
-        for i in self._window_context.window_scope_views:
-            self._window_context.window_scope_views[i].destroy()
-        self._window_context.window_scope_views = {}
-
         # remove toolbar
         if self._toolbar:
             self._toolbar.destroy()
@@ -165,10 +159,6 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
         self._side_views = []
         self._bottom_views = []
 
-        # currently hooked window-scope views
-        self._window_side_views = []
-        self._window_bottom_views = []
-
         # caches window-scope View instances
         self._views = {}
 
@@ -184,8 +174,6 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
         bottom_panel.add_item(tool_view, "ToolViewid", tool_view.get_label(), tool_view.get_icon())
         #self._window_bottom_views.append(tool_view)
 
-        # update window context
-        self._window_context.window_scope_views = self._views
 
     def _init_actions(self):
         """
@@ -384,24 +372,6 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
             for name in l:
                 self._tool_action_group.get_action(name).set_sensitive(False)
 
-        # remove all side views
-        side_views = self._window_side_views + self._side_views
-        for view in side_views:
-            self.window.get_side_panel().remove_item(view)
-            if view in self._side_views:
-                self._side_views.remove(view)
-            if view in self._window_side_views:
-                self._window_side_views.remove(view)
-
-        # remove all bottom views
-        bottom_views = self._window_bottom_views + self._bottom_views
-        for view in bottom_views:
-            self.window.get_bottom_panel().remove_item(view)
-            if view in self._bottom_views:
-                self._bottom_views.remove(view)
-            if view in self._window_bottom_views:
-                self._window_bottom_views.remove(view)
-
     def adjust(self, tab_decorator):
         """
         Adjust actions and views according to the currently active TabDecorator
@@ -509,69 +479,6 @@ class LaTeXWindowActivatable(GObject.Object, Gedit.WindowActivatable, PeasGtk.Co
             self.window.get_bottom_panel().add_item(view, "bottom_view_id" + str(i), view.get_label(), view.get_icon())
             self._bottom_views.append(view)
 
-        #
-        # adjust window-scope views
-        #
-
-        # determine set of side/bottom views BEFORE
-
-        before_window_side_views = set(self._window_side_views)
-        before_window_bottom_views = set(self._window_bottom_views)
-
-        # determine set of side/bottom views AFTER
-
-        after_window_side_views = set()
-        after_window_bottom_views = set()
-
-        try:
-            for id, clazz in WINDOW_SCOPE_VIEWS[extension].iteritems():
-
-                # find or create View instance
-                view = None
-                try:
-                    view = self._views[id]
-                except KeyError:
-                    view = clazz.__new__(clazz)
-                    clazz.__init__(view, self._window_context)
-                    self._views[id] = view
-
-                if isinstance(view, PanelView):
-                    if view.get_orientation() == Gtk.Orientation.HORIZONTAL:
-                        after_window_bottom_views.add(view)
-                    else:
-                        after_window_side_views.add(view)
-                else:
-                    raise RuntimeError("Invalid view type: %s" % view)
-        except KeyError:
-            self._log.debug("No window-scope views for this extension")
-
-        # remove BEFORE.difference(AFTER)
-        for view in before_window_side_views.difference(after_window_side_views):
-            self.window.get_side_panel().remove_item(view)
-            self._window_side_views.remove(view)
-
-        for view in before_window_bottom_views.difference(after_window_bottom_views):
-            self.window.get_bottom_panel().remove_item(view)
-            self._window_bottom_views.remove(view)
-
-        # add AFTER.difference(BEFORE)
-        i = 1
-        for view in after_window_side_views.difference(before_window_side_views):
-            self.window.get_side_panel().add_item(view, "SidePanelId_" + str(i), view.get_label(), view.get_icon())
-            self._window_side_views.append(view)
-            i += 1
-
-        i = 1
-        for view in after_window_bottom_views.difference(before_window_bottom_views):
-            self.window.get_bottom_panel().add_item(view, "BottomPanelId_" + str(i), view.get_label(), view.get_icon())
-            self._window_bottom_views.append(view)
-            i += 1
-
-        #
-        # update window context
-        #
-        self._window_context.window_scope_views = self._views
-
     def _on_tab_added(self, window, tab):
         """
         A new tab has been added



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]