Dont add null mimetypes. Fixes bgo# 337431. The patch hasnt been officially accepted...
[beagle.git] / libbeagle / beagle / beagle-query-part-human.c
blobdbad807eec29ac2eeb0b584ddab30da5e2f51636
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; -*- */
3 /*
4 * beagle-query-part-human.c
6 * Copyright (C) 2005 Novell, Inc.
8 */
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 * DEALINGS IN THE SOFTWARE.
30 #include <string.h>
32 #include "beagle-private.h"
33 #include "beagle-query-part.h"
34 #include "beagle-query-part-human.h"
36 typedef struct {
37 const char *string;
38 } BeagleQueryPartHumanPrivate;
40 #define BEAGLE_QUERY_PART_HUMAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BEAGLE_TYPE_QUERY_PART_HUMAN, BeagleQueryPartHumanPrivate))
42 static GObjectClass *parent_class = NULL;
44 G_DEFINE_TYPE (BeagleQueryPartHuman, beagle_query_part_human, BEAGLE_TYPE_QUERY_PART)
46 static GString *
47 beagle_query_part_human_to_xml (BeagleQueryPart *part)
49 BeagleQueryPartHumanPrivate *priv = BEAGLE_QUERY_PART_HUMAN_GET_PRIVATE (part);
50 GString *data = g_string_new (NULL);
52 _beagle_query_part_append_standard_header (data, part, "Human");
54 g_string_append (data, "<QueryString>");
55 g_string_append (data, priv->string);
56 g_string_append (data, "</QueryString>");
58 _beagle_query_part_append_standard_footer (data);
60 return data;
63 static void
64 beagle_query_part_human_finalize (GObject *obj)
66 if (G_OBJECT_CLASS (parent_class)->finalize)
67 G_OBJECT_CLASS (parent_class)->finalize (obj);
70 static void
71 beagle_query_part_human_class_init (BeagleQueryPartHumanClass *klass)
73 GObjectClass *obj_class = G_OBJECT_CLASS (klass);
74 BeagleQueryPartClass *query_part_class = BEAGLE_QUERY_PART_CLASS (klass);
76 parent_class = g_type_class_peek_parent (klass);
78 obj_class->finalize = beagle_query_part_human_finalize;
79 query_part_class->to_xml = beagle_query_part_human_to_xml;
81 g_type_class_add_private (klass, sizeof (BeagleQueryPartHumanPrivate));
84 static void
85 beagle_query_part_human_init (BeagleQueryPartHuman *part)
90 BeagleQueryPartHuman *
91 beagle_query_part_human_new (void)
93 BeagleQueryPartHuman *part = g_object_new (BEAGLE_TYPE_QUERY_PART_HUMAN, 0);
94 return part;
97 /**
98 * beagle_query_part_human_set_string:
99 * @part: a #BeagleQueryPartHuman
100 * @string: a #const char *
102 * Sets the "human" string on a #BeagleQueryPartHuman. This should be used
103 * for user input as it can contain query modifiers like "OR".
105 void
106 beagle_query_part_human_set_string (BeagleQueryPartHuman *part,
107 const char *string)
109 BeagleQueryPartHumanPrivate *priv;
111 g_return_if_fail (BEAGLE_IS_QUERY_PART_HUMAN (part));
112 g_return_if_fail (string != NULL);
114 priv = BEAGLE_QUERY_PART_HUMAN_GET_PRIVATE (part);
115 priv->string = string;