Inspector for ConversationViewer: Closes #6320
Activated by --inspector, this pop ups a WebKit HTML/CSS inspector that's quite useful for development and debugging.
This commit is contained in:
parent
a64bb5582c
commit
7f57e7fb4d
4 changed files with 35 additions and 5 deletions
3
THANKS
3
THANKS
|
|
@ -1,5 +1,7 @@
|
|||
The Geary team would like to thank the following contributors:
|
||||
|
||||
Robert Schroll <rschroll@gmail.com>
|
||||
|
||||
Robert Ancell <robert.ancell@canonical.com>
|
||||
Jürg Billeter <j@bitron.ch>
|
||||
Martijn Braam <pizzamartijn@gmail.com>
|
||||
|
|
@ -18,6 +20,5 @@ Tiago Quelhas <tiagoq@gmail.com>
|
|||
Tom Most <twm@freecog.net>
|
||||
Didier Roche <didrocks@ubuntu.com>
|
||||
Michel Alexandre Salim <salimma@fedoraproject.org>
|
||||
Robert Schroll <rschroll@gmail.com>
|
||||
Alexander Wilms <alexander.wilms@zoho.com>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ private const OptionEntry[] options = {
|
|||
{ "log-sql", 0, 0, OptionArg.NONE, ref log_sql, N_("Log database queries (generates lots of messages)"), null },
|
||||
/// "Normalization" can also be called "synchronization"
|
||||
{ "log-folder-normalization", 0, 0, OptionArg.NONE, ref log_folder_normalization, N_("Log folder normalization"), null },
|
||||
{ "inspector", 'i', 0, OptionArg.NONE, ref inspector, N_("Allow inspection of WebView"), null },
|
||||
{ "version", 'V', 0, OptionArg.NONE, ref version, N_("Display program version"), null },
|
||||
{ null }
|
||||
};
|
||||
|
|
@ -32,6 +33,7 @@ public bool log_conversations = false;
|
|||
public bool log_periodic = false;
|
||||
public bool log_sql = false;
|
||||
public bool log_folder_normalization = false;
|
||||
public bool inspector = false;
|
||||
public bool version = false;
|
||||
|
||||
public int parse(string[] args) {
|
||||
|
|
|
|||
|
|
@ -459,16 +459,16 @@ public class ConversationViewer : Gtk.Box {
|
|||
ConversationViewer conversation_viewer) {
|
||||
Geary.Email email = conversation_viewer.get_email_from_element(clicked_element);
|
||||
if (email != null)
|
||||
conversation_viewer.show_context_menu(email);
|
||||
conversation_viewer.show_context_menu(email, clicked_element);
|
||||
}
|
||||
|
||||
private void show_context_menu(Geary.Email email) {
|
||||
context_menu = build_context_menu(email);
|
||||
private void show_context_menu(Geary.Email email, WebKit.DOM.Element clicked_element) {
|
||||
context_menu = build_context_menu(email, clicked_element);
|
||||
context_menu.show_all();
|
||||
context_menu.popup(null, null, null, 0, 0);
|
||||
}
|
||||
|
||||
private Gtk.Menu build_context_menu(Geary.Email email) {
|
||||
private Gtk.Menu build_context_menu(Geary.Email email, WebKit.DOM.Element clicked_element) {
|
||||
Gtk.Menu menu = new Gtk.Menu();
|
||||
|
||||
if (web_view.can_copy_clipboard()) {
|
||||
|
|
@ -497,6 +497,13 @@ public class ConversationViewer : Gtk.Box {
|
|||
select_all_item.activate.connect(on_select_all);
|
||||
menu.append(select_all_item);
|
||||
|
||||
// Inspect.
|
||||
if (Args.inspector) {
|
||||
Gtk.MenuItem inspect_item = new Gtk.MenuItem.with_mnemonic(_("_Inspect"));
|
||||
inspect_item.activate.connect(() => {web_view.web_inspector.inspect_node(clicked_element);});
|
||||
menu.append(inspect_item);
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ public class ConversationWebView : WebKit.WebView {
|
|||
config.enable_java_applet = false;
|
||||
config.enable_plugins = false;
|
||||
config.enable_default_context_menu = false; // Deprecated, still needed for Precise
|
||||
config.enable_developer_extras = Args.inspector;
|
||||
settings = config;
|
||||
|
||||
// Hook up signals.
|
||||
|
|
@ -41,6 +42,7 @@ public class ConversationWebView : WebKit.WebView {
|
|||
resource_request_starting.connect(on_resource_request_starting);
|
||||
navigation_policy_decision_requested.connect(on_navigation_policy_decision_requested);
|
||||
new_window_policy_decision_requested.connect(on_navigation_policy_decision_requested);
|
||||
web_inspector.inspect_web_view.connect(activate_inspector);
|
||||
|
||||
// Load the HTML into WebKit.
|
||||
// Note: load_finished signal MUST be hooked up before this call.
|
||||
|
|
@ -317,5 +319,23 @@ public class ConversationWebView : WebKit.WebView {
|
|||
public void scroll_to_element(WebKit.DOM.HTMLElement element) {
|
||||
get_dom_document().get_default_view().scroll(element.offset_left, element.offset_top);
|
||||
}
|
||||
|
||||
private unowned WebKit.WebView activate_inspector(WebKit.WebInspector inspector, WebKit.WebView target_view) {
|
||||
Gtk.Window window = new Gtk.Window();
|
||||
window.set_default_size(600, 600);
|
||||
window.set_title(_("%s - Conversation Inspector").printf(GearyApplication.NAME));
|
||||
Gtk.ScrolledWindow scrolled = new Gtk.ScrolledWindow(null, null);
|
||||
WebKit.WebView inspector_view = new WebKit.WebView();
|
||||
scrolled.add(inspector_view);
|
||||
window.add(scrolled);
|
||||
window.show_all();
|
||||
window.delete_event.connect(() => {
|
||||
inspector.close();
|
||||
return false;
|
||||
});
|
||||
|
||||
unowned WebKit.WebView r = inspector_view;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue