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 typedef struct _HildonFileHandlingNotePrivate
51 HildonFileHandlingNotePrivate;
53 struct _HildonFileHandlingNotePrivate {
57 #ifndef HILDON_DISABLE_DEPRECATED
59 static HildonNote *parent_class;
62 /* standard forbids empty source file, therefore the ifdef must be
66 hildon_file_handling_note_class_init(HildonFileHandlingNoteClass * class);
68 static void hildon_file_handling_note_init(HildonFileHandlingNote *
71 static void hildon_file_handling_note_finalize(GObject * obj_self);
76 GType hildon_file_handling_note_get_type()
78 static GType dialog_type = 0;
81 static const GTypeInfo dialog_info = {
82 sizeof(HildonFileHandlingNoteClass),
84 NULL, /* base_finalize */
85 (GClassInitFunc) hildon_file_handling_note_class_init,
86 NULL, /* class_finalize */
87 NULL, /* class_data */
88 sizeof(HildonFileHandlingNote),
90 (GInstanceInitFunc) hildon_file_handling_note_init
93 dialog_type = g_type_register_static(HILDON_TYPE_NOTE,
94 "HildonFileHandlingNote",
101 hildon_file_handling_note_class_init(HildonFileHandlingNoteClass * class)
103 GObjectClass *object_class = G_OBJECT_CLASS(class);
105 parent_class = g_type_class_peek_parent(class);
106 g_type_class_add_private(class, sizeof(HildonFileHandlingNotePrivate));
107 object_class->finalize = hildon_file_handling_note_finalize;
110 static void hildon_file_handling_note_init(HildonFileHandlingNote * dialog)
112 HildonFileHandlingNotePrivate *priv;
114 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(dialog);
115 priv->note_type = OPENING_TYPE;
118 static void hildon_file_handling_note_finalize(GObject * obj_self)
120 if (G_OBJECT_CLASS(parent_class)->finalize)
121 G_OBJECT_CLASS(parent_class)->finalize(obj_self);
125 * hildon_file_handling_note_set_counter_and_name:
126 * @note: the #HildonFileHandlingNote widget
127 * @current: Current item
128 * @maximum: Maximum value for counter
131 * This function sets current counter value, maximum
132 * counter value and filename for dialog
133 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
135 void hildon_file_handling_note_set_counter_and_name(HildonFileHandlingNote
136 * note, guint current,
141 HildonNote *p_note = HILDON_NOTE(note);
142 HildonFileHandlingNotePrivate *priv;
144 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(note);
146 if (priv->note_type == MOVING_TYPE) {
149 g_snprintf(str, 255, _("sfil_nw_moving_file"), name);
150 hildon_note_set_button_text(p_note, _("sfil_bd_moving_file"));
152 g_snprintf(str, 255, _("docm_nw_moving_files"),
153 current, maximum, name);
154 hildon_note_set_button_text(p_note, _("docm_bd_moving_files"));
156 } else if (priv->note_type == SAVING_TYPE) {
159 g_snprintf(str, 255, _("docm_nw_saving_file"), name);
160 hildon_note_set_button_text(p_note, _("docm_bd_saving_file"));
162 g_snprintf(str, 255, _("docm_nw_saving_files"),
163 current, maximum, name);
164 hildon_note_set_button_text(p_note, _("docm_bd_saving_files"));
166 } else if (priv->note_type == OPENING_TYPE) {
169 g_snprintf(str, 255, _("docm_nw_opening_file"), name);
170 hildon_note_set_button_text(p_note, _("docm_bd_opening_file"));
172 g_snprintf(str, 255, _("docm_nw_opening_files"),
173 current, maximum, name);
174 hildon_note_set_button_text(p_note, _("docm_bd_opening_files"));
176 } else if (priv->note_type == DELETING_TYPE) {
179 g_snprintf(str, 255, _("docm_nw_deleting_file"), name);
180 hildon_note_set_button_text(p_note, _("docm_bd_deleting_file"));
182 g_snprintf(str, 255, _("docm_nw_deleting_files"),
183 current, maximum, name);
184 hildon_note_set_button_text(p_note, _("docm_bd_deleting_files"));
188 g_object_set(p_note, "description", str, NULL);
192 * hildon_file_handling_note_set_name:
193 * @note: the @HildonFileHandlingNote widget
196 * This function sets filename for dialog
197 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
199 void hildon_file_handling_note_set_name(HildonFileHandlingNote * note,
203 HildonNote *p_note = HILDON_NOTE(note);
204 HildonFileHandlingNotePrivate *priv =
205 HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(note);
207 if (priv->note_type == MOVING_TYPE) {
208 g_snprintf(str, 255, _("sfil_nw_moving_file"), name);
209 } else if (priv->note_type == SAVING_TYPE) {
210 g_snprintf(str, 255, _("docm_nw_saving_file"), name);
211 } else if (priv->note_type == OPENING_TYPE) {
212 g_snprintf(str, 255, _("docm_nw_opening_file"), name);
213 } else if (priv->note_type == DELETING_TYPE) {
214 g_snprintf(str, 255, _("docm_nw_deleting_file"), name);
217 g_object_set(p_note, "description", str, NULL);
221 * hildon_file_handling_note_set_fraction:
222 * @note: the @HildonFileHandlingNote widget
223 * @frac: value for progress bar
225 * This function sets fraction value for
227 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
229 void hildon_file_handling_note_set_fraction(HildonFileHandlingNote * note,
234 g_object_get(note, "progressbar", &progbar, NULL);
235 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progbar), frac);
239 * hildon_file_handling_note_new_moving:
240 * @parent: parent GtkWindow
242 * This function creates new dialog
243 * which is "moving" type.
245 * Return value: a new #HildonFileHandlingNote.
246 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
248 GtkWidget *hildon_file_handling_note_new_moving(GtkWindow * parent)
251 HildonFileHandlingNote *file_note;
252 HildonFileHandlingNotePrivate *priv;
254 progbar = gtk_progress_bar_new();
256 file_note = g_object_new(HILDON_TYPE_FILE_HANDLING_NOTE,
257 "note_type", HILDON_NOTE_PROGRESSBAR_TYPE,
258 "description", _("sfil_nw_moving_file"),
259 "progressbar", progbar, NULL);
261 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(file_note);
262 priv->note_type = MOVING_TYPE;
265 gtk_window_set_transient_for(GTK_WINDOW(file_note), parent);
267 return GTK_WIDGET(file_note);
271 * hildon_file_handling_note_new_deleting:
272 * @parent: parent GtkWindow
274 * This function creates new dialog
275 * which is "deleting" type.
277 * Return value: a new #HildonFileHandlingNote.
278 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
280 GtkWidget *hildon_file_handling_note_new_deleting(GtkWindow * parent)
283 HildonFileHandlingNote *file_note;
284 HildonFileHandlingNotePrivate *priv;
286 progbar = gtk_progress_bar_new();
288 file_note = g_object_new(HILDON_TYPE_FILE_HANDLING_NOTE,
289 "note_type", HILDON_NOTE_PROGRESSBAR_TYPE,
290 "description", _("docm_nw_deleting_file"),
291 "progressbar", progbar, NULL);
293 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(file_note);
294 priv->note_type = DELETING_TYPE;
297 gtk_window_set_transient_for(GTK_WINDOW(file_note), parent);
299 return GTK_WIDGET(file_note);
303 * hildon_file_handling_note_new_opening:
304 * @parent: parent GtkWindow
306 * This function creates new dialog
307 * which is "opening" type
309 * Return value: a new #HildonFileHandlingNote.
310 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
312 GtkWidget *hildon_file_handling_note_new_opening(GtkWindow * parent)
315 HildonFileHandlingNote *file_note;
316 HildonFileHandlingNotePrivate *priv;
318 progbar = gtk_progress_bar_new();
320 file_note = g_object_new(HILDON_TYPE_FILE_HANDLING_NOTE,
321 "note_type", HILDON_NOTE_PROGRESSBAR_TYPE,
322 "description", _("docm_nw_opening_file"),
323 "progressbar", progbar, NULL);
325 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(file_note);
326 priv->note_type = OPENING_TYPE;
329 gtk_window_set_transient_for(GTK_WINDOW(file_note), parent);
331 return GTK_WIDGET(file_note);
335 * hildon_file_handling_note_new_saving:
336 * @parent: parent GtkWindow
338 * This function creates new dialog
339 * which is "saving" type.
341 * Return value: a new #HildonFileHandlingNote.
342 * DEPRECATED: use hildon-note instead of hildon-file-handling-note.
344 GtkWidget *hildon_file_handling_note_new_saving(GtkWindow * parent)
347 HildonFileHandlingNote *file_note;
348 HildonFileHandlingNotePrivate *priv;
350 progbar = gtk_progress_bar_new();
352 file_note = g_object_new(HILDON_TYPE_FILE_HANDLING_NOTE,
353 "note_type", HILDON_NOTE_PROGRESSBAR_TYPE,
354 "description", _("docm_nw_saving_file"),
355 "progressbar", progbar, NULL);
357 priv = HILDON_FILE_HANDLING_NOTE_GET_PRIVATE(file_note);
358 priv->note_type = SAVING_TYPE;
361 gtk_window_set_transient_for(GTK_WINDOW(file_note), parent);
363 return GTK_WIDGET(file_note);
366 #endif /* HILDON_DISABLE_DEPRECATED */