1 /*
2  * Copyright (C) 2004, Magnus Hjorth
3  *
4  * This file is part of mhWaveEdit.
5  *
6  * mhWaveEdit is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * mhWaveEdit is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mhWaveEdit; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 
22 /* This is the status bar that is at the bottom of each
23  * Mainwindow. During normal editing, it displays cursor position, view
24  * start and endpoint and selection start/end. It can be switch into
25  * progress mode, then it displays a progress bar with a string over
26  * it. It's built as a GtkFixed with labels inside it.
27  */
28 
29 #ifndef STATUSBAR_H_INCLUDED
30 #define STATUSBAR_H_INCLUDED
31 
32 #include <gtk/gtk.h>
33 #include "main.h"
34 
35 #define STATUSBAR(obj) GTK_CHECK_CAST(obj,status_bar_get_type(),StatusBar)
36 #define STATUSBAR_CLASS(klass) GTK_CHECK_CLASS_CAST(klass,status_bar_get_type(),StatusBarClass)
37 #define IS_STATUSBAR(obj) GTK_CHECK_TYPE(obj,status_bar_get_type())
38 
39 typedef struct {
40      GtkFixed fixed;
41      GtkWidget *da;
42 
43      /* This flag decides whether we're in regular mode (0),  progress
44       * mode (1), or newly started (2). */
45      gint mode;
46 
47      /* Used in newly started mode: */
48      GtkLabel *fresh_label;
49 
50      /* These are used in progress mode: */
51      GtkLabel *progress_label; /* Also used when newly started. */
52      off_t progress_cur,progress_max;
53      guint bar_width; /* Progress bar width in pixels. */
54      gboolean progress_break;
55 
56      /* These are used in regular mode: */
57      GtkLabel *cursor,*view,*sel;
58      off_t cur,vs,ve,ss,se,rate,max;
59      gboolean rolling;
60 } StatusBar;
61 
62 typedef struct {
63      GtkFixedClass fixed_class;
64 
65      void (*progress_begin)(StatusBar *bar);
66      void (*progress_end)(StatusBar *bar);
67 
68 } StatusBarClass;
69 
70 /* Global variable that decides whether the cursor position text
71  * should update while playing. */
72 extern gboolean status_bar_roll_cursor;
73 
74 GtkType status_bar_get_type(void);
75 GtkWidget *status_bar_new(void);
76 
77 /* Reset the status bar to the original condition ("no file loaded") */
78 void status_bar_reset(StatusBar *sb);
79 
80 /* Set the information shown during regular editing. This will switch
81    the status bar into regular mode. */
82 void status_bar_set_info(StatusBar *sb, off_t cursorpos, gboolean is_rolling,
83 			 off_t viewstart, off_t viewend, off_t selstart,
84 			 off_t selend, off_t samplerate, off_t maxvalue);
85 
86 /* Go into progress mode. If called when already in progress mode,
87    description may be NULL. In that case, the old description is kept. */
88 void status_bar_begin_progress(StatusBar *sb, off_t progress_length,
89 			       gchar *description);
90 
91 /* When in progress mode, switches the status bar back into regular mode.
92  * Otherwise, does nothing. */
93 void status_bar_end_progress(StatusBar *sb);
94 
95 /* Update progress indicator. The status bar must be in progress mode
96  * when this is called. Returns TRUE if someone called
97  * status_bar_break_progress */
98 gboolean status_bar_progress(StatusBar *sb, off_t progress);
99 
100 /* Causes future calls to status_bar_progress to return TRUE */
101 void status_bar_break_progress(StatusBar *sb);
102 
103 /* Returns the number of status bars in progress mode */
104 int status_bar_progress_count(void);
105 
106 #endif
107