aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-adblock-extension.c
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-10-03 03:24:32 +0800
committerXan Lopez <xan@igalia.com>2012-10-03 05:20:59 +0800
commit59934f569070b08e57444d0f650cb6e9bd6a036e (patch)
treec33b1b861c394d483fae426825ba0518c5c035be /src/ephy-adblock-extension.c
parentbbf60892b4392af2dac4ec533932a8f40c26fe8d (diff)
downloadgsoc2013-epiphany-59934f569070b08e57444d0f650cb6e9bd6a036e.tar
gsoc2013-epiphany-59934f569070b08e57444d0f650cb6e9bd6a036e.tar.gz
gsoc2013-epiphany-59934f569070b08e57444d0f650cb6e9bd6a036e.tar.bz2
gsoc2013-epiphany-59934f569070b08e57444d0f650cb6e9bd6a036e.tar.lz
gsoc2013-epiphany-59934f569070b08e57444d0f650cb6e9bd6a036e.tar.xz
gsoc2013-epiphany-59934f569070b08e57444d0f650cb6e9bd6a036e.tar.zst
gsoc2013-epiphany-59934f569070b08e57444d0f650cb6e9bd6a036e.zip
Remove UI code from adblock, un-extensionify it
We are not using this code for now, easy enough to re-add somehow if we want to provide a UI to edit the adblock rules. With that gone, it's now trivial to drop the extension code too, so now the adblocker is just a GObject implementing the Adblock interface. https://bugzilla.gnome.org/show_bug.cgi?id=681657
Diffstat (limited to 'src/ephy-adblock-extension.c')
-rw-r--r--src/ephy-adblock-extension.c172
1 files changed, 1 insertions, 171 deletions
diff --git a/src/ephy-adblock-extension.c b/src/ephy-adblock-extension.c
index 93068f2c5..9e7bf5e94 100644
--- a/src/ephy-adblock-extension.c
+++ b/src/ephy-adblock-extension.c
@@ -23,14 +23,11 @@
#include "config.h"
#include "ephy-adblock-extension.h"
-#include "adblock-ui.h"
#include "ephy-adblock.h"
#include "ephy-adblock-manager.h"
#include "ephy-debug.h"
#include "ephy-embed-shell.h"
-#include "ephy-extension.h"
#include "ephy-file-helpers.h"
-#include "ephy-window.h"
#include "uri-tester.h"
#include <glib/gi18n-lib.h>
@@ -38,36 +35,18 @@
#define EPHY_ADBLOCK_EXTENSION_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_ADBLOCK_EXTENSION, EphyAdblockExtensionPrivate))
-#define WINDOW_DATA_KEY "EphyAdblockExtensionWindowData"
-#define STATUSBAR_EVBOX_KEY "EphyAdblockExtensionStatusbarEvbox"
-#define EXTENSION_KEY "EphyAdblockExtension"
-#define AD_BLOCK_ICON_NAME "ad-blocked"
-
-typedef struct
-{
- EphyAdblockExtension *extension;
- EphyWindow *window;
-
- GtkActionGroup *action_group;
- guint ui_id;
-} WindowData;
-
struct EphyAdblockExtensionPrivate
{
UriTester *tester;
- AdblockUI *ui;
};
-static void ephy_adblock_extension_iface_init (EphyExtensionIface *iface);
static void ephy_adblock_adblock_iface_init (EphyAdBlockIface *iface);
G_DEFINE_TYPE_WITH_CODE (EphyAdblockExtension,
ephy_adblock_extension,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (EPHY_TYPE_ADBLOCK,
- ephy_adblock_adblock_iface_init)
- G_IMPLEMENT_INTERFACE (EPHY_TYPE_EXTENSION,
- ephy_adblock_extension_iface_init))
+ ephy_adblock_adblock_iface_init))
/* Private functions. */
@@ -88,7 +67,6 @@ ephy_adblock_extension_dispose (GObject *object)
LOG ("EphyAdblockExtension disposing");
extension = EPHY_ADBLOCK_EXTENSION (object);
- g_clear_object (&extension->priv->ui);
g_clear_object (&extension->priv->tester);
G_OBJECT_CLASS (ephy_adblock_extension_parent_class)->dispose (object);
@@ -139,32 +117,6 @@ ephy_adblock_impl_edit_rule (EphyAdBlock *blocker,
const char *url,
gboolean allowed)
{
- EphyAdblockExtension *self = NULL;
- EphyAdblockExtensionPrivate *priv = NULL;
-
- LOG ("ephy_adblock_impl_edit_rule %s with state %d", url, allowed);
-
- self = EPHY_ADBLOCK_EXTENSION (blocker);
- priv = self->priv;
-
- if (priv->ui == NULL)
- {
- AdblockUI **ui;
-
- /*
- * TODO: url and allowed should be passed to the UI,
- * so the user can actually do something with it.
- */
- priv->ui = adblock_ui_new (priv->tester);
- ui = &priv->ui;
-
- g_object_add_weak_pointer ((gpointer)priv->ui,
- (gpointer *) ui);
-
- ephy_dialog_set_parent (EPHY_DIALOG (priv->ui), NULL);
- }
-
- ephy_dialog_show (EPHY_DIALOG (priv->ui));
}
static void
@@ -173,125 +125,3 @@ ephy_adblock_adblock_iface_init (EphyAdBlockIface *iface)
iface->should_load = ephy_adblock_impl_should_load;
iface->edit_rule = ephy_adblock_impl_edit_rule;
}
-
-static void
-ephy_adblock_extension_edit_cb (GtkAction *action, EphyWindow *window)
-{
- WindowData *data = NULL;
- EphyAdblockExtensionPrivate *priv = NULL;
-
- data = g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
-
- priv = data->extension->priv;
-
- if (priv->ui == NULL)
- {
- AdblockUI **ui;
-
- priv->ui = adblock_ui_new (priv->tester);
- ui = &priv->ui;
-
- g_object_add_weak_pointer ((gpointer)priv->ui,
- (gpointer *) ui);
- }
-
- ephy_dialog_set_parent (EPHY_DIALOG (priv->ui), GTK_WIDGET (window));
- ephy_dialog_show (EPHY_DIALOG (priv->ui));
-}
-
-static const GtkActionEntry edit_entries[] = {
- { "EphyAdblockExtensionEdit", NULL,
- N_("Ad Blocker"), NULL,
- N_("Configure Ad Blocker filters"),
- G_CALLBACK (ephy_adblock_extension_edit_cb) }
-};
-
-static void
-impl_attach_window (EphyExtension *ext,
- EphyWindow *window)
-{
- WindowData *data = NULL;
- GtkUIManager *manager = NULL;
-
- /* Add adblock editor's menu entry. */
- data = g_new (WindowData, 1);
- g_object_set_data_full (G_OBJECT (window),
- WINDOW_DATA_KEY,
- data,
- g_free);
-
- data->extension = EPHY_ADBLOCK_EXTENSION (ext);
- data->window = window;
-
- data->action_group = gtk_action_group_new ("EphyAdblockExtension");
- gtk_action_group_set_translation_domain (data->action_group,
- GETTEXT_PACKAGE);
- gtk_action_group_add_actions (data->action_group, edit_entries,
- G_N_ELEMENTS(edit_entries), window);
-
- manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));
-
- gtk_ui_manager_insert_action_group (manager, data->action_group, -1);
-
- /* UI manager references the new action group. */
- g_object_unref (data->action_group);
-
- data->ui_id = gtk_ui_manager_new_merge_id (manager);
-
- gtk_ui_manager_add_ui (manager,
- data->ui_id,
- "/ui/PagePopup/ExtensionsMenu",
- "EphyAdblockExtensionEdit",
- "EphyAdblockExtensionEdit",
- GTK_UI_MANAGER_MENUITEM,
- FALSE);
-
- /* Remember the xtension attached to that window. */
- g_object_set_data (G_OBJECT (window), EXTENSION_KEY, ext);
-}
-
-static void
-impl_detach_window (EphyExtension *ext,
- EphyWindow *window)
-{
- WindowData *data = NULL;
- GtkUIManager *manager = NULL;
-
- /* Remove editor UI. */
- data = g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_assert (data != NULL);
-
- manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));
-
- gtk_ui_manager_remove_ui (manager, data->ui_id);
- gtk_ui_manager_remove_action_group (manager, data->action_group);
-
- g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
-}
-
-static void
-impl_attach_tab (EphyExtension *ext,
- EphyWindow *window,
- EphyEmbed *embed)
-{
-
-}
-
-static void
-impl_detach_tab (EphyExtension *ext,
- EphyWindow *window,
- EphyEmbed *embed)
-{
-
-}
-
-static void
-ephy_adblock_extension_iface_init (EphyExtensionIface *iface)
-{
- iface->attach_window = impl_attach_window;
- iface->detach_window = impl_detach_window;
- iface->attach_tab = impl_attach_tab;
- iface->detach_tab = impl_detach_tab;
-}
-