]> Pileus Git - ~andy/gtk/blob - gtk/gtkquery.c
Include "config.h" instead of <config.h> Command used: find -name
[~andy/gtk] / gtk / gtkquery.c
1 /*
2  * Copyright (C) 2005 Novell, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  *
18  * Author: Anders Carlsson <andersca@imendio.com>
19  *
20  * Based on nautilus-query.c
21  */
22
23 #include "config.h"
24 #include <string.h>
25
26 #include "gtkquery.h"
27
28 struct _GtkQueryPrivate 
29 {
30   gchar *text;
31   gchar *location_uri;
32   GList *mime_types;
33 };
34
35 G_DEFINE_TYPE (GtkQuery, _gtk_query, G_TYPE_OBJECT);
36
37 static void
38 finalize (GObject *object)
39 {
40   GtkQuery *query;
41   
42   query = GTK_QUERY (object);
43   
44   g_free (query->priv->text);
45
46   G_OBJECT_CLASS (_gtk_query_parent_class)->finalize (object);
47 }
48
49 static void
50 _gtk_query_class_init (GtkQueryClass *class)
51 {
52   GObjectClass *gobject_class;
53   
54   gobject_class = G_OBJECT_CLASS (class);
55   gobject_class->finalize = finalize;
56
57   g_type_class_add_private (gobject_class, sizeof (GtkQueryPrivate));  
58 }
59
60 static void
61 _gtk_query_init (GtkQuery *query)
62 {
63   query->priv = G_TYPE_INSTANCE_GET_PRIVATE (query, GTK_TYPE_QUERY, GtkQueryPrivate);
64 }
65
66 GtkQuery *
67 _gtk_query_new (void)
68 {
69   return g_object_new (GTK_TYPE_QUERY,  NULL);
70 }
71
72
73 gchar *
74 _gtk_query_get_text (GtkQuery *query)
75 {
76   return g_strdup (query->priv->text);
77 }
78
79 void 
80 _gtk_query_set_text (GtkQuery    *query, 
81                     const gchar *text)
82 {
83   g_free (query->priv->text);
84   query->priv->text = g_strdup (text);
85 }
86
87 gchar *
88 _gtk_query_get_location (GtkQuery *query)
89 {
90   return g_strdup (query->priv->location_uri);
91 }
92         
93 void
94 _gtk_query_set_location (GtkQuery    *query, 
95                         const gchar *uri)
96 {
97   g_free (query->priv->location_uri);
98   query->priv->location_uri = g_strdup (uri);
99 }
100
101 GList *
102 _gtk_query_get_mime_types (GtkQuery *query)
103 {
104   GList *list, *l;
105   gchar *mime_type;
106
107   list = NULL;
108   for (l = query->priv->mime_types; l; l = l->next)
109     {
110       mime_type = (gchar*)l->data;
111       list = g_list_prepend (list, g_strdup (mime_type));
112     }
113
114   return list;
115 }
116
117 void
118 _gtk_query_set_mime_types (GtkQuery *query, 
119                            GList    *mime_types)
120 {
121   GList *l;
122   gchar *mime_type;
123
124   g_list_foreach (query->priv->mime_types, (GFunc)g_free, NULL);
125   g_list_free (query->priv->mime_types);
126   query->priv->mime_types = NULL;
127
128   for (l = mime_types; l; l = l->next)
129     {
130       mime_type = (gchar*)l->data;
131       query->priv->mime_types = g_list_prepend (query->priv->mime_types, g_strdup (mime_type));
132     }
133 }
134
135 void
136 _gtk_query_add_mime_type (GtkQuery    *query, 
137                           const gchar *mime_type)
138 {
139   query->priv->mime_types = g_list_prepend (query->priv->mime_types,
140                                             g_strdup (mime_type));
141 }
142