56
56
static int timeout_id, bp_timeout_id = -1, bp_timeout_steps = 0;
57
57
static int mute_button_toggled_cb_id;
59
void start_radio(gboolean restart)
59
static gboolean is_first_start(void)
61
GConfClient *client = gconf_client_get_default();
65
return !gconf_client_get_bool(client, "/apps/gnomeradio/first_time_flag", NULL);
68
static void set_first_time_flag(void)
70
GConfClient *client = gconf_client_get_default();
74
gconf_client_set_bool(client, "/apps/gnomeradio/first_time_flag", TRUE, NULL);
84
static gboolean initial_frequency_scan_cb(gpointer data)
86
static gfloat freq = FREQ_MIN - 4.0f/STEPS;
87
FreqScanData *fsd = data;
91
if (freq > FREQ_MAX) {
92
gtk_widget_destroy(fsd->dialog);
97
if (radio_check_station(freq)) {
98
char *text = g_strdup_printf(_("%d stations found"), g_list_length(fsd->stations) + 1);
99
gfloat *f = g_malloc(sizeof(gfloat));
100
gtk_label_set_text(GTK_LABEL(fsd->label), text);
103
g_print("%.2f is a station\n", freq);
106
fsd->stations = g_list_append(fsd->stations, f);
109
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(fsd->progress), MAX(0, (freq - FREQ_MIN)/(FREQ_MAX - FREQ_MIN)));
117
static void initial_frequency_scan(GtkWidget *app)
123
data.stations = NULL;
125
data.dialog = gtk_dialog_new_with_buttons(_("Scanning"),
126
GTK_WINDOW(app), DIALOG_FLAGS, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
127
gtk_dialog_set_has_separator(GTK_DIALOG(data.dialog), FALSE);
128
gtk_window_set_resizable(GTK_WINDOW(data.dialog), FALSE);
130
title_hdr = g_strconcat("<span weight=\"bold\">", _("Scanning for available stations:"), "</span>", NULL);
131
title = gtk_label_new(title_hdr);
132
gtk_misc_set_alignment(GTK_MISC(title), 0, 0.5);
133
gtk_label_set_use_markup(GTK_LABEL(title), TRUE);
135
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(data.dialog)->vbox), title, FALSE, FALSE, 6);
137
data.progress = gtk_progress_bar_new();
138
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(data.dialog)->vbox), data.progress, TRUE, FALSE, 6);
140
data.label = gtk_label_new(_("No stations found"));
141
gtk_misc_set_alignment(GTK_MISC(data.label), 0, 0.5);
142
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(data.dialog)->vbox), data.label, TRUE, FALSE, 6);
144
gtk_widget_show_all(data.dialog);
147
timeout_id = g_timeout_add(1000/SCAN_SPEED, (GSourceFunc)initial_frequency_scan_cb, (gpointer)&data);
148
int response = gtk_dialog_run(GTK_DIALOG(data.dialog));
152
g_source_remove(timeout_id);
154
gtk_widget_destroy(data.dialog);
156
if (g_list_length(data.stations) > 0) {
157
gfloat f = *((gfloat*)data.stations->data);
158
adj->value = f*STEPS;
165
text = g_strdup_printf(_("%d stations found. \nDo you want to add them as presets?\n"),
166
g_list_length(data.stations));
168
dialog = gtk_message_dialog_new(GTK_WINDOW(app), DIALOG_FLAGS, GTK_MESSAGE_QUESTION,
169
GTK_BUTTONS_YES_NO, text);
172
int response = gtk_dialog_run(GTK_DIALOG(dialog));
173
gtk_widget_destroy(dialog);
175
for (ptr = data.stations; ptr; ptr = ptr->next) {
176
if (response == GTK_RESPONSE_YES) {
177
preset *ps = g_malloc0(sizeof(preset));
178
ps->title = g_strdup(_("unnamed"));
179
ps->freq = *((gfloat*)ptr->data);
180
settings.presets = g_list_append(settings.presets, ps);
188
static void prefs_button_clicked_cb(GtkButton *button, gpointer app)
193
dialog = prefs_window(app);
195
/* Michael Jochum <e9725005@stud3.tuwien.ac.at> proposed to not use gnome_dialog_set_parent()
196
but following instead. */
197
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(app));
198
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
200
/*gnome_dialog_set_parent(GNOME_DIALOG(dialog), GTK_WINDOW(app));*/
202
choise = GTK_RESPONSE_HELP;
203
while (choise == GTK_RESPONSE_HELP)
205
choise = gtk_dialog_run(GTK_DIALOG(dialog));
208
case GTK_RESPONSE_HELP:
209
display_help_cb("gnomeradio-settings");
212
/* We need the hide signal to get the value of the device_entry */
213
gtk_widget_hide_all(dialog);
214
gtk_widget_destroy(dialog);
219
void start_radio(gboolean restart, GtkWidget *app)
254
418
gtk_tooltips_set_tip(tooltips, vol_scale, text, NULL);
422
g_signal_handler_block(G_OBJECT(mute_menuitem), mute_menuitem_toggled_cb_id);
423
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mute_menuitem), vol == 0);
424
g_signal_handler_unblock(G_OBJECT(mute_menuitem), mute_menuitem_toggled_cb_id);
257
426
g_signal_handler_block(G_OBJECT(mute_button), mute_button_toggled_cb_id);
258
g_signal_handler_block(G_OBJECT(mute_menuitem), mute_menuitem_toggled_cb_id);
259
427
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mute_button), vol == 0);
260
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mute_menuitem), vol == 0);
261
428
g_signal_handler_unblock(G_OBJECT(mute_button), mute_button_toggled_cb_id);
262
g_signal_handler_unblock(G_OBJECT(mute_menuitem), mute_menuitem_toggled_cb_id);
426
590
exit_gnome_radio();
429
static void prefs_button_clicked_cb(GtkButton *button, gpointer app)
434
dialog = prefs_window();
436
/* Michael Jochum <e9725005@stud3.tuwien.ac.at> proposed to not use gnome_dialog_set_parent()
437
but following instead. */
438
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(app));
439
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
441
/*gnome_dialog_set_parent(GNOME_DIALOG(dialog), GTK_WINDOW(app));*/
443
choise = GTK_RESPONSE_HELP;
444
while (choise == GTK_RESPONSE_HELP)
446
choise = gtk_dialog_run(GTK_DIALOG(dialog));
449
case GTK_RESPONSE_HELP:
450
display_help_cb("gnomeradio-settings");
453
/* We need the hide signal to get the value of the device_entry */
454
gtk_widget_hide_all(dialog);
455
gtk_widget_destroy(dialog);
460
593
void tray_icon_items_set_sensible(gboolean sensible)
462
595
GList* menuitems;
1038
static show_message(GtkMessageType type, const char* caption, const char* error_msg)
1172
static show_message(GtkMessageType type, const char* text, const char* details)
1040
1174
GtkWidget *dialog;
1042
char *text = g_strdup_printf("<b>%s</b>\n\n%s", caption, error_msg);
1044
dialog = gtk_message_dialog_new_with_markup(NULL, DIALOG_FLAGS, type, GTK_BUTTONS_CLOSE,
1178
dialog = gtk_message_dialog_new(NULL, DIALOG_FLAGS, type, GTK_BUTTONS_CLOSE,
1181
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), details);
1046
1183
gtk_dialog_run(GTK_DIALOG (dialog));
1047
1184
gtk_widget_destroy(dialog);
1051
void show_error_message(const char* caption, const char* error_msg)
1053
show_message(GTK_MESSAGE_ERROR, caption, error_msg);
1056
void show_warning_message(const char* caption, const char* error_msg)
1058
show_message(GTK_MESSAGE_WARNING, caption, error_msg);
1187
void show_error_message(const char* error, const char* details)
1189
show_message(GTK_MESSAGE_ERROR, error, details);
1192
void show_warning_message(const char* warning, const char* details)
1194
show_message(GTK_MESSAGE_WARNING, warning, details);