/* "hide-close-on-minimized-tabs" has changed */
static void _interface_tweaks_on_hide_close_on_minimized_tabs_changed(InterfaceTweaks *self, gboolean inValue)
{
	g_return_if_fail(IS_INTERFACE_TWEAKS(self));

	InterfaceTweaksPrivate	*priv=self->priv;
	GList					*browsers, *browsersIter;
	GList					*tabs, *tabsIter;

	/* If value changed set it and emit notification of property change */
	if(priv->hideCloseOnMinimizedTabs!=inValue || !priv->inited)
	{
		/* Change property */
		priv->hideCloseOnMinimizedTabs=inValue;
		if(priv->inited) midori_extension_set_boolean(priv->extension, "hide-close-on-minimized-tabs", priv->hideCloseOnMinimizedTabs);

		/* Apply new value to all tabs in all browsers */
		browsers=midori_app_get_browsers(priv->application);
		for(browsersIter=browsers; browsersIter; browsersIter=g_list_next(browsersIter))
		{
			tabs=midori_browser_get_tabs(MIDORI_BROWSER(browsersIter->data));
			for(tabsIter=tabs; tabsIter; tabsIter=g_list_next(tabsIter))
			{
				_interface_tweaks_on_notify_minimized_tab_for_close_button(self, NULL, MIDORI_VIEW(tabsIter->data));
			}
			g_list_free(tabs);
		}
		g_list_free(browsers);

		/* Notify about property change */
		g_object_notify_by_pspec(G_OBJECT(self), InterfaceTweaksProperties[PROP_HIDE_CLOSE_ON_MINIMIZED_TABS]);
	}
}
/* "group-minimized-tabs" has changed */
static void _interface_tweaks_on_group_minimized_tabs_changed(InterfaceTweaks *self, gboolean inValue)
{
	g_return_if_fail(IS_INTERFACE_TWEAKS(self));

	InterfaceTweaksPrivate	*priv=self->priv;
	GList					*browsers, *browsersIter;
	GList					*tabs, *tabsIter;
	MidoriBrowser			*browser;
	GtkNotebook				*notebook;
	MidoriView				*view;
	gboolean				minimized;

	/* If value changed set it and emit notification of property change */
	if(priv->groupMinimizedTabs!=inValue || !priv->inited)
	{
		/* Change property */
		priv->groupMinimizedTabs=inValue;
		if(priv->inited) midori_extension_set_boolean(priv->extension, "group-minimized-tabs", priv->groupMinimizedTabs);

		/* Move minimized tabs in all browsers to front if activated */
		if(priv->groupMinimizedTabs)
		{
			browsers=midori_app_get_browsers(priv->application);
			for(browsersIter=browsers; browsersIter; browsersIter=g_list_next(browsersIter))
			{
				browser=MIDORI_BROWSER(browsersIter->data);
				if(browser)
				{
					notebook=NULL;
					g_object_get(browser, "notebook", &notebook, NULL);
					if(notebook)
					{
						tabs=midori_browser_get_tabs(MIDORI_BROWSER(browsersIter->data));
						for(tabsIter=tabs; tabsIter; tabsIter=g_list_next(tabsIter))
						{
							view=MIDORI_VIEW(tabsIter->data);
							if(view)
							{
								g_signal_handlers_block_by_func(view, G_CALLBACK(_interface_tweaks_on_notify_minimized_tab_for_group_tabs), self);

								minimized=FALSE;
								g_object_get(view, "minimized", &minimized, NULL);
								if(minimized) gtk_notebook_reorder_child(GTK_NOTEBOOK(notebook), GTK_WIDGET(view), 0);

								g_signal_handlers_unblock_by_func(view, G_CALLBACK(_interface_tweaks_on_notify_minimized_tab_for_group_tabs), self);
							}
						}
						g_list_free(tabs);

						g_object_unref(notebook);
					}
				}
			}
			g_list_free(browsers);
		}

		/* Notify about property change */
		g_object_notify_by_pspec(G_OBJECT(self), InterfaceTweaksProperties[PROP_GROUP_MINIMIZED_TABS]);
	}
}
예제 #3
0
static void 
car_illegal_query_activated_cb (MidoriExtension* extension, 
                                MidoriApp*       app) 
{
   GList* browser_it = NULL;
   GList* browser_collection = midori_app_get_browsers (app);

   for (browser_it = browser_collection; browser_it != NULL; browser_it = browser_it->next) 
   {
      MidoriBrowser* browser = (MidoriBrowser*) browser_it->data;
      car_illegal_query_extension_browser_added_cb(app,browser,extension);
   }
   g_signal_connect (app, "add-browser",
       G_CALLBACK (car_illegal_query_extension_browser_added_cb), extension);
}
예제 #4
0
파일: night_mode.c 프로젝트: sinoory/webv8
static void 
night_mode_activated_cb (MidoriExtension* extension, 
                         MidoriApp*       app) 
{
   g_night_mode = false; 
   GList* browser_it = NULL;
   GList* browser_collection = midori_app_get_browsers (app);

   for (browser_it = browser_collection; browser_it != NULL; browser_it = browser_it->next) 
        {
      MidoriBrowser* browser = (MidoriBrowser*) browser_it->data;
      night_mode_extension_add_browser_cb(app,browser,extension);
        }
   g_signal_connect (app, "add-browser",
       G_CALLBACK (night_mode_extension_add_browser_cb), extension);
}
예제 #5
0
/* Application property has changed */
static void _cookie_permission_manager_on_application_changed(CookiePermissionManager *self)
{
	CookiePermissionManagerPrivate		*priv=COOKIE_PERMISSION_MANAGER(self)->priv;
	GList								*browsers, *iter;

	/* Set up all current open browser windows */
	browsers=midori_app_get_browsers(priv->application);
	for(iter=browsers; iter; iter=g_list_next(iter))
	{
		_cookie_permission_manager_on_add_browser(self, MIDORI_BROWSER(iter->data), priv->application);
	}
	g_list_free(browsers);

	/* Listen to new browser windows opened and existing ones closed */
	g_signal_connect_swapped(priv->application, "add-browser", G_CALLBACK(_cookie_permission_manager_on_add_browser), self);
}
예제 #6
0
/* Finalize this object */
static void cookie_permission_manager_finalize(GObject *inObject)
{
	CookiePermissionManager			*self=COOKIE_PERMISSION_MANAGER(inObject);
	CookiePermissionManagerPrivate	*priv=self->priv;
	GList							*browsers, *browser;
	GList							*tabs, *tab;
	WebKitWebView					*webkitView;

	/* Dispose allocated resources */
	if(priv->databaseFilename)
	{
		g_free(priv->databaseFilename);
		priv->databaseFilename=NULL;
		g_object_notify_by_pspec(inObject, CookiePermissionManagerProperties[PROP_DATABASE_FILENAME]);
	}

	if(priv->database)
	{
		sqlite3_close(priv->database);
		priv->database=NULL;
		g_object_notify_by_pspec(inObject, CookiePermissionManagerProperties[PROP_DATABASE]);
	}

	g_signal_handler_disconnect(priv->cookieJar, priv->cookieJarChangedID);
	g_object_steal_data(G_OBJECT(priv->cookieJar), "cookie-permission-manager");

	g_signal_handlers_disconnect_by_data(priv->application, self);

	browsers=midori_app_get_browsers(priv->application);
	for(browser=browsers; browser; browser=g_list_next(browser))
	{
		g_signal_handlers_disconnect_by_data(browser->data, self);

		tabs=midori_browser_get_tabs(MIDORI_BROWSER(browser->data));
		for(tab=tabs; tab; tab=g_list_next(tab))
		{
			webkitView=WEBKIT_WEB_VIEW(midori_view_get_web_view(MIDORI_VIEW(tab->data)));
			g_signal_handlers_disconnect_by_data(webkitView, self);
		}
		g_list_free(tabs);
	}
	g_list_free(browsers);

	/* Call parent's class finalize method */
	G_OBJECT_CLASS(cookie_permission_manager_parent_class)->finalize(inObject);
}
/* Application property has changed */
static void _interface_tweaks_on_application_changed(InterfaceTweaks *self, MidoriApp *inApplication)
{
	g_return_if_fail(IS_INTERFACE_TWEAKS(self));
	g_return_if_fail(inApplication==NULL || MIDORI_IS_APP(inApplication));

	InterfaceTweaksPrivate				*priv=INTERFACE_TWEAKS(self)->priv;
	GtkNotebook							*notebook;
	MidoriBrowser						*browser;
	GList								*browsers, *browsersIter;
	GList								*tabs, *tabsIter;
	WebKitWebView						*webkitView;
	InterfaceTweaksLocationbarLookup	locationbar;

	/* Release resources on current application object */
	if(priv->application)
	{
		g_signal_handlers_disconnect_by_data(priv->application, self);

		browsers=midori_app_get_browsers(priv->application);
		for(browsersIter=browsers; browsersIter; browsersIter=g_list_next(browsersIter))
		{
			browser=MIDORI_BROWSER(browsersIter->data);
			g_signal_handlers_disconnect_by_data(browser, self);

			tabs=midori_browser_get_tabs(MIDORI_BROWSER(browsersIter->data));
			for(tabsIter=tabs; tabsIter; tabsIter=g_list_next(tabsIter))
			{
				g_signal_handlers_disconnect_by_data(tabsIter->data, self);

				webkitView=WEBKIT_WEB_VIEW(midori_view_get_web_view(MIDORI_VIEW(tabsIter->data)));
				g_signal_handlers_disconnect_by_data(webkitView, self);
			}
			g_list_free(tabs);

			notebook=NULL;
			g_object_get(browser, "notebook", &notebook, NULL);
			if(notebook)
			{
				g_signal_handlers_disconnect_by_data(notebook, self);
				g_object_unref(notebook);
			}

			_interface_tweaks_find_browser_locationbar(browser, &locationbar);
			if(locationbar.widget)
			{
				GtkEntry				*entry=GTK_ENTRY(locationbar.widget);
				GtkEntryCompletion		*completion;
				gulong					hookID;
				guint					keyPressSignalID;

				g_signal_handlers_disconnect_by_data(entry, self);

				completion=gtk_entry_get_completion(GTK_ENTRY(entry));
				if(completion)
				{
					g_signal_handlers_disconnect_by_data(completion, self);
					gtk_entry_set_completion(entry, NULL);
				}

				hookID=GPOINTER_TO_SIZE(g_object_get_data(G_OBJECT(entry), "interface-tweaks-hook-id"));
				if(hookID!=0)
				{
					keyPressSignalID=g_signal_lookup("key-press-event", GTK_TYPE_ENTRY);
					g_signal_remove_emission_hook(keyPressSignalID, hookID);

					hookID=0L;
					g_object_set_data(G_OBJECT(entry), "interface-tweaks-hook-id", GSIZE_TO_POINTER(hookID));
				}
			}
		}
		g_list_free(browsers);

		g_object_unref(priv->application);
		priv->application=NULL;
	}

	/* Set new application object */
	if(!inApplication) return;
	priv->application=g_object_ref(inApplication);

	/* Set up all current open browser windows */
	browsers=midori_app_get_browsers(priv->application);
	for(browsersIter=browsers; browsersIter; browsersIter=g_list_next(browsersIter))
	{
		_interface_tweaks_on_add_browser(self, MIDORI_BROWSER(browsersIter->data), priv->application);
	}
	g_list_free(browsers);

	/* Listen to new browser windows opened */
	g_signal_connect_swapped(priv->application, "add-browser", G_CALLBACK(_interface_tweaks_on_add_browser), self);

	/* Notify about property change */
	g_object_notify_by_pspec(G_OBJECT(self), InterfaceTweaksProperties[PROP_APPLICATION]);
}