#define ADBLOCK_FILTER_VALID(__filter) \
(__filter && (g_str_has_prefix (__filter, "http") \
|| g_str_has_prefix (__filter, "file")))
+#define ADBLOCK_FILTER_SET(__filter,__active) \
+ filter[4] = __active ? (__filter[5] == ':' ? 's' : ':') : '-'
+#define ADBLOCK_FILTER_IS_SET(__filter) \
+ filter[4] != '-'
static GHashTable* pattern;
static GHashTable* keys;
g_object_set (renderer,
"activatable", ADBLOCK_FILTER_VALID (filter),
- "active", ADBLOCK_FILTER_VALID (filter) && filter[4] != '-',
+ "active", ADBLOCK_FILTER_VALID (filter) && ADBLOCK_FILTER_IS_SET (filter),
NULL);
g_free (filter);
if (ADBLOCK_FILTER_VALID (filter))
{
- filter[4] = ':';
+ ADBLOCK_FILTER_SET (filter, TRUE);
if (gtk_cell_renderer_toggle_get_active (renderer))
{
if (!strncmp (filter, "http", 4))
g_unlink (filename);
g_free (filename);
}
- filter[4] = '-';
+ ADBLOCK_FILTER_SET (filter, FALSE);
}
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, filter, -1);
gtk_tree_model_get (model, iter, 0, &filter, -1);
if (ADBLOCK_FILTER_VALID (filter))
- filter[4] = ':';
+ ADBLOCK_FILTER_SET (filter, TRUE);
g_object_set (renderer,
"text", filter,