2 * This file is part of hildon-libs
4 * Copyright (C) 2005 Nokia Corporation.
6 * Contact: Luc Pionchon <luc.pionchon@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; either version 2.1 of
11 * the License, or (at your option) 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
25 #include "hildon-note.h"
26 #include "hildon-file-handling-note.h"
32 #include <glib-object.h>
40 #define DELETING_TYPE 1
41 #define OPENING_TYPE 2
44 #define _(String) dgettext(PACKAGE, String)
46 #define HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(obj)\
47 (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
48 HILDON_TYPE_FILE_HANDLING_NOTE, HildonFileHandlingNotePrivate));
50 static HildonNote *parent_class;
52 typedef struct _HildonFileHandlingNotePrivate
53 HildonFileHandlingNotePrivate;
57 hildon_file_handling_note_class_init(HildonFileHandlingNoteClass * class);
59 static void hildon_file_handling_note_init(HildonFileHandlingNote *
62 static void hildon_file_handling_note_finalize(GObject * obj_self);
65 struct _HildonFileHandlingNotePrivate {
70 GType hildon_file_handling_note_get_type()
72 static GType dialog_type = 0;
75 static const GTypeInfo dialog_info = {
76 sizeof(HildonFileHandlingNoteClass),
78 NULL, /* base_finalize */
79 (GClassInitFunc) hildon_file_handling_note_class_init,
80 NULL, /* class_finalize */
81 NULL, /* class_data */
82 sizeof(HildonFileHandlingNote),
84 (GInstanceInitFunc) hildon_file_handling_note_init
87 dialog_type = g_type_register_static(HILDON_TYPE_NOTE,
88 "HildonFileHandlingNote",
95 hildon_file_handling_note_class_init(HildonFileHandlingNoteClass * class)
97 GObjectClass *object_class = G_OBJECT_CLASS(class);
99 parent_class = g_type_class_peek_parent(class);
100 g_type_class_add_private(class, sizeof(HildonFileHandlingNotePrivate));
101 object_class->finalize = hildon_file_handling_note_finalize;
104 static void hildon_file_handling_note_init(HildonFileHandlingNote * dialog)
106 HildonFileHandlingNotePrivate *priv;
108 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(dialog);
109 priv->note_type = OPENING_TYPE;
112 static void hildon_file_handling_note_finalize(GObject * obj_self)
114 if (G_OBJECT_CLASS(parent_class)->finalize)
115 G_OBJECT_CLASS(parent_class)->finalize(obj_self);
119 * hildon_file_handling_note_set_counter_and_name:
120 * @note: the #HildonFileHandlingNote widget
121 * @current: Current item
122 * @maximum: Maximum value for counter
125 * This function sets current counter value, maximum
126 * counter value and filename for dialog
128 void hildon_file_handling_note_set_counter_and_name(HildonFileHandlingNote
129 * note, guint current,
134 HildonNote *p_note = HILDON_NOTE(note);
135 HildonFileHandlingNotePrivate *priv;
137 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(note);
139 if (priv->note_type == MOVING_TYPE) {
142 g_snprintf(str, 255, _("sfil_nw_moving_file"), name);
143 hildon_note_set_button_text(p_note, _("sfil_bd_moving_file"));
145 g_snprintf(str, 255, _("docm_nw_moving_files"),
146 current, maximum, name);
147 hildon_note_set_button_text(p_note, _("docm_bd_moving_files"));
149 } else if (priv->note_type == SAVING_TYPE) {
152 g_snprintf(str, 255, _("docm_nw_saving_file"), name);
153 hildon_note_set_button_text(p_note, _("docm_bd_saving_file"));
155 g_snprintf(str, 255, _("docm_nw_saving_files"),
156 current, maximum, name);
157 hildon_note_set_button_text(p_note, _("docm_bd_saving_files"));
159 } else if (priv->note_type == OPENING_TYPE) {
162 g_snprintf(str, 255, _("docm_nw_opening_file"), name);
163 hildon_note_set_button_text(p_note, _("docm_bd_opening_file"));
165 g_snprintf(str, 255, _("docm_nw_opening_files"),
166 current, maximum, name);
167 hildon_note_set_button_text(p_note, _("docm_bd_opening_files"));
169 } else if (priv->note_type == DELETING_TYPE) {
172 g_snprintf(str, 255, _("docm_nw_deleting_file"), name);
173 hildon_note_set_button_text(p_note, _("docm_bd_deleting_file"));
175 g_snprintf(str, 255, _("docm_nw_deleting_files"),
176 current, maximum, name);
177 hildon_note_set_button_text(p_note, _("docm_bd_deleting_files"));
181 g_object_set(p_note, "description", str, NULL);
185 * hildon_file_handling_note_set_name:
186 * @note: the @HildonFileHandlingNote widget
189 * This function sets filename for dialog
191 void hildon_file_handling_note_set_name(HildonFileHandlingNote * note,
195 HildonNote *p_note = HILDON_NOTE(note);
196 HildonFileHandlingNotePrivate *priv =
197 HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(note);
199 if (priv->note_type == MOVING_TYPE) {
200 g_snprintf(str, 255, _("sfil_nw_moving_file"), name);
201 } else if (priv->note_type == SAVING_TYPE) {
202 g_snprintf(str, 255, _("docm_nw_saving_file"), name);
203 } else if (priv->note_type == OPENING_TYPE) {
204 g_snprintf(str, 255, _("docm_nw_opening_file"), name);
205 } else if (priv->note_type == DELETING_TYPE) {
206 g_snprintf(str, 255, _("docm_nw_deleting_file"), name);
209 g_object_set(p_note, "description", str, NULL);
213 * hildon_file_handling_note_set_fraction:
214 * @note: the @HildonFileHandlingNote widget
215 * @frac: value for progress bar
217 * This function sets fraction value for
220 void hildon_file_handling_note_set_fraction(HildonFileHandlingNote * note,
225 g_object_get(note, "progressbar", &progbar, NULL);
226 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progbar), frac);
230 * hildon_file_handling_note_new_moving:
231 * @parent: parent GtkWindow
233 * This function creates new dialog
234 * which is "moving" type.
236 * Return value: a new #HildonFileHandlingNote.
238 GtkWidget *hildon_file_handling_note_new_moving(GtkWindow * parent)
241 HildonFileHandlingNote *file_note;
242 HildonFileHandlingNotePrivate *priv;
244 progbar = gtk_progress_bar_new();
246 file_note = g_object_new(HILDON_TYPE_FILE_HANDLING_NOTE,
247 "note_type", HILDON_NOTE_PROGRESSBAR_TYPE,
248 "description", _("Moving..."),
249 "progressbar", progbar, NULL);
251 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(file_note);
252 priv->note_type = MOVING_TYPE;
255 gtk_window_set_transient_for(GTK_WINDOW(file_note), parent);
257 return GTK_WIDGET(file_note);
261 * hildon_file_handling_note_new_deleting:
262 * @parent: parent GtkWindow
264 * This function creates new dialog
265 * which is "deleting" type.
267 * Return value: a new #HildonFileHandlingNote.
269 GtkWidget *hildon_file_handling_note_new_deleting(GtkWindow * parent)
272 HildonFileHandlingNote *file_note;
273 HildonFileHandlingNotePrivate *priv;
275 progbar = gtk_progress_bar_new();
277 file_note = g_object_new(HILDON_TYPE_FILE_HANDLING_NOTE,
278 "note_type", HILDON_NOTE_PROGRESSBAR_TYPE,
279 "description", _("Deleting..."),
280 "progressbar", progbar, NULL);
282 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(file_note);
283 priv->note_type = DELETING_TYPE;
286 gtk_window_set_transient_for(GTK_WINDOW(file_note), parent);
288 return GTK_WIDGET(file_note);
292 * hildon_file_handling_note_new_opening:
293 * @parent: parent GtkWindow
295 * This function creates new dialog
296 * which is "opening" type
298 * Return value: a new #HildonFileHandlingNote.
300 GtkWidget *hildon_file_handling_note_new_opening(GtkWindow * parent)
303 HildonFileHandlingNote *file_note;
304 HildonFileHandlingNotePrivate *priv;
306 progbar = gtk_progress_bar_new();
308 file_note = g_object_new(HILDON_TYPE_FILE_HANDLING_NOTE,
309 "note_type", HILDON_NOTE_PROGRESSBAR_TYPE,
310 "description", _("Opening..."),
311 "progressbar", progbar, NULL);
313 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(file_note);
314 priv->note_type = OPENING_TYPE;
317 gtk_window_set_transient_for(GTK_WINDOW(file_note), parent);
319 return GTK_WIDGET(file_note);
323 * hildon_file_handling_note_new_saving:
324 * @parent: parent GtkWindow
326 * This function creates new dialog
327 * which is "saving" type.
329 * Return value: a new #HildonFileHandlingNote.
331 GtkWidget *hildon_file_handling_note_new_saving(GtkWindow * parent)
334 HildonFileHandlingNote *file_note;
335 HildonFileHandlingNotePrivate *priv;
337 progbar = gtk_progress_bar_new();
338 file_note = g_object_new(HILDON_TYPE_FILE_HANDLING_NOTE,
339 "note_type", HILDON_NOTE_PROGRESSBAR_TYPE,
340 "description", _("Saving..."),
341 "progressbar", progbar, NULL);
343 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(file_note);
344 priv->note_type = SAVING_TYPE;
347 gtk_window_set_transient_for(GTK_WINDOW(file_note), parent);
349 return GTK_WIDGET(file_note);