comparison audacious/genevent.c @ 197:ccd034857702 trunk

[svn] Split up generic events into audcore_generic_events(), and client-specific stuff remains in mainwin_idle_func().
author nenolod
date Tue, 15 Nov 2005 20:21:50 -0800
parents
children f31b2fc0f49d
comparison
equal deleted inserted replaced
196:b3b2fc5c8fe9 197:ccd034857702
1 /* Audacious - Cross-platform multimedia platform.
2 * Copyright (C) 2005 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; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 */
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include "main.h"
30
31 #include <glib.h>
32 #include <glib/gi18n.h>
33 #include <glib/gprintf.h>
34 #include <gdk/gdk.h>
35 #include <stdlib.h>
36 #include <string.h>
37 #include <getopt.h>
38 #include <ctype.h>
39 #include <time.h>
40
41 #include <unistd.h>
42 #include <errno.h>
43 #include <sys/types.h>
44 #include <sys/stat.h>
45 #include <signal.h>
46 #include <gdk/gdkx.h>
47 #include <X11/Xlib.h>
48 #include <X11/Xatom.h>
49
50 #include "libaudacious/configdb.h"
51 #include "libaudacious/beepctrl.h"
52 #include "libaudacious/util.h"
53 #include "libaudacious/vfs.h"
54
55 #include "controlsocket.h"
56 #include "dnd.h"
57 #include "dock.h"
58 #include "effect.h"
59 #include "equalizer.h"
60 #include "general.h"
61 #include "hints.h"
62 #include "input.h"
63 #include "logger.h"
64 #include "mainwin.h"
65 #include "output.h"
66 #include "playback.h"
67 #include "playlist.h"
68 #include "playlistwin.h"
69 #include "pluginenum.h"
70 #include "prefswin.h"
71 #include "skin.h"
72 #include "skinwin.h"
73 #include "util.h"
74 #include "visualization.h"
75
76 gboolean ev_waiting = FALSE;
77
78 static gboolean
79 idle_func_change_song(gboolean waiting)
80 {
81 static GTimer *pause_timer = NULL;
82
83 if (!pause_timer)
84 pause_timer = g_timer_new();
85
86 if (cfg.pause_between_songs) {
87 gint timeleft;
88
89 if (!waiting) {
90 g_timer_start(pause_timer);
91 waiting = TRUE;
92 }
93
94 timeleft = cfg.pause_between_songs_time -
95 (gint) g_timer_elapsed(pause_timer, NULL);
96
97 if (mainwin_10min_num != NULL) {
98 number_set_number(mainwin_10min_num, timeleft / 600);
99 number_set_number(mainwin_min_num, (timeleft / 60) % 10);
100 number_set_number(mainwin_10sec_num, (timeleft / 10) % 6);
101 number_set_number(mainwin_sec_num, timeleft % 10);
102 }
103
104 if (mainwin_sposition != NULL && !mainwin_sposition->hs_pressed) {
105 gchar time_str[5];
106
107 g_snprintf(time_str, sizeof(time_str), "%2.2d", timeleft / 60);
108 textbox_set_text(mainwin_stime_min, time_str);
109
110 g_snprintf(time_str, sizeof(time_str), "%2.2d", timeleft % 60);
111 textbox_set_text(mainwin_stime_sec, time_str);
112 }
113
114 playlistwin_set_time(timeleft * 1000, 0, TIMER_ELAPSED);
115 }
116
117 if (!cfg.pause_between_songs ||
118 g_timer_elapsed(pause_timer, NULL) >= cfg.pause_between_songs_time) {
119
120 GDK_THREADS_ENTER();
121 playlist_eof_reached();
122 GDK_THREADS_LEAVE();
123
124 waiting = FALSE;
125 }
126
127 return waiting;
128 }
129
130 gint
131 audcore_generic_events(void)
132 {
133 gint time = 0;
134
135 if (bmp_playback_get_playing()) {
136 time = bmp_playback_get_time();
137
138 switch (time) {
139 case -1:
140 /* no song playing */
141 ev_waiting = idle_func_change_song(ev_waiting);
142 break;
143
144 default:
145 ev_waiting = FALSE;
146 }
147 }
148
149 return time;
150 }
151