1 /*
2  * alarm-applet.h -- Alarm Clock applet bootstrap
3  *
4  * Copyright (C) 2007-2008 Johannes H. Jensen <joh@pseudoberries.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  *
20  * Authors:
21  * 		Johannes H. Jensen <joh@pseudoberries.com>
22  */
23 
24 #ifndef ALARMAPPLET_H_
25 #define ALARMAPPLET_H_
26 
27 #include <string.h>
28 #include <sys/time.h>
29 #include <time.h>
30 #include <libxml/parser.h>
31 
32 #include <gtk/gtk.h>
33 #include <glib/gi18n.h>
34 #include <gdk/gdkkeysyms.h>
35 #include <gconf/gconf-client.h>
36 #include <gst/gst.h>
37 #include <unique/unique.h>
38 
39 #include <config.h>
40 
41 #ifdef HAVE_APP_INDICATOR
42 #include <libappindicator/app-indicator.h>
43 #endif
44 
45 G_BEGIN_DECLS
46 
47 typedef struct _AlarmApplet AlarmApplet;
48 
49 extern GHashTable *app_command_map;
50 
51 void alarm_applet_label_update (AlarmApplet *applet);
52 void alarm_applet_clear_alarms (AlarmApplet *applet);
53 
54 #include "alarm.h"
55 #include "prefs.h"
56 #include "alarm-gconf.h"
57 #include "player.h"
58 #include "util.h"
59 #include "list-entry.h"
60 #include "ui.h"
61 
62 #define ALARM_NAME		 "Alarm Clock"
63 #define ALARM_ICON 		 "alarm-clock"
64 #define TIMER_ICON		 "alarm-timer"
65 #define TRIGGERED_ICON	 "alarm-clock-triggered"
66 #define ALARM_GCONF_DIR	 "/apps/alarm-clock"
67 #define ALARM_STD_SNOOZE 9
68 
69 typedef enum {
70 	LABEL_TYPE_INVALID = 0,
71 	LABEL_TYPE_TIME,
72 	LABEL_TYPE_REMAIN,
73 } LabelType;
74 
75 struct _AlarmApplet {
76 	/* Unique app */
77 	UniqueApp *unique_app;
78 
79     /* User Interface */
80     GtkBuilder *ui;
81 
82 #ifdef HAVE_APP_INDICATOR
83     /* App Indicator */
84     AppIndicator *app_indicator;
85 #else
86 	/* Status Icon */
87 	GtkStatusIcon *status_icon;
88 #endif
89 
90 	/* Status menu */
91     GtkWidget *status_menu;
92 
93 	/* Alarms */
94 	GList	*alarms;
95     guint   n_triggered;        // Number of triggered alarms
96 
97 	/* Sounds & apps list */
98 	GList *sounds;
99 	GList *apps;
100 
101 	/* List-alarms UI */
102 	AlarmListWindow *list_window;
103 
104     /* Alarm settings dialog */
105     AlarmSettingsDialog *settings_dialog;
106 
107 	/* Preferences */
108 	GtkDialog *prefs_dialog;
109 	GtkWidget *prefs_autostart_check;
110 
111     guint snooze_mins;
112 
113     // Actions on one alarm
114     GtkActionGroup *actions_alarm;
115 
116     GtkAction *action_edit;
117     GtkAction *action_delete;
118     GtkToggleAction *action_enabled;
119     GtkAction *action_stop;
120     GtkAction *action_snooze;
121 
122     // Global actions
123     GtkActionGroup *actions_global;
124     GtkAction *action_new;
125     GtkAction *action_stop_all;
126     GtkAction *action_snooze_all;
127     GtkToggleAction *action_toggle_list_win;
128     GtkToggleAction *action_toggle_autostart;
129     GtkToggleAction *action_toggle_show_label;
130 };
131 
132 void alarm_applet_sounds_load (AlarmApplet *applet);
133 
134 void alarm_applet_apps_load (AlarmApplet *applet);
135 
136 void alarm_applet_alarms_load (AlarmApplet *applet);
137 
138 void alarm_applet_alarms_add (AlarmApplet *applet, Alarm *alarm);
139 
140 void alarm_applet_alarms_remove (AlarmApplet *applet, Alarm *alarm);
141 
142 guint alarm_applet_alarms_snooze (AlarmApplet *applet);
143 
144 guint alarm_applet_alarms_stop (AlarmApplet *applet);
145 
146 void alarm_applet_alarm_snooze (AlarmApplet *applet, Alarm *alarm);
147 
148 void alarm_applet_alarm_stop (AlarmApplet *applet, Alarm *alarm);
149 
150 void alarm_applet_destroy (AlarmApplet *applet);
151 
152 G_END_DECLS
153 
154 #endif /*ALARMAPPLET_H_*/
155