diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-11-02 08:23:28 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-11-02 08:23:28 +0800 |
commit | 793f838a7be8618034e8544ca364c0f09457f316 (patch) | |
tree | 8ea3e85045955877d56edd31b40ef263ed11a637 /filter | |
parent | e5f0f54052e2bec6f02d4f0c3169355ffdb4f7ec (diff) | |
download | gsoc2013-evolution-793f838a7be8618034e8544ca364c0f09457f316.tar.gz gsoc2013-evolution-793f838a7be8618034e8544ca364c0f09457f316.tar.zst gsoc2013-evolution-793f838a7be8618034e8544ca364c0f09457f316.zip |
Ported to GObject.
2002-11-01 Jeffrey Stedfast <fejj@ximian.com>
* filter-element.c: Ported to GObject.
* filter-input.c: Same.
* filter-code.c: This too.
* filter-colour.c: And this.
* filter-datespec.c: You guessed it.
* filter-file.c: And again...
* filter-folder.c: Wheee! This is fun...
* filter-int.c: Gee, I wonder...
* filter-label.c: Also ported.
* filter-option.c: Yep, this too.
* filter-source.c: And finally this one.
svn path=/trunk/; revision=18495
Diffstat (limited to 'filter')
-rw-r--r-- | filter/ChangeLog | 10 | ||||
-rw-r--r-- | filter/filter-folder.c | 122 | ||||
-rw-r--r-- | filter/filter-folder.h | 34 | ||||
-rw-r--r-- | filter/filter-int.c | 143 | ||||
-rw-r--r-- | filter/filter-int.h | 25 | ||||
-rw-r--r-- | filter/filter-label.c | 87 | ||||
-rw-r--r-- | filter/filter-label.h | 19 | ||||
-rw-r--r-- | filter/filter-option.c | 150 | ||||
-rw-r--r-- | filter/filter-option.h | 38 | ||||
-rw-r--r-- | filter/filter-source.c | 177 | ||||
-rw-r--r-- | filter/filter-source.h | 54 |
11 files changed, 433 insertions, 426 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog index c41b423058..0a4c0fdadf 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -12,6 +12,16 @@ * filter-file.c: And again... + * filter-folder.c: Wheee! This is fun... + + * filter-int.c: Gee, I wonder... + + * filter-label.c: Also ported. + + * filter-option.c: Yep, this too. + + * filter-source.c: And finally this one. + 2002-10-30 Dan Winship <danw@ximian.com> * rule-editor.c (rule_add): Adjust default rule editor size to diff --git a/filter/filter-folder.c b/filter/filter-folder.c index f33735ea39..ab6531e0f8 100644 --- a/filter/filter-folder.c +++ b/filter/filter-folder.c @@ -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 <notzed@lostzed.mmc.com.au> + * Jeffrey Stedfast <fejj@ximian.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -18,9 +20,11 @@ * Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H #include <config.h> +#endif -#include <glib.h> #include <libgnome/gnome-defs.h> #include <libgnome/gnome-i18n.h> #include <libgnomeui/gnome-dialog.h> @@ -34,85 +38,84 @@ #define d(x) static gboolean validate (FilterElement *fe); -static int folder_eq(FilterElement *fe, FilterElement *cm); -static void xml_create(FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode(FilterElement *fe); -static int xml_decode(FilterElement *fe, xmlNodePtr node); -static GtkWidget *get_widget(FilterElement *fe); -static void build_code(FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp(FilterElement *, GString *); +static int folder_eq (FilterElement *fe, FilterElement *cm); +static void xml_create (FilterElement *fe, xmlNodePtr node); +static xmlNodePtr xml_encode (FilterElement *fe); +static int xml_decode (FilterElement *fe, xmlNodePtr node); +static GtkWidget *get_widget (FilterElement *fe); +static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); +static void format_sexp (FilterElement *, GString *); -extern EvolutionShellClient *global_shell_client; +static void filter_folder_class_init (FilterFolderClass *class); +static void filter_folder_init (FilterFolder *ff); +static void filter_folder_finalise (GObject *obj); -static void filter_folder_class_init (FilterFolderClass *class); -static void filter_folder_init (FilterFolder *gspaper); -static void filter_folder_finalise (GtkObject *obj); -#define _PRIVATE(x) (((FilterFolder *)(x))->priv) +static FilterElementClass *parent_class; -struct _FilterFolderPrivate { -}; -static FilterElementClass *parent_class; +extern EvolutionShellClient *global_shell_client; + -guint +GType filter_folder_get_type (void) { - static guint type = 0; + static GType type = 0; if (!type) { - GtkTypeInfo type_info = { - "FilterFolder", - sizeof(FilterFolder), - sizeof(FilterFolderClass), - (GtkClassInitFunc)filter_folder_class_init, - (GtkObjectInitFunc)filter_folder_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL + static const GTypeInfo info = { + sizeof (FilterFolderClass), + NULL, /* base_class_init */ + NULL, /* base_class_finalize */ + (GClassInitFunc) filter_folder_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (FilterFolder), + 0, /* n_preallocs */ + (GInstanceInitFunc) filter_folder_init, }; - type = gtk_type_unique (filter_element_get_type (), &type_info); + type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterFolder", &info, 0); } return type; } static void -filter_folder_class_init (FilterFolderClass *class) +filter_folder_class_init (FilterFolderClass *klass) { - GtkObjectClass *object_class; - FilterElementClass *filter_element = (FilterElementClass *)class; + GObjectClass *object_class = G_OBJECT_CLASS (klass); + FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); + + parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class (filter_element_get_type ()); - object_class->finalize = filter_folder_finalise; - + /* override methods */ - filter_element->validate = validate; - filter_element->eq = folder_eq; - filter_element->xml_create = xml_create; - filter_element->xml_encode = xml_encode; - filter_element->xml_decode = xml_decode; - filter_element->get_widget = get_widget; - filter_element->build_code = build_code; - filter_element->format_sexp = format_sexp; + fe_class->validate = validate; + fe_class->eq = folder_eq; + fe_class->xml_create = xml_create; + fe_class->xml_encode = xml_encode; + fe_class->xml_decode = xml_decode; + fe_class->get_widget = get_widget; + fe_class->build_code = build_code; + fe_class->format_sexp = format_sexp; } static void -filter_folder_init (FilterFolder *o) +filter_folder_init (FilterFolder *ff) { - o->priv = g_malloc0 (sizeof (*o->priv)); + ; } static void -filter_folder_finalise (GtkObject *obj) +filter_folder_finalise (GObject *obj) { - FilterFolder *o = (FilterFolder *)obj; + FilterFolder *ff = (FilterFolder *) obj; - g_free (o->uri); + g_free (ff->uri); - ((GtkObjectClass *)(parent_class))->finalize(obj); + G_OBJECT_CLASS (parent_class)->finalize (obj); } /** @@ -125,15 +128,14 @@ filter_folder_finalise (GtkObject *obj) FilterFolder * filter_folder_new (void) { - FilterFolder *o = (FilterFolder *)gtk_type_new (filter_folder_get_type ()); - return o; + return (FilterFolder *) g_object_new (FILTER_TYPE_FOLDER, NULL, NULL); } void -filter_folder_set_value(FilterFolder *ff, const char *uri) +filter_folder_set_value (FilterFolder *ff, const char *uri) { - g_free(ff->uri); - ff->uri = g_strdup(uri); + g_free (ff->uri); + ff->uri = g_strdup (uri); } static gboolean @@ -155,9 +157,9 @@ validate (FilterElement *fe) } static int -folder_eq(FilterElement *fe, FilterElement *cm) +folder_eq (FilterElement *fe, FilterElement *cm) { - return ((FilterElementClass *)(parent_class))->eq(fe, cm) + return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) && strcmp(((FilterFolder *)fe)->uri, ((FilterFolder *)cm)->uri) == 0; } @@ -165,7 +167,7 @@ static void xml_create (FilterElement *fe, xmlNodePtr node) { /* parent implementation */ - ((FilterElementClass *)(parent_class))->xml_create(fe, node); + FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); } static xmlNodePtr @@ -201,7 +203,7 @@ xml_decode (FilterElement *fe, xmlNodePtr node) while (n) { if (!strcmp (n->name, "folder")) { char *uri; - + uri = xmlGetProp (n, "uri"); g_free (ff->uri); ff->uri = g_strdup (uri); @@ -236,9 +238,9 @@ get_widget (FilterElement *fe) _("Select Folder"), ff->uri, allowed_types); - + gtk_widget_show (button); - gtk_signal_connect (GTK_OBJECT (button), "selected", folder_selected, ff); + g_signal_connect (button, "selected", folder_selected, ff); return button; } diff --git a/filter/filter-folder.h b/filter/filter-folder.h index d69a5e5352..0e541a580b 100644 --- a/filter/filter-folder.h +++ b/filter/filter-folder.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 <notzed@lostzed.mmc.com.au> + * Jeffrey Stedfast <fejj@ximian.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -18,38 +20,40 @@ * Boston, MA 02111-1307, USA. */ + #ifndef _FILTER_FOLDER_H #define _FILTER_FOLDER_H #include "filter-element.h" -#define FILTER_FOLDER(obj) GTK_CHECK_CAST (obj, filter_folder_get_type (), FilterFolder) -#define FILTER_FOLDER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_folder_get_type (), FilterFolderClass) -#define IS_FILTER_FOLDER(obj) GTK_CHECK_TYPE (obj, filter_folder_get_type ()) +#define FILTER_TYPE_FOLDER (filter_folder_get_type ()) +#define FILTER_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_FOLDER, FilterFolder)) +#define FILTER_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_FOLDER, FilterFolderClass)) +#define IS_FILTER_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_FOLDER)) +#define IS_FILTER_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_FOLDER)) +#define FILTER_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_FOLDER, FilterFolderClass)) -typedef struct _FilterFolder FilterFolder; -typedef struct _FilterFolderClass FilterFolderClass; +typedef struct _FilterFolder FilterFolder; +typedef struct _FilterFolderClass FilterFolderClass; struct _FilterFolder { - FilterElement parent; - struct _FilterFolderPrivate *priv; - + FilterElement parent_object; + char *uri; }; struct _FilterFolderClass { FilterElementClass parent_class; - + /* virtual methods */ - + /* signals */ }; -guint filter_folder_get_type (void); -FilterFolder *filter_folder_new (void); +GType filter_folder_get_type (void); +FilterFolder *filter_folder_new (void); /* methods */ -void filter_folder_set_value(FilterFolder *ff, const char *uri); +void filter_folder_set_value (FilterFolder *ff, const char *uri); #endif /* ! _FILTER_FOLDER_H */ - diff --git a/filter/filter-int.c b/filter/filter-int.c index e6b5cb8a55..4378204b92 100644 --- a/filter/filter-int.c +++ b/filter/filter-int.c @@ -1,30 +1,31 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Ripped off by Sam Creasey <sammy@oh.verio.com> from - * filter-score by Jeffrey Stedfast <fejj@helixcode.com> + * Authors: Jeffrey Stedfast <fejj@ximian.com> * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * Copyright 2002 Ximian, Inc. (www.ximian.com) * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. * */ + #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdlib.h> -#include <gtk/gtksignal.h> #include <gtk/gtkspinbutton.h> #include "e-util/e-sexp.h" @@ -32,7 +33,7 @@ #define d(x) -static int int_eq(FilterElement *fe, FilterElement *cm); +static int int_eq (FilterElement *fe, FilterElement *cm); static void xml_create (FilterElement *fe, xmlNodePtr node); static xmlNodePtr xml_encode (FilterElement *fe); static int xml_decode (FilterElement *fe, xmlNodePtr node); @@ -40,80 +41,73 @@ static GtkWidget *get_widget (FilterElement *fe); static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); static void format_sexp (FilterElement *fe, GString *out); -static void filter_int_class_init (FilterIntClass *class); -static void filter_int_init (FilterInt *gspaper); -static void filter_int_finalise (GtkObject *obj); +static void filter_int_class_init (FilterIntClass *klass); +static void filter_int_init (FilterInt *fi); +static void filter_int_finalise (GObject *obj); -static FilterElementClass *parent_class; -enum { - LAST_SIGNAL -}; +static FilterElementClass *parent_class; -static guint signals[LAST_SIGNAL] = { 0 }; -GtkType +GType filter_int_get_type (void) { - static GtkType type = 0; + static GType type = 0; if (!type) { - GtkTypeInfo type_info = { - "FilterInt", - sizeof (FilterInt), + static const GTypeInfo info = { sizeof (FilterIntClass), - (GtkClassInitFunc) filter_int_class_init, - (GtkObjectInitFunc) filter_int_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL + NULL, /* base_class_init */ + NULL, /* base_class_finalize */ + (GClassInitFunc) filter_int_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (FilterInt), + 0, /* n_preallocs */ + (GInstanceInitFunc) filter_int_init, }; - type = gtk_type_unique (filter_element_get_type (), &type_info); + type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterInt", &info, 0); } return type; } static void -filter_int_class_init (FilterIntClass *class) +filter_int_class_init (FilterIntClass *klass) { - GtkObjectClass *object_class; - FilterElementClass *filter_element = (FilterElementClass *)class; + GObjectClass *object_class = G_OBJECT_CLASS (klass); + FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class (filter_element_get_type ()); + parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); object_class->finalize = filter_int_finalise; /* override methods */ - filter_element->eq = int_eq; - filter_element->xml_create = xml_create; - filter_element->xml_encode = xml_encode; - filter_element->xml_decode = xml_decode; - filter_element->get_widget = get_widget; - filter_element->build_code = build_code; - filter_element->format_sexp = format_sexp; - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); + fe_class->eq = int_eq; + fe_class->xml_create = xml_create; + fe_class->xml_encode = xml_encode; + fe_class->xml_decode = xml_decode; + fe_class->get_widget = get_widget; + fe_class->build_code = build_code; + fe_class->format_sexp = format_sexp; } static void -filter_int_init (FilterInt *o) +filter_int_init (FilterInt *fi) { - o->min = 0; - o->max = G_MAXINT; + fi->min = 0; + fi->max = G_MAXINT; } static void -filter_int_finalise(GtkObject *obj) +filter_int_finalise (GObject *obj) { - FilterInt *o = (FilterInt *)obj; - - g_free(o->type); + FilterInt *fi = (FilterInt *) obj; + + g_free (fi->type); - ((GtkObjectClass *)(parent_class))->finalize(obj); + G_OBJECT_CLASS (parent_class)->finalize (obj); } /** @@ -126,30 +120,33 @@ filter_int_finalise(GtkObject *obj) FilterInt * filter_int_new (void) { - FilterInt *o = (FilterInt *)gtk_type_new(filter_int_get_type ()); - return o; + return (FilterInt *) g_object_new (FILTER_TYPE_INT, NULL, NULL); } FilterInt * -filter_int_new_type(const char *type, int min, int max) +filter_int_new_type (const char *type, int min, int max) { - FilterInt *o = (FilterInt *)gtk_type_new(filter_int_get_type ()); - o->type = g_strdup(type); - o->min = min; - o->max = max; + FilterInt *fi; + + fi = filter_int_new (); + + fi->type = g_strdup (type); + fi->min = min; + fi->max = max; + return o; } void -filter_int_set_value(FilterInt *fi, int val) +filter_int_set_value (FilterInt *fi, int val) { fi->val = val; } static int -int_eq(FilterElement *fe, FilterElement *cm) +int_eq (FilterElement *fe, FilterElement *cm) { - return ((FilterElementClass *)(parent_class))->eq(fe, cm) + return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) && ((FilterInt *)fe)->val == ((FilterInt *)cm)->val; } @@ -157,7 +154,7 @@ static void xml_create (FilterElement *fe, xmlNodePtr node) { /* parent implementation */ - ((FilterElementClass *)(parent_class))->xml_create(fe, node); + FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); } static xmlNodePtr @@ -169,7 +166,7 @@ xml_encode (FilterElement *fe) const char *type; type = fs->type?fs->type:"integer"; - + d(printf("Encoding %s as xml\n", type)); value = xmlNewNode (NULL, "value"); @@ -195,7 +192,7 @@ xml_decode (FilterElement *fe, xmlNodePtr node) d(printf ("Name = %s\n", name)); xmlFree (fe->name); fe->name = name; - + type = xmlGetProp(node, "type"); d(printf ("Type = %s\n", type)); g_free(fs->type); @@ -237,7 +234,7 @@ get_widget (FilterElement *fe) if (fs->val) gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), (gfloat) fs->val); - gtk_signal_connect (GTK_OBJECT (spin), "changed", spin_changed, fe); + g_signal_connect (spin, "changed", spin_changed, fe); return spin; } @@ -252,6 +249,6 @@ static void format_sexp (FilterElement *fe, GString *out) { FilterInt *fs = (FilterInt *)fe; - - g_string_sprintfa(out, "%d", fs->val); + + g_string_sprintfa (out, "%d", fs->val); } diff --git a/filter/filter-int.h b/filter/filter-int.h index 833fd30bc8..caba992958 100644 --- a/filter/filter-int.h +++ b/filter/filter-int.h @@ -26,16 +26,19 @@ #include "filter-element.h" -#define FILTER_INT(obj) GTK_CHECK_CAST (obj, filter_int_get_type (), FilterInt) -#define FILTER_INT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_int_get_type (), FilterIntClass) -#define IS_FILTER_INT(obj) GTK_CHECK_TYPE (obj, filter_int_get_type ()) +#define FILTER_TYPE_INT (filter_int_get_type ()) +#define FILTER_INT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_INT, FilterInt)) +#define FILTER_INT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_INT, FilterIntClass)) +#define IS_FILTER_INT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_INT)) +#define IS_FILTER_INT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_INT)) +#define FILTER_INT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_INT, FilterIntClass)) -typedef struct _FilterInt FilterInt; -typedef struct _FilterIntClass FilterIntClass; +typedef struct _FilterInt FilterInt; +typedef struct _FilterIntClass FilterIntClass; struct _FilterInt { - FilterElement parent; - + FilterElement parent_object; + char *type; int val; int min; @@ -50,10 +53,10 @@ struct _FilterIntClass { /* signals */ }; -GtkType filter_int_get_type (void); -FilterInt *filter_int_new (void); -FilterInt *filter_int_new_type(const char *type, int min, int max); -void filter_int_set_value(FilterInt *fi, int val); +GType filter_int_get_type (void); +FilterInt *filter_int_new (void); +FilterInt *filter_int_new_type (const char *type, int min, int max); +void filter_int_set_value (FilterInt *fi, int val); /* methods */ diff --git a/filter/filter-label.c b/filter/filter-label.c index c7c44fbb0f..de82f04b52 100644 --- a/filter/filter-label.c +++ b/filter/filter-label.c @@ -27,7 +27,6 @@ #endif #include <string.h> -#include <gtk/gtkobject.h> #include <gtk/gtkwidget.h> #include <libgnome/gnome-defs.h> @@ -54,33 +53,31 @@ static void xml_create (FilterElement *fe, xmlNodePtr node); static void filter_label_class_init (FilterLabelClass *klass); static void filter_label_init (FilterLabel *label); -static void filter_label_finalise (GtkObject *obj); +static void filter_label_finalise (GObject *obj); -static FilterElementClass *parent_class; -enum { - LAST_SIGNAL -}; +static FilterElementClass *parent_class; -static guint signals[LAST_SIGNAL] = { 0 }; -GtkType +GType filter_label_get_type (void) { - static GtkType type = 0; + static GType type = 0; if (!type) { - GtkTypeInfo type_info = { - "FilterLabel", - sizeof (FilterLabel), + static const GTypeInfo info = { sizeof (FilterLabelClass), - (GtkClassInitFunc) filter_label_class_init, - (GtkObjectInitFunc) filter_label_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL + NULL, /* base_class_init */ + NULL, /* base_class_finalize */ + (GClassInitFunc) filter_label_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (FilterLabel), + 0, /* n_preallocs */ + (GInstanceInitFunc) filter_label_init, }; - type = gtk_type_unique (filter_option_get_type (), &type_info); + type = g_type_register_static (FILTER_TYPE_OPTION, "FilterLabel", &info, 0); } return type; @@ -89,30 +86,27 @@ filter_label_get_type (void) static void filter_label_class_init (FilterLabelClass *klass) { - GtkObjectClass *object_class = (GtkObjectClass *) klass; - FilterElementClass *filter_element = (FilterElementClass *) klass; + GObjectClass *object_class = G_OBJECT_CLASS (klass); + FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); - parent_class = gtk_type_class (filter_option_get_type ()); + parent_class = g_type_class_ref (FILTER_TYPE_OPTION); object_class->finalize = filter_label_finalise; /* override methods */ - filter_element->xml_create = xml_create; - - /* signals */ - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); + fe_class->xml_create = xml_create; } static void -filter_label_init (FilterLabel *o) +filter_label_init (FilterLabel *fl) { - ((FilterOption *)o)->type = "label"; + ((FilterOption *) fl)->type = "label"; } static void filter_label_finalise (GtkObject *obj) { - ((GtkObjectClass *)(parent_class))->finalize (obj); + G_OBJECT_CLASS (parent_class)->finalize (obj); } /** @@ -125,7 +119,7 @@ filter_label_finalise (GtkObject *obj) FilterLabel * filter_label_new (void) { - return (FilterLabel *) gtk_type_new (filter_label_get_type ()); + return (FilterLabel *) g_object_new (FILTER_TYPE_LABEL, NULL, NULL); } static struct { @@ -140,28 +134,31 @@ static struct { { "/Mail/Labels/label_4", N_("Later"), "later" }, }; -int filter_label_count(void) +int +filter_label_count (void) { - return sizeof(labels)/sizeof(labels[0]); + return (sizeof (labels) / sizeof (labels[0])); } -const char *filter_label_label(int i) +const char * +filter_label_label (int i) { - if (i<0 || i >= sizeof(labels)/sizeof(labels[0])) + if (i < 0 || i >= sizeof (labels) / sizeof (labels[0])) return NULL; else return labels[i].value; } -int filter_label_index(const char *label) +int +filter_label_index (const char *label) { int i; - - for (i=0;i<sizeof(labels)/sizeof(labels[0]);i++) { - if (strcmp(labels[i].value, label) == 0) + + for (i = 0; i < sizeof (labels) / sizeof (labels[0]); i++) { + if (strcmp (labels[i].value, label) == 0) return i; } - + return -1; } @@ -172,9 +169,9 @@ xml_create (FilterElement *fe, xmlNodePtr node) Bonobo_ConfigDatabase db; CORBA_Environment ev; int i; - - ((FilterElementClass *)(parent_class))->xml_create(fe, node); - + + FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); + CORBA_exception_init (&ev); db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev); @@ -182,18 +179,18 @@ xml_create (FilterElement *fe, xmlNodePtr node) db = CORBA_OBJECT_NIL; CORBA_exception_free (&ev); - - for (i=0;i<sizeof(labels)/sizeof(labels[0]);i++) { + + for (i = 0; i < sizeof (labels) / sizeof (labels[0]); i++) { const char *title; char *btitle; if (db == CORBA_OBJECT_NIL - || (title = btitle = bonobo_config_get_string(db, labels[i].path, NULL)) == NULL) { + || (title = btitle = bonobo_config_get_string (db, labels[i].path, NULL)) == NULL) { btitle = NULL; title = U_(labels[i].title); } - filter_option_add(fo, labels[i].value, title, NULL); - g_free(btitle); + filter_option_add (fo, labels[i].value, title, NULL); + g_free (btitle); } } diff --git a/filter/filter-label.h b/filter/filter-label.h index a348e88efb..c62f806fa0 100644 --- a/filter/filter-label.h +++ b/filter/filter-label.h @@ -31,15 +31,18 @@ extern "C" { #include "filter-option.h" -#define FILTER_LABEL(obj) GTK_CHECK_CAST (obj, filter_label_get_type (), FilterLabel) -#define FILTER_LABEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_label_get_type (), FilterLabelClass) -#define IS_FILTER_LABEL(obj) GTK_CHECK_TYPE (obj, filter_label_get_type ()) +#define FILTER_TYPE_LABEL (filter_label_get_type ()) +#define FILTER_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_LABEL, FilterLabel)) +#define FILTER_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_LABEL, FilterLabelClass)) +#define IS_FILTER_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_LABEL)) +#define IS_FILTER_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_LABEL)) +#define FILTER_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_LABEL, FilterLabelClass)) typedef struct _FilterLabel FilterLabel; typedef struct _FilterLabelClass FilterLabelClass; struct _FilterLabel { - FilterOption parent; + FilterOption parent_object; }; struct _FilterLabelClass { @@ -50,14 +53,14 @@ struct _FilterLabelClass { /* signals */ }; -GtkType filter_label_get_type (void); +GType filter_label_get_type (void); FilterLabel *filter_label_new (void); /* Sigh, this is a mess, but its cleaner than the original mess */ -int filter_label_count(void); -const char *filter_label_label(int i); -int filter_label_index(const char *label); +int filter_label_count (void); +const char *filter_label_label (int i); +int filter_label_index (const char *label); #ifdef __cplusplus } diff --git a/filter/filter-option.c b/filter/filter-option.c index 8bf1601ca7..8d3429ca69 100644 --- a/filter/filter-option.c +++ b/filter/filter-option.c @@ -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 <notzed@lostzed.mmc.com.au> + * Jeffrey Stedfast <fejj@ximian.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -18,10 +20,13 @@ * Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H #include <config.h> +#endif #include <string.h> -#include <glib.h> + #include <gtk/gtkmenuitem.h> #include <gtk/gtkoptionmenu.h> #include <libgnome/gnome-defs.h> @@ -34,106 +39,92 @@ #define d(x) -static int option_eq(FilterElement *fe, FilterElement *cm); -static void xml_create(FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode(FilterElement *fe); -static int xml_decode(FilterElement *fe, xmlNodePtr node); -static FilterElement *clone(FilterElement *fe); -static GtkWidget *get_widget(FilterElement *fe); -static void build_code(FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp(FilterElement *, GString *); - -static void filter_option_class_init (FilterOptionClass *class); -static void filter_option_init (FilterOption *gspaper); -static void filter_option_finalise (GtkObject *obj); +static int option_eq (FilterElement *fe, FilterElement *cm); +static void xml_create (FilterElement *fe, xmlNodePtr node); +static xmlNodePtr xml_encode (FilterElement *fe); +static int xml_decode (FilterElement *fe, xmlNodePtr node); +static FilterElement *clone (FilterElement *fe); +static GtkWidget *get_widget (FilterElement *fe); +static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); +static void format_sexp (FilterElement *, GString *); -#define _PRIVATE(x) (((FilterOption *)(x))->priv) +static void filter_option_class_init (FilterOptionClass *klass); +static void filter_option_init (FilterOption *fo); +static void filter_option_finalise (GObject *obj); -struct _FilterOptionPrivate { -}; static FilterElementClass *parent_class; -enum { - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - -guint +GType filter_option_get_type (void) { - static guint type = 0; + static GType type = 0; if (!type) { - GtkTypeInfo type_info = { - "FilterOption", - sizeof(FilterOption), - sizeof(FilterOptionClass), - (GtkClassInitFunc)filter_option_class_init, - (GtkObjectInitFunc)filter_option_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL + static const GTypeInfo info = { + sizeof (FilterOptionClass), + NULL, /* base_class_init */ + NULL, /* base_class_finalize */ + (GClassInitFunc) filter_option_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (FilterOption), + 0, /* n_preallocs */ + (GInstanceInitFunc) filter_option_init, }; - type = gtk_type_unique (filter_element_get_type (), &type_info); + type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterOption", &info, 0); } return type; } static void -filter_option_class_init (FilterOptionClass *class) +filter_option_class_init (FilterOptionClass *klass) { - GtkObjectClass *object_class; - FilterElementClass *filter_element = (FilterElementClass *)class; + GObjectClass *object_class = G_OBJECT_CLASS (klass); + FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); + + parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(filter_element_get_type ()); - object_class->finalize = filter_option_finalise; /* override methods */ - filter_element->eq = option_eq; - filter_element->xml_create = xml_create; - filter_element->xml_encode = xml_encode; - filter_element->xml_decode = xml_decode; - filter_element->clone = clone; - filter_element->get_widget = get_widget; - filter_element->build_code = build_code; - filter_element->format_sexp = format_sexp; - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); + fe_class->eq = option_eq; + fe_class->xml_create = xml_create; + fe_class->xml_encode = xml_encode; + fe_class->xml_decode = xml_decode; + fe_class->clone = clone; + fe_class->get_widget = get_widget; + fe_class->build_code = build_code; + fe_class->format_sexp = format_sexp; } static void -filter_option_init (FilterOption *o) +filter_option_init (FilterOption *fo) { - o->type = "option"; - - o->priv = g_malloc0 (sizeof (*o->priv)); + fo->type = "option"; } static void -free_option(struct _filter_option *o, void *data) +free_option (struct _filter_option *o, void *data) { - g_free(o->title); - g_free(o->value); - g_free(o->code); - g_free(o); + g_free (o->title); + g_free (o->value); + g_free (o->code); + g_free (o); } static void -filter_option_finalise (GtkObject *obj) +filter_option_finalise (GObject *obj) { - FilterOption *o = (FilterOption *)obj; - - g_list_foreach(o->options, (GFunc)free_option, NULL); - g_list_free(o->options); + FilterOption *fo = (FilterOption *) obj; - ((GtkObjectClass *)(parent_class))->finalize(obj); + g_list_foreach (fo->options, (GFunc)free_option, NULL); + g_list_free (fo->options); + + G_OBJECT_CLASS (parent_class)->finalize (obj); } /** @@ -146,8 +137,7 @@ filter_option_finalise (GtkObject *obj) FilterOption * filter_option_new (void) { - FilterOption *o = (FilterOption *)gtk_type_new (filter_option_get_type ()); - return o; + return (FilterOption *) g_object_new (FILTER_TYPE_OPTION, NULL, NULL); } static struct _filter_option * @@ -180,15 +170,15 @@ void filter_option_add(FilterOption *fo, const char *value, const char *title, const char *code) { struct _filter_option *op; - + g_assert(IS_FILTER_OPTION(fo)); g_return_if_fail(find_option(fo, value) == NULL); - + op = g_malloc(sizeof(*op)); op->title = g_strdup(title); op->value = g_strdup(value); op->code = g_strdup(code); - + fo->options = g_list_append(fo->options, op); if (fo->current == NULL) fo->current = op; @@ -198,8 +188,8 @@ static int option_eq(FilterElement *fe, FilterElement *cm) { FilterOption *fo = (FilterOption *)fe, *co = (FilterOption *)cm; - - return ((FilterElementClass *)(parent_class))->eq(fe, cm) + + return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) && ((fo->current && co->current && strcmp(fo->current->value, co->current->value) == 0) || (fo->current == NULL && co->current == NULL)); } @@ -211,7 +201,7 @@ xml_create (FilterElement *fe, xmlNodePtr node) xmlNodePtr n, work; /* parent implementation */ - ((FilterElementClass *)(parent_class))->xml_create(fe, node); + FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); n = node->childs; while (n) { @@ -289,7 +279,7 @@ option_changed (GtkWidget *widget, FilterElement *fe) { FilterOption *fo = (FilterOption *)fe; - fo->current = gtk_object_get_data (GTK_OBJECT (widget), "option"); + fo->current = g_object_get_data (widget, "option"); } static GtkWidget * @@ -308,8 +298,8 @@ get_widget (FilterElement *fe) while (l) { op = l->data; item = gtk_menu_item_new_with_label (_(op->title)); - gtk_object_set_data (GTK_OBJECT (item), "option", op); - gtk_signal_connect (GTK_OBJECT (item), "activate", option_changed, fe); + g_object_set_data (item, "option", op); + g_signal_connect (item, "activate", option_changed, fe); gtk_menu_append (GTK_MENU (menu), item); gtk_widget_show (item); if (op == fo->current) { @@ -327,7 +317,7 @@ get_widget (FilterElement *fe) gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu); if (first) - gtk_signal_emit_by_name (GTK_OBJECT (first), "activate", fe); + g_signal_emit_by_name (first, "activate", fe); gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current); @@ -363,7 +353,7 @@ clone (FilterElement *fe) d(printf ("cloning option\n")); - new = FILTER_OPTION (((FilterElementClass *)(parent_class))->clone(fe)); + new = FILTER_OPTION (FILTER_ELEMENT_CLASS (parent_class)->clone (fe)); l = fo->options; while (l) { op = l->data; @@ -373,5 +363,5 @@ clone (FilterElement *fe) d(printf ("cloning option code %p, current = %p\n", new, new->current)); - return (FilterElement *)new; + return (FilterElement *) new; } diff --git a/filter/filter-option.h b/filter/filter-option.h index a296c75602..39418868ab 100644 --- a/filter/filter-option.h +++ b/filter/filter-option.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 <notzed@lostzed.mmc.com.au> + * Jeffrey Stedfast <fejj@ximian.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -18,17 +20,21 @@ * Boston, MA 02111-1307, USA. */ + #ifndef _FILTER_OPTION_H #define _FILTER_OPTION_H #include "filter-element.h" -#define FILTER_OPTION(obj) GTK_CHECK_CAST (obj, filter_option_get_type (), FilterOption) -#define FILTER_OPTION_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_option_get_type (), FilterOptionClass) -#define IS_FILTER_OPTION(obj) GTK_CHECK_TYPE (obj, filter_option_get_type ()) +#define FILTER_TYPE_OPTION (filter_option_get_type ()) +#define FILTER_OPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_OPTION, FilterOption)) +#define FILTER_OPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_OPTION, FilterOptionClass)) +#define IS_FILTER_OPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_OPTION)) +#define IS_FILTER_OPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_OPTION)) +#define FILTER_OPTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_OPTION, FilterOptionClass)) -typedef struct _FilterOption FilterOption; -typedef struct _FilterOptionClass FilterOptionClass; +typedef struct _FilterOption FilterOption; +typedef struct _FilterOptionClass FilterOptionClass; struct _filter_option { char *title; /* button title */ @@ -37,29 +43,27 @@ struct _filter_option { }; struct _FilterOption { - FilterElement parent; - struct _FilterOptionPrivate *priv; - + FilterElement parent_object; + const char *type; /* static memory, type name written to xml */ - + GList *options; struct _filter_option *current; }; struct _FilterOptionClass { FilterElementClass parent_class; - + /* virtual methods */ - + /* signals */ }; -guint filter_option_get_type (void); -FilterOption *filter_option_new (void); +GType filter_option_get_type (void); +FilterOption *filter_option_new (void); /* methods */ -void filter_option_set_current(FilterOption *option, const char *name); -void filter_option_add(FilterOption *fo, const char *name, const char *title, const char *code); +void filter_option_set_current (FilterOption *option, const char *name); +void filter_option_add (FilterOption *fo, const char *name, const char *title, const char *code); #endif /* ! _FILTER_OPTION_H */ - diff --git a/filter/filter-source.c b/filter/filter-source.c index 83e20d1bd5..4d9aa4f6f8 100644 --- a/filter/filter-source.c +++ b/filter/filter-source.c @@ -1,24 +1,24 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * filter-source.c + * Authors: Jon Trowbridge <trow@ximian.com> + * Jeffrey Stedfast <fejj@ximian.com> * - * Copyright (C) 2001 Ximian, Inc. + * Copyright 2001-2002 Ximian, Inc. (www.ximian.com) * - * Authors: Jon Trowbridge <trow@ximian.com> + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. */ @@ -41,90 +41,83 @@ #include <bonobo-conf/bonobo-config-database.h> #include <camel/camel-url.h> -typedef struct _SourceInfo SourceInfo; -struct _SourceInfo { + +static void filter_source_class_init (FilterSourceClass *klass); +static void filter_source_init (FilterSource *fs); +static void filter_source_finalize (GObject *obj); + +static int source_eq (FilterElement *fe, FilterElement *cm); +static void xml_create (FilterElement *fe, xmlNodePtr node); +static xmlNodePtr xml_encode (FilterElement *fe); +static int xml_decode (FilterElement *fe, xmlNodePtr node); +static FilterElement *clone (FilterElement *fe); +static GtkWidget *get_widget (FilterElement *fe); +static void build_code (FilterElement *fe, GString *out, struct _FilterPart *ff); +static void format_sexp (FilterElement *, GString *); + +static void filter_source_add_source (FilterSource *fs, const char *account_name, const char *name, + const char *addr, const char *url); +static void filter_source_get_sources (FilterSource *fs); + +typedef struct _SourceInfo { char *account_name; char *name; char *address; char *url; -}; +} SourceInfo; struct _FilterSourcePrivate { GList *sources; char *current_url; }; -static FilterElementClass *parent_class = NULL; -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -static void filter_source_class_init (FilterSourceClass *); -static void filter_source_init (FilterSource *); -static void filter_source_finalize (GtkObject *); - -static int source_eq(FilterElement *fe, FilterElement *cm); -static void xml_create(FilterElement *fe, xmlNodePtr node); -static xmlNodePtr xml_encode(FilterElement *fe); -static int xml_decode(FilterElement *fe, xmlNodePtr node); -static FilterElement *clone(FilterElement *fe); -static GtkWidget *get_widget(FilterElement *fe); -static void build_code(FilterElement *fe, GString *out, struct _FilterPart *ff); -static void format_sexp(FilterElement *, GString *); -static void filter_source_add_source (FilterSource *fs, const char *account_name, const char *name, - const char *addr, const char *url); -static void filter_source_get_sources (FilterSource *fs); +static FilterElementClass *parent_class = NULL; -GtkType +GType filter_source_get_type (void) { - static GtkType type = 0; + static GType type = 0; if (!type) { - GtkTypeInfo type_info = { - "FilterSource", - sizeof(FilterSource), - sizeof(FilterSourceClass), - (GtkClassInitFunc)filter_source_class_init, - (GtkObjectInitFunc)filter_source_init, - (GtkArgSetFunc)NULL, - (GtkArgGetFunc)NULL + static const GTypeInfo info = { + sizeof (FilterSourceClass), + NULL, /* base_class_init */ + NULL, /* base_class_finalize */ + (GClassInitFunc) filter_source_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (FilterSource), + 0, /* n_preallocs */ + (GInstanceInitFunc) filter_source_init, }; - type = gtk_type_unique (filter_element_get_type (), &type_info); + type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterSource", &info, 0); } return type; } static void -filter_source_class_init (FilterSourceClass *class) +filter_source_class_init (FilterSourceClass *klass) { - GtkObjectClass *object_class; - FilterElementClass *filter_element = (FilterElementClass *)class; + GObjectClass *object_class = G_OBJECT_CLASS (klass); + FilterElementClass *fe_class = FILTER_ELEMENT_CLASS (klass); + + parent_class = g_type_class_ref (FILTER_TYPE_ELEMENT); - object_class = (GtkObjectClass *)class; - parent_class = gtk_type_class(filter_element_get_type ()); - object_class->finalize = filter_source_finalize; - + /* override methods */ - filter_element->eq = source_eq; - filter_element->xml_create = xml_create; - filter_element->xml_encode = xml_encode; - filter_element->xml_decode = xml_decode; - filter_element->clone = clone; - filter_element->get_widget = get_widget; - filter_element->build_code = build_code; - filter_element->format_sexp = format_sexp; - - /* signals */ - - gtk_object_class_add_signals(object_class, signals, LAST_SIGNAL); + fe_class->eq = source_eq; + fe_class->xml_create = xml_create; + fe_class->xml_encode = xml_encode; + fe_class->xml_decode = xml_decode; + fe_class->clone = clone; + fe_class->get_widget = get_widget; + fe_class->build_code = build_code; + fe_class->format_sexp = format_sexp; } static void @@ -136,11 +129,11 @@ filter_source_init (FilterSource *fs) } static void -filter_source_finalize (GtkObject *obj) +filter_source_finalize (GObject *obj) { FilterSource *fs = FILTER_SOURCE (obj); GList *i = fs->priv->sources; - + while (i) { SourceInfo *info = i->data; g_free (info->account_name); @@ -150,29 +143,28 @@ filter_source_finalize (GtkObject *obj) g_free (info); i = g_list_next (i); } - + g_list_free (fs->priv->sources); - + g_free (fs->priv); - if (GTK_OBJECT_CLASS (parent_class)->finalize) - GTK_OBJECT_CLASS (parent_class)->finalize (obj); + G_OBJECT_CLASS (parent_class)->finalize (obj); } FilterSource * filter_source_new (void) { - FilterSource *s = (FilterSource *) gtk_type_new (filter_source_get_type ()); - return s; + return (FilterSource *) g_object_new (FILTER_TYPE_SOURCE, NULL, NULL); } static int -source_eq(FilterElement *fe, FilterElement *cm) +source_eq (FilterElement *fe, FilterElement *cm) { FilterSource *fs = (FilterSource *)fe, *cs = (FilterSource *)cm; - - return ((FilterElementClass *)parent_class)->eq(fe, cm) - && ((fs->priv->current_url && cs->priv->current_url && strcmp(fs->priv->current_url, cs->priv->current_url) == 0) + + return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm) + && ((fs->priv->current_url && cs->priv->current_url + && strcmp (fs->priv->current_url, cs->priv->current_url) == 0) || (fs->priv->current_url == NULL && cs->priv->current_url == NULL)); } @@ -180,7 +172,7 @@ static void xml_create (FilterElement *fe, xmlNodePtr node) { /* Call parent implementation */ - ((FilterElementClass *)parent_class)->xml_create (fe, node); + FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node); } static xmlNodePtr @@ -217,7 +209,7 @@ xml_decode (FilterElement *fe, xmlNodePtr node) fs->priv->current_url = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); camel_url_free (url); } - + return 0; } @@ -227,23 +219,23 @@ clone (FilterElement *fe) FilterSource *fs = (FilterSource *) fe; FilterSource *cpy = filter_source_new (); GList *i; - - ((FilterElement *)cpy)->name = xmlStrdup (fe->name); - + + ((FilterElement *) cpy)->name = xmlStrdup (fe->name); + cpy->priv->current_url = g_strdup (fs->priv->current_url); - + for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) { SourceInfo *info = (SourceInfo *) i->data; filter_source_add_source (cpy, info->account_name, info->name, info->address, info->url); } - + return (FilterElement *) cpy; } static void source_changed (GtkWidget *w, FilterSource *fs) { - SourceInfo *info = (SourceInfo *) gtk_object_get_data (GTK_OBJECT (w), "source"); + SourceInfo *info = (SourceInfo *) g_object_get_data (w, "source"); g_free (fs->priv->current_url); fs->priv->current_url = g_strdup (info->url); @@ -287,8 +279,9 @@ get_widget (FilterElement *fe) g_free (label); g_free (native_label); - gtk_object_set_data (GTK_OBJECT (item), "source", info); - gtk_signal_connect (GTK_OBJECT (item), "activate", GTK_SIGNAL_FUNC (source_changed), fs); + g_object_set_data (item, "source", info); + g_signal_connect (item, "activate", source_changed, fs); + gtk_menu_append (GTK_MENU (menu), item); gtk_widget_show (item); @@ -340,7 +333,7 @@ filter_source_add_source (FilterSource *fs, const char *account_name, const char { SourceInfo *info; - g_return_if_fail (fs && IS_FILTER_SOURCE (fs)); + g_return_if_fail (IS_FILTER_SOURCE (fs)); info = g_new0 (SourceInfo, 1); info->account_name = g_strdup (account_name); diff --git a/filter/filter-source.h b/filter/filter-source.h index da7cadb3dd..73bd63f503 100644 --- a/filter/filter-source.h +++ b/filter/filter-source.h @@ -1,52 +1,56 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * filter-source.h + * Authors: Jon Trowbridge <trow@ximian.com> + * Jeffrey Stedfast <fejj@ximian.com> * - * Copyright (C) 2001 Ximian, Inc. + * Copyright 2001-2002 Ximian, Inc. (www.ximian.com) * - * Authors: Jon Trowbridge <trow@ximian.com> + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. */ + #ifndef __FILTER_SOURCE_H__ #define __FILTER_SOURCE_H__ #include "filter-element.h" -#define FILTER_SOURCE(obj) GTK_CHECK_CAST (obj, filter_source_get_type (), FilterSource) -#define FILTER_SOURCE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_source_get_type (), FilterSourceClass) -#define IS_FILTER_SOURCE(obj) GTK_CHECK_TYPE (obj, filter_source_get_type ()) +#define FILTER_TYPE_SOURCE (filter_source_get_type ()) +#define FILTER_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILTER_TYPE_SOURCE, FilterSource)) +#define FILTER_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILTER_TYPE_SOURCE, FilterSourceClass)) +#define IS_FILTER_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILTER_TYPE_SOURCE)) +#define IS_FILTER_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_SOURCE)) +#define FILTER_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILTER_TYPE_SOURCE, FilterSourceClass)) -typedef struct _FilterSource FilterSource; -typedef struct _FilterSourceClass FilterSourceClass; -struct _FilterSourcePrivate; +typedef struct _FilterSource FilterSource; +typedef struct _FilterSourceClass FilterSourceClass; struct _FilterSource { - FilterElement parent; + FilterElement parent_object; struct _FilterSourcePrivate *priv; }; struct _FilterSourceClass { FilterElementClass parent_class; + }; -GtkType filter_source_get_type (void); -FilterSource *filter_source_new (void); -void filter_source_set_current (FilterSource *src, const gchar *url); +GType filter_source_get_type (void); +FilterSource *filter_source_new (void); -#endif /* __FILTER_SOURCE_H__ */ +void filter_source_set_current (FilterSource *src, const char *url); +#endif /* __FILTER_SOURCE_H__ */ |