Mercurial > audlegacy
annotate src/audacious/genevent.c @ 3121:3b6d316f8b09 trunk
GPL3 relicensing.
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 20 Jul 2007 08:59:47 -0500 |
parents | 01ae56759d15 |
children | f1c756f39e6c |
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 | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3042
diff
changeset
|
12 * the Free Software Foundation; under version 3 of the License. |
2313 | 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 | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3042
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses>. |
2313 | 21 */ |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 # include "config.h" | |
25 #endif | |
26 | |
27 #include "main.h" | |
28 | |
29 #include <glib.h> | |
30 #include <glib/gi18n.h> | |
31 #include <glib/gprintf.h> | |
32 #include <gdk/gdk.h> | |
33 #include <stdlib.h> | |
34 #include <string.h> | |
35 #include <getopt.h> | |
36 #include <ctype.h> | |
37 #include <time.h> | |
38 | |
39 #include <unistd.h> | |
40 #include <errno.h> | |
41 #include <sys/types.h> | |
42 #include <sys/stat.h> | |
43 #include <signal.h> | |
44 | |
45 #include "dnd.h" | |
46 #include "effect.h" | |
47 #include "general.h" | |
48 #include "hints.h" | |
49 #include "input.h" | |
50 #include "logger.h" | |
51 #include "output.h" | |
52 #include "playback.h" | |
53 #include "playlist.h" | |
2420 | 54 #include "pluginenum.h" |
55 #include "ui_main.h" | |
2313 | 56 #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
|
57 #include "ui_skinned_textbox.h" |
3001
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2954
diff
changeset
|
58 #include "ui_skinned_number.h" |
3042
01ae56759d15
mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
3001
diff
changeset
|
59 #include "ui_skinned_horizontal_slider.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 | |
3042
01ae56759d15
mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
3001
diff
changeset
|
92 if (mainwin_sposition != NULL && !UI_SKINNED_HORIZONTAL_SLIDER(mainwin_sposition)->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 |