/* delayed-load.c generated by valac 0.38.8, the Vala compiler
 * generated from delayed-load.vala, do not modify */

/*
   Copyright (C) 2012-2013 André Stösel <andre@stoesel.de>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   See the file COPYING for the full license text.
*/

#include <glib.h>
#include <glib-object.h>
#include "midori/midori-extension.h"
#include "midori/midori-view.h"
#include "katze/katze.h"
#include "midori-core.h"
#include "midori/midori-browser.h"
#include "midori/midori-app.h"
#include <glib/gi18n-lib.h>
#include "delayed-load.h"


#define DELAYED_LOAD_TYPE_MANAGER (delayed_load_manager_get_type ())
#define DELAYED_LOAD_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DELAYED_LOAD_TYPE_MANAGER, DelayedLoadManager))
#define DELAYED_LOAD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DELAYED_LOAD_TYPE_MANAGER, DelayedLoadManagerClass))
#define DELAYED_LOAD_IS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DELAYED_LOAD_TYPE_MANAGER))
#define DELAYED_LOAD_IS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DELAYED_LOAD_TYPE_MANAGER))
#define DELAYED_LOAD_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DELAYED_LOAD_TYPE_MANAGER, DelayedLoadManagerClass))

typedef struct _DelayedLoadManager DelayedLoadManager;
typedef struct _DelayedLoadManagerClass DelayedLoadManagerClass;
typedef struct _DelayedLoadManagerPrivate DelayedLoadManagerPrivate;
enum  {
	DELAYED_LOAD_MANAGER_0_PROPERTY,
	DELAYED_LOAD_MANAGER_NUM_PROPERTIES
};
static GParamSpec* delayed_load_manager_properties[DELAYED_LOAD_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))

struct _DelayedLoadManager {
	MidoriExtension parent_instance;
	DelayedLoadManagerPrivate * priv;
};

struct _DelayedLoadManagerClass {
	MidoriExtensionClass parent_class;
};


static gpointer delayed_load_manager_parent_class = NULL;

GType delayed_load_manager_get_type (void) G_GNUC_CONST;
static void delayed_load_manager_tab_changed (DelayedLoadManager* self, MidoriView* old_view, MidoriView* new_view);
static void delayed_load_manager_browser_added (DelayedLoadManager* self, MidoriBrowser* browser);
static void _delayed_load_manager_tab_changed_midori_browser_switch_tab (MidoriBrowser* _sender, MidoriView* old_view, MidoriView* new_view, gpointer self);
static void delayed_load_manager_browser_removed (DelayedLoadManager* self, MidoriBrowser* browser);
void delayed_load_manager_activated (DelayedLoadManager* self, MidoriApp* app);
static void _delayed_load_manager_browser_added_midori_app_add_browser (MidoriApp* _sender, MidoriBrowser* browser, gpointer self);
void delayed_load_manager_deactivated (DelayedLoadManager* self);
DelayedLoadManager* delayed_load_manager_new (void);
DelayedLoadManager* delayed_load_manager_construct (GType object_type);
static void _delayed_load_manager_activated_midori_extension_activate (MidoriExtension* _sender, MidoriApp* app, gpointer self);
static void _delayed_load_manager_deactivated_midori_extension_deactivate (MidoriExtension* _sender, gpointer self);


static void delayed_load_manager_tab_changed (DelayedLoadManager* self, MidoriView* old_view, MidoriView* new_view) {
	MidoriView* _tmp0_;
#line 14 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_return_if_fail (self != NULL);
#line 15 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_tmp0_ = new_view;
#line 15 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	if (_tmp0_ != NULL) {
#line 80 "delayed-load.c"
		KatzeItem* item = NULL;
		MidoriView* _tmp1_;
		KatzeItem* _tmp2_;
		gint64 delay = 0LL;
		KatzeItem* _tmp3_;
		gint64 _tmp4_;
		gboolean _tmp5_ = FALSE;
		gint64 _tmp6_;
#line 16 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		_tmp1_ = new_view;
#line 16 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		_tmp2_ = midori_view_get_proxy_item (_tmp1_);
#line 16 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		item = _tmp2_;
#line 18 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		_tmp3_ = item;
#line 18 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		_tmp4_ = katze_item_get_meta_integer (_tmp3_, "delay");
#line 18 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		delay = _tmp4_;
#line 19 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		_tmp6_ = delay;
#line 19 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		if (_tmp6_ == ((gint64) MIDORI_DELAY_PENDING_UNDELAY)) {
#line 105 "delayed-load.c"
			MidoriView* _tmp7_;
			gdouble _tmp8_;
			gdouble _tmp9_;
#line 19 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
			_tmp7_ = new_view;
#line 19 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
			_tmp8_ = midori_tab_get_progress ((MidoriTab*) _tmp7_);
#line 19 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
			_tmp9_ = _tmp8_;
#line 19 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
			_tmp5_ = _tmp9_ < 1.0;
#line 117 "delayed-load.c"
		} else {
#line 19 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
			_tmp5_ = FALSE;
#line 121 "delayed-load.c"
		}
#line 19 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		if (_tmp5_) {
#line 125 "delayed-load.c"
			MidoriView* _tmp10_;
#line 20 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
			_tmp10_ = new_view;
#line 20 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
			midori_view_reload (_tmp10_, TRUE);
#line 131 "delayed-load.c"
		}
	}
}


static void _delayed_load_manager_tab_changed_midori_browser_switch_tab (MidoriBrowser* _sender, MidoriView* old_view, MidoriView* new_view, gpointer self) {
#line 26 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	delayed_load_manager_tab_changed ((DelayedLoadManager*) self, old_view, new_view);
#line 140 "delayed-load.c"
}


static void delayed_load_manager_browser_added (DelayedLoadManager* self, MidoriBrowser* browser) {
	MidoriBrowser* _tmp0_;
#line 25 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_return_if_fail (self != NULL);
#line 25 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_return_if_fail (browser != NULL);
#line 26 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_tmp0_ = browser;
#line 26 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_signal_connect_object (_tmp0_, "switch-tab", (GCallback) _delayed_load_manager_tab_changed_midori_browser_switch_tab, self, G_CONNECT_AFTER);
#line 154 "delayed-load.c"
}


static void delayed_load_manager_browser_removed (DelayedLoadManager* self, MidoriBrowser* browser) {
	MidoriBrowser* _tmp0_;
	guint _tmp1_;
#line 29 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_return_if_fail (self != NULL);
#line 29 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_return_if_fail (browser != NULL);
#line 30 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_tmp0_ = browser;
#line 30 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_signal_parse_name ("switch-tab", MIDORI_TYPE_BROWSER, &_tmp1_, NULL, FALSE);
#line 30 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_signal_handlers_disconnect_matched (_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _delayed_load_manager_tab_changed_midori_browser_switch_tab, self);
#line 171 "delayed-load.c"
}


static gpointer _g_object_ref0 (gpointer self) {
#line 34 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	return self ? g_object_ref (self) : NULL;
#line 178 "delayed-load.c"
}


static void _delayed_load_manager_browser_added_midori_app_add_browser (MidoriApp* _sender, MidoriBrowser* browser, gpointer self) {
#line 37 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	delayed_load_manager_browser_added ((DelayedLoadManager*) self, browser);
#line 185 "delayed-load.c"
}


void delayed_load_manager_activated (DelayedLoadManager* self, MidoriApp* app) {
	MidoriApp* _tmp0_;
	GList* _tmp1_;
	MidoriApp* _tmp4_;
#line 33 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_return_if_fail (self != NULL);
#line 33 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_return_if_fail (app != NULL);
#line 34 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_tmp0_ = app;
#line 34 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_tmp1_ = midori_app_get_browsers (_tmp0_);
#line 201 "delayed-load.c"
	{
		GList* browser_collection = NULL;
		GList* browser_it = NULL;
#line 34 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		browser_collection = _tmp1_;
#line 34 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		for (browser_it = browser_collection; browser_it != NULL; browser_it = browser_it->next) {
#line 209 "delayed-load.c"
			MidoriBrowser* _tmp2_;
			MidoriBrowser* browser = NULL;
#line 34 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
			_tmp2_ = _g_object_ref0 ((MidoriBrowser*) browser_it->data);
#line 34 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
			browser = _tmp2_;
#line 216 "delayed-load.c"
			{
				MidoriBrowser* _tmp3_;
#line 35 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
				_tmp3_ = browser;
#line 35 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
				delayed_load_manager_browser_added (self, _tmp3_);
#line 34 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
				_g_object_unref0 (browser);
#line 225 "delayed-load.c"
			}
		}
#line 34 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		_g_list_free0 (browser_collection);
#line 230 "delayed-load.c"
	}
#line 37 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_tmp4_ = app;
#line 37 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_signal_connect_object (_tmp4_, "add-browser", (GCallback) _delayed_load_manager_browser_added_midori_app_add_browser, self, 0);
#line 236 "delayed-load.c"
}


