From 9fd7dd8e0ca925b2aa738b1c495ff3b41f0f2487 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Sat, 2 Nov 2002 04:58:18 +0000 Subject: Ported to glib2/GObject. 2002-11-02 Jeffrey Stedfast * rule-context.c: Ported to glib2/GObject. svn path=/trunk/; revision=18501 --- filter/rule-context.h | 125 ++++++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 59 deletions(-) (limited to 'filter/rule-context.h') diff --git a/filter/rule-context.h b/filter/rule-context.h index 60d0d6f932..62e6f4ac19 100644 --- a/filter/rule-context.h +++ b/filter/rule-context.h @@ -1,7 +1,9 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Copyright (C) 2000 Ximian Inc. + * Copyright (C) 2000-2002 Ximian Inc. * * Authors: Not Zed + * Jeffrey Stedfast * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -21,60 +23,64 @@ #ifndef _RULE_CONTEXT_H #define _RULE_CONTEXT_H -#include +#include +#include #include #include "filter-part.h" #include "filter-rule.h" -#define RULE_CONTEXT(obj) GTK_CHECK_CAST (obj, rule_context_get_type (), RuleContext) -#define RULE_CONTEXT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, rule_context_get_type (), RuleContextClass) -#define IS_RULE_CONTEXT(obj) GTK_CHECK_TYPE (obj, rule_context_get_type ()) +#define RULE_TYPE_CONTEXT (rule_context_get_type ()) +#define RULE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RULE_TYPE_CONTEXT, RuleContext)) +#define RULE_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RULE_TYPE_CONTEXT, RuleContextClass)) +#define IS_RULE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RULE_TYPE_CONTEXT)) +#define IS_RULE_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RULE_TYPE_CONTEXT)) +#define RULE_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RULE_TYPE_CONTEXT, RuleContextClass)) -typedef struct _RuleContext RuleContext; -typedef struct _RuleContextClass RuleContextClass; +typedef struct _RuleContext RuleContext; +typedef struct _RuleContextClass RuleContextClass; struct _RuleContext { - GtkObject parent; + GObject parent_object; struct _RuleContextPrivate *priv; - - char *error; /* string version of error */ - - xmlDocPtr system; /* system rules source */ - xmlDocPtr user; /* user defined rules source */ - + + char *error; /* string version of error */ + + xmlDocPtr system; /* system rules source */ + xmlDocPtr user; /* user defined rules source */ + GList *parts; GList *rules; - - GHashTable *part_set_map;/* map set types to part types */ + + GHashTable *part_set_map; /* map set types to part types */ GList *part_set_list; - GHashTable *rule_set_map;/* map set types to rule types */ + GHashTable *rule_set_map; /* map set types to rule types */ GList *rule_set_list; }; -typedef void (*RCRegisterFunc)(RuleContext *f, FilterRule *rule, gpointer data); +typedef void (*RCRegisterFunc) (RuleContext *f, FilterRule *rule, gpointer user_data); struct _RuleContextClass { - GtkObjectClass parent_class; - + GObjectClass parent_class; + /* virtual methods */ - int (*load)(RuleContext *f, const char *system, const char *user); - int (*save)(RuleContext *f, const char *user); - int (*revert)(RuleContext *f, const char *user); - - GList *(*delete_uri)(RuleContext *f, const char *uri, GCompareFunc cmp); - GList *(*rename_uri)(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); - + int (*load) (RuleContext *f, const char *system, const char *user); + int (*save) (RuleContext *f, const char *user); + int (*revert) (RuleContext *f, const char *user); + + GList *(*delete_uri) (RuleContext *f, const char *uri, GCompareFunc cmp); + GList *(*rename_uri) (RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); + /* signals */ - void (*rule_added)(RuleContext *f, FilterRule *rule); - void (*rule_removed)(RuleContext *f, FilterRule *rule); - void (*changed)(RuleContext *f); + void (*rule_added) (RuleContext *f, FilterRule *rule); + void (*rule_removed) (RuleContext *f, FilterRule *rule); + void (*changed) (RuleContext *f); }; -typedef void (*RCPartFunc)(RuleContext *f, FilterPart *part); -typedef void (*RCRuleFunc)(RuleContext *f, FilterRule *part); -typedef FilterPart * (*RCNextPartFunc)(RuleContext *f, FilterPart *part); -typedef FilterRule * (*RCNextRuleFunc)(RuleContext *f, FilterRule *rule, const char *source); +typedef void (*RCPartFunc) (RuleContext *f, FilterPart *part); +typedef void (*RCRuleFunc) (RuleContext *f, FilterRule *part); +typedef FilterPart * (*RCNextPartFunc) (RuleContext *f, FilterPart *part); +typedef FilterRule * (*RCNextRuleFunc) (RuleContext *f, FilterRule *rule, const char *source); struct _part_set_map { char *name; @@ -90,39 +96,40 @@ struct _rule_set_map { RCNextRuleFunc next; }; -guint rule_context_get_type (void); -RuleContext *rule_context_new (void); +GType rule_context_get_type (void); +RuleContext *rule_context_new (void); /* methods */ -int rule_context_load(RuleContext *f, const char *system, const char *user); -int rule_context_save(RuleContext *f, const char *user); -int rule_context_revert(RuleContext *f, const char *user); - -void rule_context_add_part(RuleContext *f, FilterPart *new); -FilterPart *rule_context_find_part(RuleContext *f, const char *name); -FilterPart *rule_context_create_part(RuleContext *f, const char *name); -FilterPart *rule_context_next_part(RuleContext *f, FilterPart *last); - -FilterRule *rule_context_next_rule(RuleContext *f, FilterRule *last, const char *source); -FilterRule *rule_context_find_rule(RuleContext *f, const char *name, const char *source); -FilterRule *rule_context_find_rank_rule(RuleContext *f, int rank, const char *source); -void rule_context_add_rule(RuleContext *f, FilterRule *new); -void rule_context_add_rule_gui(RuleContext *f, FilterRule *rule, const char *title, const char *path); -void rule_context_remove_rule(RuleContext *f, FilterRule *rule); +int rule_context_load (RuleContext *f, const char *system, const char *user); +int rule_context_save (RuleContext *f, const char *user); +int rule_context_revert (RuleContext *f, const char *user); + +void rule_context_add_part (RuleContext *f, FilterPart *new); +FilterPart *rule_context_find_part (RuleContext *f, const char *name); +FilterPart *rule_context_create_part (RuleContext *f, const char *name); +FilterPart *rule_context_next_part (RuleContext *f, FilterPart *last); + +FilterRule *rule_context_next_rule (RuleContext *f, FilterRule *last, const char *source); +FilterRule *rule_context_find_rule (RuleContext *f, const char *name, const char *source); +FilterRule *rule_context_find_rank_rule (RuleContext *f, int rank, const char *source); +void rule_context_add_rule (RuleContext *f, FilterRule *new); +void rule_context_add_rule_gui (RuleContext *f, FilterRule *rule, const char *title, const char *path); +void rule_context_remove_rule (RuleContext *f, FilterRule *rule); /* get/set the rank (position) of a rule */ -void rule_context_rank_rule(RuleContext *f, FilterRule *rule, int rank); -int rule_context_get_rank_rule(RuleContext *f, FilterRule *rule, const char *source); +void rule_context_rank_rule (RuleContext *f, FilterRule *rule, int rank); +int rule_context_get_rank_rule (RuleContext *f, FilterRule *rule, const char *source); /* setup type for set parts */ -void rule_context_add_part_set(RuleContext *f, const char *setname, int part_type, RCPartFunc append, RCNextPartFunc next); -void rule_context_add_rule_set(RuleContext *f, const char *setname, int rule_type, RCRuleFunc append, RCNextRuleFunc next); +void rule_context_add_part_set (RuleContext *f, const char *setname, int part_type, + RCPartFunc append, RCNextPartFunc next); +void rule_context_add_rule_set (RuleContext *f, const char *setname, int rule_type, + RCRuleFunc append, RCNextRuleFunc next); /* uri's disappear/renamed externally */ -GList *rule_context_delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp); -GList *rule_context_rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); +GList *rule_context_delete_uri (RuleContext *f, const char *uri, GCompareFunc cmp); +GList *rule_context_rename_uri (RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); -void rule_context_free_uri_list(RuleContext *f, GList *uris); +void rule_context_free_uri_list (RuleContext *f, GList *uris); #endif /* ! _RULE_CONTEXT_H */ - -- cgit v1.2.3