* hildon-widgets/gtk-intoprint.c (find_banner_for_parent): Added check for "is-timed...
[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 deprecated. 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    gboolean is_timed;
43
44    toplevels = gtk_window_list_toplevels();
45    for (iter = toplevels; iter; iter = iter->next)
46       if (HILDON_IS_BANNER(iter->data) && 
47           gtk_window_get_transient_for(GTK_WINDOW(iter->data)) == parent)
48       {
49          g_object_get(iter->data, "is-timed", &is_timed, NULL);
50
51          /* We do not want to touch timed infoprints */
52          if (!is_timed) {
53            result = iter->data;
54            break;
55          }
56       }
57
58    g_list_free(toplevels);
59    return result;
60 }
61
62 /**************************************************/
63 /** Public                                       **/
64 /**************************************************/
65
66 /**
67  * gtk_infoprint:
68  * @parent: The transient window for the infoprint.
69  * @text: The text in infoprint
70  *
71  * Opens a new infoprint with @text content.
72  * 
73  * If parent is %NULL, the infoprint is a system infoprint.
74  * Normally you should use your application window
75  * or dialog as a transient parent and avoid passing %NULL.
76  *
77  * Deprecated: Use #hildon_banner_show_information instead.
78  */
79 void gtk_infoprint(GtkWindow * parent, const gchar * text)
80 {
81     hildon_banner_show_information((GtkWidget *) parent, NULL, text);    
82 }
83
84 /**
85  * gtk_infoprint_with_icon_stock:
86  * @parent: The transient window for the infoprint.
87  * @text: The text in infoprint
88  * @stock_id: The stock id of the custom icon
89  *
90  * Opens a new infoprint with @text content.
91  * With this function you can also set a custom icon
92  * by giving a stock id as last parameter.
93  * 
94  * If parent is %NULL, the infoprint is a system infoprint.
95  * Normally you should use your application window
96  * or dialog as a transient parent and avoid passing %NULL.
97  *
98  * Deprecated: Use #hildon_banner_show_information instead.
99  */
100 void
101 gtk_infoprint_with_icon_stock(GtkWindow * parent,
102                               const gchar * text, const gchar * stock_id)
103 {
104    hildon_banner_show_information((GtkWidget *) parent, NULL, text);
105 }
106
107 /**
108  * gtk_infoprint_with_icon_name:
109  * @parent: The transient window for the infoprint.
110  * @text: The text in infoprint
111  * @icon_name: The name of the icon
112  *
113  * Opens a new infoprint with @text content.
114  * With this function you can also set a custom icon
115  * by giving a icon name as last parameter.
116  * 
117  * If parent is %NULL, the infoprint is a system infoprint.
118  * Normally you should use your application window
119  * or dialog as a transient parent and avoid passing %NULL.
120  *
121  * Deprecated: Use #hildon_banner_show_information instead.
122  */
123 void
124 gtk_infoprint_with_icon_name(GtkWindow * parent,
125                               const gchar * text, const gchar * icon_name)
126 {
127    hildon_banner_show_information((GtkWidget *) parent, icon_name, text);
128 }                                                                        
129
130 /**
131  * gtk_infoprintf:
132  * @parent: The transient window for the infoprint.
133  * @format: Format of the text.
134  * @Varargs: List of parameters.
135  *
136  * Opens a new infoprint with @text printf-style formatting
137  * string and comma-separated list of parameters.
138  * 
139  * If parent is %NULL, the infoprint is a system infoprint.
140  * This version of infoprint allow you to make printf-like formatting
141  * easily.
142  *
143  * Deprecated: Use #hildon_banner_show_information instead.
144  */
145 void gtk_infoprintf(GtkWindow * parent, const gchar * format, ...)
146 {
147     gchar *message;
148     va_list args;
149
150     va_start(args, format);
151     message = g_strdup_vprintf(format, args);
152     va_end(args);
153
154     gtk_infoprint(parent, message);
155
156     g_free(message);
157 }
158
159 /**
160  * gtk_infoprint_temporarily_disable_wrap:
161  * 
162  * Will disable wrapping for the next shown infoprint. This only
163  * affects next infoprint shown in this application.
164  *
165  * Currently it does nothing.
166  *
167  * Deprecated: 
168  */
169 void gtk_infoprint_temporarily_disable_wrap(void)
170 {
171 }
172
173 /**
174  * gtk_confirmation_banner:
175  * @parent: The transient window for the confirmation banner.
176  * @text: The text in confirmation banner
177  * @stock_id: The stock id of the custom icon
178  *
179  * Opens a new confirmation banner with @text content.
180  * With this function you can also set a custom icon
181  * by giving a stock id as last parameter.
182  *
183  * If parent is %NULL, the banner is a system banner.
184  * Normally you should use your application window
185  * or dialog as a transient parent and avoid passing %NULL.
186  * 
187  * This function is otherwise similar to
188  * gtk_infoprint_with_icon_stock except in always restricts
189  * the text to one line and the font is emphasized.
190  *
191  * Deprecated: Use #hildon_banner_show_information instead.
192  */
193 void
194 gtk_confirmation_banner(GtkWindow * parent, const gchar * text,
195                         const gchar * stock_id)
196 {
197   gchar *s;
198   s = g_strdup_printf("<b>%s</b>", text);
199
200   hildon_banner_show_information_with_markup((GtkWidget *) parent, NULL, s);
201
202   g_free(s);
203 }
204
205 /**
206  * gtk_confirmation_banner_with_icon_name:
207  * @parent: The transient window for the confirmation banner.
208  * @text: The text in confirmation banner
209  * @icon_name: The name of the custom icon in icon theme
210  *
211  * Opens a new confirmation banner with @text content.
212  * With this function you can also set a custom icon
213  * by giving a icon theme's icon name as last parameter.
214  *
215  * If parent is %NULL, the banner is a system banner.
216  * Normally you should use your application window
217  * or dialog as a transient parent and avoid passing %NULL.
218  * 
219  * This function is otherwise similar to
220  * gtk_infoprint_with_icon_name except in always restricts
221  * the text to one line and the font is emphasized.
222  *
223  * Deprecated: Use #hildon_banner_show_information instead.
224  */
225 void
226 gtk_confirmation_banner_with_icon_name(GtkWindow * parent, const gchar * text,
227                         const gchar * icon_name)
228 {
229    hildon_banner_show_information((GtkWidget *) parent, icon_name, text);
230 }
231
232 /**
233  * gtk_banner_show_animation:
234  * @parent: #GtkWindow
235  * @text: #const gchar *
236  *
237  * The @text is the text shown in banner.
238  * Creates a new banner with the animation.
239  *
240  * Deprecated: Use #hildon_banner_show_animation instead.
241  */
242 void gtk_banner_show_animation(GtkWindow * parent, const gchar * text)
243 {
244    (void) hildon_banner_show_animation((GtkWidget *) parent, NULL, text);
245 }
246
247 /**
248  * gtk_banner_show_bar
249  * @parent: #GtkWindow
250  * @text: #const gchar *
251  *
252  * The @text is the text shown in banner.
253  * Creates a new banner with the progressbar.
254  *
255  * Deprecated: Use #hildon_banner_show_progress instead.
256  */
257 void gtk_banner_show_bar(GtkWindow * parent, const gchar * text)
258 {
259    (void) hildon_banner_show_progress((GtkWidget *) parent, NULL, text);
260 }
261
262 /**
263  * gtk_banner_set_text
264  * @parent: #GtkWindow
265  * @text: #const gchar *
266  *
267  * The @text is the text shown in banner.
268  * Sets the banner text.
269  *
270  * Deprecated: Use #hildon_banner_set_text instead.
271  */
272 void gtk_banner_set_text(GtkWindow * parent, const gchar * text)
273 {
274    GtkWidget *banner;
275
276    g_return_if_fail(GTK_IS_WINDOW(parent) || parent == NULL);
277
278    banner = find_banner_for_parent(parent);
279    if (banner)
280       hildon_banner_set_text(HILDON_BANNER(banner), text);
281 }
282
283 /**
284  * gtk_banner_set_fraction:
285  * @parent: #GtkWindow
286  * @fraction: #gdouble
287  *
288  * The fraction is the completion of progressbar, 
289  * the scale is from 0.0 to 1.0.
290  * Sets the amount of fraction the progressbar has.
291  *
292  * Deprecated: Use #hildon_banner_set_fraction instead.
293  */
294 void gtk_banner_set_fraction(GtkWindow * parent, gdouble fraction)
295 {
296    GtkWidget *banner;
297
298    g_return_if_fail(GTK_IS_WINDOW(parent) || parent == NULL);
299
300    banner = find_banner_for_parent(parent);
301    if (banner)
302       hildon_banner_set_fraction(HILDON_BANNER(banner), fraction);
303 }
304
305 /**
306  * gtk_banner_close:
307  * @parent: #GtkWindow
308  *
309  * Destroys the banner
310  *
311  * Deprecated:
312  */
313 void gtk_banner_close(GtkWindow * parent)
314 {
315    GtkWidget *banner;
316
317    g_return_if_fail(GTK_IS_WINDOW(parent) || parent == NULL);
318
319    banner = find_banner_for_parent(parent);
320    if (banner)
321       gtk_widget_destroy(banner);
322 }
323
324 /**
325  * gtk_banner_temporarily_disable_wrap
326  * 
327  * Will disable wrapping for the next shown banner. This only
328  * affects next banner shown in this application.
329  *
330  * Currently it does nothing.
331  *
332  * Deprecated:
333  **/
334 void gtk_banner_temporarily_disable_wrap(void)
335 {
336 }