annotate src/alarm/alarm.c @ 1040:1b0890d5c00b trunk

[svn] - Add filename to error message for unreadable metadata
author ertzing
date Wed, 16 May 2007 04:10:36 -0700
parents 711ec8d39ca6
children 2649ba83333b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
2 * Copyright (C) Adam Feakin <adamf@snika.uklinux.net>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
3 *
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
4 * modified by Daniel Stodden <stodden@in.tum.de>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
5 *
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
8 * as published by the Free Software Foundation; either version 2
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
9 * of the License, or (at your option) any later version.
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
10 *
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
14 * GNU General Public License for more details.
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
15 *
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
19 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
20
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
21 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
22 * xmms-alarm.c - a XMMS plugin which allows you to set a time for it to
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
23 * start playing a playlist with the volume fading up and more things
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
24 * the next time I get bored
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
25 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
26
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
27 /* this file really should get split/cleaned up sometime ;) */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
28 #include "config.h"
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
29
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
30 #if STDC_HEADERS
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
31 # include <stdlib.h>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
32 #endif
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
33
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
34 #include <time.h>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
35 #if TM_IN_SYS_TIME
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
36 # include <sys/time.h>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
37 #endif
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
38
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
39 #include <string.h>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
40 #include <stdio.h>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
41 #include <audacious/plugin.h>
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
42 #include <audacious/auddrct.h>
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
43 #include <audacious/configdb.h>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
44 #include <gdk/gdk.h>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
45 #include <gtk/gtk.h>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
46 #include <pthread.h>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
47 #include <assert.h>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
48 #include <math.h>
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
49
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
50 #include "alarm.h"
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
51 #include "interface.h"
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
52 #include "callbacks.h"
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
53
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
54 static pthread_t start_tid; /* thread id of alarm loop */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
55 static pthread_t stop_tid; /* thread id of stop loop */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
56 static pthread_mutex_t fader_lock = PTHREAD_MUTEX_INITIALIZER;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
57
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
58 static GeneralPlugin alarm_plugin;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
59
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
60 /* string tokens to allow loops and shorten code */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
61 static char day_cb[7][7] = {"sun_cb", "mon_cb", "tue_cb",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
62 "wed_cb", "thu_cb", "fri_cb", "sat_cb"};
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
63
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
64 static char day_flags[7][10] = {"sun_flags", "mon_flags", "tue_flags",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
65 "wed_flags", "thu_flags", "fri_flags", "sat_flags"};
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
66
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
67 static char day_h[7][6] = {"sun_h", "mon_h", "tue_h",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
68 "wed_h", "thu_h", "fri_h", "sat_h"};
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
69
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
70 static char day_m[7][6] = {"sun_m", "mon_m", "tue_m",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
71 "wed_m", "thu_m", "fri_m", "sat_m"};
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
72
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
73 static char day_def[7][8] = {"sun_def", "mon_def", "tue_def",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
74 "wed_def", "thu_def", "fri_def", "sat_def"};
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
75
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
76 static struct
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
77 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
78 GtkSpinButton *alarm_h;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
79 GtkSpinButton *alarm_m;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
80
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
81 GtkToggleButton *stop_on;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
82 GtkSpinButton *stop_h;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
83 GtkSpinButton *stop_m;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
84
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
85 GtkRange *volume;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
86 GtkRange *quietvol;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
87
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
88 GtkSpinButton *fading;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
89
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
90 GtkEntry *cmdstr;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
91 GtkToggleButton *cmd_on;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
92
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
93 GtkEntry *playlist;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
94
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
95 int default_hour;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
96 int default_min;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
97
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
98 // array allows looping of days
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
99 alarmday day[7];
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
100
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
101
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
102 GtkEntry *reminder;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
103 GtkToggleButton *reminder_cb;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
104 gchar *reminder_msg;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
105 gboolean reminder_on;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
106 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
107 alarm_conf;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
108
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
109 static gint alarm_h, alarm_m;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
110
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
111 static gboolean stop_on;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
112 static gint stop_h, stop_m;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
113
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
114 static gint volume, quietvol;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
115
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
116 static gint fading;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
117
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
118 static gchar *cmdstr = NULL;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
119 static gboolean cmd_on;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
120
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
121 static gchar *playlist = NULL;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
122
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
123 static GtkWidget *config_dialog = NULL;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
124 static GtkWidget *alarm_dialog = NULL;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
125
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
126 static GtkWidget *lookup_widget(GtkWidget *w, const gchar *name)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
127 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
128 GtkWidget *widget;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
129
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
130 widget = (GtkWidget*) gtk_object_get_data(GTK_OBJECT(w),
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
131 name);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
132 g_return_val_if_fail(widget != NULL, NULL);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
133
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
134 return widget;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
135 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
136
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
137 static void dialog_destroyed(GtkWidget *dialog, gpointer data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
138 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
139 DEBUG("dialog destroyed\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
140 *(GtkObject**)data = NULL;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
141 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
142
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
143 static inline gboolean dialog_visible(GtkWidget *dialog)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
144 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
145 return(((dialog != NULL) && GTK_WIDGET_VISIBLE(dialog)));
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
146 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
147
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
148 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
149 * tell the user about that bug
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
150 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
151 static void alarm_warning(void)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
152 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
153
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
154 static GtkWidget *warning_dialog = NULL;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
155
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
156 if(dialog_visible(warning_dialog))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
157 return;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
158
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
159 warning_dialog = create_warning_dialog();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
160
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
161 gtk_signal_connect(GTK_OBJECT(warning_dialog), "destroy",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
162 GTK_SIGNAL_FUNC(dialog_destroyed), &warning_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
163
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
164 gtk_widget_show_all(warning_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
165
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
166 return;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
167 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
168
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
169 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
170 * the callback function that is called when the save button is
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
171 * pressed saves configuration to ~/.bmp/alarmconfig
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
172 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
173 void alarm_save(GtkButton *w, gpointer data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
174 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
175 int daynum = 0; // used to identify day number
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
176 ConfigDb *conf;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
177
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
178 DEBUG("alarm_save\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
179
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
180 conf = bmp_cfg_db_open();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
181
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
182 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
183 * update the live values and write them out
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
184 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
185 alarm_h = alarm_conf.default_hour =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
186 gtk_spin_button_get_value_as_int(alarm_conf.alarm_h);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
187 bmp_cfg_db_set_int(conf, "alarm", "alarm_h", alarm_h);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
188
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
189 alarm_m = alarm_conf.default_min =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
190 gtk_spin_button_get_value_as_int(alarm_conf.alarm_m);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
191 bmp_cfg_db_set_int(conf, "alarm", "alarm_m", alarm_m);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
192
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
193
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
194 stop_h =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
195 gtk_spin_button_get_value_as_int( alarm_conf.stop_h);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
196
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
197 stop_m =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
198 gtk_spin_button_get_value_as_int(alarm_conf.stop_m);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
199
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
200 stop_on =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
201 gtk_toggle_button_get_active(alarm_conf.stop_on);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
202
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
203 /* days of the week */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
204 for(; daynum < 7; daynum++)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
205 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
206 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alarm_conf.day[daynum].cb)))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
207 alarm_conf.day[daynum].flags = 0;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
208 else
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
209 alarm_conf.day[daynum].flags = ALARM_OFF;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
210
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
211 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(alarm_conf.day[daynum].cb_def)))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
212 alarm_conf.day[daynum].flags |= ALARM_DEFAULT;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
213
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
214 alarm_conf.day[daynum].hour =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
215 gtk_spin_button_get_value_as_int(alarm_conf.day[daynum].spin_hr);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
216 alarm_conf.day[daynum].min =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
217 gtk_spin_button_get_value_as_int(alarm_conf.day[daynum].spin_min);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
218
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
219 bmp_cfg_db_set_int(conf, "alarm", day_flags[daynum], alarm_conf.day[daynum].flags);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
220 bmp_cfg_db_set_int(conf, "alarm", day_h[daynum], alarm_conf.day[daynum].hour);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
221 bmp_cfg_db_set_int(conf, "alarm", day_m[daynum], alarm_conf.day[daynum].min);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
222 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
223
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
224 /* END: days of week */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
225
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
226 volume =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
227 gtk_range_get_adjustment(alarm_conf.volume)->value;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
228 bmp_cfg_db_set_int(conf, "alarm", "volume", volume);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
229
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
230 quietvol =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
231 gtk_range_get_adjustment(alarm_conf.quietvol)->value;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
232 bmp_cfg_db_set_int(conf, "alarm", "quietvol", quietvol);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
233
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
234 fading =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
235 gtk_spin_button_get_value_as_int(alarm_conf.fading);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
236 //xmms_cfg_write_int(conf, "alarm", "fading", fading);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
237
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
238 /* lets check to see if we need to show the bug warning */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
239 if((stop_on == TRUE) &&
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
240 ((((stop_h * 60) + stop_m) * 60) < (fading + 65)))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
241 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
242 DEBUG("Displaying bug warning, stop %dh %dm, fade %d\n",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
243 stop_h, stop_m, fading);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
244 alarm_warning();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
245 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
246 else if((stop_on == TRUE) && (fading < 10))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
247 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
248 DEBUG("Displaying bug warning, stop %dh %dm, fade %d\n",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
249 stop_h, stop_m, fading);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
250 alarm_warning();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
251 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
252 else
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
253 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
254 /* write the new values */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
255 bmp_cfg_db_set_int(conf, "alarm", "stop_h", stop_h);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
256 bmp_cfg_db_set_int(conf, "alarm", "stop_m", stop_m);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
257 bmp_cfg_db_set_int(conf, "alarm", "fading", fading);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
258 bmp_cfg_db_set_bool(conf, "alarm", "stop_on", stop_on);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
259 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
260
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
261
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
262 g_free(cmdstr);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
263 cmdstr = gtk_editable_get_chars(GTK_EDITABLE(alarm_conf.cmdstr),
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
264 0, -1);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
265 bmp_cfg_db_set_string(conf, "alarm", "cmdstr", cmdstr);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
266
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
267 cmd_on =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
268 gtk_toggle_button_get_active(alarm_conf.cmd_on);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
269 bmp_cfg_db_set_bool(conf, "alarm", "cmd_on", cmd_on);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
270
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
271 g_free(playlist);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
272 playlist = gtk_editable_get_chars(GTK_EDITABLE(alarm_conf.playlist),
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
273 0, -1);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
274 bmp_cfg_db_set_string(conf, "alarm", "playlist", playlist);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
275
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
276 /* reminder */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
277 g_free(alarm_conf.reminder_msg);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
278 alarm_conf.reminder_msg = gtk_editable_get_chars(GTK_EDITABLE(alarm_conf.reminder),
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
279 0, -1);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
280 bmp_cfg_db_set_string(conf, "alarm", "reminder_msg", alarm_conf.reminder_msg);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
281
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
282 alarm_conf.reminder_on =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
283 gtk_toggle_button_get_active(alarm_conf.reminder_cb);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
284 bmp_cfg_db_set_bool(conf, "alarm", "reminder_on", alarm_conf.reminder_on);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
285
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
286 bmp_cfg_db_close(conf);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
287 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
288
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
289 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
290 * read the current configuration from the file
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
291 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
292 static void alarm_read_config()
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
293 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
294 int daynum = 0; // used for day number
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
295 ConfigDb *conf;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
296
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
297 DEBUG("alarm_read_config\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
298
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
299 conf = bmp_cfg_db_open();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
300
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
301 if(!bmp_cfg_db_get_int(conf, "alarm", "alarm_h", &alarm_h))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
302 alarm_h = DEFAULT_ALARM_HOUR;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
303 if(!bmp_cfg_db_get_int(conf, "alarm", "alarm_m", &alarm_m))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
304 alarm_m = DEFAULT_ALARM_MIN;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
305
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
306 /* save them here too */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
307 alarm_conf.default_hour = alarm_h;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
308 alarm_conf.default_min = alarm_m;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
309
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
310 if(!bmp_cfg_db_get_int( conf, "alarm", "stop_h", &stop_h))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
311 stop_h = DEFAULT_STOP_HOURS;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
312 if(!bmp_cfg_db_get_int( conf, "alarm", "stop_m", &stop_m))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
313 stop_m = DEFAULT_STOP_MINS;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
314 if(!bmp_cfg_db_get_bool(conf, "alarm", "stop_on", &stop_on))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
315 stop_on = TRUE;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
316
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
317 if(!bmp_cfg_db_get_int(conf, "alarm", "volume", &volume))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
318 volume = DEFAULT_VOLUME;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
319 if(!bmp_cfg_db_get_int(conf, "alarm", "quietvol", &quietvol))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
320 quietvol = DEFAULT_QUIET_VOL;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
321
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
322 if(!bmp_cfg_db_get_int(conf, "alarm", "fading", &fading))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
323 fading = DEFAULT_FADING;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
324
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
325 if(!bmp_cfg_db_get_string(conf, "alarm", "cmdstr", &cmdstr))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
326 cmdstr = g_strdup("");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
327 if(!bmp_cfg_db_get_bool(conf, "alarm", "cmd_on", &cmd_on))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
328 cmd_on = FALSE;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
329
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
330 if(!bmp_cfg_db_get_string(conf, "alarm", "playlist", &playlist))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
331 playlist = g_strdup("");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
332
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
333 if(!bmp_cfg_db_get_string(conf, "alarm", "reminder_msg", &alarm_conf.reminder_msg))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
334 alarm_conf.reminder_msg = g_strdup("");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
335 if(!bmp_cfg_db_get_bool(conf, "alarm", "reminder_on", &alarm_conf.reminder_on))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
336 alarm_conf.reminder_on = FALSE;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
337
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
338 /* day flags and times */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
339 for(; daynum < 7; daynum++)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
340 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
341 /* read the flags */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
342 if(!bmp_cfg_db_get_int(conf, "alarm", day_flags[daynum], &alarm_conf.day[daynum].flags)) {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
343 // only turn alarm off by default on a sunday
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
344 if(daynum != 0)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
345 alarm_conf.day[daynum].flags = DEFAULT_FLAGS;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
346 else
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
347 alarm_conf.day[daynum].flags = DEFAULT_FLAGS | ALARM_OFF;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
348 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
349
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
350 /* read the times */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
351 if(!bmp_cfg_db_get_int(conf, "alarm", day_h[daynum], &alarm_conf.day[daynum].hour))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
352 alarm_conf.day[daynum].hour = DEFAULT_ALARM_HOUR;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
353
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
354 if(!bmp_cfg_db_get_int(conf, "alarm", day_m[daynum], &alarm_conf.day[daynum].min))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
355 alarm_conf.day[daynum].min = DEFAULT_ALARM_MIN;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
356 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
357
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
358 DEBUG("END alarm_read_config\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
359 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
360
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
361 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
362 * display an about box
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
363 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
364 static void alarm_about()
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
365 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
366 static GtkWidget *about_dialog = NULL;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
367
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
368 DEBUG("alarm_about\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
369
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
370 if(dialog_visible(about_dialog))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
371 return;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
372
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
373 about_dialog = create_about_dialog();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
374
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
375 gtk_signal_connect(GTK_OBJECT(about_dialog), "destroy",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
376 GTK_SIGNAL_FUNC(dialog_destroyed), &about_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
377
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
378 gtk_widget_show_all(about_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
379
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
380 return;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
381 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
382
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
383 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
384 * create a playlist file selection dialog
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
385 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
386 static void alarm_playlist_browse(GtkButton *button, gpointer data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
387 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
388 GtkWidget *fs;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
389 gchar *dirname, *path;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
390
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
391 dirname = g_dirname(playlist);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
392 DEBUG("dirname = %s\n", dirname);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
393 path = g_strdup_printf("%s/", dirname);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
394 DEBUG("path = %s\n", path);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
395 g_free(dirname);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
396
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
397 fs = create_playlist_fileselection();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
398
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
399 gtk_file_selection_set_filename(GTK_FILE_SELECTION(fs), path);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
400 g_free(path);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
401
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
402 gtk_widget_show_all(fs);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
403 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
404
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
405 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
406 * save selected playlist to the corresponding text entry
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
407 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
408 void alarm_store_playlistname(GtkButton *button, gpointer data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
409 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
410 GtkFileSelection *fs = GTK_FILE_SELECTION(data);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
411 gchar *plist;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
412
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
413 DEBUG("alarm_store_playlistname\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
414
132
26a5aef73955 [svn] Fixes compiler warnings that "Joker" was talking about in #audacious.
asheldon
parents: 129
diff changeset
415 plist = g_strdup(gtk_file_selection_get_filename(fs));
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
416
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
417 gtk_entry_set_text(alarm_conf.playlist, plist);
132
26a5aef73955 [svn] Fixes compiler warnings that "Joker" was talking about in #audacious.
asheldon
parents: 129
diff changeset
418 g_free(plist);
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
419 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
420
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
421 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
422 * displays the configuration window and opens the config file.
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
423 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
424 static void alarm_configure(void)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
425 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
426 int daynum = 0; // used to loop days
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
427 GtkWidget *w;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
428
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
429 DEBUG("alarm_configure\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
430
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
431 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
432 * dont want to show more than one config window
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
433 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
434 if(dialog_visible(config_dialog))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
435 return;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
436
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
437 alarm_read_config();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
438
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
439 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
440 * Create the widgets
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
441 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
442 config_dialog = create_config_dialog();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
443
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
444 w = lookup_widget(config_dialog, "alarm_h_spin");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
445 alarm_conf.alarm_h = GTK_SPIN_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
446 gtk_spin_button_set_value(alarm_conf.alarm_h, alarm_h);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
447
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
448 w = lookup_widget(config_dialog, "alarm_m_spin");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
449 alarm_conf.alarm_m = GTK_SPIN_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
450 gtk_spin_button_set_value(alarm_conf.alarm_m, alarm_m);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
451
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
452 w = lookup_widget(config_dialog, "stop_h_spin");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
453 alarm_conf.stop_h = GTK_SPIN_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
454 gtk_spin_button_set_value(alarm_conf.stop_h, stop_h);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
455
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
456 w = lookup_widget(config_dialog, "stop_m_spin");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
457 alarm_conf.stop_m = GTK_SPIN_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
458 gtk_spin_button_set_value(alarm_conf.stop_m, stop_m);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
459
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
460 w = lookup_widget(config_dialog, "stop_checkb");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
461 alarm_conf.stop_on = GTK_TOGGLE_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
462 gtk_toggle_button_set_active(alarm_conf.stop_on, stop_on);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
463
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
464 w = lookup_widget(config_dialog, "vol_scale");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
465 alarm_conf.volume = GTK_RANGE(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
466 gtk_range_set_adjustment(alarm_conf.volume,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
467 GTK_ADJUSTMENT(gtk_adjustment_new(volume,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
468 0,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
469 100, 1,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
470 5, 0)));
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
471
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
472 w = lookup_widget(config_dialog, "quiet_vol_scale");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
473 alarm_conf.quietvol = GTK_RANGE(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
474 gtk_range_set_adjustment(alarm_conf.quietvol,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
475 GTK_ADJUSTMENT(gtk_adjustment_new(quietvol,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
476 0,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
477 100, 1,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
478 5, 0)));
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
479
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
480 /* days of week */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
481 for(; daynum < 7; daynum++)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
482 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
483 w = lookup_widget(config_dialog, day_cb[daynum]);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
484 alarm_conf.day[daynum].cb = GTK_CHECK_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
485 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alarm_conf.day[daynum].cb),
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
486 !(alarm_conf.day[daynum].flags & ALARM_OFF));
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
487
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
488 w = lookup_widget(config_dialog, day_def[daynum]);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
489 alarm_conf.day[daynum].cb_def = GTK_CHECK_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
490 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alarm_conf.day[daynum].cb_def),
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
491 alarm_conf.day[daynum].flags & ALARM_DEFAULT);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
492
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
493
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
494 /* Changed to show default time instead of set time when ALARM_DEFAULT set,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
495 * as suggested by Mark Brown
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
496 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
497 /* w = lookup_widget(config_dialog, day_h[daynum]);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
498 alarm_conf.day[daynum].spin_hr = GTK_SPIN_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
499 gtk_spin_button_set_value(alarm_conf.day[daynum].spin_hr, alarm_conf.day[daynum].hour);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
500
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
501 w = lookup_widget(config_dialog, day_m[daynum]);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
502 alarm_conf.day[daynum].spin_min = GTK_SPIN_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
503 gtk_spin_button_set_value(alarm_conf.day[daynum].spin_min, alarm_conf.day[daynum].min);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
504 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
505 if(alarm_conf.day[daynum].flags & ALARM_DEFAULT)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
506 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
507 w = lookup_widget(config_dialog, day_h[daynum]);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
508 alarm_conf.day[daynum].spin_hr = GTK_SPIN_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
509 gtk_spin_button_set_value(alarm_conf.day[daynum].spin_hr, alarm_conf.default_hour);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
510
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
511 w = lookup_widget(config_dialog, day_m[daynum]);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
512 alarm_conf.day[daynum].spin_min = GTK_SPIN_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
513 gtk_spin_button_set_value(alarm_conf.day[daynum].spin_min, alarm_conf.default_min);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
514
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
515 gtk_widget_set_sensitive((GtkWidget *)alarm_conf.day[daynum].spin_hr, FALSE);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
516 gtk_widget_set_sensitive((GtkWidget *)alarm_conf.day[daynum].spin_min, FALSE);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
517 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
518 else
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
519 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
520 w = lookup_widget(config_dialog, day_h[daynum]);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
521 alarm_conf.day[daynum].spin_hr = GTK_SPIN_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
522 gtk_spin_button_set_value(alarm_conf.day[daynum].spin_hr, alarm_conf.day[daynum].hour);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
523
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
524 w = lookup_widget(config_dialog, day_m[daynum]);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
525 alarm_conf.day[daynum].spin_min = GTK_SPIN_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
526 gtk_spin_button_set_value(alarm_conf.day[daynum].spin_min, alarm_conf.day[daynum].min);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
527
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
528 gtk_widget_set_sensitive((GtkWidget *)alarm_conf.day[daynum].spin_hr, TRUE);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
529 gtk_widget_set_sensitive((GtkWidget *)alarm_conf.day[daynum].spin_min, TRUE);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
530 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
531 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
532
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
533 /* END: days of week */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
534
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
535 w = lookup_widget(config_dialog,"fading_spin");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
536 alarm_conf.fading = GTK_SPIN_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
537 gtk_spin_button_set_value(alarm_conf.fading, fading);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
538
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
539 w = lookup_widget(config_dialog, "cmd_entry");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
540 alarm_conf.cmdstr = GTK_ENTRY(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
541 gtk_entry_set_text(alarm_conf.cmdstr, cmdstr);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
542
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
543 w = lookup_widget(config_dialog, "cmd_checkb");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
544 alarm_conf.cmd_on = GTK_TOGGLE_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
545 gtk_toggle_button_set_active(alarm_conf.cmd_on, cmd_on);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
546
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
547 w = lookup_widget(config_dialog, "playlist");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
548 alarm_conf.playlist = GTK_ENTRY(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
549 gtk_entry_set_text(alarm_conf.playlist, playlist);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
550
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
551 w = lookup_widget(config_dialog, "reminder_text");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
552 alarm_conf.reminder = GTK_ENTRY(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
553 gtk_entry_set_text(alarm_conf.reminder, alarm_conf.reminder_msg);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
554
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
555 w = lookup_widget(config_dialog, "reminder_cb");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
556 alarm_conf.reminder_cb = GTK_TOGGLE_BUTTON(w);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
557 gtk_toggle_button_set_active(alarm_conf.reminder_cb, alarm_conf.reminder_on);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
558
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
559 w = lookup_widget(config_dialog, "playlist_browse_button");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
560 gtk_signal_connect(GTK_OBJECT(w), "clicked",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
561 GTK_SIGNAL_FUNC(alarm_playlist_browse), NULL);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
562
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
563 gtk_signal_connect(GTK_OBJECT(config_dialog), "destroy",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
564 GTK_SIGNAL_FUNC(dialog_destroyed), &config_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
565
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
566 gtk_widget_show_all(config_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
567
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
568 DEBUG("END alarm_configure\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
569 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
570
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
571 /* functions for greying out the time for days */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
572 void on_day_def_toggled(GtkToggleButton *togglebutton, gpointer user_data, int daynum)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
573 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
574 GtkWidget *w;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
575
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
576 /* change the time shown too */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
577 w = lookup_widget(config_dialog, day_h[daynum]);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
578 if(w == NULL)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
579 return;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
580
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
581 if(gtk_toggle_button_get_active(togglebutton) == TRUE)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
582 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
583 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), alarm_conf.default_hour);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
584 gtk_widget_set_sensitive(w, FALSE);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
585 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
586 else
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
587 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
588 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), alarm_conf.day[daynum].hour);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
589 gtk_widget_set_sensitive(w, TRUE);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
590 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
591
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
592 w = lookup_widget(config_dialog, day_m[daynum]);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
593 if(gtk_toggle_button_get_active(togglebutton) == TRUE)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
594 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
595 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), alarm_conf.default_min);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
596 gtk_widget_set_sensitive(w, FALSE);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
597 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
598 else
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
599 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
600 gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), alarm_conf.day[daynum].min);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
601 gtk_widget_set_sensitive(w, TRUE);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
602 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
603 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
604
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
605 void on_sun_def_toggled(GtkToggleButton *togglebutton, gpointer user_data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
606 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
607 on_day_def_toggled(togglebutton, user_data, 0);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
608 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
609
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
610 void on_mon_def_toggled(GtkToggleButton *togglebutton, gpointer user_data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
611 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
612 on_day_def_toggled(togglebutton, user_data, 1);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
613 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
614
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
615 void on_tue_def_toggled(GtkToggleButton *togglebutton, gpointer user_data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
616 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
617 on_day_def_toggled(togglebutton, user_data, 2);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
618 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
619
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
620 void on_wed_def_toggled(GtkToggleButton *togglebutton, gpointer user_data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
621 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
622 on_day_def_toggled(togglebutton, user_data, 3);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
623 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
624
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
625 void on_thu_def_toggled(GtkToggleButton *togglebutton, gpointer user_data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
626 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
627 on_day_def_toggled(togglebutton, user_data, 4);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
628 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
629
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
630 void on_fri_def_toggled(GtkToggleButton *togglebutton, gpointer user_data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
631 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
632 on_day_def_toggled(togglebutton, user_data, 5);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
633 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
634
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
635 void on_sat_def_toggled(GtkToggleButton *togglebutton, gpointer user_data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
636 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
637 on_day_def_toggled(togglebutton, user_data, 6);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
638 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
639
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
640 /* END: greying things */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
641
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
642 void alarm_current_volume(GtkButton *button, gpointer data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
643 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
644 gint vol;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
645 GtkAdjustment *adj;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
646
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
647 DEBUG("on_current_button_clicked\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
648
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
649 audacious_drct_get_volume_main(&vol);
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
650
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
651 adj = gtk_range_get_adjustment(alarm_conf.volume);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
652 gtk_adjustment_set_value(adj, (gfloat)vol);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
653 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
654
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
655 GeneralPlugin *get_gplugin_info()
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
656 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
657 return &alarm_plugin;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
658 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
659
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
660 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
661 * a thread safe sleeping function -
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
662 * and it even works in solaris (I think)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
663 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
664 static void threadsleep(float x)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
665 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
666 DEBUG("threadsleep: waiting %f seconds\n", x);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
667
122
96fc1ef32c99 [svn] - push fixes from p4://depot/svn-audacious-plugins-devel/virt-branches/audalarm/src
nenolod
parents: 121
diff changeset
668 g_usleep((int) ((float) x * (float) 1000000.0));
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
669
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
670 return;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
671 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
672
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
673 static inline pthread_t alarm_thread_create(void *(*start_routine)(void *), void *args, unsigned int detach)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
674 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
675 pthread_t tid;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
676 pthread_attr_t attr;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
677
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
678 pthread_attr_init(&attr);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
679
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
680 if(detach != 0)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
681 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
682
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
683 pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
684 pthread_attr_setschedpolicy(&attr, SCHED_OTHER);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
685 pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
686
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
687 pthread_create(&tid, &attr, start_routine, args);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
688
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
689 return(tid);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
690 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
691
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
692 static void *alarm_fade(void *arg)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
693 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
694 fader *vols = (fader *)arg;
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
695 guint i, v;
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
696 gint inc, diff, adiff;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
697
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
698 /* lock */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
699 pthread_mutex_lock(&fader_lock);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
700
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
701 /* slide volume */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
702 /* the Kaspar Giger way of fading, check the current mixer volume and
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
703 * increment from there so that if you have some other app lowering the
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
704 * volume at the same time xmms-alarm will not ignore it. If you have some
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
705 * other app increasing the volume, then it could get louder that you expect
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
706 * though - because the loop does not recalculate the difference each time.
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
707 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
708
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
709 /* difference between the 2 volumes */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
710 diff = vols->end - vols->start;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
711 adiff = abs(diff);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
712
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
713 /* Are we going up or down? */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
714 if(diff < 0)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
715 inc = -1;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
716 else
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
717 inc = 1;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
718
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
719 audacious_drct_set_volume_main((gint)vols->start);
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
720 //for(i=0;i<(vols->end - vols->start);i++)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
721 for(i=0;i<adiff;i++)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
722 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
723 //threadsleep((gfloat)fading / (vols->end - vols->start));
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
724 threadsleep((gfloat)fading / (gfloat)adiff);
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
725 audacious_drct_get_volume_main(&v);
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
726 audacious_drct_set_volume_main((gint)(v + inc));
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
727 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
728 /* Setting the volume to the end volume sort of defeats the point if having
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
729 * the code in there to allow other apps to control volume too :)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
730 */
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
731 //audacious_drct_set_volume_main((gint)vols->end);
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
732
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
733 /* and */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
734 pthread_mutex_unlock(&fader_lock);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
735
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
736 DEBUG("volume = %f%%\n", (gdouble)vols->end);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
737 return(0);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
738 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
739
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
740 static void *alarm_stop_thread( void *args )
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
741 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
742 gint currvol;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
743 fader fade_vols;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
744 pthread_t f_tid;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
745
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
746 DEBUG("alarm_stop_thread\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
747
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
748
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
749 /* sleep for however long we are meant to be sleeping for until
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
750 * its time to shut up
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
751 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
752 threadsleep(((stop_h * 60) + stop_m) * 60);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
753
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
754 DEBUG("alarm_stop triggered\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
755
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
756 if (dialog_visible(alarm_dialog))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
757 gtk_widget_destroy(alarm_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
758
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
759 audacious_drct_get_volume_main(&currvol),
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
760
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
761 /* fade back to zero */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
762 fade_vols.start = currvol;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
763 fade_vols.end = 0;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
764
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
765 /* The fader thread locks the fader_mutex now */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
766 f_tid = alarm_thread_create(alarm_fade, &fade_vols, 0);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
767
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
768 pthread_join(f_tid, NULL);
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
769 audacious_drct_stop();
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
770
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
771 /* might as well set the volume to something higher than zero so we
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
772 * dont confuse the poor people who just woke up and cant work out why
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
773 * theres no music playing when they press the little play button :)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
774 */
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
775 audacious_drct_set_volume_main(currvol);
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
776
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
777 DEBUG("alarm_stop done\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
778 return(NULL);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
779 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
780
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
781 void alarm_stop_cancel(GtkButton *w, gpointer data)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
782 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
783 DEBUG("alarm_stop_cancel\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
784 pthread_cancel(stop_tid);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
785 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
786
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
787 /* the main alarm thread */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
788 static void *alarm_start_thread(void *args)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
789 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
790 struct tm *currtime;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
791 time_t timenow;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
792 unsigned int play_start = 0;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
793 guint today;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
794
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
795 /* give it time to set start_tid to something */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
796 threadsleep(1);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
797
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
798 while(start_tid != 0)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
799 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
800 /* sit around and wait for the faders to not be doing anything */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
801 DEBUG("Waiting for fader to be unlocked..");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
802 pthread_mutex_lock(&fader_lock);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
803 DEBUG("Ok\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
804 pthread_mutex_unlock(&fader_lock);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
805
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
806 DEBUG("Getting time\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
807 timenow = time(NULL);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
808 currtime = localtime(&timenow);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
809 today = currtime->tm_wday;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
810 DEBUG("Today is %d\n", today);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
811
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
812 /* see if its time to do something */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
813 DEBUG("Checking Day\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
814
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
815 /* Had to put something here so I put the hour string.
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
816 ** Its only debug stuff anyway */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
817 DEBUG(day_h[today]);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
818
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
819 if(alarm_conf.day[today].flags & ALARM_OFF)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
820 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
821 threadsleep(8.5);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
822 continue;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
823 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
824 else
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
825 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
826 /* set the alarm_h and alarm_m for today, if not default */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
827 if(!(alarm_conf.day[today].flags & ALARM_DEFAULT))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
828 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
829 alarm_h = alarm_conf.day[today].hour;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
830 alarm_m = alarm_conf.day[today].min;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
831 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
832 else
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
833 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
834 alarm_h = alarm_conf.default_hour;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
835 alarm_m = alarm_conf.default_min;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
836 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
837 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
838
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
839 DEBUG("Alarm time is %d:%d (def: %d:%d)\n", alarm_h, alarm_m,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
840 alarm_conf.default_hour, alarm_conf.default_min);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
841
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
842 DEBUG("Checking time (%d:%d)\n", currtime->tm_hour, currtime->tm_min);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
843 if((currtime->tm_hour != alarm_h) || (currtime->tm_min != alarm_m))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
844 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
845 threadsleep(8.5);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
846 continue;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
847 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
848
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
849 if(cmd_on == TRUE)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
850 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
851 DEBUG("Executing %s, cmd_on is true\n", cmdstr);
963
9549fea94794 [svn] Warning fixes from SuSe.
chainsaw
parents: 628
diff changeset
852 if(system(cmdstr) == -1)
9549fea94794 [svn] Warning fixes from SuSe.
chainsaw
parents: 628
diff changeset
853 {
9549fea94794 [svn] Warning fixes from SuSe.
chainsaw
parents: 628
diff changeset
854 DEBUG("Executing %s failed\n",cmdstr);
9549fea94794 [svn] Warning fixes from SuSe.
chainsaw
parents: 628
diff changeset
855 }
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
856 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
857
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
858 DEBUG("strcmp playlist, playlist is [%s]\n", playlist);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
859 if(strcmp(playlist, ""))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
860 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
861 DEBUG("playlist is not blank, aparently\n");
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
862 GList list;
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
863
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
864 list.prev = list.next = NULL;
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
865 list.data = playlist;
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
866
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
867 audacious_drct_pl_clear();
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
868 audacious_drct_pl_add(&list);
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
869 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
870
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
871 if(fading)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
872 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
873 fader fade_vols;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
874
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
875 DEBUG("Fading is true\n");
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
876 audacious_drct_set_volume_main(quietvol);
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
877
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
878 /* start playing */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
879 play_start = time(NULL);
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
880 audacious_drct_play();
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
881
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
882 /* fade volume */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
883 fade_vols.start = quietvol;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
884 fade_vols.end = volume;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
885
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
886 //alarm_fade(quietvol, volume);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
887 alarm_thread_create(alarm_fade, &fade_vols, 0);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
888 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
889 else
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
890 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
891 /* no fading */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
892
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
893 /* set volume */
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
894 audacious_drct_set_volume_main(volume);
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
895
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
896 /* start playing */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
897 play_start = time(NULL);
1035
711ec8d39ca6 [svn] Changed alarm and projectm plugins so they use auddrct now.
magma
parents: 1005
diff changeset
898 audacious_drct_play();
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
899 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
900
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
901 if(alarm_conf.reminder_on == TRUE)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
902 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
903 GtkWidget *reminder_dialog;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
904 DEBUG("Showing reminder '%s'\n", alarm_conf.reminder_msg);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
905
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
906 GDK_THREADS_ENTER();
132
26a5aef73955 [svn] Fixes compiler warnings that "Joker" was talking about in #audacious.
asheldon
parents: 129
diff changeset
907 reminder_dialog = (GtkWidget*) create_reminder_dialog(alarm_conf.reminder_msg);
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
908 gtk_signal_connect(GTK_OBJECT(reminder_dialog), "destroy",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
909 GTK_SIGNAL_FUNC(dialog_destroyed), &reminder_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
910 gtk_widget_show_all(reminder_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
911 GDK_THREADS_LEAVE();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
912 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
913
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
914 /* bring up the wakeup call dialog if stop_on is set TRUE, this
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
915 * has been moved to after making xmms play so that it doesnt
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
916 * get in the way for people with manual window placement turned on
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
917 *
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
918 * this means that the dialog doesnt get shown until the volume has
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
919 * finished fading though !, so thats something else to fix
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
920 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
921 if(stop_on == TRUE)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
922 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
923 /* ok, so when we want to open dialogs in threaded programs
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
924 * we use this do we?
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
925 * anyone?
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
926 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
927 GDK_THREADS_ENTER();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
928 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
929 DEBUG("stop_on is true\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
930 alarm_dialog = create_alarm_dialog();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
931 DEBUG("created alarm dialog, %p\n", alarm_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
932
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
933 gtk_signal_connect(GTK_OBJECT(alarm_dialog), "destroy",
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
934 GTK_SIGNAL_FUNC(dialog_destroyed), &alarm_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
935 DEBUG("attached destroy signal to alarm dialog, %p\n", alarm_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
936 gtk_widget_show_all(alarm_dialog);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
937 DEBUG("dialog now showing\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
938
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
939 DEBUG("now starting stop thread\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
940 stop_tid = alarm_thread_create(alarm_stop_thread, NULL, 0);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
941 DEBUG("Created wakeup dialog and started stop thread(%d)\n", (int)stop_tid);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
942
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
943 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
944 GDK_THREADS_LEAVE();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
945
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
946 /* now wait for the stop thread */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
947 DEBUG("Waiting for stop to stop.... (%d)", (int)stop_tid);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
948 pthread_join(stop_tid, NULL);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
949 /* loop until we are out of the starting minute */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
950 while(time(NULL) < (play_start + 61))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
951 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
952 DEBUG("Waiting until out of starting minute\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
953 threadsleep(5.0);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
954 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
955 DEBUG("OK\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
956 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
957 /* loop until we are out of the starting minute */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
958 while(time(NULL) < (play_start + 61))
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
959 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
960 threadsleep(5.0);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
961 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
962 threadsleep(fading);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
963 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
964
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
965 DEBUG("Main thread has gone...\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
966 return NULL;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
967 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
968
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
969 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
970 * initialization
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
971 * opens the config file and reads the value, creates a new
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
972 * config in memory if the file doesnt exist and sets default vals
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
973 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
974 static void alarm_init()
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
975 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
976 DEBUG("alarm_init\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
977
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
978 alarm_read_config();
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
979
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
980 /* start the main thread running */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
981 start_tid = alarm_thread_create(alarm_start_thread, NULL, 1);
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
982 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
983
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
984 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
985 * kill the main thread
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
986 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
987 static void alarm_cleanup()
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
988 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
989 DEBUG("alarm_cleanup\n");
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
990
129
dae03298753f [svn] - don't cancel threads that don't exist (TODO: GThreadify)
nenolod
parents: 122
diff changeset
991 if (start_tid)
dae03298753f [svn] - don't cancel threads that don't exist (TODO: GThreadify)
nenolod
parents: 122
diff changeset
992 pthread_cancel(start_tid);
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
993 start_tid = 0;
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
994 if(stop_tid)
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
995 pthread_cancel(stop_tid);
129
dae03298753f [svn] - don't cancel threads that don't exist (TODO: GThreadify)
nenolod
parents: 122
diff changeset
996 stop_tid = 0;
121
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
997 }
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
998
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
999 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1000 * for xmms to get the function names
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1001 */
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1002 static GeneralPlugin alarm_plugin =
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1003 {
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1004 NULL,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1005 NULL,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1006 -1,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1007 "Alarm "VERSION,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1008 alarm_init,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1009 alarm_about,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1010 alarm_configure,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1011 alarm_cleanup,
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1012 };
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1013
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1014 /*
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1015 * vi:ai:expandtab:ts=2 sts=2 shiftwidth=2:nowrap:
b59bca84e3cd [svn] - add xmms-alarm port
nenolod
parents:
diff changeset
1016 */