35
36
#include "../pixmaps/digits.xpm"
36
37
#include "../pixmaps/signal.xpm"
37
38
#include "../pixmaps/stereo.xpm"
38
#include "../pixmaps/vol_up.xpm"
39
#include "../pixmaps/vol_down.xpm"
40
39
#include "../pixmaps/freq_up.xpm"
41
40
#include "../pixmaps/freq_down.xpm"
42
41
#include "../pixmaps/radio.xpm"
52
51
static GtkWidget *drawing_area;
53
52
static GdkPixmap *digits, *signal_s, *stereo;
54
static GtkWidget *freq_scale, *vol_scale;
53
static GtkWidget *freq_scale;
54
static GtkWidget *rec_pixmap;
56
56
static int timeout_id, bp_timeout_id = -1, bp_timeout_steps = 0;
57
static int mute_button_toggled_cb_id;
59
58
static gboolean is_first_start(void)
263
262
vol = mixer_get_volume();
265
gtk_adjustment_set_value(volume, (double)vol);
264
bacon_volume_button_set_value(BACON_VOLUME_BUTTON(mute_button), vol);
265
/*gtk_adjustment_set_value(volume, (double)vol);*/
407
407
radio_setfreq(adj->value/STEPS);
410
static void volume_value_changed_cb(GtkAdjustment* data, gpointer window)
410
static void volume_value_changed_cb(BaconVolumeButton *button, gpointer user_data)
413
int vol = (int)volume->value;
413
int vol = (int)(bacon_volume_button_get_value(BACON_VOLUME_BUTTON(mute_button)) + 0.5f);
415
415
mixer_set_volume(vol);
417
text = g_strdup_printf(_("Volume: %d%%"), vol);
417
/* text = g_strdup_printf(_("Volume: %d%%"), vol);
418
418
gtk_tooltips_set_tip(tooltips, vol_scale, text, NULL);
422
422
g_signal_handler_block(G_OBJECT(mute_menuitem), mute_menuitem_toggled_cb_id);
423
423
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mute_menuitem), vol == 0);
424
424
g_signal_handler_unblock(G_OBJECT(mute_menuitem), mute_menuitem_toggled_cb_id);
426
g_signal_handler_block(G_OBJECT(mute_button), mute_button_toggled_cb_id);
427
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mute_button), vol == 0);
428
g_signal_handler_unblock(G_OBJECT(mute_button), mute_button_toggled_cb_id);
701
698
mixer_set_volume(vol);
702
gtk_adjustment_set_value(volume, vol);
699
bacon_volume_button_set_value(BACON_VOLUME_BUTTON(mute_button), vol);
700
/*gtk_adjustment_set_value(volume, vol);*/
705
703
static void mute_button_toggled_cb(GtkButton *button, gpointer data)
790
788
gtk_window_present(GTK_WINDOW(app));
794
792
GtkWidget* gnome_radio_gui(void)
797
795
GtkWidget *prefs_button, *quit_button, *scfw_button, *scbw_button;
798
796
GtkWidget *stfw_button, *stbw_button, *about_button, *rec_button;
799
797
GtkWidget *prefs_pixmap, *quit_pixmap, *scfw_pixmap, *scbw_pixmap;
800
GtkWidget *stfw_pixmap, *stbw_pixmap, *about_pixmap, *mute_pixmap, *rec_pixmap;
798
GtkWidget *stfw_pixmap, *stbw_pixmap, *about_pixmap;
801
799
GtkWidget *vol_up_pixmap, *vol_down_pixmap, *freq_up_pixmap, *freq_down_pixmap;
802
800
GdkPixbuf *vol_up_pixbuf, *vol_down_pixbuf, *freq_up_pixbuf, *freq_down_pixbuf;
803
801
GtkWidget *hbox1, *hbox2, *vbox, *menubox, *freq_vol_box;
804
GtkWidget *vseparator1, *vseparator2, *vseparator3, *vseparator4;
802
GtkWidget *vseparator1, *vseparator2, *vseparator4;
805
803
GtkWidget *label;
806
804
GtkWidget *frame;
821
819
stfw_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_NEXT, GTK_ICON_SIZE_LARGE_TOOLBAR);
822
820
stbw_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PREVIOUS, GTK_ICON_SIZE_LARGE_TOOLBAR);
823
821
about_pixmap = gtk_image_new_from_stock(GTK_STOCK_ABOUT, GTK_ICON_SIZE_LARGE_TOOLBAR);
824
mute_pixmap = gtk_image_new_from_stock(GNOME_STOCK_VOLUME, GTK_ICON_SIZE_LARGE_TOOLBAR);
822
/*mute_pixmap = gtk_image_new_from_stock(GNOME_STOCK_VOLUME, GTK_ICON_SIZE_LARGE_TOOLBAR);*/
825
823
rec_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_RECORD, GTK_ICON_SIZE_LARGE_TOOLBAR);
826
824
/*help_pixmap = gtk_image_new_from_stock(GTK_STOCK_HELP, GTK_ICON_SIZE_LARGE_TOOLBAR);*/
832
830
stfw_button = gtk_button_new();
833
831
stbw_button = gtk_button_new();
834
832
about_button = gtk_button_new();
835
mute_button = gtk_toggle_button_new();
833
/*mute_button = gtk_toggle_button_new();*/
834
mute_button = bacon_volume_button_new(GTK_ICON_SIZE_LARGE_TOOLBAR, 0, 100, 1);
835
gtk_button_set_relief(GTK_BUTTON(mute_button), GTK_RELIEF_NORMAL);
836
836
rec_button = gtk_button_new();
837
837
/*help_button = gtk_button_new();*/
843
843
gtk_container_add(GTK_CONTAINER(stfw_button), stfw_pixmap);
844
844
gtk_container_add(GTK_CONTAINER(stbw_button), stbw_pixmap);
845
845
gtk_container_add(GTK_CONTAINER(about_button), about_pixmap);
846
gtk_container_add(GTK_CONTAINER(mute_button), mute_pixmap);
846
/*gtk_container_add(GTK_CONTAINER(mute_button), mute_pixmap);*/
847
847
gtk_container_add(GTK_CONTAINER(rec_button), rec_pixmap);
848
848
/*gtk_container_add(GTK_CONTAINER(help_button), help_pixmap);*/
854
854
freq_vol_box = gtk_hbox_new(FALSE, 0);
856
856
adj = GTK_ADJUSTMENT(gtk_adjustment_new(SUNSHINE*STEPS, FREQ_MIN*STEPS, FREQ_MAX*STEPS+1, 1, STEPS, 1));
857
volume = GTK_ADJUSTMENT(gtk_adjustment_new(100, 0, 101, 1, 10, 1));
857
/* volume = GTK_ADJUSTMENT(gtk_adjustment_new(100, 0, 101, 1, 10, 1)); */
859
859
preset_combo = gtk_combo_box_new_text();
860
860
g_signal_connect(GTK_OBJECT(preset_combo), "changed", GTK_SIGNAL_FUNC(preset_combo_change_cb), NULL);
865
865
freq_scale = gtk_hscale_new(adj);
866
866
/*gtk_range_set_update_policy(GTK_RANGE(freq_scale), GTK_UPDATE_DELAYED);*/
867
vol_scale = gtk_hscale_new(volume);
867
/*vol_scale = gtk_hscale_new(volume);*/
869
vol_up_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)vol_up_xpm);
870
vol_down_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)vol_down_xpm);
869
/*vol_up_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)vol_up_xpm);
870
vol_down_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)vol_down_xpm);*/
871
871
freq_up_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)freq_up_xpm);
872
872
freq_down_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)freq_down_xpm);
874
vol_up_pixmap = gtk_image_new_from_pixbuf(vol_up_pixbuf);
875
vol_down_pixmap = gtk_image_new_from_pixbuf(vol_down_pixbuf);
874
/*vol_up_pixmap = gtk_image_new_from_pixbuf(vol_up_pixbuf);
875
vol_down_pixmap = gtk_image_new_from_pixbuf(vol_down_pixbuf);*/
876
876
freq_up_pixmap = gtk_image_new_from_pixbuf(freq_up_pixbuf);
877
877
freq_down_pixmap = gtk_image_new_from_pixbuf(freq_down_pixbuf);
879
879
/*gtk_widget_set_usize(freq_scale, 160, 10);*/
880
gtk_widget_set_size_request(freq_scale, 160, -1);
880
/*gtk_widget_set_size_request(freq_scale, 160, -1);*/
882
882
gtk_widget_realize(app);
883
883
drawing_area = gtk_drawing_area_new();
888
888
vseparator1 = gtk_vseparator_new();
889
889
vseparator2 = gtk_vseparator_new();
890
vseparator3 = gtk_vseparator_new();
890
/*vseparator3 = gtk_vseparator_new();*/
891
891
vseparator4 = gtk_vseparator_new();
893
893
gtk_scale_set_digits(GTK_SCALE(freq_scale), 0);
894
894
gtk_scale_set_draw_value(GTK_SCALE(freq_scale), FALSE);
895
gtk_scale_set_digits(GTK_SCALE(vol_scale), 0);
895
/* gtk_scale_set_digits(GTK_SCALE(vol_scale), 0);
896
896
gtk_scale_set_draw_value(GTK_SCALE(vol_scale), FALSE);
898
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mute_button), mixer_get_volume() == 0);
898
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mute_button), mixer_get_volume() == 0);*/
900
900
gtk_widget_set_size_request(drawing_area, DIGIT_WIDTH*6+10+SIGNAL_WIDTH+STEREO_WIDTH, DIGIT_HEIGTH+10);
922
922
gtk_box_pack_start(GTK_BOX(menubox), preset_combo, TRUE, TRUE, 0);
924
924
gtk_box_pack_start(GTK_BOX(freq_vol_box), freq_down_pixmap, FALSE, FALSE, 2);
925
gtk_box_pack_start(GTK_BOX(freq_vol_box), freq_scale, FALSE, FALSE, 0);
925
gtk_box_pack_start(GTK_BOX(freq_vol_box), freq_scale, TRUE, TRUE, 0);
926
926
gtk_box_pack_start(GTK_BOX(freq_vol_box), freq_up_pixmap, FALSE, FALSE, 2);
927
gtk_box_pack_start(GTK_BOX(freq_vol_box), vseparator3, FALSE, FALSE, 2);
927
/*gtk_box_pack_start(GTK_BOX(freq_vol_box), vseparator3, FALSE, FALSE, 2);
928
928
gtk_box_pack_start(GTK_BOX(freq_vol_box), vol_down_pixmap, FALSE, FALSE, 2);
929
929
gtk_box_pack_start(GTK_BOX(freq_vol_box), vol_scale, TRUE, TRUE, 0);
930
gtk_box_pack_start(GTK_BOX(freq_vol_box), vol_up_pixmap, FALSE, FALSE, 2);
930
gtk_box_pack_start(GTK_BOX(freq_vol_box), vol_up_pixmap, FALSE, FALSE, 2);*/
932
932
gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 4);
933
933
gtk_box_pack_start(GTK_BOX(vbox), freq_vol_box, TRUE, TRUE, 2);
949
949
g_signal_connect(GTK_OBJECT(app), "delete_event", GTK_SIGNAL_FUNC(delete_event_cb), NULL);
950
950
g_signal_connect(GTK_OBJECT(quit_button), "clicked", GTK_SIGNAL_FUNC(quit_button_clicked_cb), NULL);
951
951
g_signal_connect(GTK_OBJECT(adj), "value-changed", GTK_SIGNAL_FUNC(adj_value_changed_cb), (gpointer) app);
952
g_signal_connect(GTK_OBJECT(volume), "value-changed", GTK_SIGNAL_FUNC(volume_value_changed_cb), NULL);
952
g_signal_connect(GTK_OBJECT(mute_button), "value-changed", GTK_SIGNAL_FUNC(volume_value_changed_cb), NULL);
953
953
g_signal_connect(GTK_OBJECT(stfw_button), "pressed", GTK_SIGNAL_FUNC(step_button_pressed_cb), (gpointer)TRUE);
954
954
g_signal_connect(GTK_OBJECT(stbw_button), "pressed", GTK_SIGNAL_FUNC(step_button_pressed_cb), (gpointer)FALSE);
955
955
g_signal_connect(GTK_OBJECT(stfw_button), "clicked", GTK_SIGNAL_FUNC(step_button_clicked_cb), (gpointer)TRUE);
959
959
g_signal_connect(GTK_OBJECT(scfw_button), "clicked", GTK_SIGNAL_FUNC(scfw_button_clicked_cb), NULL);
960
960
g_signal_connect(GTK_OBJECT(scbw_button), "clicked", GTK_SIGNAL_FUNC(scbw_button_clicked_cb), NULL);
961
961
g_signal_connect(GTK_OBJECT(about_button), "clicked", GTK_SIGNAL_FUNC(about_button_clicked_cb), NULL);
962
mute_button_toggled_cb_id =
963
g_signal_connect(GTK_OBJECT(mute_button), "toggled", GTK_SIGNAL_FUNC(mute_button_toggled_cb), NULL);
964
962
g_signal_connect(GTK_OBJECT(rec_button), "clicked", GTK_SIGNAL_FUNC(rec_button_clicked_cb), (gpointer) app);
965
963
g_signal_connect(GTK_OBJECT(prefs_button), "clicked", GTK_SIGNAL_FUNC(prefs_button_clicked_cb), (gpointer) app);
966
964
g_signal_connect(GTK_OBJECT(drawing_area), "expose-event", GTK_SIGNAL_FUNC(expose_event_cb), NULL);
977
975
text = g_strdup_printf(_("Frequency: %.2f MHz"), adj->value/STEPS);
978
976
gtk_tooltips_set_tip(tooltips, freq_scale, text, NULL);
980
text = g_strdup_printf(_("Volume: %d%%"), (gint)volume->value);
978
/* text = g_strdup_printf(_("Volume: %d%%"), (gint)volume->value);
981
979
gtk_tooltips_set_tip(tooltips, vol_scale, text, NULL);
1017
1015
GtkToggleButton *tb = GTK_TOGGLE_BUTTON(mute_button);
1018
1016
gboolean state = gtk_toggle_button_get_active(tb);
1019
1017
/*g_print("%s key pressed: %d\n", gdk_keyval_name(event->keyval), event->keyval);*/
1019
int vol = (int)(bacon_volume_button_get_value(BACON_VOLUME_BUTTON(mute_button)) + 0.5f);
1021
1021
switch (event->keyval)
1046
1046
case GDK_KP_Add:
1048
gtk_adjustment_set_value(volume, (volume->value > 95) ? 100 : volume->value+5);
1048
bacon_volume_button_set_value(BACON_VOLUME_BUTTON(mute_button), vol > 95 ? 100 : vol + 5);
1049
/*gtk_adjustment_set_value(volume, (volume->value > 95) ? 100 : volume->value+5);*/
1050
1051
case GDK_minus:
1051
1052
case GDK_KP_Subtract:
1052
gtk_adjustment_set_value(volume,(volume->value < 5) ? 0 : volume->value-5);
1053
bacon_volume_button_set_value(BACON_VOLUME_BUTTON(mute_button), vol < 5 ? 0 : vol - 5);
1054
/*gtk_adjustment_set_value(volume,(volume->value < 5) ? 0 : volume->value-5);*/