[evolution-patches] Cleanups for evolution/filter
- From: Kjartan Maraas <kmaraas broadpark no>
- To: evolution-patches <evolution-patches gnome org>
- Subject: [evolution-patches] Cleanups for evolution/filter
- Date: Sat, 10 Dec 2005 19:56:28 +0100
- mark a struct static
- mark some functions static
- shuffle around these and drop unneeded prototypes
Cheers
Kjartan
? filter.error
Index: filter-element.c
===================================================================
RCS file: /cvs/gnome/evolution/filter/filter-element.c,v
retrieving revision 1.34
diff -u -p -r1.34 filter-element.c
--- filter-element.c 17 Jun 2004 07:34:07 -0000 1.34
+++ filter-element.c 10 Dec 2005 18:45:23 -0000
@@ -48,7 +48,6 @@ static void filter_element_init (FilterE
static void filter_element_finalise (GObject *obj);
static GObjectClass *parent_class = NULL;
-static GHashTable *fe_table;
GType
filter_element_get_type (void)
@@ -67,7 +66,6 @@ filter_element_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) filter_element_init,
};
- fe_table = g_hash_table_new(g_str_hash, g_str_equal);
type = g_type_register_static (G_TYPE_OBJECT, "FilterElement", &info, 0);
}
Index: rule-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/filter/rule-editor.c,v
retrieving revision 1.65
diff -u -p -r1.65 rule-editor.c
--- rule-editor.c 9 Aug 2005 23:29:27 -0000 1.65
+++ rule-editor.c 10 Dec 2005 18:45:24 -0000
@@ -37,9 +37,6 @@
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);
-
#define d(x)
static void set_source (RuleEditor *re, const char *source);
@@ -228,6 +225,95 @@ editor_destroy (RuleEditor *re, GObject
}
static void
+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->rule = rule;
+ undo->type = type;
+ undo->rank = rank;
+ undo->newrank = newrank;
+
+ undo->next = re->undo_log;
+ re->undo_log = undo;
+ } else {
+ g_object_unref (rule);
+ }
+}
+
+static void
+rule_editor_play_undo (RuleEditor *re)
+{
+ RuleEditorUndo *undo, *next;
+ FilterRule *rule;
+
+ re->undo_active = TRUE;
+ undo = re->undo_log;
+ re->undo_log = NULL;
+ while (undo) {
+ next = undo->next;
+ switch (undo->type) {
+ case RULE_EDITOR_LOG_EDIT:
+ d(printf ("Undoing edit on rule '%s'\n", undo->rule->name));
+ rule = rule_context_find_rank_rule (re->context, undo->rank, undo->rule->source);
+ if (rule) {
+ d(printf (" name was '%s'\n", rule->name));
+ filter_rule_copy (rule, undo->rule);
+ d(printf (" name is '%s'\n", rule->name));
+ } else {
+ g_warning ("Could not find the right rule to undo against?");
+ }
+ break;
+ case RULE_EDITOR_LOG_ADD:
+ d(printf ("Undoing add on rule '%s'\n", undo->rule->name));
+ rule = rule_context_find_rank_rule (re->context, undo->rank, undo->rule->source);
+ if (rule)
+ rule_context_remove_rule (re->context, rule);
+ break;
+ case RULE_EDITOR_LOG_REMOVE:
+ d(printf ("Undoing remove on rule '%s'\n", undo->rule->name));
+ g_object_ref (undo->rule);
+ rule_context_add_rule (re->context, undo->rule);
+ rule_context_rank_rule (re->context, undo->rule, re->source, undo->rank);
+ break;
+ case RULE_EDITOR_LOG_RANK:
+ rule = rule_context_find_rank_rule (re->context, undo->newrank, undo->rule->source);
+ if (rule)
+ rule_context_rank_rule (re->context, rule, re->source, undo->rank);
+ break;
+ }
+
+ g_object_unref (undo->rule);
+ g_free (undo);
+ undo = next;
+ }
+ re->undo_active = FALSE;
+}
+
+static void
+editor_response (GtkWidget *dialog, int button, RuleEditor *re)
+{
+ if (button == GTK_RESPONSE_CANCEL) {
+ if (enable_undo)
+ rule_editor_play_undo (re);
+ else {
+ RuleEditorUndo *undo, *next;
+
+ undo = re->undo_log;
+ re->undo_log = 0;
+ while (undo) {
+ next = undo->next;
+ g_object_unref (undo->rule);
+ g_free (undo);
+ undo = next;
+ }
+ }
+ }
+}
+
+static void
add_editor_response (GtkWidget *dialog, int button, RuleEditor *re)
{
GtkTreeSelection *selection;
@@ -582,95 +668,6 @@ set_source (RuleEditor *re, const char *
re->source = g_strdup (source);
re->current = NULL;
rule_editor_set_sensitive (re);
-}
-
-void
-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->rule = rule;
- undo->type = type;
- undo->rank = rank;
- undo->newrank = newrank;
-
- undo->next = re->undo_log;
- re->undo_log = undo;
- } else {
- g_object_unref (rule);
- }
-}
-
-void
-rule_editor_play_undo (RuleEditor *re)
-{
- RuleEditorUndo *undo, *next;
- FilterRule *rule;
-
- re->undo_active = TRUE;
- undo = re->undo_log;
- re->undo_log = NULL;
- while (undo) {
- next = undo->next;
- switch (undo->type) {
- case RULE_EDITOR_LOG_EDIT:
- d(printf ("Undoing edit on rule '%s'\n", undo->rule->name));
- rule = rule_context_find_rank_rule (re->context, undo->rank, undo->rule->source);
- if (rule) {
- d(printf (" name was '%s'\n", rule->name));
- filter_rule_copy (rule, undo->rule);
- d(printf (" name is '%s'\n", rule->name));
- } else {
- g_warning ("Could not find the right rule to undo against?");
- }
- break;
- case RULE_EDITOR_LOG_ADD:
- d(printf ("Undoing add on rule '%s'\n", undo->rule->name));
- rule = rule_context_find_rank_rule (re->context, undo->rank, undo->rule->source);
- if (rule)
- rule_context_remove_rule (re->context, rule);
- break;
- case RULE_EDITOR_LOG_REMOVE:
- d(printf ("Undoing remove on rule '%s'\n", undo->rule->name));
- g_object_ref (undo->rule);
- rule_context_add_rule (re->context, undo->rule);
- rule_context_rank_rule (re->context, undo->rule, re->source, undo->rank);
- break;
- case RULE_EDITOR_LOG_RANK:
- rule = rule_context_find_rank_rule (re->context, undo->newrank, undo->rule->source);
- if (rule)
- rule_context_rank_rule (re->context, rule, re->source, undo->rank);
- break;
- }
-
- g_object_unref (undo->rule);
- g_free (undo);
- undo = next;
- }
- re->undo_active = FALSE;
-}
-
-static void
-editor_response (GtkWidget *dialog, int button, RuleEditor *re)
-{
- if (button == GTK_RESPONSE_CANCEL) {
- if (enable_undo)
- rule_editor_play_undo (re);
- else {
- RuleEditorUndo *undo, *next;
-
- undo = re->undo_log;
- re->undo_log = 0;
- while (undo) {
- next = undo->next;
- g_object_unref (undo->rule);
- g_free (undo);
- undo = next;
- }
- }
- }
}
GtkWidget *rule_editor_treeview_new (char *widget_name, char *string1, char *string2,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]