thread safety
[hildon] / hildon-widgets / gtk-infoprint.c
1 /*
2  * This file is part of hildon-libs
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Luc Pionchon <luc.pionchon@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24
25 /**
26  * SECTION:gtk-infoprint
27  * @short_description: deprecated widget. Use #HildonBanner instead
28  *
29  * This widget is deprectaed. Use #HildonBanner instead
30  */
31
32 #include "gtk-infoprint.h"
33 #include "hildon-banner.h"
34
35 /* This is a helper function that searches the banner for
36    given window. This is needed to provide backwards
37    compatibility. */
38 static GtkWidget *find_banner_for_parent(GtkWindow *parent)
39 {
40    GList *toplevels, *iter;
41    GtkWidget *result = NULL;
42
43    toplevels = gtk_window_list_toplevels();
44    for (iter = toplevels; iter; iter = iter->next)
45       if (HILDON_IS_BANNER(iter->data) && 
46           gtk_window_get_transient_for(GTK_WINDOW(iter->data)) == parent)
47       {
48          result = iter->data;
49          break;
50       }
51
52    g_list_free(toplevels);
53    return result;
54 }
55
56 /**************************************************/
57 /** Public                                       **/
58 /**************************************************/
59
60 /**
61  * gtk_infoprint:
62  * @parent: The transient window for the infoprint.
63  * @text: The text in infoprint
64  *
65  * Opens a new infoprint with @text content.
66  * 
67  * If parent is %NULL, the infoprint is a system infoprint.
68  * Normally you should use your application window
69  * or dialog as a transient parent and avoid passing %NULL.
70  *
71  * Deprecated: Use #hildon_banner_show_information instead.
72  */
73 void gtk_infoprint(GtkWindow * parent, const gchar * text)
74 {
75     hildon_banner_show_information((GtkWidget *) parent, NULL, text);    
76 }
77
78 /**
79  * gtk_infoprint_with_icon_stock:
80  * @parent: The transient window for the infoprint.
81  * @text: The text in infoprint
82  * @stock_id: The stock id of the custom icon
83  *
84  * Opens a new infoprint with @text content.
85  * With this function you can also set a custom icon
86  * by giving a stock id as last parameter.
87  * 
88  * If parent is %NULL, the infoprint is a system infoprint.
89  * Normally you should use your application window
90  * or dialog as a transient parent and avoid passing %NULL.
91  *
92  * Deprecated: Use #hildon_banner_show_information instead.
93  */
94 void
95 gtk_infoprint_with_icon_stock(GtkWindow * parent,
96                               const gchar * text, const gchar * stock_id)
97 {
98    hildon_banner_show_information((GtkWidget *) parent, NULL, text);
99 }
100
101 /**
102  * gtk_infoprint_with_icon_name:
103  * @parent: The transient window for the infoprint.
104  * @text: The text in infoprint
105  * @icon_name: The name of the icon
106  *
107  * Opens a new infoprint with @text content.
108  * With this function you can also set a custom icon
109  * by giving a icon name as last parameter.
110  * 
111  * If parent is %NULL, the infoprint is a system infoprint.
112  * Normally you should use your application window
113  * or dialog as a transient parent and avoid passing %NULL.
114  *
115  * Deprecated: Use #hildon_banner_show_information instead.
116  */
117 void
118 gtk_infoprint_with_icon_name(GtkWindow * parent,
119                               const gchar * text, const gchar * icon_name)
120 {
121    hildon_banner_show_information((GtkWidget *) parent, icon_name, text);
122 }                                                                        
123
124 /**
125  * gtk_infoprintf:
126  * @parent: The transient window for the infoprint.
127  * @format: Format of the text.
128  * @Varargs: List of parameters.
129  *
130  * Opens a new infoprint with @text printf-style formatting
131  * string and comma-separated list of parameters.
132  * 
133  * If parent is %NULL, the infoprint is a system infoprint.
134  * This version of infoprint allow you to make printf-like formatting
135  * easily.
136  *
137  * Deprecated: Use #hildon_banner_show_information instead.
138  */
139 void gtk_infoprintf(GtkWindow * parent, const gchar * format, ...)
140 {
141     gchar *message;
142     va_list args;
143
144     va_start(args, format);
145     message = g_strdup_vprintf(format, args);
146     va_end(args);
147
148     gtk_infoprint(parent, message);
149
150     g_free(message);
151 }
152
153 /**
154  * gtk_infoprint_temporarily_disable_wrap:
155  * 
156  * Will disable wrapping for the next shown infoprint. This only
157  * affects next infoprint shown in this application.
158  *
159  * Currently it does nothing.
160  *
161  * Deprecated: 
162  */
163 void gtk_infoprint_temporarily_disable_wrap(void)
164 {
165 }
166
167 /**
168  * gtk_confirmation_banner:
169  * @parent: The transient window for the confirmation banner.
170  * @text: The text in confirmation banner
171  * @stock_id: The stock id of the custom icon
172  *
173  * Opens a new confirmation banner with @text content.
174  * With this function you can also set a custom icon
175  * by giving a stock id as last parameter.
176  *
177  * If parent is %NULL, the banner is a system banner.
178  * Normally you should use your application window
179  * or dialog as a transient parent and avoid passing %NULL.
180  * 
181  * This function is otherwise similar to
182  * gtk_infoprint_with_icon_stock except in always restricts
183  * the text to one line and the font is emphasized.
184  *
185  * Deprecated: Use #hildon_banner_show_information instead.
186  */
187 void
188 gtk_confirmation_banner(GtkWindow * parent, const gchar * text,
189                         const gchar * stock_id)
190 {
191    hildon_banner_show_information((GtkWidget *) parent, NULL, text);
192 }
193
194 /**
195  * gtk_confirmation_banner_with_icon_name:
196  * @parent: The transient window for the confirmation banner.
197  * @text: The text in confirmation banner
198  * @icon_name: The name of the custom icon in icon theme
199  *
200  * Opens a new confirmation banner with @text content.
201  * With this function you can also set a custom icon
202  * by giving a icon theme's icon name as last parameter.
203  *
204  * If parent is %NULL, the banner is a system banner.
205  * Normally you should use your application window
206  * or dialog as a transient parent and avoid passing %NULL.
207  * 
208  * This function is otherwise similar to
209  * gtk_infoprint_with_icon_name except in always restricts
210  * the text to one line and the font is emphasized.
211  *
212  * Deprecated: Use #hildon_banner_show_information instead.
213  */
214 void
215 gtk_confirmation_banner_with_icon_name(GtkWindow * parent, const gchar * text,
216                         const gchar * icon_name)
217 {
218    hildon_banner_show_information((GtkWidget *) parent, icon_name, text);
219 }
220
221 /**
222  * gtk_banner_show_animation:
223  * @parent: #GtkWindow
224  * @text: #const gchar *
225  *
226  * The @text is the text shown in banner.
227  * Creates a new banner with the animation.
228  *
229  * Deprecated: Use #hildon_banner_show_animation instead.
230  */
231 void gtk_banner_show_animation(GtkWindow * parent, const gchar * text)
232 {
233    (void) hildon_banner_show_animation((GtkWidget *) parent, NULL, text);
234 }
235
236 /**
237  * gtk_banner_show_bar
238  * @parent: #GtkWindow
239  * @text: #const gchar *
240  *
241  * The @text is the text shown in banner.
242  * Creates a new banner with the progressbar.
243  *
244  * Deprecated: Use #hildon_banner_show_progress instead.
245  */
246 void gtk_banner_show_bar(GtkWindow * parent, const gchar * text)
247 {
248    (void) hildon_banner_show_progress((GtkWidget *) parent, NULL, text);
249 }
250
251 /**
252  * gtk_banner_set_text
253  * @parent: #GtkWindow
254  * @text: #const gchar *
255  *
256  * The @text is the text shown in banner.
257  * Sets the banner text.
258  *
259  * Deprecated: Use #hildon_banner_set_text instead.
260  */
261 void gtk_banner_set_text(GtkWindow * parent, const gchar * text)
262 {
263    GtkWidget *banner;
264
265    g_return_if_fail(GTK_IS_WINDOW(parent) || parent == NULL);
266
267    banner = find_banner_for_parent(parent);
268    if (banner)
269       hildon_banner_set_text(HILDON_BANNER(banner), text);
270 }
271
272 /**
273  * gtk_banner_set_fraction:
274  * @parent: #GtkWindow
275  * @fraction: #gdouble
276  *
277  * The fraction is the completion of progressbar, 
278  * the scale is from 0.0 to 1.0.
279  * Sets the amount of fraction the progressbar has.
280  *
281  * Deprecated: Use #hildon_banner_set_fraction instead.
282  */
283 void gtk_banner_set_fraction(GtkWindow * parent, gdouble fraction)
284 {
285    GtkWidget *banner;
286
287    g_return_if_fail(GTK_IS_WINDOW(parent) || parent == NULL);
288
289    banner = find_banner_for_parent(parent);
290    if (banner)
291       hildon_banner_set_fraction(HILDON_BANNER(banner), fraction);
292 }
293
294 /**
295  * gtk_banner_close:
296  * @parent: #GtkWindow
297  *
298  * Destroys the banner
299  *
300  * Deprecated:
301  */
302 void gtk_banner_close(GtkWindow * parent)
303 {
304    GtkWidget *banner;
305
306    g_return_if_fail(GTK_IS_WINDOW(parent) || parent == NULL);
307
308    banner = find_banner_for_parent(parent);
309    if (banner)
310       gtk_widget_destroy(banner);
311 }
312
313 /**
314  * gtk_banner_temporarily_disable_wrap
315  * 
316  * Will disable wrapping for the next shown banner. This only
317  * affects next banner shown in this application.
318  *
319  * Currently it does nothing.
320  *
321  * Deprecated:
322  **/
323 void gtk_banner_temporarily_disable_wrap(void)
324 {
325 }