void delayed_load_manager_deactivated (DelayedLoadManager* self) {
	MidoriApp* app = NULL;
	MidoriApp* _tmp0_;
	MidoriApp* _tmp1_;
	MidoriApp* _tmp2_;
	GList* _tmp3_;
	MidoriApp* _tmp6_;
	guint _tmp7_;
#line 40 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_return_if_fail (self != NULL);
#line 41 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_tmp0_ = midori_extension_get_app ((MidoriExtension*) self);
#line 41 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_tmp1_ = _g_object_ref0 (_tmp0_);
#line 41 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	app = _tmp1_;
#line 42 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_tmp2_ = app;
#line 42 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_tmp3_ = midori_app_get_browsers (_tmp2_);
#line 260 "delayed-load.c"
	{
		GList* browser_collection = NULL;
		GList* browser_it = NULL;
#line 42 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		browser_collection = _tmp3_;
#line 42 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		for (browser_it = browser_collection; browser_it != NULL; browser_it = browser_it->next) {
#line 268 "delayed-load.c"
			MidoriBrowser* _tmp4_;
			MidoriBrowser* browser = NULL;
#line 42 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
			_tmp4_ = _g_object_ref0 ((MidoriBrowser*) browser_it->data);
#line 42 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
			browser = _tmp4_;
#line 275 "delayed-load.c"
			{
				MidoriBrowser* _tmp5_;
#line 43 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
				_tmp5_ = browser;
#line 43 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
				delayed_load_manager_browser_removed (self, _tmp5_);
#line 42 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
				_g_object_unref0 (browser);
#line 284 "delayed-load.c"
			}
		}
#line 42 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
		_g_list_free0 (browser_collection);
#line 289 "delayed-load.c"
	}
#line 45 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_tmp6_ = app;
#line 45 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_signal_parse_name ("add-browser", MIDORI_TYPE_APP, &_tmp7_, NULL, FALSE);
#line 45 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_signal_handlers_disconnect_matched (_tmp6_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp7_, 0, NULL, (GCallback) _delayed_load_manager_browser_added_midori_app_add_browser, self);
#line 40 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_g_object_unref0 (app);
#line 299 "delayed-load.c"
}


static void _delayed_load_manager_activated_midori_extension_activate (MidoriExtension* _sender, MidoriApp* app, gpointer self) {
#line 54 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	delayed_load_manager_activated ((DelayedLoadManager*) self, app);
#line 306 "delayed-load.c"
}


static void _delayed_load_manager_deactivated_midori_extension_deactivate (MidoriExtension* _sender, gpointer self) {
#line 55 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	delayed_load_manager_deactivated ((DelayedLoadManager*) self);
#line 313 "delayed-load.c"
}


DelayedLoadManager* delayed_load_manager_construct (GType object_type) {
	DelayedLoadManager * self = NULL;
#line 49 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	self = (DelayedLoadManager*) g_object_new (object_type, "name", _ ("Delayed load"), "description", _ ("Delay page load until you actually use the tab."), "version", "0.2", "authors", "André Stösel <andre@stoesel.de>", NULL);
#line 54 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_signal_connect_object ((MidoriExtension*) self, "activate", (GCallback) _delayed_load_manager_activated_midori_extension_activate, self, 0);
#line 55 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	g_signal_connect_object ((MidoriExtension*) self, "deactivate", (GCallback) _delayed_load_manager_deactivated_midori_extension_deactivate, self, 0);
#line 48 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	return self;
#line 327 "delayed-load.c"
}


DelayedLoadManager* delayed_load_manager_new (void) {
#line 48 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	return delayed_load_manager_construct (DELAYED_LOAD_TYPE_MANAGER);
#line 334 "delayed-load.c"
}


static void delayed_load_manager_class_init (DelayedLoadManagerClass * klass) {
#line 13 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	delayed_load_manager_parent_class = g_type_class_peek_parent (klass);
#line 341 "delayed-load.c"
}


static void delayed_load_manager_instance_init (DelayedLoadManager * self) {
}


GType delayed_load_manager_get_type (void) {
	static volatile gsize delayed_load_manager_type_id__volatile = 0;
	if (g_once_init_enter (&delayed_load_manager_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DelayedLoadManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) delayed_load_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DelayedLoadManager), 0, (GInstanceInitFunc) delayed_load_manager_instance_init, NULL };
		GType delayed_load_manager_type_id;
		delayed_load_manager_type_id = g_type_register_static (MIDORI_TYPE_EXTENSION, "DelayedLoadManager", &g_define_type_info, 0);
		g_once_init_leave (&delayed_load_manager_type_id__volatile, delayed_load_manager_type_id);
	}
	return delayed_load_manager_type_id__volatile;
}


MidoriExtension* extension_init (void) {
	MidoriExtension* result = NULL;
	DelayedLoadManager* _tmp0_;
#line 61 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	_tmp0_ = delayed_load_manager_new ();
#line 61 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	result = (MidoriExtension*) _tmp0_;
#line 61 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/delayed-load.vala"
	return result;
#line 370 "delayed-load.c"
}



