2
* edit-alarm.c -- Alarm settings dialog
4
* Copyright (C) 2007-2008 Johannes H. Jensen <joh@pseudoberries.com>
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.
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.
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.
21
* Johannes H. Jensen <joh@pseudoberries.com>
24
#include "edit-alarm.h"
25
#include "alarm-applet.h"
30
#include <glib-object.h>
34
alarm_settings_update_time (AlarmSettingsDialog *dialog);
37
time_changed_cb (GtkSpinButton *spinbutton, gpointer data);
40
sound_combo_changed_cb (GtkComboBox *combo, AlarmSettingsDialog *dialog);
43
app_combo_changed_cb (GtkComboBox *combo, AlarmSettingsDialog *dialog);
47
#define REPEAT_LABEL _("<b>T_rigger alarm:</b> %s")
55
create_img_label (const gchar *label_text, const gchar *icon_name)
59
tmp = g_strdup_printf ("<b>%s</b>", label_text);
62
GtkWidget *img, *label, *spacer; // TODO: Ugly with spacer
65
icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
69
img = gtk_image_new_from_pixbuf(icon);
70
label = g_object_new (GTK_TYPE_LABEL,
76
hbox = g_object_new (GTK_TYPE_HBOX, "spacing", 6, NULL);
78
spacer = g_object_new (GTK_TYPE_LABEL, "label", "", NULL);
79
gtk_box_pack_start_defaults (GTK_BOX (hbox), spacer);
81
gtk_box_pack_start(GTK_BOX (hbox), img, FALSE, FALSE, 0);
82
gtk_box_pack_start(GTK_BOX (hbox), label, FALSE, FALSE, 0);
84
spacer = g_object_new (GTK_TYPE_LABEL, "label", "", NULL);
85
gtk_box_pack_start_defaults (GTK_BOX (hbox), spacer);
97
* Utility functions for updating various parts of the settings dialog.
101
alarm_settings_update_type (AlarmSettingsDialog *dialog)
103
if (dialog->alarm->type == ALARM_TYPE_CLOCK) {
104
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->clock_toggle), TRUE);
105
gtk_widget_set_sensitive(dialog->repeat_expand, TRUE);
107
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->timer_toggle), TRUE);
108
gtk_widget_set_sensitive(dialog->repeat_expand, FALSE);
113
alarm_settings_update_time (AlarmSettingsDialog *dialog)
117
tm = alarm_get_time(dialog->alarm);
119
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->hour_spin), tm->tm_hour);
120
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->min_spin), tm->tm_min);
121
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->sec_spin), tm->tm_sec);
125
alarm_settings_update_repeat (AlarmSettingsDialog *dialog)
135
for (r = ALARM_REPEAT_SUN, i = 0; r <= ALARM_REPEAT_SAT; r = 1 << ++i) {
136
check = (dialog->alarm->repeat & r) != 0;
138
// Activate the appropriate widget
139
g_object_set (dialog->repeat_check[i], "active", check, NULL);
144
* Update fancy expander label
147
if (dialog->alarm->repeat == ALARM_REPEAT_NONE) {
149
label = g_strdup_printf (REPEAT_LABEL, _("Once"));
151
} else if (dialog->alarm->repeat == ALARM_REPEAT_WEEKDAYS) {
153
label = g_strdup_printf (REPEAT_LABEL, _("Weekdays"));
155
} else if (dialog->alarm->repeat == ALARM_REPEAT_WEEKENDS) {
157
label = g_strdup_printf (REPEAT_LABEL, _("Weekends"));
159
} else if (dialog->alarm->repeat == ALARM_REPEAT_ALL) {
161
label = g_strdup_printf (REPEAT_LABEL, _("Every day"));
165
label = g_strdup_printf (REPEAT_LABEL, _("Custom"));
168
g_object_set (dialog->repeat_label, "label", label, NULL);
174
alarm_settings_update_snooze (AlarmSettingsDialog *dialog)
176
g_object_set (dialog->snooze_spin, "value", (gdouble)dialog->alarm->snooze, NULL);
178
g_object_set (dialog->snooze_check, "active", dialog->alarm->snooze > 0, NULL);
182
alarm_settings_update_notify_type (AlarmSettingsDialog *dialog)
185
switch (dialog->alarm->notify_type) {
186
case ALARM_NOTIFY_COMMAND:
187
g_object_set (dialog->notify_app_radio, "active", TRUE, NULL);
188
g_object_set (dialog->notify_app_box, "sensitive", TRUE, NULL);
191
g_object_set (dialog->notify_sound_box, "sensitive", FALSE, NULL);
193
if (dialog->player && dialog->player->state == MEDIA_PLAYER_PLAYING) {
194
// Stop preview player
195
media_player_stop (dialog->player);
201
g_object_set (dialog->notify_sound_radio, "active", TRUE, NULL);
202
g_object_set (dialog->notify_sound_box, "sensitive", TRUE, NULL);
205
g_object_set (dialog->notify_app_box, "sensitive", FALSE, NULL);
211
alarm_settings_update_sound (AlarmSettingsDialog *dialog)
213
AlarmListEntry *item;
215
guint pos, len, combo_len;
218
g_debug ("alarm_settings_update_sound (%p): sound_combo: %p, applet: %p, sounds: %p", dialog, dialog->notify_sound_combo, dialog->applet, dialog->applet->sounds);
220
/* Fill sounds list */
221
fill_combo_box (GTK_COMBO_BOX (dialog->notify_sound_combo),
222
dialog->applet->sounds, _("Select sound file..."));
224
// Look for the selected sound file
225
for (l = dialog->applet->sounds, pos = 0; l != NULL; l = l->next, pos++) {
226
item = (AlarmListEntry *)l->data;
227
if (strcmp (item->data, dialog->alarm->sound_file) == 0) {
230
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->notify_sound_combo), pos);
237
alarm_settings_update_app (AlarmSettingsDialog *dialog)
239
AlarmListEntry *item;
241
guint pos, len, combo_len;
242
gboolean custom = FALSE;
244
g_debug ("alarm_settings_update_app (%p): app_combo: %p, applet: %p, apps: %p", dialog, dialog->notify_app_combo, dialog->applet, dialog->applet->apps);
245
g_debug ("alarm_settings_update_app setting entry to %s", dialog->alarm->command);
248
fill_combo_box (GTK_COMBO_BOX (dialog->notify_app_combo),
249
dialog->applet->apps, _("Custom command..."));
251
// Look for the selected command
252
len = g_list_length (dialog->applet->apps);
253
for (l = dialog->applet->apps, pos = 0; l != NULL; l = l->next, pos++) {
254
item = (AlarmListEntry *)l->data;
255
if (strcmp (item->data, dialog->alarm->command) == 0) {
261
/* Only change sensitivity of the command entry if user
262
* isn't typing a custom command there already. */
269
g_debug ("CMD ENTRY HAS FOCUS? %d", GTK_WIDGET_HAS_FOCUS (dialog->notify_app_command_entry));
271
if (!GTK_WIDGET_HAS_FOCUS (dialog->notify_app_command_entry))
272
g_object_set (dialog->notify_app_command_entry, "sensitive", custom, NULL);
274
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->notify_app_combo), pos);
278
alarm_settings_update (AlarmSettingsDialog *dialog)
280
Alarm *alarm = ALARM (dialog->alarm);
282
g_object_set (dialog->label_entry, "text", alarm->message, NULL);
283
g_object_set (dialog->notify_sound_loop_check, "active", alarm->sound_loop, NULL);
284
g_object_set (dialog->notify_app_command_entry, "text", dialog->alarm->command, NULL);
285
g_object_set (dialog->notify_bubble_check, "active", alarm->notify_bubble, NULL);
287
alarm_settings_update_type (dialog);
288
alarm_settings_update_time (dialog);
289
alarm_settings_update_repeat (dialog);
290
alarm_settings_update_snooze (dialog);
291
alarm_settings_update_notify_type (dialog);
292
alarm_settings_update_sound (dialog);
293
alarm_settings_update_app (dialog);
302
* Alarm object callbacks
306
alarm_type_changed (GObject *object,
310
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
312
alarm_settings_update_type (dialog);
316
alarm_time_changed (GObject *object,
320
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
322
/* Only interesting if alarm is a CLOCK */
323
if (dialog->alarm->type != ALARM_TYPE_CLOCK)
326
alarm_settings_update_time (dialog);
330
alarm_repeat_changed (GObject *object,
334
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
336
alarm_settings_update_repeat (dialog);
340
alarm_snooze_changed (GObject *object,
344
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
346
alarm_settings_update_snooze (dialog);
350
alarm_timer_changed (GObject *object,
354
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
356
/* Only interesting if alarm is a TIMER */
357
if (dialog->alarm->type != ALARM_TYPE_TIMER)
360
alarm_settings_update_time (dialog);
364
alarm_notify_type_changed (GObject *object,
368
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
370
alarm_settings_update_notify_type (dialog);
374
alarm_settings_sound_file_changed (GObject *object,
378
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
380
g_debug ("alarm_settings_sound_file_changed (%p)", data);
382
// Block sound combo signals to prevent infinite loop
383
// because the "changed" signal will be emitted when we
384
// change the combo box tree model.
385
g_signal_handlers_block_matched (dialog->notify_sound_combo,
387
0, 0, NULL, sound_combo_changed_cb, NULL);
390
alarm_settings_update_sound (dialog);
392
// Unblock combo signals
393
g_signal_handlers_unblock_matched (dialog->notify_sound_combo,
395
0, 0, NULL, sound_combo_changed_cb, NULL);
399
alarm_sound_repeat_changed (GObject *object,
403
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
405
g_debug ("alarm_sound_repeat_changed to: %d", dialog->alarm->sound_loop);
409
alarm_settings_command_changed (GObject *object,
413
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
415
g_debug ("alarm_settings_command_changed (%p)", data);
417
// Block sound combo signals to prevent infinite loop
418
// because the "changed" signal will be emitted when we
419
// change the combo box tree model.
420
g_signal_handlers_block_matched (dialog->notify_app_combo,
422
0, 0, NULL, app_combo_changed_cb, NULL);
425
alarm_settings_update_app (dialog);
427
// Unblock combo signals
428
g_signal_handlers_unblock_matched (dialog->notify_app_combo,
430
0, 0, NULL, app_combo_changed_cb, NULL);
439
open_sound_file_chooser (AlarmSettingsDialog *dialog)
443
chooser = gtk_file_chooser_dialog_new (_("Select sound file..."),
444
GTK_WINDOW (dialog->dialog),
445
GTK_FILE_CHOOSER_ACTION_OPEN,
446
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
447
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
450
gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (chooser), dialog->alarm->sound_file);
452
if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT) {
455
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser));
457
g_debug ("RESPONSE ACCEPT: %s", uri);
459
g_object_set (dialog->alarm, "sound_file", uri, NULL);
463
g_debug ("RESPONSE CANCEL");
464
alarm_settings_update_sound (dialog);
467
gtk_widget_destroy (chooser);
477
type_toggle_cb (GtkToggleButton *toggle, gpointer data)
479
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
480
GtkWidget *toggle2 = (GTK_WIDGET (toggle) == dialog->clock_toggle) ? dialog->timer_toggle : dialog->clock_toggle;
481
gboolean toggled = gtk_toggle_button_get_active(toggle);
483
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle2), !toggled);
485
if (GTK_WIDGET (toggle) == dialog->clock_toggle && toggled) {
486
g_object_set (dialog->alarm, "type", ALARM_TYPE_CLOCK, NULL);
488
g_object_set (dialog->alarm, "type", ALARM_TYPE_TIMER, NULL);
491
time_changed_cb (GTK_SPIN_BUTTON (dialog->hour_spin), dialog);
495
time_changed_cb (GtkSpinButton *spinbutton, gpointer data)
497
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
498
guint hour, min, sec;
500
hour = gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->hour_spin));
501
min = gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->min_spin));
502
sec = gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->sec_spin));
504
alarm_set_time (dialog->alarm, hour, min, sec);
508
repeat_changed_cb (GtkToggleButton *togglebutton,
511
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
514
AlarmRepeat rep, new_rep;
517
/* The check buttons have the same name as the 3 letter
518
* string representation of the day.
520
name = gtk_widget_get_name (GTK_WIDGET (togglebutton));
521
rep = alarm_repeat_from_string (name);
522
active = gtk_toggle_button_get_active (togglebutton);
526
new_rep = dialog->alarm->repeat | rep;
529
new_rep = dialog->alarm->repeat & ~rep;
531
g_object_set (dialog->alarm, "repeat", new_rep, NULL);
535
snooze_changed_cb (GtkSpinButton *spinbutton, gpointer data)
537
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
539
g_object_set (dialog->alarm, "snooze", (gint)gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->snooze_spin)), NULL);
543
snooze_check_changed_cb (GtkToggleButton *togglebutton, gpointer data)
545
AlarmSettingsDialog *dialog = (AlarmSettingsDialog *)data;
547
if (gtk_toggle_button_get_active (togglebutton) && dialog->alarm->snooze == 0) {
548
g_object_set (dialog->alarm, "snooze", ALARM_DEF_SNOOZE, NULL);
549
} else if (!gtk_toggle_button_get_active (togglebutton) && dialog->alarm->snooze > 0) {
550
g_object_set (dialog->alarm, "snooze", 0, NULL);
555
notify_type_changed_cb (GtkToggleButton *togglebutton,
556
AlarmSettingsDialog *dialog)
558
const gchar *name = gtk_widget_get_name (GTK_WIDGET (togglebutton));
559
gboolean value = gtk_toggle_button_get_active (togglebutton);
562
// Not checked, not interested
566
g_debug ("notify_type_changed: %s", name);
568
if (strcmp (name, "app-radio") == 0) {
569
g_object_set (dialog->alarm, "notify_type", ALARM_NOTIFY_COMMAND, NULL);
571
g_object_set (dialog->alarm, "notify_type", ALARM_NOTIFY_SOUND, NULL);
574
alarm_settings_update_notify_type (dialog);
578
sound_combo_changed_cb (GtkComboBox *combo,
579
AlarmSettingsDialog *dialog)
581
g_debug ("SOUND Combo_changed");
584
AlarmListEntry *item;
585
guint current_index, len, combo_len;
587
model = gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->notify_sound_combo));
588
combo_len = gtk_tree_model_iter_n_children (model, NULL);
589
current_index = gtk_combo_box_get_active (combo);
590
len = g_list_length (dialog->applet->sounds);
592
g_debug ("Current index: %d, n sounds: %d", current_index, len);
594
if (current_index < 0)
598
if (current_index >= len) {
600
g_debug ("Open SOUND file chooser...");
601
open_sound_file_chooser (dialog);
605
// Valid file selected, update alarm
606
item = (AlarmListEntry *) g_list_nth_data (dialog->applet->sounds, current_index);
607
g_object_set (dialog->alarm, "sound_file", item->data, NULL);
611
app_combo_changed_cb (GtkComboBox *combo,
612
AlarmSettingsDialog *dialog)
614
g_debug ("APP Combo_changed");
616
if (GTK_WIDGET_HAS_FOCUS (dialog->notify_app_command_entry)) {
617
g_debug (" ---- Skipping because command_entry has focus!");
622
AlarmListEntry *item;
623
guint current_index, len, combo_len;
625
model = gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->notify_app_combo));
626
combo_len = gtk_tree_model_iter_n_children (model, NULL);
627
current_index = gtk_combo_box_get_active (combo);
628
len = g_list_length (dialog->applet->apps);
630
if (current_index < 0)
634
if (current_index >= len) {
636
g_debug ("CUSTOM command selected...");
638
g_object_set (dialog->notify_app_command_entry, "sensitive", TRUE, NULL);
639
gtk_widget_grab_focus (dialog->notify_app_command_entry);
643
g_object_set (dialog->notify_app_command_entry, "sensitive", FALSE, NULL);
646
item = (AlarmListEntry *) g_list_nth_data (dialog->applet->apps, current_index);
647
g_object_set (dialog->alarm, "command", item->data, NULL);
657
preview_player_state_cb (MediaPlayer *player, MediaPlayerState state, AlarmSettingsDialog *dialog)
661
if (state == MEDIA_PLAYER_PLAYING) {
662
stock = "gtk-media-stop";
664
stock = "gtk-media-play";
666
g_debug ("AlarmSettingsDialog: Freeing media player %p", player);
668
media_player_free (player);
669
dialog->player = NULL;
673
gtk_button_set_label (GTK_BUTTON (dialog->notify_sound_preview), stock);
677
preview_sound_cb (GtkButton *button,
678
AlarmSettingsDialog *dialog)
680
if (dialog->player && dialog->player->state == MEDIA_PLAYER_PLAYING) {
681
// Stop preview player
682
media_player_stop (dialog->player);
684
// Start preview player
685
if (dialog->player == NULL)
686
dialog->player = media_player_new (dialog->alarm->sound_file,
687
dialog->alarm->sound_loop,
688
preview_player_state_cb, dialog,
689
media_player_error_cb, dialog->dialog);
691
g_debug ("AlarmSettingsDialog: preview_start...");
692
media_player_start (dialog->player);
702
alarm_settings_dialog_close (AlarmSettingsDialog *dialog)
704
g_hash_table_remove (dialog->applet->edit_alarm_dialogs, dialog->alarm->id);
706
gtk_widget_destroy (GTK_WIDGET (dialog->dialog));
708
if (dialog->player) {
709
if (dialog->player->state == MEDIA_PLAYER_STOPPED) {
710
media_player_free (dialog->player);
712
media_player_stop (dialog->player);
716
/* Remove alarm notify handlers! This would otherwise cause segfaults as
717
* the callbacks would look for a non-existant dialog struct.
719
g_signal_handlers_disconnect_matched (dialog->alarm, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, dialog);
721
// TODO: Why does this cause segfaults once the UI is reused?
722
Alarm *a = dialog->alarm;
723
g_debug ("FREE AlarmSettingsDialog %p alarm is %p", dialog, a);
725
g_debug ("\talarm is %p", a);
729
alarm_settings_dialog_response_cb (GtkDialog *dialog,
731
AlarmSettingsDialog *settings_dialog)
733
alarm_settings_dialog_close (settings_dialog);
743
* TODO: A bug exists which somehow causes some widgets to become NULL
744
* and thus crashes the program. Investigate further.
747
static AlarmSettingsDialog *
748
alarm_settings_dialog_new (Alarm *alarm, AlarmApplet *applet)
750
AlarmSettingsDialog *dialog;
751
GtkWidget *clock_content, *timer_content, *snooze_label;
755
GladeXML *ui = glade_xml_new (ALARM_UI_XML, "edit-alarm", NULL);
758
dialog = g_new0 (AlarmSettingsDialog, 1);
760
dialog->applet = applet;
761
dialog->alarm = alarm;
762
dialog->player = NULL;
763
dialog->dialog = glade_xml_get_widget (ui, "edit-alarm");
765
g_debug ("NEW AlarmSettingsDialog %p for alarm #%d", dialog, alarm->id);
766
g_debug ("\talarm is %p");
768
/* Response from dialog */
769
g_signal_connect (dialog->dialog, "response",
770
G_CALLBACK (alarm_settings_dialog_response_cb), dialog);
773
* TYPE TOGGLE BUTTONS
775
dialog->clock_toggle = glade_xml_get_widget (ui, "toggle-clock");
776
clock_content = create_img_label ("Alarm Clock", "alarm-clock");
778
dialog->timer_toggle = glade_xml_get_widget (ui, "toggle-timer");
779
timer_content = create_img_label ("Timer", "alarm-timer");
781
gtk_container_add (GTK_CONTAINER (dialog->clock_toggle), clock_content);
782
gtk_widget_show_all (GTK_WIDGET (dialog->clock_toggle));
784
gtk_container_add (GTK_CONTAINER (dialog->timer_toggle), timer_content);
785
gtk_widget_show_all (GTK_WIDGET (dialog->timer_toggle));
790
dialog->label_entry = glade_xml_get_widget (ui, "label-entry");
791
gtk_widget_grab_focus (dialog->label_entry);
793
dialog->hour_spin = glade_xml_get_widget (ui, "hour-spin");
794
dialog->min_spin = glade_xml_get_widget (ui, "minute-spin");
795
dialog->sec_spin = glade_xml_get_widget (ui, "second-spin");
800
dialog->repeat_expand = glade_xml_get_widget (ui, "repeat-expand");
801
dialog->repeat_label = glade_xml_get_widget (ui, "repeat-label");
803
/* The check buttons have the same name as the 3 letter
804
* string representation of the day.
806
for (r = ALARM_REPEAT_SUN, i = 0; r <= ALARM_REPEAT_SAT; r = 1 << ++i) {
807
dialog->repeat_check[i] = glade_xml_get_widget (ui, alarm_repeat_to_string (r));
813
dialog->snooze_check = glade_xml_get_widget (ui, "snooze-check");
814
dialog->snooze_spin = glade_xml_get_widget (ui, "snooze-spin");
816
snooze_label = gtk_bin_get_child (GTK_BIN (dialog->snooze_check));
817
g_object_set (G_OBJECT (snooze_label), "use-markup", TRUE, NULL);
822
dialog->notify_sound_radio = glade_xml_get_widget (ui, "sound-radio");
823
dialog->notify_sound_box = glade_xml_get_widget (ui, "sound-box");
824
dialog->notify_sound_combo = glade_xml_get_widget (ui, "sound-combo");
825
dialog->notify_sound_preview = glade_xml_get_widget (ui, "sound-play");
826
dialog->notify_sound_loop_check = glade_xml_get_widget (ui, "sound-loop-check");
827
dialog->notify_app_radio = glade_xml_get_widget (ui, "app-radio");
828
dialog->notify_app_box = glade_xml_get_widget (ui, "app-box");
829
dialog->notify_app_combo = glade_xml_get_widget (ui, "app-combo");
830
dialog->notify_app_command_box = glade_xml_get_widget (ui, "app-command-box");
831
dialog->notify_app_command_entry = glade_xml_get_widget (ui, "app-command-entry");
832
dialog->notify_bubble_check = glade_xml_get_widget (ui, "notify-bubble-check");
838
alarm_applet_apps_load (applet);
843
alarm_settings_update (dialog);
846
#ifndef HAVE_LIBNOTIFY
847
g_object_set (dialog->notify_bubble_check, "sensitive", FALSE, NULL);
848
gtk_widget_set_tooltip_text (GTK_WIDGET (dialog->notify_bubble_check), _("This feature requires libnotify to be installed"));
854
alarm_bind (alarm, "message", dialog->label_entry, "text");
855
alarm_bind (alarm, "sound-repeat", dialog->notify_sound_loop_check, "active");
856
alarm_bind (alarm, "command", dialog->notify_app_command_entry, "text");
857
alarm_bind (alarm, "notify-bubble", dialog->notify_bubble_check, "active");
860
* Special widgets require special attention!
864
g_signal_connect (alarm, "notify::type", G_CALLBACK (alarm_type_changed), dialog);
865
g_signal_connect (dialog->clock_toggle, "toggled", G_CALLBACK (type_toggle_cb), dialog);
866
g_signal_connect (dialog->timer_toggle, "toggled", G_CALLBACK (type_toggle_cb), dialog);
869
g_signal_connect (alarm, "notify::time", G_CALLBACK (alarm_time_changed), dialog);
870
g_signal_connect (alarm, "notify::timer", G_CALLBACK (alarm_timer_changed), dialog);
872
g_signal_connect (dialog->hour_spin, "value-changed", G_CALLBACK (time_changed_cb), dialog);
873
g_signal_connect (dialog->min_spin, "value-changed", G_CALLBACK (time_changed_cb), dialog);
874
g_signal_connect (dialog->sec_spin, "value-changed", G_CALLBACK (time_changed_cb), dialog);
877
g_signal_connect (alarm, "notify::repeat", G_CALLBACK (alarm_repeat_changed), dialog);
878
for (i = 0; i < 7; i++)
879
g_signal_connect (dialog->repeat_check[i], "toggled", G_CALLBACK (repeat_changed_cb), dialog);
882
g_signal_connect (alarm, "notify::snooze", G_CALLBACK (alarm_snooze_changed), dialog);
884
g_signal_connect (dialog->snooze_spin, "value-changed", G_CALLBACK (snooze_changed_cb), dialog);
885
g_signal_connect (dialog->snooze_check, "toggled", G_CALLBACK (snooze_check_changed_cb), dialog);
888
g_signal_connect (alarm, "notify::notify-type", G_CALLBACK (alarm_notify_type_changed), dialog);
889
g_signal_connect (dialog->notify_sound_radio, "toggled", G_CALLBACK (notify_type_changed_cb), dialog);
890
g_signal_connect (dialog->notify_app_radio, "toggled", G_CALLBACK (notify_type_changed_cb), dialog);
893
g_signal_connect (alarm, "notify::sound-file",
894
G_CALLBACK (alarm_settings_sound_file_changed), dialog);
895
g_signal_connect (dialog->notify_sound_combo, "changed",
896
G_CALLBACK (sound_combo_changed_cb), dialog);
898
g_signal_connect (dialog->notify_sound_preview, "clicked",
899
G_CALLBACK (preview_sound_cb), dialog);
902
g_signal_connect (alarm, "notify::command",
903
G_CALLBACK (alarm_settings_command_changed), dialog);
905
g_signal_connect (dialog->notify_app_combo, "changed",
906
G_CALLBACK (app_combo_changed_cb), dialog);
908
/*g_signal_connect (dialog->notify_app_command_entry, "changed",
909
G_CALLBACK (app_command_changed_cb), dialog);*/
917
display_edit_alarm_dialog (AlarmApplet *applet, Alarm *alarm)
919
AlarmSettingsDialog *dialog;
921
// Check if a dialog is already open for this alarm
922
dialog = (AlarmSettingsDialog *)g_hash_table_lookup (applet->edit_alarm_dialogs, alarm->id);
926
gtk_window_present (GTK_WINDOW (dialog->dialog));
930
dialog = alarm_settings_dialog_new (alarm, applet);
931
g_hash_table_insert (applet->edit_alarm_dialogs, alarm->id, dialog);