Removed inlines
[liblqr.git] / lqr / lqr_progress.c
bloba9a68f4b21ba8a4b7d24aa898617664165248a68
1 /* LiquidRescaling Library
2 * Copyright (C) 2007-2009 Carlo Baldassi (the "Author") <carlobaldassi@gmail.com>.
3 * All Rights Reserved.
5 * This library implements the algorithm described in the paper
6 * "Seam Carving for Content-Aware Image Resizing"
7 * by Shai Avidan and Ariel Shamir
8 * which can be found at http://www.faculty.idc.ac.il/arik/imret.pdf
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; version 3 dated June, 2007.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, see <http://www.gnu.org/licenses/>
23 #ifdef HAVE_CONFIG_H
24 # include <config.h>
25 #endif
27 #include <glib.h>
29 #include <lqr/lqr_base.h>
30 #include <lqr/lqr_progress.h>
32 /* LQR_PUBLIC */
33 LqrProgress *
34 lqr_progress_new(void)
36 LqrProgress *progress;
37 LQR_TRY_N_N(progress = g_try_new0(LqrProgress, 1));
39 lqr_progress_set_init_width_message(progress, "Resizing width...");
40 lqr_progress_set_init_height_message(progress, "Resizing height...");
41 lqr_progress_set_end_width_message(progress, "done");
42 lqr_progress_set_end_height_message(progress, "done");
43 lqr_progress_set_update_step(progress, (float) 0.02);
45 return progress;
48 LqrRetVal
49 lqr_progress_init(LqrProgress * p, const gchar *message)
51 LQR_CATCH_F(p != NULL);
52 if (p->init) {
53 return p->init(message);
54 } else {
55 return LQR_OK;
59 LqrRetVal
60 lqr_progress_update(LqrProgress * p, gdouble percentage)
62 LQR_CATCH_F(p != NULL);
63 if (p->update) {
64 return p->update(percentage);
65 } else {
66 return LQR_OK;
70 LqrRetVal
71 lqr_progress_end(LqrProgress * p, const gchar *message)
73 LQR_CATCH_F(p != NULL);
74 if (p->end) {
75 return p->end(message);
76 } else {
77 return LQR_OK;
81 /* LQR_PUBLIC */
82 LqrRetVal
83 lqr_progress_set_init(LqrProgress * p, LqrProgressFuncInit init_func)
85 p->init = init_func;
86 return LQR_OK;
89 /* LQR_PUBLIC */
90 LqrRetVal
91 lqr_progress_set_update(LqrProgress * p, LqrProgressFuncUpdate update_func)
93 p->update = update_func;
94 return LQR_OK;
97 /* LQR_PUBLIC */
98 LqrRetVal
99 lqr_progress_set_end(LqrProgress * p, LqrProgressFuncEnd end_func)
101 p->end = end_func;
102 return LQR_OK;
105 /* LQR_PUBLIC */
106 LqrRetVal
107 lqr_progress_set_update_step(LqrProgress * p, gfloat update_step)
109 p->update_step = update_step;
110 return LQR_OK;
113 /* LQR_PUBLIC */
114 LqrRetVal
115 lqr_progress_set_init_width_message(LqrProgress * p, const gchar *message)
117 LQR_CATCH_F(p);
118 g_strlcpy(p->init_width_message, message, LQR_PROGRESS_MAX_MESSAGE_LENGTH);
119 return LQR_OK;
122 /* LQR_PUBLIC */
123 LqrRetVal
124 lqr_progress_set_init_height_message(LqrProgress * p, const gchar *message)
126 LQR_CATCH_F(p != NULL);
127 g_strlcpy(p->init_height_message, message, LQR_PROGRESS_MAX_MESSAGE_LENGTH);
128 return LQR_OK;
131 /* LQR_PUBLIC */
132 LqrRetVal
133 lqr_progress_set_end_width_message(LqrProgress * p, const gchar *message)
135 LQR_CATCH_F(p != NULL);
136 g_strlcpy(p->end_width_message, message, LQR_PROGRESS_MAX_MESSAGE_LENGTH);
137 return LQR_OK;
140 /* LQR_PUBLIC */
141 LqrRetVal
142 lqr_progress_set_end_height_message(LqrProgress * p, const gchar *message)
144 LQR_CATCH_F(p != NULL);
145 g_strlcpy(p->end_height_message, message, LQR_PROGRESS_MAX_MESSAGE_LENGTH);
146 return LQR_OK;