0f9be2aa75ed3bdf61e7f542cd4bd2d47b29cb8e
[hildon] / hildon-widgets / gtk-infoprint.c
1 /*
2  * This file is part of hildon-libs
3  *
4  * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
5  *
6  * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@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; version 2.1 of
11  * the License.
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   gchar *s;
230   s = g_strdup_printf("<b>%s</b>", text);
231
232   hildon_banner_show_information_with_markup((GtkWidget *) parent, icon_name, s);
233
234   g_free(s);
235 }
236
237 /**
238  * gtk_banner_show_animation:
239  * @parent: #GtkWindow
240  * @text: #const gchar *
241  *
242  * The @text is the text shown in banner.
243  * Creates a new banner with the animation.
244  *
245  * Deprecated: Use #hildon_banner_show_animation instead.
246  */
247 void gtk_banner_show_animation(GtkWindow * parent, const gchar * text)
248 {
249    (void) hildon_banner_show_animation((GtkWidget *) parent, NULL, text);
250 }
251
252 /**
253  * gtk_banner_show_bar
254  * @parent: #GtkWindow
255  * @text: #const gchar *
256  *
257  * The @text is the text shown in banner.
258  * Creates a new banner with the progressbar.
259  *
260  * Deprecated: Use #hildon_banner_show_progress instead.
261  */
262 void gtk_banner_show_bar(GtkWindow * parent, const gchar * text)
263 {
264    (void) hildon_banner_show_progress((GtkWidget *) parent, NULL, text);
265 }
266
267 /**
268  * gtk_banner_set_text
269  * @parent: #GtkWindow
270  * @text: #const gchar *
271  *
272  * The @text is the text shown in banner.
273  * Sets the banner text.
274  *
275  * Deprecated: Use #hildon_banner_set_text instead.
276  */
277 void gtk_banner_set_text(GtkWindow * parent, const gchar * text)
278 {
279    GtkWidget *banner;
280
281    g_return_if_fail(GTK_IS_WINDOW(parent) || parent == NULL);
282
283    banner = find_banner_for_parent(parent);
284    if (banner)
285       hildon_banner_set_text(HILDON_BANNER(banner), text);
286 }
287
288 /**
289  * gtk_banner_set_fraction:
290  * @parent: #GtkWindow
291  * @fraction: #gdouble
292  *
293  * The fraction is the completion of progressbar, 
294  * the scale is from 0.0 to 1.0.
295  * Sets the amount of fraction the progressbar has.
296  *
297  * Deprecated: Use #hildon_banner_set_fraction instead.
298  */
299 void gtk_banner_set_fraction(GtkWindow * parent, gdouble fraction)
300 {
301    GtkWidget *banner;
302
303    g_return_if_fail(GTK_IS_WINDOW(parent) || parent == NULL);
304
305    banner = find_banner_for_parent(parent);
306    if (banner)
307       hildon_banner_set_fraction(HILDON_BANNER(banner), fraction);
308 }
309
310 /**
311  * gtk_banner_close:
312  * @parent: #GtkWindow
313  *
314  * Destroys the banner
315  *
316  * Deprecated:
317  */
318 void gtk_banner_close(GtkWindow * parent)
319 {
320    GtkWidget *banner;
321
322    g_return_if_fail(GTK_IS_WINDOW(parent) || parent == NULL);
323
324    banner = find_banner_for_parent(parent);
325    if (banner)
326       gtk_widget_destroy(banner);
327 }
328
329 /**
330  * gtk_banner_temporarily_disable_wrap
331  * 
332  * Will disable wrapping for the next shown banner. This only
333  * affects next banner shown in this application.
334  *
335  * Currently it does nothing.
336  *
337  * Deprecated:
338  **/
339 void gtk_banner_temporarily_disable_wrap(void)
340 {
341 }