Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/inspector.py
diff options
context:
space:
mode:
Diffstat (limited to 'inspector.py')
-rw-r--r--inspector.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/inspector.py b/inspector.py
new file mode 100644
index 0000000..df3db38
--- /dev/null
+++ b/inspector.py
@@ -0,0 +1,79 @@
+# Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import gtk
+import webkit
+
+class Inspector (gtk.Window):
+ def __init__ (self, inspector):
+ """initialize the WebInspector class"""
+ gtk.Window.__init__(self)
+ self.set_default_size(600, 480)
+
+ self._web_inspector = inspector
+
+ self._web_inspector.connect("inspect-web-view",
+ self._inspect_web_view_cb)
+ self._web_inspector.connect("show-window",
+ self._show_window_cb)
+ self._web_inspector.connect("attach-window",
+ self._attach_window_cb)
+ self._web_inspector.connect("detach-window",
+ self._detach_window_cb)
+ self._web_inspector.connect("close-window",
+ self._close_window_cb)
+ self._web_inspector.connect("finished",
+ self._finished_cb)
+
+ self.connect("delete-event", self._close_window_cb)
+
+ def _inspect_web_view_cb (self, inspector, web_view):
+ """Called when the 'inspect' menu item is activated"""
+ scrolled_window = gtk.ScrolledWindow()
+ scrolled_window.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC
+ scrolled_window.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC
+ webview = webkit.WebView()
+ scrolled_window.add(webview)
+ scrolled_window.show_all()
+
+ self.add(scrolled_window)
+ return webview
+
+ def _show_window_cb (self, inspector):
+ """Called when the inspector window should be displayed"""
+ self.present()
+ return True
+
+ def _attach_window_cb (self, inspector):
+ """Called when the inspector should displayed in the same
+ window as the WebView being inspected
+ """
+ return False
+
+ def _detach_window_cb (self, inspector):
+ """Called when the inspector should appear in a separate window"""
+ return False
+
+ def _close_window_cb (self, inspector, view):
+ """Called when the inspector window should be closed"""
+ self.hide()
+ return True
+
+ def _finished_cb (self, inspector):
+ """Called when inspection is done"""
+ self._web_inspector = 0
+ self.destroy()
+ return False