Mercurial > audlegacy
annotate src/audacious/genevent.c @ 3012:d891850c4042 trunk
branch merge
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Mon, 09 Jul 2007 12:08:39 +0200 |
parents | 6d4b7b739232 |
children | 01ae56759d15 |
rev | line source |
---|---|
2313 | 1 /* Audacious - Cross-platform multimedia platform. |
2 * Copyright (C) 2005-2007 Audacious development team. | |
3 * | |
4 * Based on BMP: | |
5 * Copyright (C) 2003-2004 BMP development team. | |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; under version 2 of the License. | |
13 * | |
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 General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 # include "config.h" | |
26 #endif | |
27 | |
28 #include "main.h" | |
29 | |
30 #include <glib.h> | |
31 #include <glib/gi18n.h> | |
32 #include <glib/gprintf.h> | |
33 #include <gdk/gdk.h> | |
34 #include <stdlib.h> | |
35 #include <string.h> | |
36 #include <getopt.h> | |
37 #include <ctype.h> | |
38 #include <time.h> | |
39 | |
40 #include <unistd.h> | |
41 #include <errno.h> | |
42 #include <sys/types.h> | |
43 #include <sys/stat.h> | |
44 #include <signal.h> | |
45 | |
46 #include "dnd.h" | |
47 #include "effect.h" | |
48 #include "general.h" | |
49 #include "hints.h" | |
50 #include "input.h" | |
51 #include "logger.h" | |
52 #include "output.h" | |
53 #include "playback.h" | |
54 #include "playlist.h" | |
2420 | 55 #include "pluginenum.h" |
56 #include "ui_main.h" | |
2313 | 57 #include "ui_playlist.h" |
2942
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2717
diff
changeset
|
58 #include "ui_skinned_textbox.h" |
3001
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2954
diff
changeset
|
59 #include "ui_skinned_number.h" |
2313 | 60 #include "util.h" |
61 #include "visualization.h" | |
2420 | 62 #include "vfs.h" |
2313 | 63 |
64 gboolean ev_waiting = FALSE; | |
65 | |
66 static gboolean | |
67 idle_func_change_song(gboolean waiting) | |
68 { | |
69 static GTimer *pause_timer = NULL; | |
70 | |
71 if (!pause_timer) | |
72 pause_timer = g_timer_new(); | |
73 | |
74 if (cfg.pause_between_songs) { | |
75 gint timeleft; | |
76 | |
77 if (!waiting) { | |
78 g_timer_start(pause_timer); | |
79 waiting = TRUE; | |
80 } | |
81 | |
82 timeleft = cfg.pause_between_songs_time - | |
83 (gint) g_timer_elapsed(pause_timer, NULL); | |
84 | |
85 if (mainwin_10min_num != NULL) { | |
3001
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2954
diff
changeset
|
86 ui_skinned_number_set_number(mainwin_10min_num, timeleft / 600); |
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2954
diff
changeset
|
87 ui_skinned_number_set_number(mainwin_min_num, (timeleft / 60) % 10); |
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2954
diff
changeset
|
88 ui_skinned_number_set_number(mainwin_10sec_num, (timeleft / 10) % 6); |
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2954
diff
changeset
|
89 ui_skinned_number_set_number(mainwin_sec_num, timeleft % 10); |
2313 | 90 } |
91 | |
92 if (mainwin_sposition != NULL && !mainwin_sposition->hs_pressed) { | |
2954
cfb04f784a84
user g_strdup_printf instead of fixed-size gchar array
Tomasz Mon <desowin@gmail.com>
parents:
2942
diff
changeset
|
93 gchar *time_str; |
2313 | 94 |
2954
cfb04f784a84
user g_strdup_printf instead of fixed-size gchar array
Tomasz Mon <desowin@gmail.com>
parents:
2942
diff
changeset
|
95 time_str = g_strdup_printf("%2.2d", timeleft / 60); |
2942
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2717
diff
changeset
|
96 ui_skinned_textbox_set_text(mainwin_stime_min, time_str); |
3001
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2954
diff
changeset
|
97 g_free(time_str); |
2313 | 98 |
2954
cfb04f784a84
user g_strdup_printf instead of fixed-size gchar array
Tomasz Mon <desowin@gmail.com>
parents:
2942
diff
changeset
|
99 time_str = g_strdup_printf("%2.2d", timeleft % 60); |
2942
1a59a0ced6a8
make scrolling stop for second when it reaches end, replace remaining mainwin TextBox with UiSkinnedTextbox
Tomasz Mon <desowin@gmail.com>
parents:
2717
diff
changeset
|
100 ui_skinned_textbox_set_text(mainwin_stime_sec, time_str); |
3001
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2954
diff
changeset
|
101 g_free(time_str); |
2313 | 102 } |
103 | |
104 playlistwin_set_time(timeleft * 1000, 0, TIMER_ELAPSED); | |
105 } | |
106 | |
107 if (!cfg.pause_between_songs || | |
108 g_timer_elapsed(pause_timer, NULL) >= cfg.pause_between_songs_time) | |
109 { | |
110 Playlist *playlist = playlist_get_active(); | |
111 | |
112 GDK_THREADS_ENTER(); | |
113 playlist_eof_reached(playlist); | |
114 GDK_THREADS_LEAVE(); | |
115 | |
116 waiting = FALSE; | |
117 } | |
118 | |
119 return waiting; | |
120 } | |
121 | |
122 gint | |
123 audcore_generic_events(void) | |
124 { | |
125 gint time = 0; | |
126 | |
127 if (playback_get_playing()) { | |
128 time = playback_get_time(); | |
129 | |
130 switch (time) { | |
131 case -1: | |
132 /* no song playing */ | |
133 ev_waiting = idle_func_change_song(ev_waiting); | |
134 break; | |
135 | |
136 default: | |
137 ev_waiting = FALSE; | |
138 } | |
139 } | |
140 | |
141 return time; | |
142 } | |
143 |