]> Pileus Git - ~andy/gtk/blob - gtk/gtkquery.c
stylecontext: Do invalidation on first resize container
[~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, see <http://www.gnu.org/licenses/>.
16  *
17  * Author: Anders Carlsson <andersca@imendio.com>
18  *
19  * Based on nautilus-query.c
20  */
21
22 #include "config.h"
23 #include <string.h>
24
25 #include "gtkquery.h"
26
27 struct _GtkQueryPrivate 
28 {
29   gchar *text;
30   gchar *location_uri;
31   GList *mime_types;
32 };
33
34 G_DEFINE_TYPE (GtkQuery, _gtk_query, G_TYPE_OBJECT);
35
36 static void
37 finalize (GObject *object)
38 {
39   GtkQuery *query;
40   
41   query = GTK_QUERY (object);
42   
43   g_free (query->priv->text);
44
45   G_OBJECT_CLASS (_gtk_query_parent_class)->finalize (object);
46 }
47
48 static void
49 _gtk_query_class_init (GtkQueryClass *class)
50 {
51   GObjectClass *gobject_class;
52   
53   gobject_class = G_OBJECT_CLASS (class);
54   gobject_class->finalize = finalize;
55
56   g_type_class_add_private (gobject_class, sizeof (GtkQueryPrivate));  
57 }
58
59 static void
60 _gtk_query_init (GtkQuery *query)
61 {
62   query->priv = G_TYPE_INSTANCE_GET_PRIVATE (query, GTK_TYPE_QUERY, GtkQueryPrivate);
63 }
64
65 GtkQuery *
66 _gtk_query_new (void)
67 {
68   return g_object_new (GTK_TYPE_QUERY,  NULL);
69 }
70
71
72 gchar *
73 _gtk_query_get_text (GtkQuery *query)
74 {
75   return g_strdup (query->priv->text);
76 }
77
78 void 
79 _gtk_query_set_text (GtkQuery    *query, 
80                     const gchar *text)
81 {
82   g_free (query->priv->text);
83   query->priv->text = g_strdup (text);
84 }
85
86 gchar *
87 _gtk_query_get_location (GtkQuery *query)
88 {
89   return g_strdup (query->priv->location_uri);
90 }
91         
92 void
93 _gtk_query_set_location (GtkQuery    *query, 
94                         const gchar *uri)
95 {
96   g_free (query->priv->location_uri);
97   query->priv->location_uri = g_strdup (uri);
98 }
99
100 GList *
101 _gtk_query_get_mime_types (GtkQuery *query)
102 {
103   GList *list, *l;
104   gchar *mime_type;
105
106   list = NULL;
107   for (l = query->priv->mime_types; l; l = l->next)
108     {
109       mime_type = (gchar*)l->data;
110       list = g_list_prepend (list, g_strdup (mime_type));
111     }
112
113   return list;
114 }
115
116 void
117 _gtk_query_set_mime_types (GtkQuery *query, 
118                            GList    *mime_types)
119 {
120   GList *l;
121   gchar *mime_type;
122
123   g_list_free_full (query->priv->mime_types, g_free);
124   query->priv->mime_types = NULL;
125
126   for (l = mime_types; l; l = l->next)
127     {
128       mime_type = (gchar*)l->data;
129       query->priv->mime_types = g_list_prepend (query->priv->mime_types, g_strdup (mime_type));
130     }
131 }
132
133 void
134 _gtk_query_add_mime_type (GtkQuery    *query, 
135                           const gchar *mime_type)
136 {
137   query->priv->mime_types = g_list_prepend (query->priv->mime_types,
138                                             g_strdup (mime_type));
139 }
140