aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-11-05 11:09:44 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-11-05 11:09:44 +0800
commitbabf0f4f8cf0c7fbe68ab52068a092901f02b380 (patch)
tree235bd04205cd716cea8921cf5882fee5644ad530
parentfab377c503df250439b84aba95db023786d33ee1 (diff)
downloadgsoc2013-evolution-babf0f4f8cf0c7fbe68ab52068a092901f02b380.tar.gz
gsoc2013-evolution-babf0f4f8cf0c7fbe68ab52068a092901f02b380.tar.zst
gsoc2013-evolution-babf0f4f8cf0c7fbe68ab52068a092901f02b380.zip
Also ported.
2002-11-04 Jeffrey Stedfast <fejj@ximian.com> * filter-editor.c: Also ported. * rule-editor.c: Ported to gtk2 and removed unnecessary e_utf8 snot. svn path=/trunk/; revision=18539
-rw-r--r--filter/ChangeLog6
-rw-r--r--filter/filter-editor.c88
-rw-r--r--filter/filter-editor.h34
-rw-r--r--filter/rule-editor.c267
-rw-r--r--filter/rule-editor.h64
5 files changed, 225 insertions, 234 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 7b81ec9b20..7d7652762b 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,9 @@
+2002-11-04 Jeffrey Stedfast <fejj@ximian.com>
+
+ * filter-editor.c: Also ported.
+
+ * rule-editor.c: Ported to gtk2 and removed unnecessary e_utf8 snot.
+
2002-11-02 Jeffrey Stedfast <fejj@ximian.com>
* filter-context.c: Ported this too.
diff --git a/filter/filter-editor.c b/filter/filter-editor.c
index 4f7183b103..ae5d47563b 100644
--- a/filter/filter-editor.c
+++ b/filter/filter-editor.c
@@ -1,5 +1,6 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2000, 2001 Ximian Inc.
+ * Copyright (C) 2000-2002 Ximian Inc.
*
* Authors: Not Zed <notzed@lostzed.mmc.com.au>
* Jeffrey Stedfast <fejj@ximian.com>
@@ -19,96 +20,83 @@
* Boston, MA 02111-1307, USA.
*/
+
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
-#include <glib.h>
#include <gtk/gtkframe.h>
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkoptionmenu.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
-#include <glade/glade.h>
-#include <gal/widgets/e-unicode.h>
#include "filter-editor.h"
-#include "filter-context.h"
-#include "filter-filter.h"
#define d(x)
static FilterRule * create_rule(RuleEditor *re);
-static void filter_editor_class_init (FilterEditorClass *class);
-static void filter_editor_init (FilterEditor *gspaper);
-static void filter_editor_finalise (GtkObject *obj);
-
-#define _PRIVATE(x) (((FilterEditor *)(x))->priv)
-
-struct _FilterEditorPrivate {
-};
+static void filter_editor_class_init (FilterEditorClass *klass);
+static void filter_editor_init (FilterEditor *fe);
+static void filter_editor_finalise (GObject *obj);
-static GnomeDialogClass *parent_class;
-enum {
- LAST_SIGNAL
-};
+static GnomeDialogClass *parent_class = NULL;
-static guint signals[LAST_SIGNAL] = { 0 };
-guint
+GtkType
filter_editor_get_type (void)
{
- static guint type = 0;
+ static GtkType type = 0;
if (!type) {
- GtkTypeInfo type_info = {
+ static const GtkTypeInfo info = {
"FilterEditor",
- sizeof(FilterEditor),
- sizeof(FilterEditorClass),
- (GtkClassInitFunc)filter_editor_class_init,
- (GtkObjectInitFunc)filter_editor_init,
- (GtkArgSetFunc)NULL,
- (GtkArgGetFunc)NULL
+ sizeof (FilterEditor),
+ sizeof (FilterEditorClass),
+ (GtkClassInitFunc) filter_editor_class_init,
+ (GtkObjectInitFunc) filter_editor_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
};
- type = gtk_type_unique (rule_editor_get_type (), &type_info);
+ type = gtk_type_unique (RULE_TYPE_EDITOR, &info);
}
return type;
}
static void
-filter_editor_class_init (FilterEditorClass *class)
+filter_editor_class_init (FilterEditorClass *klass)
{
- GtkObjectClass *object_class = (GtkObjectClass *)class;
- RuleEditorClass *re_class = (RuleEditorClass *)class;
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkObjectClass *object_class = (GtkObjectClass *) klass;
+ RuleEditorClass *re_class = (RuleEditorClass *) klass;
parent_class = gtk_type_class (gnome_dialog_get_type ());
- object_class->finalize = filter_editor_finalise;
+ gobject_class->finalize = filter_editor_finalise;
/* override methods */
re_class->create_rule = create_rule;
-
- /* signals */
-
- gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
}
static void
-filter_editor_init (FilterEditor *o)
+filter_editor_init (FilterEditor *fe)
{
- o->priv = g_malloc0 (sizeof (*o->priv));
+ fe->priv = g_malloc0 (sizeof (*fe->priv));
}
static void
-filter_editor_finalise (GtkObject *obj)
+filter_editor_finalise (GObject *obj)
{
- FilterEditor *o = (FilterEditor *)obj;
+ FilterEditor *fe = (FilterEditor *) obj;
- g_free(o->priv);
+ g_free (fe->priv);
- ((GtkObjectClass *)(parent_class))->finalize (obj);
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
}
/**
@@ -119,21 +107,21 @@ filter_editor_finalise (GtkObject *obj)
* Return value: A new #FilterEditor object.
**/
FilterEditor *
-filter_editor_new(FilterContext *f, const char **source_names)
+filter_editor_new (FilterContext *fc, const char **source_names)
{
- FilterEditor *o = (FilterEditor *)gtk_type_new (filter_editor_get_type ());
+ FilterEditor *editor = (FilterEditor *) gtk_type_new (filter_editor_get_type ());
GladeXML *gui;
GtkWidget *w;
gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "rule_editor");
- filter_editor_construct (o, f, gui, source_names);
+ filter_editor_construct (editor, fc, gui, source_names);
w = glade_xml_get_widget (gui, "rule_frame");
gtk_frame_set_label (GTK_FRAME (w), _("Filter Rules"));
- gtk_object_unref (GTK_OBJECT (gui));
+ g_object_unref (gui);
- return o;
+ return fe;
}
static void
@@ -159,10 +147,10 @@ filter_editor_construct (FilterEditor *fe, FilterContext *fc, GladeXML *gui, con
for (i = 0; source_names[i]; i++) {
item = gtk_menu_item_new_with_label (_(source_names[i]));
- gtk_object_set_data_full (GTK_OBJECT (item), "source", g_strdup (source_names[i]), g_free);
+ g_object_set_data_full (item, "source", g_strdup (source_names[i]), g_free);
gtk_menu_append (GTK_MENU (menu), item);
gtk_widget_show (item);
- gtk_signal_connect (GTK_OBJECT (item), "activate", select_source, fe);
+ g_signal_connect (item, "activate", select_source, fe);
}
gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
gtk_widget_show (omenu);
diff --git a/filter/filter-editor.h b/filter/filter-editor.h
index 6a859951a1..8936147a5d 100644
--- a/filter/filter-editor.h
+++ b/filter/filter-editor.h
@@ -1,7 +1,9 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2000, 2001 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
@@ -22,33 +24,35 @@
#define _FILTER_EDITOR_H
#include "rule-editor.h"
+#include "filter-context.h"
-#define FILTER_EDITOR(obj) GTK_CHECK_CAST (obj, filter_editor_get_type (), FilterEditor)
-#define FILTER_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, filter_editor_get_type (), FilterEditorClass)
-#define IS_FILTER_EDITOR(obj) GTK_CHECK_TYPE (obj, filter_editor_get_type ())
+#define FILTER_TYPE_EDITOR (filter_editor_get_type ())
+#define FILTER_EDITOR(obj) (GTK_CHECK_CAST ((obj), FILTER_TYPE_EDITOR, FilterEditor))
+#define FILTER_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FILTER_TYPE_EDITOR, FilterEditorClass))
+#define IS_FILTER_EDITOR(obj) (GTK_CHECK_TYPE ((obj), FILTER_TYPE_EDITOR))
+#define IS_FILTER_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FILTER_TYPE_EDITOR))
+#define FILTER_EDITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), FILTER_TYPE_EDITOR, FilterEditorClass))
-typedef struct _FilterEditor FilterEditor;
-typedef struct _FilterEditorClass FilterEditorClass;
+typedef struct _FilterEditor FilterEditor;
+typedef struct _FilterEditorClass FilterEditorClass;
struct _FilterEditor {
- RuleEditor parent;
+ RuleEditor parent_object;
struct _FilterEditorPrivate *priv;
-
+
};
struct _FilterEditorClass {
RuleEditorClass parent_class;
-
+
/* virtual methods */
-
+
/* signals */
};
-struct _FilterContext;
+GtkType filter_editor_get_type (void);
-guint filter_editor_get_type (void);
-FilterEditor *filter_editor_new(struct _FilterContext *f, const char **source_names);
-void filter_editor_construct(FilterEditor *fe, struct _FilterContext *fc, struct _GladeXML *gui, const char **source_names);
+FilterEditor *filter_editor_new (FilterContext *f, const char **source_names);
+void filter_editor_construct (FilterEditor *fe, FilterContext *fc, GladeXML *gui, const char **source_names);
#endif /* ! _FILTER_EDITOR_H */
-
diff --git a/filter/rule-editor.c b/filter/rule-editor.c
index fac6f47476..45d18d1a05 100644
--- a/filter/rule-editor.c
+++ b/filter/rule-editor.c
@@ -1,8 +1,10 @@
+/* -*- 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
* License as published by the Free Software Foundation.
@@ -18,39 +20,37 @@
* Boston, MA 02111-1307, USA.
*/
+
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
+/* for getenv only, remove when getenv need removed */
+#include <stdlib.h>
-#include <glib.h>
#include <gtk/gtkframe.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomeui/gnome-dialog.h>
#include <libgnomeui/gnome-dialog-util.h>
-#include <glade/glade.h>
-#include <gal/widgets/e-unicode.h>
-#include <gal/util/e-unicode-i18n.h>
-#include "rule-editor.h"
-#include "rule-context.h"
-#include "filter-rule.h"
-/* for getenv only, remove when getenv need removed */
-#include <stdlib.h>
+#include "rule-editor.h"
-static int enable_undo;
+static int enable_undo = 0;
-void rule_editor_add_undo(RuleEditor *re, int type, FilterRule *rule, int rank, int newrank);
-void rule_editor_play_undo(RuleEditor *re);
+void rule_editor_add_undo (RuleEditor *re, int type, FilterRule *rule, int rank, int newrank);
+void rule_editor_play_undo (RuleEditor *re);
#define d(x) x
-static void set_source(RuleEditor *re, const char *source);
-static void set_sensitive(RuleEditor *re);
-static FilterRule *create_rule(RuleEditor *re);
+static void set_source (RuleEditor *re, const char *source);
+static void set_sensitive (RuleEditor *re);
+static FilterRule *create_rule (RuleEditor *re);
-static void rule_editor_class_init(RuleEditorClass *class);
-static void rule_editor_init (RuleEditor *gspaper);
-static void rule_editor_finalise (GtkObject *obj);
+static void rule_editor_class_init (RuleEditorClass *klass);
+static void rule_editor_init (RuleEditor *re);
+static void rule_editor_finalise (GObject *obj);
static void rule_editor_destroy (GtkObject *obj);
#define _PRIVATE(x)(((RuleEditor *)(x))->priv)
@@ -68,84 +68,76 @@ struct _RuleEditorPrivate {
GtkButton *buttons[BUTTON_LAST];
};
-static GnomeDialogClass *parent_class;
+static GnomeDialogClass *parent_class = NULL;
-enum {
- LAST_SIGNAL
-};
-static guint signals[LAST_SIGNAL] = { 0 };
-
-guint
-rule_editor_get_type(void)
+GtkType
+rule_editor_get_type (void)
{
- static guint type = 0;
+ static GtkType type = 0;
if (!type) {
- GtkTypeInfo type_info = {
+ static const GtkTypeInfo info = {
"RuleEditor",
sizeof (RuleEditor),
sizeof (RuleEditorClass),
(GtkClassInitFunc) rule_editor_class_init,
(GtkObjectInitFunc) rule_editor_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
};
-
+
/* TODO: Remove when it works (or never will) */
- enable_undo = getenv("EVOLUTION_RULE_UNDO") != NULL;
-
- type = gtk_type_unique (gnome_dialog_get_type (), &type_info);
+ enable_undo = getenv ("EVOLUTION_RULE_UNDO") != NULL;
+
+ type = gtk_type_unique (gnome_dialog_get_type (), &info);
}
return type;
}
static void
-rule_editor_class_init (RuleEditorClass *class)
+rule_editor_class_init (RuleEditorClass *klass)
{
- GtkObjectClass *object_class;
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkObjectClass *object_class = (GtkObjectClass *) klass;
- object_class = (GtkObjectClass *)class;
- parent_class = gtk_type_class(gnome_dialog_get_type());
+ parent_class = gtk_type_class (gnome_dialog_get_type ());
- object_class->finalize = rule_editor_finalise;
+ gobject_class->finalize = rule_editor_finalise;
object_class->destroy = rule_editor_destroy;
/* override methods */
- class->set_source = set_source;
- class->set_sensitive = set_sensitive;
- class->create_rule = create_rule;
-
- /* signals */
-
- gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+ klass->set_source = set_source;
+ klass->set_sensitive = set_sensitive;
+ klass->create_rule = create_rule;
}
static void
-rule_editor_init (RuleEditor *o)
+rule_editor_init (RuleEditor *re)
{
- o->priv = g_malloc0 (sizeof (*o->priv));
+ re->priv = g_malloc0 (sizeof (*re->priv));
}
static void
-rule_editor_finalise (GtkObject *obj)
+rule_editor_finalise (GObject *obj)
{
RuleEditor *re = (RuleEditor *)obj;
RuleEditorUndo *undo, *next;
-
- gtk_object_unref (GTK_OBJECT (re->context));
+
+ g_object_unref (re->context);
g_free (re->priv);
-
+
undo = re->undo_log;
while (undo) {
next = undo->next;
- gtk_object_unref((GtkObject *)undo->rule);
- g_free(undo);
+ g_object_unref (undo->rule);
+ g_free (undo);
undo = next;
}
- ((GtkObjectClass *)(parent_class))->finalize (obj);
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
}
static void
@@ -153,8 +145,10 @@ rule_editor_destroy (GtkObject *obj)
{
RuleEditor *re = (RuleEditor *) obj;
- if (re->dialog)
+ if (re->dialog) {
gtk_widget_destroy (GTK_WIDGET (re->dialog));
+ re->dialog = NULL;
+ }
((GtkObjectClass *)(parent_class))->destroy (obj);
}
@@ -167,42 +161,42 @@ rule_editor_destroy (GtkObject *obj)
* Return value: A new #RuleEditor object.
**/
RuleEditor *
-rule_editor_new (RuleContext *f, const char *source)
+rule_editor_new (RuleContext *rc, const char *source)
{
+ RuleEditor *editor = (RuleEditor *) gtk_type_new (rule_editor_get_type ());
GladeXML *gui;
- RuleEditor *o = (RuleEditor *)gtk_type_new (rule_editor_get_type ());
GtkWidget *w;
gui = glade_xml_new (FILTER_GLADEDIR "/filter.glade", "rule_editor");
- rule_editor_construct (o, f, gui, source);
+ rule_editor_construct (editor, rc, gui, source);
w = glade_xml_get_widget (gui, "rule_frame");
- gtk_frame_set_label ((GtkFrame *)w, _("Rules"));
+ gtk_frame_set_label ((GtkFrame *) w, _("Rules"));
- gtk_object_unref (GTK_OBJECT (gui));
+ g_object_unref (gui);
- return o;
+ return editor;
}
/* used internally by implementations if required */
void
rule_editor_set_sensitive (RuleEditor *re)
{
- return ((RuleEditorClass *)((GtkObject *)re)->klass)->set_sensitive(re);
+ return RULE_EDITOR_GET_CLASS (re)->set_sensitive (re);
}
/* used internally by implementations */
void
rule_editor_set_source (RuleEditor *re, const char *source)
{
- return ((RuleEditorClass *)((GtkObject *)re)->klass)->set_source(re, source);
+ return RULE_EDITOR_GET_CLASS (re)->set_source (re, source);
}
/* factory method for "add" button */
FilterRule *
rule_editor_create_rule (RuleEditor *re)
{
- return ((RuleEditorClass *)((GtkObject *)re)->klass)->create_rule(re);
+ return RULE_EDITOR_GET_CLASS (re)->create_rule (re);
}
static FilterRule *
@@ -223,33 +217,30 @@ add_editor_clicked (GtkWidget *dialog, int button, RuleEditor *re)
{
GtkWidget *item;
GList *l = NULL;
- char *string;
-
+
switch (button) {
case 0:
if (!filter_rule_validate (re->edit)) {
/* no need to popup a dialog because the validate code does that. */
return;
}
-
- if (rule_context_find_rule(re->context, re->edit->name, re->edit->source)) {
+
+ if (rule_context_find_rule (re->context, re->edit->name, re->edit->source)) {
GtkWidget *dialog;
char *what;
-
+
what = g_strdup_printf(_("Rule name '%s' is not unique, choose another"), re->edit->name);
dialog = gnome_ok_dialog (what);
- g_free(what);
+ g_free (what);
gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
-
+
return;
}
- gtk_object_ref (GTK_OBJECT (re->edit));
- string = e_utf8_to_gtk_string (GTK_WIDGET (re->list), re->edit->name);
- item = gtk_list_item_new_with_label (string);
- g_free (string);
+ g_object_ref (re->edit);
+ item = gtk_list_item_new_with_label (re->edit->name);
- gtk_object_set_data (GTK_OBJECT (item), "rule", re->edit);
+ g_object_set_data (item, "rule", re->edit);
gtk_widget_show (item);
l = g_list_append (l, GTK_LIST_ITEM (item));
@@ -259,15 +250,16 @@ add_editor_clicked (GtkWidget *dialog, int button, RuleEditor *re)
re->current = re->edit;
rule_context_add_rule (re->context, re->current);
-
- gtk_object_ref((GtkObject *)re->current);
- rule_editor_add_undo(re, RULE_EDITOR_LOG_ADD, re->current, rule_context_get_rank_rule (re->context, re->current, re->current->source), 0);
+
+ g_object_ref (re->current);
+ rule_editor_add_undo (re, RULE_EDITOR_LOG_ADD, re->current,
+ rule_context_get_rank_rule (re->context, re->current, re->current->source), 0);
case 1:
default:
gnome_dialog_close (GNOME_DIALOG (dialog));
case -1:
if (re->edit) {
- gtk_object_unref (GTK_OBJECT (re->edit));
+ g_object_unref (re->edit);
re->edit = NULL;
}
@@ -279,9 +271,9 @@ add_editor_clicked (GtkWidget *dialog, int button, RuleEditor *re)
}
static void
-add_editor_destroyed(GtkWidget *w, RuleEditor *re)
+add_editor_destroyed (GtkWidget *w, RuleEditor *re)
{
- add_editor_clicked(w, -1, re);
+ add_editor_clicked (w, -1, re);
}
static void
@@ -305,8 +297,8 @@ rule_add (GtkWidget *widget, RuleEditor *re)
gtk_window_set_policy (GTK_WINDOW (re->dialog), FALSE, TRUE, FALSE);
gtk_widget_set_parent_window (GTK_WIDGET (re->dialog), GTK_WIDGET (re)->window);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (re->dialog)->vbox), rules, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (re->dialog), "clicked", add_editor_clicked, re);
- gtk_signal_connect (GTK_OBJECT (re->dialog), "destroy", add_editor_destroyed, re);
+ g_signal_connect (re->dialog, "clicked", add_editor_clicked, re);
+ g_signal_connect (re->dialog, "destroy", add_editor_destroyed, re);
gtk_widget_set_sensitive (GTK_WIDGET (re), FALSE);
gtk_widget_show (re->dialog);
@@ -315,40 +307,37 @@ rule_add (GtkWidget *widget, RuleEditor *re)
static void
edit_editor_clicked (GtkWidget *dialog, int button, RuleEditor *re)
{
+ FilterRule *rule;
GtkWidget *item;
- char *string;
int pos;
- struct _FilterRule *rule;
-
+
switch (button) {
case 0:
if (!filter_rule_validate (re->edit)) {
/* no need to popup a dialog because the validate code does that. */
return;
}
-
- rule = rule_context_find_rule(re->context, re->edit->name, re->edit->source);
+
+ rule = rule_context_find_rule (re->context, re->edit->name, re->edit->source);
if (rule != NULL && rule != re->current) {
GtkWidget *dialog;
char *what;
-
- what = g_strdup_printf(_("Rule name '%s' is not unique, choose another"), re->edit->name);
+
+ what = g_strdup_printf (_("Rule name '%s' is not unique, choose another"), re->edit->name);
dialog = gnome_ok_dialog (what);
- g_free(what);
+ g_free (what);
gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
-
+
return;
}
pos = rule_context_get_rank_rule (re->context, re->current, re->source);
if (pos != -1) {
item = g_list_nth_data (GTK_LIST (re->list)->children, pos);
- string = e_utf8_to_gtk_string (GTK_WIDGET (item), re->edit->name);
- gtk_label_set_text (GTK_LABEL (GTK_BIN (item)->child), string);
- g_free (string);
-
- rule_editor_add_undo(re, RULE_EDITOR_LOG_EDIT, filter_rule_clone(re->current), pos, 0);
-
+ gtk_label_set_text (GTK_LABEL (GTK_BIN (item)->child), re->edit->name);
+
+ rule_editor_add_undo (re, RULE_EDITOR_LOG_EDIT, filter_rule_clone (re->current), pos, 0);
+
/* replace the old rule with the new rule */
filter_rule_copy (re->current, re->edit);
}
@@ -357,7 +346,7 @@ edit_editor_clicked (GtkWidget *dialog, int button, RuleEditor *re)
gnome_dialog_close (GNOME_DIALOG (dialog));
case -1:
if (re->edit) {
- gtk_object_unref (GTK_OBJECT (re->edit));
+ g_object_unref (re->edit);
re->edit = NULL;
}
@@ -369,9 +358,9 @@ edit_editor_clicked (GtkWidget *dialog, int button, RuleEditor *re)
}
static void
-edit_editor_destroyed(GtkWidget *w, RuleEditor *re)
+edit_editor_destroyed (GtkWidget *w, RuleEditor *re)
{
- edit_editor_clicked(w, -1, re);
+ edit_editor_clicked (w, -1, re);
}
static void
@@ -394,8 +383,8 @@ rule_edit (GtkWidget *widget, RuleEditor *re)
gtk_window_set_default_size (GTK_WINDOW (re->dialog), 600, 400);
gtk_window_set_policy (GTK_WINDOW (re->dialog), FALSE, TRUE, FALSE);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (re->dialog)->vbox), rules, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (re->dialog), "clicked", edit_editor_clicked, re);
- gtk_signal_connect (GTK_OBJECT (re->dialog), "destroy", edit_editor_destroyed, re);
+ g_signal_connect (re->dialog, "clicked", edit_editor_clicked, re);
+ g_signal_connect (re->dialog, "destroy", edit_editor_destroyed, re);
gtk_widget_set_sensitive (GTK_WIDGET (re), FALSE);
@@ -421,9 +410,10 @@ rule_delete (GtkWidget *widget, RuleEditor *re)
gtk_list_remove_items (re->list, l);
g_list_free (l);
- rule_editor_add_undo(re, RULE_EDITOR_LOG_REMOVE, re->current, rule_context_get_rank_rule(re->context, re->current, re->current->source), 0);
+ rule_editor_add_undo( re, RULE_EDITOR_LOG_REMOVE, re->current,
+ rule_context_get_rank_rule (re->context, re->current, re->current->source), 0);
#if 0
- gtk_object_unref (GTK_OBJECT (re->current));
+ g_object_unref (re->current);
#endif
re->current = NULL;
@@ -441,9 +431,10 @@ rule_move (RuleEditor *re, int from, int to)
{
GList *l;
GtkListItem *item;
-
- gtk_object_ref((GtkObject *)re->current);
- rule_editor_add_undo(re, RULE_EDITOR_LOG_RANK, re->current, rule_context_get_rank_rule(re->context, re->current, re->current->source), to);
+
+ g_object_ref (re->current);
+ rule_editor_add_undo (re, RULE_EDITOR_LOG_RANK, re->current,
+ rule_context_get_rank_rule (re->context, re->current, re->current->source), to);
d(printf ("moving %d to %d\n", from, to));
rule_context_rank_rule (re->context, re->current, to);
@@ -496,7 +487,7 @@ set_sensitive (RuleEditor *re)
FilterRule *rule = NULL;
int index = -1, count = 0;
- while ((rule = rule_context_next_rule(re->context, rule, re->source))) {
+ while ((rule = rule_context_next_rule (re->context, rule, re->source))) {
if (rule == re->current)
index = count;
count++;
@@ -516,7 +507,7 @@ set_sensitive (RuleEditor *re)
static void
select_rule (GtkWidget *w, GtkWidget *child, RuleEditor *re)
{
- re->current = gtk_object_get_data (GTK_OBJECT (child), "rule");
+ re->current = g_object_get_data (child, "rule");
g_assert (re->current);
@@ -538,18 +529,15 @@ set_source (RuleEditor *re, const char *source)
FilterRule *rule = NULL;
GList *newitems = NULL;
- gtk_list_clear_items(GTK_LIST(re->list), 0, -1);
+ gtk_list_clear_items (GTK_LIST (re->list), 0, -1);
d(printf("Checking for rules that are of type %s\n", source?source:"<nil>"));
- while ((rule = rule_context_next_rule(re->context, rule, source)) != NULL) {
+ while ((rule = rule_context_next_rule (re->context, rule, source)) != NULL) {
GtkWidget *item;
- char *s;
- d(printf(" hit %s(%s)\n", rule->name, source?source:"<nil>"));
- s = e_utf8_to_gtk_string (GTK_WIDGET (re->list), rule->name);
- item = gtk_list_item_new_with_label (s);
- g_free (s);
- gtk_object_set_data (GTK_OBJECT (item), "rule", rule);
+ d(printf(" hit %s(%s)\n", rule->name, source ? source : "<nil>"));
+ item = gtk_list_item_new_with_label (rule->name);
+ g_object_set_data (item, "rule", rule);
gtk_widget_show (GTK_WIDGET (item));
newitems = g_list_append (newitems, item);
}
@@ -562,30 +550,30 @@ set_source (RuleEditor *re, const char *source)
}
void
-rule_editor_add_undo(RuleEditor *re, int type, FilterRule *rule, int rank, int newrank)
+rule_editor_add_undo (RuleEditor *re, int type, FilterRule *rule, int rank, int newrank)
{
RuleEditorUndo *undo;
-
+
if (!re->undo_active && enable_undo) {
- undo = g_malloc0(sizeof(*undo));
+ undo = g_malloc0 (sizeof (*undo));
undo->rule = rule;
undo->type = type;
undo->rank = rank;
undo->newrank = newrank;
-
+
undo->next = re->undo_log;
re->undo_log = undo;
} else {
- gtk_object_unref((GtkObject *)rule);
+ g_object_unref (rule);
}
}
void
-rule_editor_play_undo(RuleEditor *re)
+rule_editor_play_undo (RuleEditor *re)
{
RuleEditorUndo *undo, *next;
FilterRule *rule;
-
+
re->undo_active = TRUE;
undo = re->undo_log;
re->undo_log = NULL;
@@ -611,7 +599,7 @@ rule_editor_play_undo(RuleEditor *re)
break;
case RULE_EDITOR_LOG_REMOVE:
printf("Undoing remove on rule '%s'\n", undo->rule->name);
- gtk_object_ref((GtkObject *)undo->rule);
+ g_object_ref (undo->rule);
rule_context_add_rule(re->context, undo->rule);
rule_context_rank_rule(re->context, undo->rule, undo->rank);
break;
@@ -621,7 +609,7 @@ rule_editor_play_undo(RuleEditor *re)
rule_context_rank_rule(re->context, rule, undo->rank);
break;
}
- gtk_object_unref((GtkObject *)undo->rule);
+ g_object_unref (undo->rule);
g_free(undo);
undo = next;
}
@@ -636,12 +624,12 @@ editor_clicked (GtkWidget *dialog, int button, RuleEditor *re)
rule_editor_play_undo(re);
else {
RuleEditorUndo *undo, *next;
-
+
undo = re->undo_log;
re->undo_log = 0;
while (undo) {
next = undo->next;
- gtk_object_unref((GtkObject *)undo->rule);
+ g_object_unref (undo->rule);
g_free(undo);
undo = next;
}
@@ -656,7 +644,7 @@ rule_editor_construct (RuleEditor *re, RuleContext *context, GladeXML *gui, cons
int i;
re->context = context;
- gtk_object_ref (GTK_OBJECT (context));
+ g_object_ref (context);
gtk_window_set_policy (GTK_WINDOW (re), FALSE, TRUE, FALSE);
@@ -665,17 +653,16 @@ rule_editor_construct (RuleEditor *re, RuleContext *context, GladeXML *gui, cons
for (i = 0; i < BUTTON_LAST; i++) {
re->priv->buttons[i] = (GtkButton *)w = glade_xml_get_widget (gui, edit_buttons[i].name);
- gtk_signal_connect (GTK_OBJECT (w), "clicked", edit_buttons[i].func, re);
+ g_signal_connect (w, "clicked", edit_buttons[i].func, re);
}
re->list = (GtkList *) w = glade_xml_get_widget(gui, "rule_list");
- gtk_signal_connect (GTK_OBJECT (w), "select_child", select_rule, re);
- gtk_signal_connect (GTK_OBJECT (w), "button_press_event",
- GTK_SIGNAL_FUNC (double_click), re);
-
- gtk_signal_connect (GTK_OBJECT (re), "clicked", editor_clicked, re);
+ g_signal_connect (w, "select_child", select_rule, re);
+ g_signal_connect (w, "button_press_event", double_click, re);
+
+ g_signal_connect (re, "clicked", editor_clicked, re);
rule_editor_set_source (re, source);
-
+
if (enable_undo) {
gnome_dialog_append_buttons (GNOME_DIALOG (re), GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL, NULL);
diff --git a/filter/rule-editor.h b/filter/rule-editor.h
index f054023c87..df940db3e5 100644
--- a/filter/rule-editor.h
+++ b/filter/rule-editor.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,47 +20,55 @@
* Boston, MA 02111-1307, USA.
*/
+
#ifndef _RULE_EDITOR_H
#define _RULE_EDITOR_H
#include <gtk/gtklist.h>
+#include <glade/glade.h>
#include <libgnomeui/gnome-dialog.h>
-#define RULE_EDITOR(obj) GTK_CHECK_CAST (obj, rule_editor_get_type (), RuleEditor)
-#define RULE_EDITOR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, rule_editor_get_type (), RuleEditorClass)
-#define IS_RULE_EDITOR(obj) GTK_CHECK_TYPE (obj, rule_editor_get_type ())
+#include "rule-context.h"
+#include "filter-rule.h"
+
+#define RULE_TYPE_EDITOR (rule_editor_get_type ())
+#define RULE_EDITOR(obj) (GTK_CHECK_CAST ((obj), RULE_TYPE_EDITOR, RuleEditor))
+#define RULE_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), RULE_TYPE_EDITOR, RuleEditorClass))
+#define IS_RULE_EDITOR(obj) (GTK_CHECK_TYPE ((obj), RULE_TYPE_EDITOR))
+#define IS_RULE_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), RULE_TYPE_EDITOR))
+#define RULE_EDITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), RULE_TYPE_EDITOR, RuleEditorClass))
typedef struct _RuleEditor RuleEditor;
typedef struct _RuleEditorClass RuleEditorClass;
typedef struct _RuleEditorUndo RuleEditorUndo;
struct _RuleEditor {
- GnomeDialog parent;
-
+ GnomeDialog parent_object;
+
GtkList *list;
- struct _RuleContext *context;
- struct _FilterRule *current;
- struct _FilterRule *edit; /* for editing/adding rules, so we only do 1 at a time */
+ RuleContext *context;
+ FilterRule *current;
+ FilterRule *edit; /* for editing/adding rules, so we only do 1 at a time */
GtkWidget *dialog;
char *source;
-
+
struct _RuleEditorUndo *undo_log; /* cancel/undo log */
unsigned int undo_active:1; /* we're performing undo */
-
+
struct _RuleEditorPrivate *priv;
};
struct _RuleEditorClass {
GnomeDialogClass parent_class;
-
+
/* virtual methods */
- void (*set_sensitive)(RuleEditor *);
- void (*set_source)(RuleEditor *, const char *source);
-
- struct _FilterRule *(*create_rule)(RuleEditor *);
-
+ void (*set_sensitive) (RuleEditor *);
+ void (*set_source) (RuleEditor *, const char *source);
+
+ FilterRule *(*create_rule) (RuleEditor *);
+
/* signals */
};
@@ -71,26 +81,22 @@ enum {
struct _RuleEditorUndo {
struct _RuleEditorUndo *next;
-
+
unsigned int type;
- struct _FilterRule *rule;
+ FilterRule *rule;
int rank;
int newrank;
};
-struct _GladeXML;
-struct _RuleContext;
-
-guint rule_editor_get_type (void);
-RuleEditor *rule_editor_new (struct _RuleContext *, const char *source);
-void rule_editor_construct (RuleEditor *re, struct _RuleContext *context, struct _GladeXML *gui, const char *source);
+GtkType rule_editor_get_type (void);
+RuleEditor *rule_editor_new (struct _RuleContext *, const char *source);
+void rule_editor_construct (RuleEditor *re, RuleContext *context, GladeXML *gui, const char *source);
/* methods */
-void rule_editor_set_source(RuleEditor *re, const char *source);
+void rule_editor_set_source (RuleEditor *re, const char *source);
/* calculates the sensitivity of the editor */
-void rule_editor_set_sensitive(RuleEditor *re);
+void rule_editor_set_sensitive (RuleEditor *re);
/* used internally to create a new rule appropriate for the editor */
-struct _FilterRule *rule_editor_create_rule(RuleEditor *re);
+struct _FilterRule *rule_editor_create_rule (RuleEditor *re);
#endif /* ! _RULE_EDITOR_H */
-