Porting urgentcontentnotify to Seed



Hi.

I'm trying to port the "Urgent Content Notify" extension
(http://www.sstuhr.dk/epiphany-extensions/) from Python to Seed.

AFAICT I have managed to hook into the window attach and detach cleanly,
but my hook into the tab is causing errors, and the window is never set
urgent.  I even managed to crash the browser once.

I have appended the current extension, debugging print statements
included.  As far as I can tell, I'm hooking into the right signal for
the tab (the signal fires at the appropriate time), but I'm not handling
the signal right, and I'm not sure what I need to change.

What am I doing wrong?

-- 
Bruce Guenter <bruce untroubled org>                http://untroubled.org/

function window_set_focus(window, event)
{
	window.set_urgency_hint(false);
	return false;
}

function content_changed(embed, data)
{
	print("changed");
	print(embed);
	window = embed.get_window();
	print(window);
	window.set_urgency_hint(true);
	return false;
}

function attach_tab(window, tab)
{
	var embed = (tab.get_embed != null) ? tab.get_embed() : tab;
	var webview = embed.get_web_view();
	webview._ucn_load_finished_signal = webview.signal.load_finished.connect(content_changed);
}

function detach_tab(window, tab)
{
	var embed = (tab.get_embed != null) ? tab.get_embed() : tab;
	var webview = embed.get_web_view();
	if (webview._ucn_load_finished_signal) {
		webview.signal.disconnect(webview._ucn_load_finished_signal);
	}
}

function attach_window(window)
{
	window._ucn_window_focus_in_event_signal = window.signal.focus_in_event.connect(window_set_focus);
}

function detach_window(window)
{
	if (window._ucn_window_focus_in_event_signal) {
		window.signal.disconnect(window._ucn_window_focus_in_event_signal);
	}
}

extension = {
    attach_tab: attach_tab,
    detach_tab: detach_tab,
    attach_window: attach_window,
    detach_window: detach_window,
};

Attachment: pgpIrrN0RQS7R.pgp
Description: PGP signature



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