aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-10-03 03:09:43 +0800
committerXan Lopez <xan@igalia.com>2012-10-03 05:20:42 +0800
commitbbf60892b4392af2dac4ec533932a8f40c26fe8d (patch)
tree728481bd7b98e62935b78a9819f81ed375564f27 /embed
parent1ceb8519aca45aa866e9c40d47a58f93f8b59ca3 (diff)
downloadgsoc2013-epiphany-bbf60892b4392af2dac4ec533932a8f40c26fe8d.tar
gsoc2013-epiphany-bbf60892b4392af2dac4ec533932a8f40c26fe8d.tar.gz
gsoc2013-epiphany-bbf60892b4392af2dac4ec533932a8f40c26fe8d.tar.bz2
gsoc2013-epiphany-bbf60892b4392af2dac4ec533932a8f40c26fe8d.tar.lz
gsoc2013-epiphany-bbf60892b4392af2dac4ec533932a8f40c26fe8d.tar.xz
gsoc2013-epiphany-bbf60892b4392af2dac4ec533932a8f40c26fe8d.tar.zst
gsoc2013-epiphany-bbf60892b4392af2dac4ec533932a8f40c26fe8d.zip
ephy-adblock-manager: use new coding style
https://bugzilla.gnome.org/show_bug.cgi?id=681657
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-adblock-manager.c98
-rw-r--r--embed/ephy-adblock-manager.h39
2 files changed, 70 insertions, 67 deletions
diff --git a/embed/ephy-adblock-manager.c b/embed/ephy-adblock-manager.c
index f4b8a7ebf..19a5ae454 100644
--- a/embed/ephy-adblock-manager.c
+++ b/embed/ephy-adblock-manager.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Copyright © 2003 Marco Pesenti Gritti
* Copyright © 2003 Christian Persch
@@ -20,22 +21,19 @@
*/
#include "config.h"
-#include "ephy-debug.h"
-
#include "ephy-adblock-manager.h"
+
#include "ephy-adblock.h"
+#include "ephy-debug.h"
struct _EphyAdBlockManagerPrivate
{
- EphyAdBlock *blocker;
+ EphyAdBlock *blocker;
};
G_DEFINE_TYPE (EphyAdBlockManager, ephy_adblock_manager, G_TYPE_OBJECT);
-#define EPHY_ADBLOCK_MANAGER_GET_PRIVATE(object) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
- EPHY_TYPE_ADBLOCK_MANAGER, EphyAdBlockManagerPrivate))
-
+#define EPHY_ADBLOCK_MANAGER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_ADBLOCK_MANAGER, EphyAdBlockManagerPrivate))
/**
* ephy_adblock_manager_set_blocker:
@@ -48,9 +46,12 @@ G_DEFINE_TYPE (EphyAdBlockManager, ephy_adblock_manager, G_TYPE_OBJECT);
**/
void
ephy_adblock_manager_set_blocker (EphyAdBlockManager *self,
- EphyAdBlock *blocker)
+ EphyAdBlock *blocker)
{
- self->priv->blocker = blocker;
+ g_return_if_fail (EPHY_IS_ADBLOCK_MANAGER (self));
+ g_return_if_fail (EPHY_IS_ADBLOCK (blocker));
+
+ self->priv->blocker = blocker;
}
/**
@@ -65,46 +66,48 @@ ephy_adblock_manager_set_blocker (EphyAdBlockManager *self,
**/
gboolean
ephy_adblock_manager_should_load (EphyAdBlockManager *self,
- EphyEmbed *embed,
- const char *url,
- AdUriCheckType check_type)
+ EphyEmbed *embed,
+ const char *url,
+ AdUriCheckType check_type)
{
- if (self->priv->blocker != NULL)
- {
- return ephy_adblock_should_load (self->priv->blocker,
- embed,
- url,
- check_type);
- }
-
- /* default: let's process any url */
- return TRUE;
+ g_return_val_if_fail (EPHY_IS_ADBLOCK_MANAGER (self), TRUE);
+ g_return_val_if_fail (EPHY_IS_EMBED (embed), TRUE);
+ g_return_val_if_fail (url, TRUE);
+
+ if (self->priv->blocker != NULL)
+ return ephy_adblock_should_load (self->priv->blocker,
+ embed,
+ url,
+ check_type);
+
+ /* Default: let's process any url. */
+ return TRUE;
}
static void
ephy_adblock_manager_init (EphyAdBlockManager *self)
{
- LOG ("ephy_adblock_manager_init");
+ LOG ("ephy_adblock_manager_init");
- self->priv = EPHY_ADBLOCK_MANAGER_GET_PRIVATE(self);
+ self->priv = EPHY_ADBLOCK_MANAGER_GET_PRIVATE(self);
}
static void
ephy_adblock_manager_class_init (EphyAdBlockManagerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_signal_new ("rules_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EphyAdBlockManagerClass, rules_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0,
- 0);
-
- g_type_class_add_private (object_class, sizeof (EphyAdBlockManagerPrivate));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_signal_new ("rules_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyAdBlockManagerClass, rules_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ 0);
+
+ g_type_class_add_private (object_class, sizeof (EphyAdBlockManagerPrivate));
}
/**
@@ -118,15 +121,16 @@ ephy_adblock_manager_class_init (EphyAdBlockManagerClass *klass)
**/
void
ephy_adblock_manager_edit_rule (EphyAdBlockManager *self,
- const char *url,
- gboolean allowed)
+ const char *url,
+ gboolean allowed)
{
- if (self->priv->blocker != NULL)
- {
- ephy_adblock_edit_rule (self->priv->blocker,
- url,
- allowed);
- }
+ g_return_if_fail (EPHY_IS_ADBLOCK_MANAGER (self));
+ g_return_if_fail (url);
+
+ if (self->priv->blocker != NULL)
+ ephy_adblock_edit_rule (self->priv->blocker,
+ url,
+ allowed);
}
/**
@@ -140,5 +144,7 @@ ephy_adblock_manager_edit_rule (EphyAdBlockManager *self,
gboolean
ephy_adblock_manager_has_blocker (EphyAdBlockManager *self)
{
- return self->priv->blocker != NULL;
+ g_return_val_if_fail (EPHY_IS_ADBLOCK_MANAGER (self), FALSE);
+
+ return self->priv->blocker != NULL;
}
diff --git a/embed/ephy-adblock-manager.h b/embed/ephy-adblock-manager.h
index cb18ca754..08c120682 100644
--- a/embed/ephy-adblock-manager.h
+++ b/embed/ephy-adblock-manager.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Copyright © 2003 Marco Pesenti Gritti
* Copyright © 2003 Christian Persch
@@ -44,34 +45,30 @@ typedef struct _EphyAdBlockManagerClass EphyAdBlockManagerClass;
typedef struct _EphyAdBlockManagerPrivate EphyAdBlockManagerPrivate;
struct _EphyAdBlockManager {
- GObject parent;
+ GObject parent;
- /* < private > */
- EphyAdBlockManagerPrivate *priv;
+ /* < private > */
+ EphyAdBlockManagerPrivate *priv;
};
struct _EphyAdBlockManagerClass {
- GObjectClass parent_class;
+ GObjectClass parent_class;
- /* Signals */
- void (* rules_changed) (EphyAdBlockManager *manager);
+ /* Signals */
+ void (* rules_changed) (EphyAdBlockManager *manager);
};
-GType ephy_adblock_manager_get_type (void);
-
-gboolean ephy_adblock_manager_should_load (EphyAdBlockManager *self,
- EphyEmbed *embed,
- const char *url,
- AdUriCheckType check_type);
-
-void ephy_adblock_manager_set_blocker (EphyAdBlockManager *self,
- EphyAdBlock *blocker);
-
-void ephy_adblock_manager_edit_rule (EphyAdBlockManager *self,
- const char *url,
- gboolean allowed);
-
-gboolean ephy_adblock_manager_has_blocker (EphyAdBlockManager *self);
+GType ephy_adblock_manager_get_type (void);
+gboolean ephy_adblock_manager_should_load (EphyAdBlockManager *self,
+ EphyEmbed *embed,
+ const char *url,
+ AdUriCheckType check_type);
+void ephy_adblock_manager_set_blocker (EphyAdBlockManager *self,
+ EphyAdBlock *blocker);
+void ephy_adblock_manager_edit_rule (EphyAdBlockManager *self,
+ const char *url,
+ gboolean allowed);
+gboolean ephy_adblock_manager_has_blocker (EphyAdBlockManager *self);
G_END_DECLS