2 * This file is part of hildon-libs
4 * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
6 * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
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 or any later version.
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.
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
26 * SECTION:hildon-file-handling-note
27 * @short_description: Displaying the notification when a move
28 * operation is in progress.
29 * @see_also: #HildonFileHandlingNote
31 * This is the notification displayed when a move operation is in
32 * progress. The notification uses a progress bar to indicate the
33 * progress of the operation. For operation containing multiple items, a
34 * separe progress bar is shown for each item. The notification has a
35 * single button, which allows users to stop the move operation.
38 #include "hildon-note.h"
39 #include "hildon-file-handling-note.h"
45 #include <glib-object.h>
53 #define DELETING_TYPE 1
54 #define OPENING_TYPE 2
57 /*#define _(String) dgettext(PACKAGE, String)*/
58 #define _(String) dgettext("hildon-fm", String) /* FIXME: this file should be moved to hildon-fm */
60 #define HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(obj)\
61 (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
62 HILDON_TYPE_FILE_HANDLING_NOTE, HildonFileHandlingNotePrivate));
64 typedef struct _HildonFileHandlingNotePrivate
65 HildonFileHandlingNotePrivate;
67 struct _HildonFileHandlingNotePrivate {
72 static HildonNote *parent_class;
75 /* standard forbids empty source file, therefore the ifdef must be
79 hildon_file_handling_note_class_init(HildonFileHandlingNoteClass * class);
81 static void hildon_file_handling_note_init(HildonFileHandlingNote *
84 static void hildon_file_handling_note_finalize(GObject * obj_self);
89 GType hildon_file_handling_note_get_type()
91 static GType dialog_type = 0;
94 static const GTypeInfo dialog_info = {
95 sizeof(HildonFileHandlingNoteClass),
97 NULL, /* base_finalize */
98 (GClassInitFunc) hildon_file_handling_note_class_init,
99 NULL, /* class_finalize */
100 NULL, /* class_data */
101 sizeof(HildonFileHandlingNote),
103 (GInstanceInitFunc) hildon_file_handling_note_init
106 dialog_type = g_type_register_static(HILDON_TYPE_NOTE,
107 "HildonFileHandlingNote",
114 hildon_file_handling_note_class_init(HildonFileHandlingNoteClass * class)
116 GObjectClass *object_class = G_OBJECT_CLASS(class);
118 parent_class = g_type_class_peek_parent(class);
119 g_type_class_add_private(class, sizeof(HildonFileHandlingNotePrivate));
120 object_class->finalize = hildon_file_handling_note_finalize;
123 static void hildon_file_handling_note_init(HildonFileHandlingNote * dialog)
125 HildonFileHandlingNotePrivate *priv;
127 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(dialog);
128 priv->note_type = OPENING_TYPE;
131 static void hildon_file_handling_note_finalize(GObject * obj_self)
133 if (G_OBJECT_CLASS(parent_class)->finalize)
134 G_OBJECT_CLASS(parent_class)->finalize(obj_self);
138 * hildon_file_handling_note_set_counter_and_name:
139 * @note: the #HildonFileHandlingNote widget
140 * @current: progress, current item being processed
141 * @maximum: maximum value for counter (number of items)
144 * This function sets current counter value, maximum
145 * counter value and filename for dialog
147 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
149 void hildon_file_handling_note_set_counter_and_name(HildonFileHandlingNote
150 * note, guint current,
155 HildonNote *p_note = HILDON_NOTE(note);
156 HildonFileHandlingNotePrivate *priv;
158 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(note);
160 if (priv->note_type == MOVING_TYPE) {
163 g_snprintf(str, 255, _("sfil_nw_moving_file"), name);
164 hildon_note_set_button_text(p_note, _("sfil_bd_moving_file"));
166 g_snprintf(str, 255, _("docm_nw_moving_files"),
167 current, maximum, name);
168 hildon_note_set_button_text(p_note, _("docm_bd_moving_files"));
170 } else if (priv->note_type == SAVING_TYPE) {
173 g_snprintf(str, 255, _("docm_nw_saving_file"), name);
174 hildon_note_set_button_text(p_note, _("docm_bd_saving_file"));
176 g_snprintf(str, 255, _("docm_nw_saving_files"),
177 current, maximum, name);
178 hildon_note_set_button_text(p_note, _("docm_bd_saving_files"));
180 } else if (priv->note_type == OPENING_TYPE) {
183 g_snprintf(str, 255, _("docm_nw_opening_file"), name);
184 hildon_note_set_button_text(p_note, _("docm_bd_opening_file"));
186 g_snprintf(str, 255, _("docm_nw_opening_files"),
187 current, maximum, name);
188 hildon_note_set_button_text(p_note, _("docm_bd_opening_files"));
190 } else if (priv->note_type == DELETING_TYPE) {
193 g_snprintf(str, 255, _("docm_nw_deleting_file"), name);
194 hildon_note_set_button_text(p_note, _("docm_bd_deleting_file"));
196 g_snprintf(str, 255, _("docm_nw_deleting_files"),
197 current, maximum, name);
198 hildon_note_set_button_text(p_note, _("docm_bd_deleting_files"));
202 g_object_set(p_note, "description", str, NULL);
206 * hildon_file_handling_note_set_name:
207 * @note: the @HildonFileHandlingNote widget
210 * This function sets the filename for dialog
211 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
213 void hildon_file_handling_note_set_name(HildonFileHandlingNote * note,
217 HildonNote *p_note = HILDON_NOTE(note);
218 HildonFileHandlingNotePrivate *priv =
219 HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(note);
221 if (priv->note_type == MOVING_TYPE) {
222 g_snprintf(str, 255, _("sfil_nw_moving_file"), name);
223 } else if (priv->note_type == SAVING_TYPE) {
224 g_snprintf(str, 255, _("docm_nw_saving_file"), name);
225 } else if (priv->note_type == OPENING_TYPE) {
226 g_snprintf(str, 255, _("docm_nw_opening_file"), name);
227 } else if (priv->note_type == DELETING_TYPE) {
228 g_snprintf(str, 255, _("docm_nw_deleting_file"), name);
231 g_object_set(p_note, "description", str, NULL);
235 * hildon_file_handling_note_set_fraction:
236 * @note: the @HildonFileHandlingNote widget
237 * @frac: value for progress bar
239 * This function sets fraction value for
241 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
243 void hildon_file_handling_note_set_fraction(HildonFileHandlingNote * note,
248 g_object_get(note, "progressbar", &progbar, NULL);
249 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progbar), frac);
253 * hildon_file_handling_note_new_moving:
254 * @parent: parent GtkWindow
256 * This function creates new dialog
257 * which is "moving" type.
259 * Returns: a new #HildonFileHandlingNote
260 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
262 GtkWidget *hildon_file_handling_note_new_moving(GtkWindow * parent)
265 HildonFileHandlingNote *file_note;
266 HildonFileHandlingNotePrivate *priv;
268 progbar = gtk_progress_bar_new();
270 file_note = g_object_new(HILDON_TYPE_FILE_HANDLING_NOTE,
271 "note_type", HILDON_NOTE_PROGRESSBAR_TYPE,
272 "description", _("sfil_nw_moving_file"),
273 "progressbar", progbar, NULL);
275 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(file_note);
276 priv->note_type = MOVING_TYPE;
279 gtk_window_set_transient_for(GTK_WINDOW(file_note), parent);
281 return GTK_WIDGET(file_note);
285 * hildon_file_handling_note_new_deleting:
286 * @parent: parent GtkWindow
288 * This function creates new dialog
289 * which is "deleting" type.
291 * Returns: a new #HildonFileHandlingNote
292 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
294 GtkWidget *hildon_file_handling_note_new_deleting(GtkWindow * parent)
297 HildonFileHandlingNote *file_note;
298 HildonFileHandlingNotePrivate *priv;
300 progbar = gtk_progress_bar_new();
302 file_note = g_object_new(HILDON_TYPE_FILE_HANDLING_NOTE,
303 "note_type", HILDON_NOTE_PROGRESSBAR_TYPE,
304 "description", _("docm_nw_deleting_file"),
305 "progressbar", progbar, NULL);
307 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(file_note);
308 priv->note_type = DELETING_TYPE;
311 gtk_window_set_transient_for(GTK_WINDOW(file_note), parent);
313 return GTK_WIDGET(file_note);
317 * hildon_file_handling_note_new_opening:
318 * @parent: parent GtkWindow
320 * This function creates new dialog
321 * which is "opening" type
323 * Returns: a new #HildonFileHandlingNote
324 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
326 GtkWidget *hildon_file_handling_note_new_opening(GtkWindow * parent)
329 HildonFileHandlingNote *file_note;
330 HildonFileHandlingNotePrivate *priv;
332 progbar = gtk_progress_bar_new();
334 file_note = g_object_new(HILDON_TYPE_FILE_HANDLING_NOTE,
335 "note_type", HILDON_NOTE_PROGRESSBAR_TYPE,
336 "description", _("docm_nw_opening_file"),
337 "progressbar", progbar, NULL);
339 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(file_note);
340 priv->note_type = OPENING_TYPE;
343 gtk_window_set_transient_for(GTK_WINDOW(file_note), parent);
345 return GTK_WIDGET(file_note);
349 * hildon_file_handling_note_new_saving:
350 * @parent: parent GtkWindow
352 * This function creates new dialog
353 * which is "saving" type.
355 * Returns: a new #HildonFileHandlingNote
356 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
358 GtkWidget *hildon_file_handling_note_new_saving(GtkWindow * parent)
361 HildonFileHandlingNote *file_note;
362 HildonFileHandlingNotePrivate *priv;
364 progbar = gtk_progress_bar_new();
366 file_note = g_object_new(HILDON_TYPE_FILE_HANDLING_NOTE,
367 "note_type", HILDON_NOTE_PROGRESSBAR_TYPE,
368 "description", _("docm_nw_saving_file"),
369 "progressbar", progbar, NULL);
371 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(file_note);
372 priv->note_type = SAVING_TYPE;
375 gtk_window_set_transient_for(GTK_WINDOW(file_note), parent);
377 return GTK_WIDGET(file_note);