aboutsummaryrefslogtreecommitdiffstats
path: root/filter/filter-file.c
diff options
context:
space:
mode:
Diffstat (limited to 'filter/filter-file.c')
-rw-r--r--filter/filter-file.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/filter/filter-file.c b/filter/filter-file.c
index 3fc797dff5..0418a36a2d 100644
--- a/filter/filter-file.c
+++ b/filter/filter-file.c
@@ -62,7 +62,7 @@ GType
filter_file_get_type (void)
{
static GType type = 0;
-
+
if (!type) {
static const GTypeInfo info = {
sizeof (FilterFileClass),
@@ -75,10 +75,10 @@ filter_file_get_type (void)
0, /* n_preallocs */
(GInstanceInitFunc) filter_file_init,
};
-
+
type = g_type_register_static (FILTER_TYPE_ELEMENT, "FilterFile", &info, 0);
}
-
+
return type;
}
@@ -87,11 +87,11 @@ filter_file_class_init (FilterFileClass *klass)
{
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->finalize = filter_file_finalise;
-
+
/* override methods */
fe_class->validate = validate;
fe_class->eq = file_eq;
@@ -113,10 +113,10 @@ static void
filter_file_finalise (GObject *obj)
{
FilterFile *ff = (FilterFile *) obj;
-
+
xmlFree (ff->type);
g_free (ff->path);
-
+
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -124,7 +124,7 @@ filter_file_finalise (GObject *obj)
* filter_file_new:
*
* Create a new FilterFile object.
- *
+ *
* Return value: A new #FilterFile object.
**/
FilterFile *
@@ -138,10 +138,10 @@ FilterFile *
filter_file_new_type_name (const char *type)
{
FilterFile *file;
-
+
file = filter_file_new ();
file->type = (char *)xmlStrdup ((xmlChar *)type);
-
+
return file;
}
@@ -156,7 +156,7 @@ static gboolean
validate (FilterElement *fe)
{
FilterFile *file = (FilterFile *) fe;
-
+
if (!file->path) {
/* FIXME: FilterElement should probably have a
GtkWidget member pointing to the value gotten with
@@ -166,9 +166,9 @@ validate (FilterElement *fe)
return FALSE;
}
-
+
/* FIXME: do more to validate command-lines? */
-
+
if (strcmp (file->type, "file") == 0) {
if (!g_file_test (file->path, G_FILE_TEST_IS_REGULAR)) {
/* FIXME: FilterElement should probably have a
@@ -176,7 +176,7 @@ validate (FilterElement *fe)
::get_widget() so that we can get the parent window
here. */
e_error_run(NULL, "filter:bad-file", file->path, NULL);
-
+
return FALSE;
}
} else if (strcmp (file->type, "command") == 0) {
@@ -184,7 +184,7 @@ validate (FilterElement *fe)
be an empty string */
return file->path[0] != '\0';
}
-
+
return TRUE;
}
@@ -192,7 +192,7 @@ static int
file_eq (FilterElement *fe, FilterElement *cm)
{
FilterFile *ff = (FilterFile *)fe, *cf = (FilterFile *)cm;
-
+
return FILTER_ELEMENT_CLASS (parent_class)->eq (fe, cm)
&& ((ff->path && cf->path && strcmp (ff->path, cf->path) == 0)
|| (ff->path == NULL && cf->path == NULL))
@@ -213,18 +213,18 @@ xml_encode (FilterElement *fe)
FilterFile *file = (FilterFile *) fe;
xmlNodePtr cur, value;
char *type;
-
+
type = file->type ? file->type : "file";
-
+
d(printf ("Encoding %s as xml\n", type));
-
+
value = xmlNewNode (NULL, (const unsigned char *)"value");
xmlSetProp (value, (const unsigned char *)"name", (unsigned char *)fe->name);
xmlSetProp (value, (const unsigned char *)"type", (unsigned char *)type);
-
+
cur = xmlNewChild (value, NULL, (unsigned char *)type, NULL);
xmlNodeSetContent (cur, (unsigned char *)file->path);
-
+
return value;
}
@@ -234,37 +234,37 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
FilterFile *file = (FilterFile *)fe;
char *name, *str, *type;
xmlNodePtr n;
-
+
name = (char *)xmlGetProp (node, (const unsigned char *)"name");
type = (char *)xmlGetProp (node, (const unsigned char *)"type");
-
+
d(printf("Decoding %s from xml %p\n", type, fe));
d(printf ("Name = %s\n", name));
-
+
xmlFree (fe->name);
fe->name = name;
xmlFree (file->type);
file->type = type;
-
+
g_free (file->path);
file->path = NULL;
-
+
n = node->children;
while (n != NULL) {
if (!strcmp ((char *)n->name, type)) {
str = (char *)xmlNodeGetContent (n);
file->path = g_strdup (str ? str : "");
xmlFree (str);
-
+
d(printf (" '%s'\n", file->path));
break;
} else if (n->type == XML_ELEMENT_NODE) {
g_warning ("Unknown node type '%s' encountered decoding a %s\n", n->name, type);
}
-
+
n = n->next;
}
-
+
return 0;
}
@@ -273,7 +273,7 @@ filename_changed (GtkWidget *widget, FilterElement *fe)
{
FilterFile *file = (FilterFile *) fe;
const char *new;
-
+
new = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
g_free (file->path);
file->path = g_strdup (new);
@@ -287,7 +287,7 @@ get_widget (FilterElement *fe)
filewidget = (GtkWidget *) gtk_file_chooser_button_new (_("Choose a file"), GTK_FILE_CHOOSER_ACTION_OPEN);
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filewidget), file->path);
- g_signal_connect (GTK_FILE_CHOOSER_BUTTON (filewidget), "selection-changed",
+ g_signal_connect (GTK_FILE_CHOOSER_BUTTON (filewidget), "selection-changed",
G_CALLBACK (filename_changed), fe);
return filewidget;
}
@@ -302,6 +302,6 @@ static void
format_sexp (FilterElement *fe, GString *out)
{
FilterFile *file = (FilterFile *) fe;
-
+
e_sexp_encode_string (out, file->path);
}