File: libbalsa-progress.h

package info (click to toggle)
balsa 2.6.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,576 kB
  • sloc: ansic: 99,871; xml: 4,934; makefile: 769; sh: 185; awk: 60; python: 34
file content (87 lines) | stat: -rw-r--r-- 3,507 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
/*
 * Flexible progress dialogue for Balsa
 * Copyright (C) 2017 Albrecht Dreß <albrecht.dress@arcor.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses/>.
 */

#ifndef LIBBALSA_PROGRESS_H_
#define LIBBALSA_PROGRESS_H_


#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <gtk/gtk.h>


/** \brief Progress dialogue
 *
 * Structure containing the actual progress dialogue widget and a mutex for protecting concurrent accesses.  As to initialise a
 * variable of this type, put it either in static memory, or set the \ref ProgressDialog::dialog to NULL and initialise \ref
 * ProgressDialog::mutex.
 */
typedef struct {
	GtkWidget *dialog;
	GMutex     mutex;
} ProgressDialog;


/** \brief Ensure that a progress dialogue and progress section exists
 *
 * \param progress_dialog properly initialised progress dialogue
 * \param dialog_title dialogue title, used only if a new dialogue is created
 * \param parent parent window
 * \param progress_id progress identifier, also used as section title, \em must be unique
 *
 * If the passed progress dialogue \ref ProgressDialog::dialog is NULL, a new dialogue is created.
 *
 * If no progress section with the passed id exists, it is appended.  An already existing section is revealed if necessary.
 *
 * \note This function may be called from a thread.  In this case, the function will block in the thread until the "real" work has
 *       been done in the main thread.
 */
void libbalsa_progress_dialog_ensure(ProgressDialog *progress_dialog,
									 const gchar    *dialog_title,
									 GtkWindow      *parent,
									 const gchar    *progress_id);


/** \brief Progress dialogue update
 *
 * \param progress_dialog progress dialogue, initialised by libbalsa_progress_dialog_ensure()
 * \param progress_id progress identifier passed to libbalsa_progress_dialog_ensure()
 * \param finished indicates whether the progress element shall be removed from the dialogue.  When no progress elements are left,
 *                 the dialogue is destroyed
 * \param fraction progress bar value between 0.0 and 1.0, or INF to switch to activity mode, or NAN to keep the current value
 * \param message printf-like format string which shall be printed above the progress bar, or NULL to keep the current message
 * \param ... additional arguments for the message format string
 *
 * Update the information of the passed progress dialogue.
 *
 * \note This function may be called from a thread.  In this case, the "real" work is done in an idle callback and may therefore
 *       be performed only after this function returns.
 */
void libbalsa_progress_dialog_update(ProgressDialog *progress_dialog,
									 const gchar    *progress_id,
									 gboolean        finished,
									 gdouble         fraction,
									 const gchar    *message,
									 ...)
	G_GNUC_PRINTF(5, 6);


#endif /* LIBBALSA_PROGRESS_H_ */