24
24
static gchar *info_text[] = {
25
"<b>GKrellM Radio Plugin\n\n",
26
"This plugin allow you to control the radio card of your Linux box,\
27
if you have one installed.\n",
28
"<b>\nUser Interface:\n",
29
"\n\t* Clicking the right button will turn the radio on and off.\n",
30
"\t* Clicking the left text will tune to the next channel configured",
31
" under configuration.\n"
32
"\t* Using your mousewheel will tune up or down.\n",
33
"\t*Right mouse button will pop up a channel menu\n",
35
"\n\tLars Christensen - Upstream author untill version 0.2.1\n",
36
"\tGerd Knorr - borrowed some of the radio interface code from his Xawtv",
37
" radio application.\n",
25
N_("<b>GKrellM Radio Plugin\n\n"),
26
N_("This plugin allow you to control the radio card of your Linux box," \
27
"if you have one installed.\n"),
28
N_("<b>\nUser Interface:\n"),
29
N_("\n\t* Clicking the right button will turn the radio on and off.\n"),
30
N_("\t* Clicking the left text will tune to the next channel configured" \
31
" under configuration.\n"),
32
N_("\t* Using your mousewheel will tune up or down.\n"),
33
N_("\t*Right mouse button will pop up a channel menu\n"),
34
N_("<b>\nThanks to:\n"),
35
N_("\n\tLars Christensen - Upstream author untill version 0.2.1\n" \
36
"\tGerd Knorr - borrowed some of the radio interface code from his Xawtv" \
37
" radio application.\n"),
38
N_("<b>\nHomepage:\n"),
39
39
"\n\thttp://gkrellm.luon.net/gkrellm-radio.phtml\n"
43
static Monitor *plugin_monitor;
45
static Decal *station_text, *decal_onoff_pix;
47
DecalButton *onoff_button;
42
static GkrellmPanel *panel;
43
static GkrellmMonitor *plugin_monitor;
45
static GkrellmDecal *station_text, *decal_onoff_pix;
47
GkrellmDecalbutton *onoff_button;
49
49
static gint style_id;
114
114
do_switch_station(int nr) {
115
gchar *text_utf8 = NULL, *text_locale = NULL;
116
117
currentstation = nr;
117
118
start_mute_timer();
118
119
radio_tune(stations[nr].freq);
120
gkrellm_locale_dup_string(&text_utf8, stations[nr].station_name, &text_locale);
119
121
gkrellm_draw_decal_text(panel, station_text,
120
stations[nr].station_name, -1);
121
gkrellm_draw_layers_force(panel);
123
gkrellm_draw_panel_layers(panel);
124
126
static void exit_func(void) {
172
178
imgid = D_MISC_BUTTON_OUT;
173
179
gkrellm_set_decal_button_index(onoff_button, imgid);
180
gkrellm_draw_panel_layers(panel);
176
183
void reopen_radio() {
177
184
if (!attempt_reopen) return;
179
186
if (open_radio() != -1) {
180
if (radio_ismute()) {
182
onoff_state = 0; /* off */
184
187
start_mute_timer();
188
radio_tune(current_freq());
189
set_text_freq(current_freq());
185
190
onoff_state = 1; /* on */
188
192
set_onoff_button(onoff_state);
191
195
void gkrellm_radio_turn_onoff(void) {
192
onoff_state = !onoff_state;
194
197
if (open_radio() == -1) {
195
gkrellm_message_window("GKrellM error",
196
"GKrellM radio plugin couldn't open /dev/radio", NULL);
198
gkrellm_message_window("GKrellM radio plugin",
199
_("Couldn't open /dev/radio"), NULL);
198
201
/* radio was opened */
202
onoff_state = 1; /* on */
199
203
start_mute_timer();
200
204
radio_tune(current_freq());
201
205
set_text_freq(current_freq());
202
206
set_onoff_button(onoff_state);
209
onoff_state = 0; /* off */
205
210
set_onoff_button(onoff_state);
211
cb_button(DecalButton *button)
216
cb_button(GkrellmDecalbutton *button)
213
218
if (GPOINTER_TO_INT(button->data) == 1) { switch_station(); }
214
219
if (GPOINTER_TO_INT(button->data) == 2) { gkrellm_radio_turn_onoff(); }
217
222
static void set_text_freq(float freq) {
218
gkrellm_draw_decal_text(panel, station_text, station_name(freq), -1);
219
gkrellm_draw_layers_force(panel);
223
gchar *text_utf8 = NULL, *text_locale = NULL;
224
gkrellm_locale_dup_string(&text_utf8, station_name(freq), &text_locale);
225
gkrellm_draw_decal_text(panel, station_text, text_locale, -1);
226
gkrellm_draw_panel_layers(panel);
223
panel_expose_event(GtkWidget *widget, GdkEventExpose *ev)
230
panel_expose_event(GtkWidget *widget, GdkEventExpose *ev) {
225
231
gdk_draw_pixmap(widget->window,
226
232
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
227
233
panel->pixmap, ev->area.x, ev->area.y, ev->area.x, ev->area.y,
239
245
button_release_event(GtkWidget *widget, GdkEventButton *ev, void *N) {
241
switch (ev->button) {
243
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
244
ev->state, ev->time);
247
gkrellm_radio_finetune_delta(+0.05);
250
gkrellm_radio_finetune_delta(-0.05);
247
if (ev->button == 3) {
248
if (menu == NULL) gkrellm_message_window("GKrellM radio plugin",
249
_("Please setup some channels in the configuration"),NULL);
250
else gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
251
ev->state, ev->time);
259
gkrellm_draw_layers(panel);
256
static gint scroll_event(GtkWidget *widget,GdkEventScroll *ev,gpointer data) {
257
float delta = ev->direction == GDK_SCROLL_UP ? 0.05 : -0.05;
258
gkrellm_radio_finetune_delta(delta);
263
263
create_plugin(GtkWidget *vbox, gint first_create) {
265
TextStyle *ts, *ts_alt;
265
GkrellmTextstyle *ts, *ts_alt;
266
GkrellmMargin *margin;
266
267
GdkPixmap *pixmap;
271
gchar *text_utf8 = NULL, *text_locale = NULL;
271
273
if (first_create) {
272
274
panel = gkrellm_panel_new0();
289
291
panel->textstyle = ts; /* would be used for a panel label */
291
293
y = 2; /* some border */
292
station_text = gkrellm_create_decal_text(panel, "Hello World", ts_alt, style, 2, y, 40);
294
station_text = gkrellm_create_decal_text(panel, _("Hello World"), ts_alt, style, 2, y, 40);
294
296
/* Create a pixmap decal and place it to the right of station_text. Use
295
297
| decals from the builtin decal_misc.xpm.
304
306
/* Configure the panel to hold the above created decals, add in a little
305
307
| bottom margin for looks, and create the panel.
307
gkrellm_configure_panel(panel, NULL, style);
308
panel->label->h_panel += 2; /* Some bottom margin */
309
gkrellm_create_panel(vbox, panel, gkrellm_bg_meter_image(style_id));
310
gkrellm_monitor_height_adjust(panel->h);
309
gkrellm_panel_configure(panel, NULL, style);
310
gkrellm_panel_create(vbox, plugin_monitor,panel);
312
312
/* After the panel is created, the decals can be converted into buttons.
313
313
| First draw the initial text into the text decal button and then
316
316
| decal. Just pass the frame we want to be the out image and the
317
317
| frame for the in or pressed image.
319
gkrellm_draw_decal_text(panel, station_text, station_name(current_freq()),
319
gkrellm_locale_dup_string(&text_utf8, station_name(current_freq()), &text_locale);
320
gkrellm_draw_decal_text(panel, station_text, text_locale,
323
margin = gkrellm_get_style_margins(style);
322
324
gkrellm_put_decal_in_meter_button(panel, station_text, cb_button,
325
GINT_TO_POINTER(1),margin);
325
327
gkrellm_make_decal_button(panel, decal_onoff_pix, cb_button,
326
328
GINT_TO_POINTER(2),
336
338
if (first_create) {
337
gtk_signal_connect(GTK_OBJECT (panel->drawing_area), "expose_event",
339
g_signal_connect(GTK_OBJECT (panel->drawing_area), "expose_event",
338
340
(GtkSignalFunc) panel_expose_event, NULL);
339
gtk_signal_connect(GTK_OBJECT (panel->drawing_area), "button_release_event",
341
g_signal_connect(GTK_OBJECT (panel->drawing_area), "button_release_event",
340
342
GTK_SIGNAL_FUNC(button_release_event), NULL);
343
g_signal_connect(GTK_OBJECT (panel->drawing_area), "scroll_event",
344
GTK_SIGNAL_FUNC(scroll_event), NULL);
348
gkrellm_draw_panel_layers(panel);
346
351
static GtkWidget *gui_station_list = NULL;
401
406
table = gtk_table_new(2, 2, 0);
403
label = gtk_label_new("Station Name:");
408
label = gtk_label_new(_("Station Name:"));
404
409
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_EXPAND, GTK_FILL, 4, 4);
406
411
gui_station_name_input = gtk_entry_new();
407
412
gtk_table_attach(GTK_TABLE(table), gui_station_name_input, 1, 2, 0, 1, GTK_EXPAND, GTK_FILL, 4, 4);
409
label = gtk_label_new("Frequency:");
414
label = gtk_label_new(_("Frequency:"));
410
415
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_EXPAND, GTK_FILL, 4, 4);
412
417
adj = gtk_adjustment_new(current_freq(), 0.05, 999.99, 0.05, 1, 1);
494
499
GtkWidget *text, *label, *panel, *button, *hbox, *scrolled, *frame, *vbox;
496
501
gchar *plugin_about_text;
497
gchar *station_tab_titles[3] = { "Station", "Frequency", "" };
502
gchar *station_tab_titles[3] = { _("Station"), _("Frequency"), "" };
540
545
hbox = gtk_hbox_new(0, 0);
542
button = gtk_button_new_with_label("New");
547
button = gtk_button_new_with_label(_("New"));
543
548
gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)gui_new_station, NULL);
545
550
gtk_box_pack_start(GTK_BOX(hbox), button, 0, 0, 2);
546
button = gtk_button_new_with_label("Edit");
551
button = gtk_button_new_with_label(_("Edit"));
547
552
gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)gui_edit_station, NULL);
549
554
gtk_box_pack_start(GTK_BOX(hbox), button, 0, 0, 2);
550
button = gtk_button_new_with_label("Delete");
555
button = gtk_button_new_with_label(_("Delete"));
551
556
gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)gui_delete_station, NULL);
553
558
gtk_box_pack_start(GTK_BOX(hbox), button, 0, 0, 2);
554
button = gtk_button_new_with_label("Up");
559
button = gtk_button_new_with_label(_("Up"));
555
560
gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)gui_moveup_station, NULL);
557
562
gtk_box_pack_start(GTK_BOX(hbox), button, 0, 0, 2);
559
button = gtk_button_new_with_label("Down");
564
button = gtk_button_new_with_label(_("Down"));
560
565
gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)gui_movedown_station, NULL);
561
566
gtk_box_pack_start(GTK_BOX(hbox), button, 0, 0, 2);
563
label = gtk_label_new("Stations");
568
label = gtk_label_new(_("Stations"));
565
570
gtk_box_pack_start(GTK_BOX(panel), hbox, FALSE, FALSE, 4);
577
582
hbox = gtk_hbox_new(0, 0);
578
583
gtk_box_pack_start(GTK_BOX(vbox), hbox, 0, 0, 2);
580
label = gtk_label_new("Time to mute on channel jump (seconds):");
585
label = gtk_label_new(_("Time to mute on channel jump (seconds):"));
581
586
gtk_box_pack_start(GTK_BOX(hbox), label, 0, 0, 2);
583
588
adj = gtk_adjustment_new(mutetime, 0.0, 9.99, 0.01, 0.1, 1);
590
595
/* reopenoption */ {
592
gui_reopen_toggle = gtk_check_button_new_with_label("Attempt to reopen radio on startup");
597
gui_reopen_toggle = gtk_check_button_new_with_label(_("Attempt to reopen radio on startup"));
593
598
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui_reopen_toggle), attempt_reopen);
594
599
gtk_box_pack_start(GTK_BOX(vbox), gui_reopen_toggle, 0, 0, 2);
595
600
/* close radio on exit toggle */
596
601
gui_close_toggle =
597
gtk_check_button_new_with_label("Turn radio off when exiting gkrellm");
602
gtk_check_button_new_with_label(_("Turn radio off when exiting gkrellm"));
598
603
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui_close_toggle),
600
605
gtk_box_pack_start(GTK_BOX(vbox), gui_close_toggle, 0, 0, 2);
604
label = gtk_label_new("Options");
609
label = gtk_label_new(_("Options"));
605
610
gtk_notebook_append_page(GTK_NOTEBOOK(tabs), vbox, label);
609
614
frame = gtk_frame_new(NULL);
610
gtk_container_border_width(GTK_CONTAINER(frame), 3);
611
scrolled = gtk_scrolled_window_new(NULL, NULL);
612
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
613
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
614
gtk_container_add(GTK_CONTAINER(frame), scrolled);
615
label = gtk_label_new("Info");
616
gtk_notebook_append_page(GTK_NOTEBOOK(tabs), frame, label);
618
text = gtk_text_new(NULL, NULL);
619
gtk_text_set_editable(GTK_TEXT(text), FALSE);
621
gkrellm_add_info_text(text,info_text,sizeof(info_text)/sizeof(gchar *));
622
gtk_container_add(GTK_CONTAINER(scrolled), text);
615
scrolled = gkrellm_gtk_notebook_page(tabs,_("Info"));
616
text = gkrellm_gtk_scrolled_text_view(scrolled,NULL,
617
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
619
for (i=0; i < sizeof(info_text)/sizeof(gchar *); ++i)
620
gkrellm_gtk_text_view_append(text, _(info_text[i]));
626
623
plugin_about_text = g_strdup_printf(
627
"Radio Plugin " VERSION "\n" \
624
_("Radio Plugin %s\n" \
628
625
"GKrellM radio Plugin\n\n" \
629
626
"Copyright (C) 2001-2002 Sjoerd Simons\n" \
630
627
"sjoerd@luon.net\n" \
631
628
"http://gkrellm.luon.net/gkrellm-radio.phtml\n\n" \
632
"Released under the GNU General Public Licence");
629
"Released under the GNU General Public Licence"), VERSION);
634
631
text = gtk_label_new(plugin_about_text);
635
label = gtk_label_new("About");
632
label = gtk_label_new(_("About"));
636
633
gtk_notebook_append_page(GTK_NOTEBOOK(tabs),text,label);
637
634
g_free(plugin_about_text);
729
726
/* The monitor structure tells GKrellM how to call the plugin routines.
731
static Monitor plugin_mon =
728
static GkrellmMonitor plugin_mon =
733
730
CONFIG_NAME, /* Name, for config tab. */
734
731
0, /* Id, 0 if a plugin */
735
732
create_plugin, /* The create function */
736
update_plugin, /* The update function */
733
NULL, /* The update function */
737
734
create_config, /* The config tab create function */
738
735
apply_config, /* Apply the config function */