2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU Library General Public License for more details.
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
#include <gconf/gconf-client.h>
24
#define UN_NAMED "unnamed"
26
static GtkWidget *name_entry, *device_entry, *freq_spin;
27
static GtkWidget *mixer_combo;
28
static GtkWidget *mute_on_exit_cb;
29
//static GtkWidget *clist;
30
static GtkWidget *list_view;
31
static GtkListStore *list_store;
32
static GtkTreeSelection *selection;
33
static GtkAdjustment *spin;
34
static gint selected_row = -1;
36
static gnomeradio_settings tmp_settings;
38
gboolean save_settings(void)
43
GConfClient* client = NULL;
45
if (!gconf_is_initialized())
48
client = gconf_client_get_default();
52
/* Store general settings */
53
gconf_client_set_string(client, "/apps/gnomeradio/device", settings.device, NULL);
54
gconf_client_set_string(client, "/apps/gnomeradio/mixer", settings.mixer, NULL);
55
gconf_client_set_string(client, "/apps/gnomeradio/mixer-device", settings.mixer_dev, NULL);
56
gconf_client_set_bool(client, "/apps/gnomeradio/mute-on-exit", settings.mute_on_exit, NULL);
57
//gconf_client_set_float(client, "/apps/gnomeradio/volume", volume->value, NULL);
58
gconf_client_set_float(client, "/apps/gnomeradio/last-freq", adj->value/STEPS, NULL);
60
/* Store recording settings */
61
gconf_client_set_string(client, "/apps/gnomeradio/recording/audiodevice", rec_settings.audiodevice, NULL);
62
gconf_client_set_string(client, "/apps/gnomeradio/recording/last-filename", rec_settings.filename, NULL);
63
gconf_client_set_bool(client, "/apps/gnomeradio/recording/record-as-mp3", rec_settings.mp3, NULL);
64
gconf_client_set_string(client, "/apps/gnomeradio/recording/sample-rate", rec_settings.rate, NULL);
65
gconf_client_set_string(client, "/apps/gnomeradio/recording/sample-format", rec_settings.sample, NULL);
66
gconf_client_set_bool(client, "/apps/gnomeradio/recording/record-in-stereo", rec_settings.stereo, NULL);
67
gconf_client_set_string(client, "/apps/gnomeradio/recording/encoder", rec_settings.encoder, NULL);
68
gconf_client_set_string(client, "/apps/gnomeradio/recording/bitrate", rec_settings.bitrate, NULL);
70
/* Store the presets */
71
count = g_list_length(settings.presets);
72
gconf_client_set_int(client, "/apps/gnomeradio/presets/presets", count, NULL);
75
ps = g_list_nth_data(settings.presets, i);
76
buffer = g_strdup_printf("/apps/gnomeradio/presets/%d/name", i);
77
gconf_client_set_string(client, buffer, ps->name, NULL);
79
buffer = g_strdup_printf("/apps/gnomeradio/presets/%d/freqency", i);
80
gconf_client_set_float(client, buffer, ps->freq, NULL);
83
gconf_client_set_int(client, "/apps/gnomeradio/presets/last", mom_ps, NULL);
84
g_print("Storing Settings in GConf database\n");
89
gboolean load_settings(void)
94
GConfClient *client = NULL;
97
settings.presets = NULL;
99
if (!gconf_is_initialized())
102
client = gconf_client_get_default();
106
/* Load general settings */
107
settings.device = gconf_client_get_string(client, "/apps/gnomeradio/device" , NULL);
108
if (!settings.device)
109
settings.device = g_strdup("/dev/radio");
110
settings.mixer = gconf_client_get_string(client, "/apps/gnomeradio/mixer", NULL);
112
settings.mixer = g_strdup("line");
113
settings.mixer_dev = gconf_client_get_string(client, "/apps/gnomeradio/mixer-device", NULL);
114
if (!settings.mixer_dev)
115
settings.mixer_dev = g_strdup("/dev/mixer");
116
settings.mute_on_exit = gconf_client_get_bool(client, "/apps/gnomeradio/mute-on-exit", NULL);
117
//volume->value = gconf_client_get_float(client, "/apps/gnomeradio/volume", NULL);
118
freq = gconf_client_get_float(client, "/apps/gnomeradio/last-freq", NULL);
119
if ((freq < FREQ_MIN) || (freq > FREQ_MAX))
120
adj->value = FREQ_MIN * STEPS;
122
adj->value = freq * STEPS;
124
/* Load recording settings */
125
rec_settings.audiodevice = gconf_client_get_string(client, "/apps/gnomeradio/recording/audiodevice", NULL);
126
if (!rec_settings.audiodevice)
127
rec_settings.audiodevice = g_strdup("/dev/audio");
128
rec_settings.filename = gconf_client_get_string(client, "/apps/gnomeradio/recording/last-filename", NULL);
129
if (!rec_settings.filename)
130
rec_settings.filename = g_strdup("/");
131
rec_settings.mp3 = gconf_client_get_bool(client, "/apps/gnomeradio/recording/record-as-mp3", NULL);
132
rec_settings.rate = gconf_client_get_string(client, "/apps/gnomeradio/recording/sample-rate", NULL);
133
if (!rec_settings.rate)
134
rec_settings.rate = g_strdup("44100");
135
rec_settings.sample = gconf_client_get_string(client, "/apps/gnomeradio/recording/sample-format", NULL);
136
if (!rec_settings.sample)
137
rec_settings.sample = g_strdup("16");
138
rec_settings.stereo = gconf_client_get_bool(client, "/apps/gnomeradio/recording/record-in-stereo", NULL);
139
rec_settings.encoder = gconf_client_get_string(client, "/apps/gnomeradio/recording/encoder", NULL);
140
if (!rec_settings.encoder)
141
rec_settings.encoder = g_strdup("lame");
142
rec_settings.bitrate = gconf_client_get_string(client, "/apps/gnomeradio/recording/bitrate", NULL);
143
if (!rec_settings.bitrate)
144
rec_settings.bitrate = g_strdup("128");
146
/* Load the presets */
147
count = gconf_client_get_int(client, "/apps/gnomeradio/presets/presets", NULL);
148
for (i=0;i<count;i++)
151
ps = malloc(sizeof(preset));
152
buffer = g_strdup_printf("/apps/gnomeradio/presets/%d/name", i);
153
tmp = gconf_client_get_string(client, buffer, NULL);
156
strncpy(ps->name, tmp, 20);
159
buffer = g_strdup_printf("/apps/gnomeradio/presets/%d/freqency", i);
160
freq = gconf_client_get_float(client, buffer, NULL);
161
if ((freq < FREQ_MIN) || (freq > FREQ_MAX))
166
settings.presets = g_list_append(settings.presets, (gpointer)ps);
168
mom_ps = gconf_client_get_int(client, "/apps/gnomeradio/presets/last", NULL);
175
gint backup_settings(void)
180
//g_print("Making a backup of settings\n");
182
tmp_settings.device = g_strdup(settings.device);
183
tmp_settings.mixer = g_strdup(settings.mixer);
184
tmp_settings.mute_on_exit = settings.mute_on_exit;
185
tmp_settings.presets = NULL;
186
for (i=0;i<g_list_length(settings.presets);i++)
188
ps = malloc(sizeof(preset));
189
tmp = g_list_nth_data(settings.presets, i);
190
strcpy(ps->name, tmp->name);
191
ps->freq = tmp->freq;
192
tmp_settings.presets = g_list_append(tmp_settings.presets, (gpointer) ps);
197
gint commit_settings(gpointer app)
203
//g_print("Committing Settings\n");
205
ptr = settings.device;
206
settings.device = tmp_settings.device;
207
if (strcmp(ptr, tmp_settings.device))
208
start_radio(TRUE, app);
210
tmp_settings.device = NULL;
211
ptr = settings.mixer;
212
settings.mixer = tmp_settings.mixer;
213
if (strcmp(ptr, tmp_settings.mixer))
214
start_mixer(TRUE, app);
216
tmp_settings.mixer = NULL;
217
settings.mute_on_exit = tmp_settings.mute_on_exit;
218
for (i=0;i<g_list_length(settings.presets);i++)
220
tmp = g_list_nth_data(settings.presets, i);
223
g_list_free(settings.presets);
224
settings.presets = tmp_settings.presets;
225
tmp_settings.presets = NULL;
231
gint rollback_settings(void)
236
//g_print("Undo Changes\n");
238
g_free(tmp_settings.device);
239
g_free(tmp_settings.mixer);
240
for (i=0;i<g_list_length(tmp_settings.presets);i++)
242
tmp = g_list_nth_data(tmp_settings.presets, i);
245
g_list_free(tmp_settings.presets);
246
tmp_settings.presets = NULL;
252
static void mute_on_exit_toggled_cb(GtkWidget* widget, gpointer data)
254
tmp_settings.mute_on_exit = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mute_on_exit_cb));
257
static gboolean device_entry_focus_out_event_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data)
259
if (tmp_settings.device)
260
g_free(tmp_settings.device);
261
tmp_settings.device = g_strdup(gtk_entry_get_text(GTK_ENTRY(device_entry)));
265
static gboolean mixer_entry_focus_out_event_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data)
268
if (tmp_settings.mixer)
269
g_free(tmp_settings.mixer);
270
tmp_settings.mixer = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(mixer_combo)->entry)));
272
if ((tmp = strstr(tmp_settings.mixer, " (")))
278
static void add_button_clicked_cb(GtkWidget *widget, gpointer data)
281
GtkTreeIter iter = {0};
283
GtkAdjustment *v_scb;
285
text = (char*)gtk_entry_get_text(GTK_ENTRY(name_entry));
292
ps = malloc(sizeof(preset));
293
strcpy(ps->name, text);
294
ps->freq = spin->value;
295
tmp_settings.presets = g_list_append(tmp_settings.presets, (gpointer) ps);
296
buffer = g_strdup_printf("%.2f", spin->value);
298
gtk_list_store_append(list_store, &iter);
299
gtk_list_store_set(list_store, &iter, 0, text, 1, buffer, -1);
301
gtk_entry_set_text(GTK_ENTRY(name_entry), "");
304
gtk_tree_selection_unselect_all(selection);
306
v_scb = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(list_view));
307
gtk_adjustment_set_value(v_scb, v_scb->upper);
311
static void del_button_clicked_cb(GtkWidget *widget, gpointer data)
313
GtkTreePath *path = NULL;
314
GtkTreeViewColumn *focus_column = NULL;
319
gtk_tree_view_get_cursor(GTK_TREE_VIEW(list_view), &path, &focus_column);
323
g_print("\aNo row selected\n");
327
row = gtk_tree_path_get_indices(path);
329
g_assert(*row < g_list_length(tmp_settings.presets));
331
//g_print("path: %s row %d\n", gtk_tree_path_to_string(path), *row);
332
ps = g_list_nth_data(tmp_settings.presets, *row);
334
tmp_settings.presets = g_list_remove(tmp_settings.presets, (gpointer)ps);
337
gtk_tree_model_get_iter(GTK_TREE_MODEL(list_store), &iter, path);
338
gtk_list_store_remove(list_store, &iter);
340
if (!gtk_tree_path_prev(path))
342
gtk_tree_view_set_cursor(GTK_TREE_VIEW(list_view), path, NULL, FALSE);
346
static void update_button_clicked_cb(GtkWidget *widget, gpointer data)
348
GtkTreePath *path = NULL;
349
GtkTreeViewColumn *focus_column = NULL;
355
gtk_tree_view_get_cursor(GTK_TREE_VIEW(list_view), &path, &focus_column);
359
g_print("\aNo row selected\n");
363
row = gtk_tree_path_get_indices(path);
365
g_assert(*row < g_list_length(tmp_settings.presets));
367
text = (char*)gtk_entry_get_text(GTK_ENTRY(name_entry));
373
ps = g_list_nth_data(tmp_settings.presets, *row);
376
strcpy(ps->name, text);
377
ps->freq = spin->value;
378
buffer = g_strdup_printf("%.2f", spin->value);
380
gtk_tree_model_get_iter(GTK_TREE_MODEL(list_store), &iter, path);
381
gtk_list_store_set(list_store, &iter, 0, text, 1, buffer, -1);
386
static gboolean list_view_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
388
if (event->keyval == GDK_Delete)
389
del_button_clicked_cb(widget, user_data);
395
static void freq_spin_activate_cb(void)
397
GtkTreePath *path = NULL;
398
GtkTreeViewColumn *focus_column = NULL;
400
gtk_tree_view_get_cursor(GTK_TREE_VIEW(list_view), &path, &focus_column);
403
add_button_clicked_cb(NULL, NULL);
405
update_button_clicked_cb(NULL, NULL);
408
static gboolean enter_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
410
//g_print("keyval = %d\n", event->keyval);
411
if (event->keyval == GDK_Return)
412
freq_spin_activate_cb();
419
list_view_select_cb(GtkTreeSelection *selection, GtkTreeModel *model,
420
GtkTreePath *path, gboolean path_currently_selected, gpointer data)
426
row = gtk_tree_path_get_indices(path);
428
g_assert(*row < g_list_length(tmp_settings.presets));
429
g_print("row: %d %d\n", *row, path_currently_selected);
430
if (!path_currently_selected)
434
ps = (preset*)g_list_nth_data(tmp_settings.presets, *row);
436
gtk_entry_set_text(GTK_ENTRY(name_entry), text);
437
gtk_adjustment_set_value(spin, ps->freq);
442
list_view_cursor_changed_cb(GtkWidget *widget, gpointer data)
447
GtkTreePath *path = NULL;
448
GtkTreeViewColumn *focus_column = NULL;
450
gtk_tree_view_get_cursor(GTK_TREE_VIEW(list_view), &path, &focus_column);
457
row = gtk_tree_path_get_indices(path);
459
g_assert(*row < g_list_length(tmp_settings.presets));
461
ps = (preset*)g_list_nth_data(tmp_settings.presets, *row);
463
gtk_entry_set_text(GTK_ENTRY(name_entry), text);
464
gtk_adjustment_set_value(spin, ps->freq);
469
static void clist_select_row_cb(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer user_data)
474
g_assert(row < g_list_length(tmp_settings.presets));
477
ps = (preset*)g_list_nth_data(tmp_settings.presets, row);
479
gtk_entry_set_text(GTK_ENTRY(name_entry), text);
480
//freq_entry_set_value(ps->freq);
481
//freq_entry_activate_cb(NULL, NULL);
482
gtk_adjustment_set_value(spin, ps->freq);
485
static void clist_unselect_row_cb(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer user_data)
490
static void spin_value_changed_cb(GtkWidget *widget, gpointer data)
494
value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(freq_spin));
495
gtk_adjustment_set_value(adj, value*STEPS);
497
preset_menu_set_item(mom_ps);
500
GtkWidget* prefs_window(void)
503
GtkWidget *frame1, *frame2;
504
GtkWidget *misc_box, *preset_box, *hbox;
505
GtkWidget *device_label, *device_box;
506
GtkWidget *mixer_label, *mixer_box;
507
GtkWidget *name_label, *freq_label;
508
GtkWidget *button_box, *entry_box, *freq_box;
509
GtkWidget *add_button, *del_button, *update_button;
510
GtkWidget *add_pixmap, *del_pixmap, *update_pixmap;
511
GtkWidget *scrolled_window;
512
GtkWidget *separator;
513
GtkCellRenderer *cellrenderer;
514
GtkTreeViewColumn *list_column;
519
dialog = gtk_dialog_new_with_buttons(_("Gnomeradio Settings"), NULL,
520
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
521
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
522
GTK_STOCK_OK, GTK_RESPONSE_OK,
523
GTK_STOCK_HELP, GTK_RESPONSE_HELP,
526
frame1 = gtk_frame_new(_("Misc Settings"));
527
frame2 = gtk_frame_new(_("Presets"));
528
gtk_container_set_border_width(GTK_CONTAINER(frame1), 5);
529
gtk_container_set_border_width(GTK_CONTAINER(frame2), 5);
531
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame1, TRUE, TRUE, 0);
532
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame2, TRUE, TRUE, 0);
534
misc_box = gtk_vbox_new(FALSE, 6);
535
gtk_container_set_border_width(GTK_CONTAINER(misc_box), 8);
536
gtk_container_add(GTK_CONTAINER(frame1), misc_box);
538
device_box = gtk_hbox_new(FALSE, 10);
539
device_label = gtk_label_new(_("Radio Device:"));
540
gtk_misc_set_alignment(GTK_MISC(device_label), 0.0f, 0.5f);
541
device_entry = gtk_entry_new();
542
gtk_entry_set_text(GTK_ENTRY(device_entry), tmp_settings.device);
543
gtk_box_pack_start(GTK_BOX(device_box), device_label, TRUE, TRUE, 0);
544
gtk_box_pack_start(GTK_BOX(device_box), device_entry, TRUE, TRUE, 0);
546
mixer_box = gtk_hbox_new(FALSE, 10);
547
mixer_label = gtk_label_new(_("Mixer Source:"));
548
gtk_misc_set_alignment(GTK_MISC(mixer_label), 0.0f, 0.5f);
549
mixer_combo = gtk_combo_new();
550
mixer_devs = get_mixer_recdev_list();
553
gtk_combo_set_popdown_strings(GTK_COMBO(mixer_combo), mixer_devs);
554
g_list_foreach(mixer_devs, (GFunc)g_free, NULL);
555
g_list_free(mixer_devs);
557
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(mixer_combo)->entry), tmp_settings.mixer);
558
gtk_box_pack_start(GTK_BOX(mixer_box), mixer_label, TRUE, TRUE, 0);
559
gtk_box_pack_start(GTK_BOX(mixer_box), mixer_combo, TRUE, TRUE, 0);
561
mute_on_exit_cb = gtk_check_button_new_with_label(_("Mute on exit?"));
562
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mute_on_exit_cb), tmp_settings.mute_on_exit);
564
gtk_box_pack_start(GTK_BOX(misc_box), device_box, FALSE, FALSE, 2);
565
gtk_box_pack_start(GTK_BOX(misc_box), mixer_box, FALSE, FALSE, 2);
566
gtk_box_pack_start(GTK_BOX(misc_box), mute_on_exit_cb, FALSE, FALSE, 2);
568
preset_box = gtk_vbox_new(FALSE, 4);
569
hbox = gtk_hbox_new(FALSE, 4);
570
gtk_container_set_border_width(GTK_CONTAINER(hbox), 8);
571
gtk_container_add(GTK_CONTAINER(frame2), hbox);
573
/*scrolled_window = gtk_scrolled_window_new(NULL, NULL);
574
clist = gtk_clist_new(2);
575
gtk_container_add(GTK_CONTAINER(scrolled_window), clist);
576
gtk_widget_set_usize(clist, 50, 80);
577
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
578
gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE);
579
gtk_clist_set_column_width(GTK_CLIST(clist), 0, 120);
580
//gtk_clist_set_column_width(GTK_CLIST(clist), 1, 40);*/
582
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
583
list_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
584
list_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_store));
585
gtk_container_add(GTK_CONTAINER(scrolled_window), list_view);
586
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN);
587
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
588
//gtk_widget_set_usize(list_view, 130, 100);
589
gtk_widget_set_size_request(list_view, 130, 100);
590
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list_view), FALSE);
592
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list_view));
593
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
594
/*gtk_tree_selection_select_path(selection, gtk_tree_path_new_from_string("0"));
595
gtk_tree_selection_set_select_function(selection, (GtkTreeSelectionFunc)list_view_select_cb, NULL, NULL);*/
597
cellrenderer = gtk_cell_renderer_text_new();
598
list_column = gtk_tree_view_column_new_with_attributes(NULL, cellrenderer, "text", 0, NULL);
599
gtk_tree_view_column_set_min_width(list_column, 130);
600
gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), list_column);
601
cellrenderer = gtk_cell_renderer_text_new();
602
list_column = gtk_tree_view_column_new_with_attributes(NULL, cellrenderer, "text", 1, NULL);
603
//gtk_tree_view_column_set_min_width(list_column, 30);
604
gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), list_column);
606
entry_box = gtk_hbox_new(FALSE, 10);
607
button_box = gtk_vbox_new(TRUE, 3);
609
name_label = gtk_label_new(_("Name:"));
610
gtk_misc_set_alignment(GTK_MISC(name_label), 0.0f, 0.5f);
611
name_entry = gtk_entry_new();
612
gtk_entry_set_max_length(GTK_ENTRY(name_entry), 20);
613
//gtk_entry_set_text(GTK_ENTRY(name_entry), UN_NAMED);
614
gtk_editable_set_editable(GTK_EDITABLE(name_entry), TRUE);
616
gtk_box_pack_start(GTK_BOX(entry_box), name_label, TRUE, TRUE, 0);
617
gtk_box_pack_start(GTK_BOX(entry_box), name_entry, TRUE, TRUE, 0);
619
add_pixmap = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON);
620
del_pixmap = gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON);
621
update_pixmap = gtk_image_new_from_stock(GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON);
623
add_button = gtk_button_new();
624
del_button = gtk_button_new();
625
update_button = gtk_button_new();
627
/*add_button = gtk_button_new_from_stock(GTK_STOCK_ADD);
628
del_button = gtk_button_new_from_stock(GTK_STOCK_DELETE);
629
update_button = gtk_button_new_from_stock(GTK_STOCK_REFRESH);*/
632
separator = gtk_hseparator_new();
634
gtk_container_add(GTK_CONTAINER(add_button), add_pixmap);
635
gtk_container_add(GTK_CONTAINER(del_button), del_pixmap);
636
gtk_container_add(GTK_CONTAINER(update_button), update_pixmap);
638
gtk_box_pack_start(GTK_BOX(button_box), add_button, FALSE, FALSE, 0);
639
gtk_box_pack_start(GTK_BOX(button_box), del_button, FALSE, FALSE, 0);
640
gtk_box_pack_start(GTK_BOX(button_box), update_button, FALSE, FALSE, 0);
642
freq_box = gtk_hbox_new(FALSE, 4);
643
freq_label = gtk_label_new(_("Frequency:"));
644
gtk_misc_set_alignment(GTK_MISC(freq_label), 0.0f, 0.5f);
645
/*freq_entry = gtk_entry_new_with_max_length(6);
646
freq_entry_set_value(adj->value/STEPS);
647
gtk_widget_set_usize(freq_entry, 50, 23);
648
freq_spin = my_spin();*/
650
spin = GTK_ADJUSTMENT(gtk_adjustment_new(adj->value/STEPS, FREQ_MIN, FREQ_MAX, 0.05, 1, 1));
651
freq_spin = gtk_spin_button_new(spin, 0.05, 2);
652
gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(freq_spin), TRUE);
653
gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(freq_spin), TRUE);
654
//gtk_widget_set_usize(fgtk_spin_button_get_snap_to_ticksreq_spin, 120, 23);
656
gtk_box_pack_start(GTK_BOX(freq_box), freq_label, TRUE, TRUE, 0);
657
//gtk_box_pack_start(GTK_BOX(freq_box), freq_entry, TRUE, TRUE, 0);
658
gtk_box_pack_start(GTK_BOX(freq_box), freq_spin, TRUE, TRUE, 0);
660
gtk_box_pack_start(GTK_BOX(preset_box), scrolled_window, TRUE, TRUE, 2);
661
gtk_box_pack_start(GTK_BOX(preset_box), separator, TRUE, TRUE, 0);
662
gtk_box_pack_start(GTK_BOX(preset_box), entry_box, TRUE, TRUE, 2);
663
gtk_box_pack_start(GTK_BOX(preset_box), freq_box, TRUE, TRUE, 2);
664
//gtk_box_pack_start(GTK_BOX(preset_box), button_box, TRUE, TRUE, 2);
666
gtk_box_pack_start(GTK_BOX(hbox), preset_box, TRUE, TRUE, 2);
667
gtk_box_pack_start(GTK_BOX(hbox), button_box, TRUE, FALSE, 10);
669
//g_signal_connect(GTK_OBJECT(freq_spin), "button-press-event", GTK_SIGNAL_FUNC(freq_spin_button_press_event_cb), NULL);
670
g_signal_connect(GTK_OBJECT(device_entry), "focus-out-event", GTK_SIGNAL_FUNC(device_entry_focus_out_event_cb), NULL);
671
g_signal_connect(GTK_OBJECT(GTK_COMBO(mixer_combo)->entry), "focus-out-event", GTK_SIGNAL_FUNC(mixer_entry_focus_out_event_cb), NULL);
672
g_signal_connect(GTK_OBJECT(mute_on_exit_cb), "toggled", GTK_SIGNAL_FUNC(mute_on_exit_toggled_cb), NULL);
673
g_signal_connect(GTK_OBJECT(add_button), "clicked", GTK_SIGNAL_FUNC(add_button_clicked_cb), NULL);
674
g_signal_connect(GTK_OBJECT(del_button), "clicked", GTK_SIGNAL_FUNC(del_button_clicked_cb), NULL);
675
g_signal_connect(GTK_OBJECT(update_button), "clicked", GTK_SIGNAL_FUNC(update_button_clicked_cb), NULL);
676
//g_signal_connect(GTK_OBJECT(clist), "select-row", GTK_SIGNAL_FUNC(clist_select_row_cb), NULL);
677
//g_signal_connect(GTK_OBJECT(clist), "unselect-row", GTK_SIGNAL_FUNC(clist_unselect_row_cb), NULL);
678
g_signal_connect(GTK_OBJECT(list_view), "key-press-event", GTK_SIGNAL_FUNC(list_view_key_press_event_cb), NULL);
679
/* FIXME: Does not really work :-( */
680
/*g_signal_connect_after(GTK_OBJECT(freq_spin), "activate", GTK_SIGNAL_FUNC(freq_spin_activate_cb), NULL);
681
g_signal_connect(GTK_OBJECT(name_entry), "key-press-event", GTK_SIGNAL_FUNC(enter_key_press_event_cb), NULL);*/
682
g_signal_connect(GTK_OBJECT(spin), "value-changed", GTK_SIGNAL_FUNC(spin_value_changed_cb), NULL);
683
g_signal_connect(GTK_OBJECT(list_view), "cursor-changed", GTK_SIGNAL_FUNC(list_view_cursor_changed_cb), NULL);
686
for (i=0;i<g_list_length(tmp_settings.presets);i++)
688
GtkTreeIter iter = {0};
690
ps = g_list_nth_data(tmp_settings.presets, i);
691
buffer = g_strdup_printf("%0.2f", ps->freq);
692
gtk_list_store_append(list_store, &iter);
693
gtk_list_store_set(list_store, &iter, 0, ps->name, 1, buffer, -1);
697
gtk_tooltips_set_tip(tooltips, device_entry, _("Specify the radio-device (in most cases /dev/radio)"), NULL);
698
gtk_tooltips_set_tip(tooltips, GTK_COMBO(mixer_combo)->entry,
699
_("Choose the mixer source (line, line1, etc.) that is able to control the volume of your radio"), NULL);
700
gtk_tooltips_set_tip(tooltips, mute_on_exit_cb, _("If unchecked, gnomeradio won't mute after exiting"), NULL);
701
gtk_tooltips_set_tip(tooltips, add_button, _("Add a new preset"), NULL);
702
gtk_tooltips_set_tip(tooltips, del_button, _("Remove preset from List"), NULL);
703
gtk_tooltips_set_tip(tooltips, update_button, _("Update the preset in the List"), NULL);
705
gtk_widget_show_all(dialog);