~blackskad/gnomeradio/dev-vol-button

2 by mfcn
Initial revision
1
/* gui.c
2
 *
3
 * Copyright (C) 2001 Jörgen Scheibengruber
4
 *
5
 * This program is free software; you can redistribute it and/or 
6
 * modify it under the terms of the GNU General Public License as 
7
 * published by the Free Software Foundation; either version 2 of the
8
 * License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18
 * USA
19
 */
20
21
/*** the gui to gnomeradio */
22
23
#include <config.h>
24
#include <gnome.h>
25
#include <gconf/gconf-client.h>
26
#include <math.h>
27
#include "gui.h"
121 by mfcn
* po/POTFILES.in, src/Makefile.am, trayicon.*, gui.*, prefs.c:
28
#include "trayicon.h"
2 by mfcn
Initial revision
29
#include "tech.h"
191 by mfcn
* data/gnomeradio.schemas.in:
30
#include "radio.h"
2 by mfcn
Initial revision
31
#include "rec_tech.h"
32
#include "lirc.h"
33
#include "prefs.h"
34
#include "record.h"
146 by mfcn
* .cvsignore:
35
#include "../data/pixmaps/digits.xpm"
36
#include "../data/pixmaps/signal.xpm"
37
#include "../data/pixmaps/stereo.xpm"
38
#include "../data/pixmaps/freq_up.xpm"
39
#include "../data/pixmaps/freq_down.xpm"
2 by mfcn
Initial revision
40
41
#define DIGIT_WIDTH 20
42
#define DIGIT_HEIGTH 30
43
#define SIGNAL_WIDTH 25
44
#define STEREO_WIDTH 35
45
#define SCAN_SPEED 20
46
47
#define TRANSLATORS "TRANSLATORS"
48
183 by mfcn
* help/C/gnomeradio.xml:
49
GtkWidget* mute_button, *preset_combo;
50
GtkAdjustment *adj;
51
GtkTooltips *tooltips;
52
53
int mom_ps;
54
gnomeradio_settings settings;
55
204 by mfcn
* src/gui.c (main):
56
gboolean main_visible;
57
2 by mfcn
Initial revision
58
static GtkWidget *drawing_area;
59
static GdkPixmap *digits, *signal_s, *stereo;
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
60
static GtkWidget *freq_scale;
61
static GtkWidget *rec_pixmap;
25 by mfcn
Added a system tray icon
62
2 by mfcn
Initial revision
63
static int timeout_id, bp_timeout_id = -1, bp_timeout_steps = 0;
64
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
65
static gboolean is_first_start(void)
66
{
67
	GConfClient *client = gconf_client_get_default();
68
	if (!client)
69
		return TRUE;
70
71
	return !gconf_client_get_bool(client, "/apps/gnomeradio/first_time_flag", NULL);
72
}
73
74
static void set_first_time_flag(void)
75
{
76
	GConfClient *client = gconf_client_get_default();
77
	if (!client)
78
		return;
79
80
	gconf_client_set_bool(client, "/apps/gnomeradio/first_time_flag", TRUE, NULL);
81
}
82
83
typedef struct {
84
	GtkWidget *dialog;
85
	GtkWidget *progress;
86
	GList *stations;
87
	GtkWidget *label;
88
} FreqScanData;
89
90
static gboolean initial_frequency_scan_cb(gpointer data)
91
{
92
	static gfloat freq = FREQ_MIN - 4.0f/STEPS;
93
	FreqScanData *fsd = data;
94
	
95
	g_assert(fsd);
96
	
97
	if (freq > FREQ_MAX) {
98
		gtk_widget_destroy(fsd->dialog);
99
		timeout_id = 0;
100
		return FALSE;
101
	}
102
	
103
	if (radio_check_station(freq)) {
104
		char *text = g_strdup_printf(_("%d stations found"), g_list_length(fsd->stations) + 1);
105
		gfloat *f = g_malloc(sizeof(gfloat));
106
		gtk_label_set_text(GTK_LABEL(fsd->label), text);
107
		g_free(text);
108
		
109
		g_print("%.2f is a station\n", freq);
110
		
111
		*f = freq;
112
		fsd->stations = g_list_append(fsd->stations, f);
113
	}
114
115
	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(fsd->progress), MAX(0, (freq - FREQ_MIN)/(FREQ_MAX - FREQ_MIN)));	
116
	
117
	freq += 1.0/STEPS;
191 by mfcn
* data/gnomeradio.schemas.in:
118
	radio_set_freq(freq);
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
119
	
120
	return TRUE;
121
}
122
123
static void initial_frequency_scan(GtkWidget *app)
124
{
125
	FreqScanData data;
126
	GtkWidget *title;
127
	char *title_hdr;
128
	
129
	data.stations = NULL;
130
	
131
	data.dialog = gtk_dialog_new_with_buttons(_("Scanning"),
132
		GTK_WINDOW(app), DIALOG_FLAGS, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
133
	gtk_dialog_set_has_separator(GTK_DIALOG(data.dialog), FALSE);
134
	gtk_window_set_resizable(GTK_WINDOW(data.dialog), FALSE);
135
	
136
	title_hdr = g_strconcat("<span weight=\"bold\">", _("Scanning for available stations:"), "</span>", NULL);
137
	title = gtk_label_new(title_hdr);
138
	gtk_misc_set_alignment(GTK_MISC(title), 0, 0.5);
139
	gtk_label_set_use_markup(GTK_LABEL(title), TRUE);
140
	g_free(title_hdr);
141
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(data.dialog)->vbox), title, FALSE, FALSE, 6);
142
	
143
	data.progress = gtk_progress_bar_new();
144
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(data.dialog)->vbox), data.progress, TRUE, FALSE, 6);
145
	
146
	data.label = gtk_label_new(_("No stations found"));
147
	gtk_misc_set_alignment(GTK_MISC(data.label), 0, 0.5);
148
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(data.dialog)->vbox), data.label, TRUE, FALSE, 6);
149
	
150
	gtk_widget_show_all(data.dialog);
151
	
152
	radio_mute();
153
	timeout_id = g_timeout_add(1000/SCAN_SPEED, (GSourceFunc)initial_frequency_scan_cb, (gpointer)&data);	
154
	int response = gtk_dialog_run(GTK_DIALOG(data.dialog));
155
156
	radio_unmute();
157
	if (timeout_id) {
158
		g_source_remove(timeout_id);
159
		timeout_id = 0;
160
		gtk_widget_destroy(data.dialog);
161
	} else {
162
		if (g_list_length(data.stations) > 0) {
163
			gfloat f = *((gfloat*)data.stations->data);
164
			adj->value = f*STEPS;
191 by mfcn
* data/gnomeradio.schemas.in:
165
			radio_set_freq(f);
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
166
			
167
			GtkWidget *dialog;
168
			GList *ptr;
169
			char *text;
170
			
171
			text = g_strdup_printf(_("%d stations found. \nDo you want to add them as presets?\n"),
172
					g_list_length(data.stations));
173
			
174
			dialog = gtk_message_dialog_new(GTK_WINDOW(app), DIALOG_FLAGS, GTK_MESSAGE_QUESTION,
175
					GTK_BUTTONS_YES_NO, text);
176
			g_free(text);
177
			
178
			int response = gtk_dialog_run(GTK_DIALOG(dialog));
179
			gtk_widget_destroy(dialog);
180
181
			for (ptr = data.stations; ptr; ptr = ptr->next) {
182
				if (response == GTK_RESPONSE_YES) {
183
					preset *ps = g_malloc0(sizeof(preset));
184
					ps->title = g_strdup(_("unnamed"));
185
					ps->freq = *((gfloat*)ptr->data);
186
					settings.presets = g_list_append(settings.presets, ps);
187
				}
188
				g_free(ptr->data);
189
			}	
190
		}
191
	}	
192
}	
193
207 by Thomas Meire
Replaced bacon-volume-button with GtkVolumeButton
194
int gtk_volume_button_get_value (GtkWidget *button)
195
{
196
	return (int) (gtk_scale_button_get_value(GTK_SCALE_BUTTON(button)) * 100);
197
}
198
199
void gtk_volume_button_set_value (GtkWidget *button, int value)
200
{
201
	gtk_scale_button_set_value(GTK_SCALE_BUTTON(button), (gdouble) value / 100);
202
}
203
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
204
static void prefs_button_clicked_cb(GtkButton *button, gpointer app)
205
{
206
	GtkWidget* dialog;
207
	gint choise;
208
	
209
	dialog = prefs_window(app);
210
	
211
	/* Michael Jochum <e9725005@stud3.tuwien.ac.at> proposed to not use gnome_dialog_set_parent()
212
	   but following instead. */
213
	gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(app));
214
	gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
215
	
216
	/*gnome_dialog_set_parent(GNOME_DIALOG(dialog), GTK_WINDOW(app));*/
217
	
218
	choise = GTK_RESPONSE_HELP;
219
	while (choise == GTK_RESPONSE_HELP)
220
	{
221
		choise = gtk_dialog_run(GTK_DIALOG(dialog)); 
222
		switch (choise)
223
		{
224
			case GTK_RESPONSE_HELP:
225
				display_help_cb("gnomeradio-settings");
226
			break;
227
			default:
228
				/* We need the hide signal to get the value of the device_entry */
229
				gtk_widget_hide_all(dialog);
230
				gtk_widget_destroy(dialog);
231
		}
232
	}
233
}
234
235
void start_radio(gboolean restart, GtkWidget *app)
2 by mfcn
Initial revision
236
{
191 by mfcn
* data/gnomeradio.schemas.in:
237
    DriverType driver = DRIVER_ANY;
2 by mfcn
Initial revision
238
	if (restart)
239
		radio_stop();
240
	
191 by mfcn
* data/gnomeradio.schemas.in:
241
    if (settings.driver) {
242
        if (0 == strcmp(settings.driver, "v4l1"))
243
            driver = DRIVER_V4L1;
244
        if (0 == strcmp(settings.driver, "v4l2"))
245
            driver = DRIVER_V4L2;
246
    }
247
248
	if (!radio_init(settings.device, driver))
2 by mfcn
Initial revision
249
	{
119 by mfcn
* Ported Recording to gstreamer
250
		char *caption = g_strdup_printf(_("Could not open device \"%s\"!"), settings.device);
251
		char *detail = g_strdup_printf(_("Check your settings and make sure that no other\n"
252
				"program is using %s.\nAlso make sure that you have read-access to it."), settings.device);
253
		show_error_message(caption, detail);
254
		g_free(caption);
255
		g_free(detail);
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
256
		
257
		if (!restart)
258
			prefs_button_clicked_cb(NULL, app);
259
	}
2 by mfcn
Initial revision
260
}
261
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
262
void start_mixer(gboolean restart, GtkWidget *app)
2 by mfcn
Initial revision
263
{
264
	gint res, vol;
265
	
266
	if (restart)
267
		mixer_close();
268
	
269
	res = mixer_init(settings.mixer_dev, settings.mixer);
270
	if (res <1) 
271
	{
272
		char *buffer;
273
		
274
		if (res == -1)
275
			buffer = g_strdup_printf(_("Mixer source \"%s\" is not a valid source!"), settings.mixer);
276
		else 
277
			buffer = g_strdup_printf(_("Could not open \"%s\"!"), settings.mixer_dev);
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
278
		
279
		show_error_message(buffer, NULL);
2 by mfcn
Initial revision
280
		
281
		g_free(buffer);
282
	}		
283
	vol = mixer_get_volume();
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
284
	if (vol >= 0) {
207 by Thomas Meire
Replaced bacon-volume-button with GtkVolumeButton
285
		g_message("setting volume: %d -> %d", gtk_volume_button_get_value(mute_button), vol);
286
		gtk_volume_button_set_value(mute_button, vol);
287
		g_message("new volume: %d", gtk_volume_button_get_value(mute_button));
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
288
		/*gtk_adjustment_set_value(volume, (double)vol);*/
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
289
	}
2 by mfcn
Initial revision
290
}
291
292
GList* get_mixer_recdev_list(void)
293
{
294
	int i;
295
	char **array, *dev;
296
	GList *result = NULL;
297
	
298
	array = mixer_get_rec_devices();
299
	if (!array)
300
		return NULL;
301
	
302
	i = 0;	
303
	dev = array[i];
304
	while (dev)
305
	{
113 by mfcn
2006-02-14 Jön Scheibengruber <mfcn@gmx.de>
306
		char *text = g_strdup(dev);
2 by mfcn
Initial revision
307
		result = g_list_append(result, text);
308
		free(dev);
309
		dev = array[++i];
310
	}			
311
	free(array);
312
	
313
	return result;
314
}
315
121 by mfcn
* po/POTFILES.in, src/Makefile.am, trayicon.*, gui.*, prefs.c:
316
static gboolean redraw_status_window(void)
2 by mfcn
Initial revision
317
{
318
69 by mfcn
Fixes #167962
319
	GdkWindow *real_window, *window;
320
	GdkGC *gc;
2 by mfcn
Initial revision
321
	int win_width, win_height;
79 by mfcn
Fixed some issues that came along with the massive code-change...
322
	int val, freq[5], signal_strength, is_stereo;
69 by mfcn
Fixes #167962
323
	
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
324
	val = (int)(rint(adj->value/STEPS * 100.0));
69 by mfcn
Fixes #167962
325
	
326
	freq[0] = val / 10000;
327
	freq[1] = (val % 10000) / 1000;
328
	freq[2] = (val % 1000) / 100; 
329
	freq[3] = (val % 100) / 10;
330
	freq[4] = val % 10;
2 by mfcn
Initial revision
331
191 by mfcn
* data/gnomeradio.schemas.in:
332
	signal_strength = radio_get_signal();
333
	is_stereo = radio_get_stereo();
2 by mfcn
Initial revision
334
	
69 by mfcn
Fixes #167962
335
	if (signal_strength > 3) signal_strength = 3;
336
	if (signal_strength < 0) signal_strength = 0;
337
	is_stereo = (is_stereo == 1) ? 1 : 0;
338
	
339
	real_window = drawing_area->window;
154 by mfcn
* src/gui.c: (redraw_status_window), (adj_value_changed_cb),
340
	if (real_window == NULL)
341
		/* UI has not been realized yet */
342
		return TRUE;
69 by mfcn
Fixes #167962
343
	gc = gdk_gc_new(real_window);
344
	gdk_drawable_get_size(real_window, &win_width, &win_height);
345
	
346
	/* use doublebuffering to avoid flickering */
347
	window = gdk_pixmap_new(real_window, win_width, win_height, -1);
2 by mfcn
Initial revision
348
69 by mfcn
Fixes #167962
349
	gdk_draw_rectangle(window, gc, TRUE, 0, 0, win_width, win_height);
2 by mfcn
Initial revision
350
	
351
	win_width -= 5;
352
	
69 by mfcn
Fixes #167962
353
	if (freq[0])	gdk_draw_drawable(window, gc, digits, freq[0] * DIGIT_WIDTH, 0, win_width - DIGIT_WIDTH*6, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
354
	else gdk_draw_rectangle(window, gc, TRUE, win_width - DIGIT_WIDTH*6, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
355
356
	gdk_draw_drawable(window, gc, digits, freq[1] * DIGIT_WIDTH, 0, win_width - DIGIT_WIDTH*5, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
357
	gdk_draw_drawable(window, gc, digits, freq[2] * DIGIT_WIDTH, 0, win_width - DIGIT_WIDTH*4, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
358
	gdk_draw_drawable(window, gc, digits, 10 * DIGIT_WIDTH, 0, win_width - DIGIT_WIDTH*3, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
359
	gdk_draw_drawable(window, gc, digits, freq[3] * DIGIT_WIDTH, 0, win_width - DIGIT_WIDTH*2, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
360
	gdk_draw_drawable(window, gc, digits, freq[4] * DIGIT_WIDTH, 0, win_width - DIGIT_WIDTH*1, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
361
	gdk_draw_drawable(window, gc, signal_s, signal_strength * SIGNAL_WIDTH, 0, win_width - DIGIT_WIDTH*6-SIGNAL_WIDTH, 5, SIGNAL_WIDTH, DIGIT_HEIGTH);
362
	gdk_draw_drawable(window, gc, stereo, is_stereo * STEREO_WIDTH, 0, win_width - DIGIT_WIDTH*6-SIGNAL_WIDTH-STEREO_WIDTH, 5, STEREO_WIDTH, DIGIT_HEIGTH);
363
364
	/* draw the pixmap to the real window */	
365
	gdk_draw_drawable(real_window, gc, window, 0, 0, 0, 0, win_width + 5, win_height);
366
	
367
	g_object_unref(G_OBJECT(gc));
368
	g_object_unref(G_OBJECT(window));
2 by mfcn
Initial revision
369
	
370
	return TRUE;	
371
}
372
	
373
121 by mfcn
* po/POTFILES.in, src/Makefile.am, trayicon.*, gui.*, prefs.c:
374
static gboolean expose_event_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
2 by mfcn
Initial revision
375
{
69 by mfcn
Fixes #167962
376
	redraw_status_window();
377
	return TRUE;
2 by mfcn
Initial revision
378
}	
379
380
void exit_gnome_radio(void)
381
{
382
	if (settings.mute_on_exit)
383
	{
384
		radio_mute();
385
		radio_stop();
386
	}
387
	mixer_close();
388
	save_settings();
389
	gtk_main_quit();
390
}
391
113 by mfcn
2006-02-14 Jön Scheibengruber <mfcn@gmx.de>
392
const char* get_preset(float freq, int *num)
393
{
394
	GList *node = settings.presets;
395
396
	int i = *num = -1;
397
	for (;node;)
398
	{
399
		++i;
400
		preset *ps = (preset*)node->data;
401
		if (fabs(ps->freq - freq) < 0.01)
402
		{
403
			*num = i;
404
			return ps->title;
405
		}
406
		node = node->next;
407
	}
408
	return NULL;
409
}
410
2 by mfcn
Initial revision
411
static void adj_value_changed_cb(GtkAdjustment* data, gpointer window)
412
{
113 by mfcn
2006-02-14 Jön Scheibengruber <mfcn@gmx.de>
413
	char *buffer;
414
	float freq = rint(adj->value)/STEPS;
415
	const char *preset_title = get_preset(freq, &mom_ps);
416
417
	preset_combo_set_item(mom_ps);
69 by mfcn
Fixes #167962
418
	
419
	redraw_status_window();
2 by mfcn
Initial revision
420
	
113 by mfcn
2006-02-14 Jön Scheibengruber <mfcn@gmx.de>
421
	if (preset_title)
422
		buffer = g_strdup_printf(_("Gnomeradio - %s"), preset_title);
423
	else
424
		buffer = g_strdup_printf(_("Gnomeradio - %.2f MHz"), freq);
425
	gtk_window_set_title(GTK_WINDOW(window), buffer);
202 by mfcn
* src/Makefile.am:
426
	if (tray_icon) gtk_status_icon_set_tooltip(GTK_STATUS_ICON(tray_icon), buffer); //gtk_tooltips_set_tip(tooltips, tray_icon, buffer, NULL);
2 by mfcn
Initial revision
427
	g_free(buffer);
428
	
113 by mfcn
2006-02-14 Jön Scheibengruber <mfcn@gmx.de>
429
	buffer = g_strdup_printf(_("Frequency: %.2f MHz"), freq);
2 by mfcn
Initial revision
430
	gtk_tooltips_set_tip(tooltips, freq_scale, buffer, NULL);
431
	g_free(buffer);
432
191 by mfcn
* data/gnomeradio.schemas.in:
433
	radio_set_freq(adj->value/STEPS);
2 by mfcn
Initial revision
434
}
435
207 by Thomas Meire
Replaced bacon-volume-button with GtkVolumeButton
436
static void volume_value_changed_cb(GtkVolumeButton *button, gpointer user_data)
2 by mfcn
Initial revision
437
{
438
	char *text;
207 by Thomas Meire
Replaced bacon-volume-button with GtkVolumeButton
439
	int vol = (int)(gtk_volume_button_get_value(mute_button) + 0.5f);
440
114 by mfcn
2006-02-15 Jön Scheibengruber <mfcn@gmx.de>
441
	mixer_set_volume(vol);
442
	
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
443
/*	text = g_strdup_printf(_("Volume: %d%%"), vol);
2 by mfcn
Initial revision
444
	gtk_tooltips_set_tip(tooltips, vol_scale, text, NULL);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
445
	g_free(text);*/
114 by mfcn
2006-02-15 Jön Scheibengruber <mfcn@gmx.de>
446
	
183 by mfcn
* help/C/gnomeradio.xml:
447
    if (tray_menu) {
448
	    g_signal_handler_block(G_OBJECT(mute_menuitem), mute_menuitem_toggled_cb_id);
449
	    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mute_menuitem), vol == 0);
450
	    g_signal_handler_unblock(G_OBJECT(mute_menuitem), mute_menuitem_toggled_cb_id);
451
    }
2 by mfcn
Initial revision
452
}
453
454
#if 0
455
static gboolean poll_volume_change(gpointer data)
456
{
457
	int vol;
458
	if ((vol = mixer_get_volume()) < 0)
459
		return FALSE;
460
	
461
	if (vol != (int)volume->value)
462
	{
463
		g_print("external volume change detected\n");
464
		gtk_adjustment_set_value(volume, (double)vol);
465
	}
466
	
467
	return TRUE;
468
}
469
#endif
470
121 by mfcn
* po/POTFILES.in, src/Makefile.am, trayicon.*, gui.*, prefs.c:
471
static void change_frequency(gpointer data)
2 by mfcn
Initial revision
472
{
473
	gboolean increase = (gboolean)data;
474
	
475
	if (increase)
476
	{
477
		if (adj->value >= FREQ_MAX*STEPS)
478
			gtk_adjustment_set_value(adj, FREQ_MIN*STEPS);
479
		else
480
			gtk_adjustment_set_value(adj, adj->value+1);
481
	}
482
	else
483
	{
484
		if (adj->value <= FREQ_MIN*STEPS)
485
			gtk_adjustment_set_value(adj, FREQ_MAX*STEPS);
486
		else
487
			gtk_adjustment_set_value(adj, adj->value-1);
488
	}
489
}
490
121 by mfcn
* po/POTFILES.in, src/Makefile.am, trayicon.*, gui.*, prefs.c:
491
static gboolean change_frequency_timeout(gpointer data)
2 by mfcn
Initial revision
492
{
493
	change_frequency(data);
494
	if (bp_timeout_steps < 10)
495
	{
496
		gtk_timeout_remove(bp_timeout_id);
497
		bp_timeout_id = gtk_timeout_add(200 - 20*bp_timeout_steps,
498
			(GtkFunction)change_frequency_timeout, data);
499
		bp_timeout_steps++; 
500
	}
501
	return TRUE;
502
}	
503
504
static void step_button_pressed_cb(GtkButton *button, gpointer data)
505
{
506
	bp_timeout_id = gtk_timeout_add(500, (GtkFunction)change_frequency_timeout, data);
507
}
508
509
static void step_button_clicked_cb(GtkButton *button, gpointer data)
510
{
511
	change_frequency(data);
512
}
513
514
static void step_button_released_cb(GtkButton *button, gpointer data)
515
{
516
	if (bp_timeout_id > -1)
517
		gtk_timeout_remove(bp_timeout_id);
518
	bp_timeout_id = -1;
519
	bp_timeout_steps = 0;
520
}
521
522
static gboolean scan_freq(gpointer data)
523
{
524
	static gint start, mom, max;
525
	gint dir = (gint)(data);
526
	
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
527
	if (!max) {
2 by mfcn
Initial revision
528
		max = (FREQ_MAX - FREQ_MIN) * STEPS;
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
529
	}	
530
		
531
	if (radio_check_station(adj->value/STEPS) || (start > max))	{
532
		start = mom = 0;
2 by mfcn
Initial revision
533
		radio_unmute();
534
		timeout_id = 0;
535
		return FALSE;
536
	}
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
537
	if (!mom) {
538
		mom = adj->value;
539
	}
540
		
2 by mfcn
Initial revision
541
	if (mom > FREQ_MAX*STEPS) 
542
		mom = FREQ_MIN*STEPS;
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
543
	else if (mom < FREQ_MIN*STEPS)
2 by mfcn
Initial revision
544
		mom = FREQ_MAX*STEPS;
545
	else	
546
		mom = mom + dir;
547
	start += 1;
548
	gtk_adjustment_set_value(adj, mom);
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
549
2 by mfcn
Initial revision
550
	return TRUE;
551
}
552
553
void scfw_button_clicked_cb(GtkButton *button, gpointer data)
554
{
75 by mfcn
Some more changes
555
	if (timeout_id) {
556
		gtk_timeout_remove(timeout_id);
557
		timeout_id = 0;
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
558
		radio_unmute();
2 by mfcn
Initial revision
559
		return;
75 by mfcn
Some more changes
560
	}
2 by mfcn
Initial revision
561
	radio_mute();
562
	timeout_id = gtk_timeout_add(1000/SCAN_SPEED, (GtkFunction)scan_freq, (gpointer)1);	
563
}
564
565
void scbw_button_clicked_cb(GtkButton *button, gpointer data)
566
{
75 by mfcn
Some more changes
567
	if (timeout_id) {
568
		gtk_timeout_remove(timeout_id);
569
		timeout_id = 0;
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
570
		radio_unmute();
2 by mfcn
Initial revision
571
		return;
75 by mfcn
Some more changes
572
	}
2 by mfcn
Initial revision
573
	radio_mute();
574
	timeout_id = gtk_timeout_add(1000/SCAN_SPEED, (GtkFunction)scan_freq, (gpointer)(-1));	
79 by mfcn
Fixed some issues that came along with the massive code-change...
575
}
576
577
void preset_combo_set_item(gint i)
578
{
81 by mfcn
some more fixes...
579
	if (i < -1) return;
154 by mfcn
* src/gui.c: (redraw_status_window), (adj_value_changed_cb),
580
	if (preset_combo == NULL) return;
81 by mfcn
some more fixes...
581
	gtk_combo_box_set_active(GTK_COMBO_BOX(preset_combo), i + 1);
79 by mfcn
Fixed some issues that came along with the massive code-change...
582
}
583
584
static void preset_combo_change_cb(GtkWidget *combo, gpointer data)
585
{
81 by mfcn
some more fixes...
586
	preset* ps;
587
	mom_ps = gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) - 1;
588
	
589
	if (mom_ps < 0) return;
590
	
591
	ps = (preset*)g_list_nth_data(settings.presets, mom_ps);
79 by mfcn
Fixed some issues that came along with the massive code-change...
592
	gtk_adjustment_set_value(adj, ps->freq * STEPS);
2 by mfcn
Initial revision
593
}
594
121 by mfcn
* po/POTFILES.in, src/Makefile.am, trayicon.*, gui.*, prefs.c:
595
void change_preset(gboolean next)
2 by mfcn
Initial revision
596
{
597
	preset *ps;
598
	int len = g_list_length(settings.presets);
599
	if (len < 1)
600
		return;
601
602
	if (next)
603
		mom_ps = (mom_ps + 1) % len;
604
	else
605
		mom_ps = (mom_ps - 1 + len) % len;
606
607
	ps = g_list_nth_data(settings.presets, mom_ps);
608
	gtk_adjustment_set_value(adj, ps->freq*STEPS);
79 by mfcn
Fixed some issues that came along with the massive code-change...
609
	preset_combo_set_item(mom_ps);
2 by mfcn
Initial revision
610
}
611
612
static void quit_button_clicked_cb(GtkButton *button, gpointer data)
613
{
614
	exit_gnome_radio();
615
}
616
115 by mfcn
2006-02-15 Jön Scheibengruber <mfcn@gmx.de>
617
void tray_icon_items_set_sensible(gboolean sensible)
618
{
619
	GList* menuitems;
620
	GtkWidget *menuitem;
621
	int i, cnt = g_list_length(settings.presets);
622
	
623
	
624
	menuitems = GTK_MENU_SHELL(tray_menu)->children;
625
	
626
	g_assert(cnt + 6 == g_list_length(menuitems));
627
	
628
	/* Disable the presets */
629
	for (i = 0; i < cnt; i++) {
630
		menuitem = g_list_nth_data(menuitems, i);
631
		gtk_widget_set_sensitive(menuitem, sensible);
632
	}	
633
	
634
	/* Disable the mute button (separator => +1) */
635
	menuitem = g_list_nth_data(menuitems, cnt + 1);
636
	gtk_widget_set_sensitive(menuitem, sensible);
637
638
	/* Disable the record button */
639
	menuitem = g_list_nth_data(menuitems, cnt + 2);
640
	gtk_widget_set_sensitive(menuitem, sensible);
641
	
642
	/* Disable the quit button */
643
	menuitem = g_list_nth_data(menuitems, cnt + 5);
644
	gtk_widget_set_sensitive(menuitem, sensible);
645
}
646
153 by mfcn
* src/gui.c: (start_recording), (rec_button_clicked_cb):
647
static int start_recording(const gchar *destination, const char* station, const char* time)
2 by mfcn
Initial revision
648
{
649
	GtkWidget *dialog;
119 by mfcn
* Ported Recording to gstreamer
650
	Recording* recording;
153 by mfcn
* src/gui.c: (start_recording), (rec_button_clicked_cb):
651
	char *filename;
2 by mfcn
Initial revision
652
	
653
	if (!mixer_set_rec_device())
654
	{
655
		GtkWidget *dialog;
656
		dialog = gtk_message_dialog_new(NULL, DIALOG_FLAGS, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
657
				"Could not set \"%s\" as recording Source", settings.mixer);
658
		gtk_dialog_run (GTK_DIALOG (dialog));
659
		gtk_widget_destroy (dialog);
660
		return -1;
661
	}
74 by mfcn
* lots of changes. HIG-ifieing continued, recording dialog removed/reworked
662
	
153 by mfcn
* src/gui.c: (start_recording), (rec_button_clicked_cb):
663
	/* You can translate the filename for a recording:
664
	 * args for this format are: path, station title, time 
665
	 */ 
666
	filename = g_strdup_printf(_("%s/%s_%s"), 
667
 		destination, 
668
 		station, 
669
 		time);
119 by mfcn
* Ported Recording to gstreamer
670
	recording = recording_start(filename);
153 by mfcn
* src/gui.c: (start_recording), (rec_button_clicked_cb):
671
	g_free(filename);
119 by mfcn
* Ported Recording to gstreamer
672
	if (!recording)
673
		return -1;
674
	
115 by mfcn
2006-02-15 Jön Scheibengruber <mfcn@gmx.de>
675
	tray_icon_items_set_sensible(FALSE);
676
	
153 by mfcn
* src/gui.c: (start_recording), (rec_button_clicked_cb):
677
	recording->station = g_strdup(station);
119 by mfcn
* Ported Recording to gstreamer
678
	dialog = record_status_window(recording);
2 by mfcn
Initial revision
679
	
119 by mfcn
* Ported Recording to gstreamer
680
	run_status_window(recording);
74 by mfcn
* lots of changes. HIG-ifieing continued, recording dialog removed/reworked
681
2 by mfcn
Initial revision
682
	return 1;
683
}
684
121 by mfcn
* po/POTFILES.in, src/Makefile.am, trayicon.*, gui.*, prefs.c:
685
void rec_button_clicked_cb(GtkButton *button, gpointer app)
2 by mfcn
Initial revision
686
{
687
	GtkWidget *dialog;
153 by mfcn
* src/gui.c: (start_recording), (rec_button_clicked_cb):
688
	char *station;
74 by mfcn
* lots of changes. HIG-ifieing continued, recording dialog removed/reworked
689
	char time_str[100];
690
	time_t t;
2 by mfcn
Initial revision
691
	
74 by mfcn
* lots of changes. HIG-ifieing continued, recording dialog removed/reworked
692
	t = time(NULL);
693
	/* consult man strftime to translate this. This is a filename, so don't use "/" or ":", please */
694
	strftime(time_str, 100, _("%B-%d-%Y_%H-%M-%S"), localtime(&t));
695
	
119 by mfcn
* Ported Recording to gstreamer
696
	if (mom_ps < 0) {
154 by mfcn
* src/gui.c: (redraw_status_window), (adj_value_changed_cb),
697
		station = g_strdup_printf(_("%.2f MHz"), rint(adj->value)/STEPS);
119 by mfcn
* Ported Recording to gstreamer
698
	} else {
699
		g_assert(mom_ps < g_list_length(settings.presets));
700
		preset* ps = g_list_nth_data(settings.presets, mom_ps);
701
		g_assert(ps);
153 by mfcn
* src/gui.c: (start_recording), (rec_button_clicked_cb):
702
	
703
		station = g_strdup(ps->title);
119 by mfcn
* Ported Recording to gstreamer
704
	}	
705
		
706
/*	if (!check_filename(filename)) {
74 by mfcn
* lots of changes. HIG-ifieing continued, recording dialog removed/reworked
707
		GtkWidget *errdialog;
708
		errdialog = gtk_message_dialog_new(GTK_WINDOW(app), DIALOG_FLAGS, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
709
					_("Error opening file '%s':\n%s"), filename, strerror(errno));
710
		gtk_dialog_run (GTK_DIALOG (errdialog));
711
		gtk_widget_destroy (errdialog);
119 by mfcn
* Ported Recording to gstreamer
712
	} else */
153 by mfcn
* src/gui.c: (start_recording), (rec_button_clicked_cb):
713
	start_recording(rec_settings.destination, station, time_str);
714
	g_free(station);
2 by mfcn
Initial revision
715
}
716
114 by mfcn
2006-02-15 Jön Scheibengruber <mfcn@gmx.de>
717
void toggle_volume(void)
2 by mfcn
Initial revision
718
{
114 by mfcn
2006-02-15 Jön Scheibengruber <mfcn@gmx.de>
719
	static int old_vol;
720
	int vol = mixer_get_volume();
2 by mfcn
Initial revision
721
	
114 by mfcn
2006-02-15 Jön Scheibengruber <mfcn@gmx.de>
722
	if (vol) {
723
		old_vol = vol;
724
		vol = 0;
725
	} else {
726
		vol = old_vol;
727
	}	
728
	mixer_set_volume(vol);
207 by Thomas Meire
Replaced bacon-volume-button with GtkVolumeButton
729
	gtk_volume_button_set_value(mute_button, vol);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
730
	/*gtk_adjustment_set_value(volume, vol);*/
114 by mfcn
2006-02-15 Jön Scheibengruber <mfcn@gmx.de>
731
}	
732
733
static void mute_button_toggled_cb(GtkButton *button, gpointer data)
734
{
735
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mute_button)))
736
	{		
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
737
		gtk_tooltips_set_tip(tooltips, mute_button, _("Unmute"), NULL);
738
	}
739
	else
740
	{
2 by mfcn
Initial revision
741
		gtk_tooltips_set_tip(tooltips, mute_button, _("Mute"), NULL);
742
	}
114 by mfcn
2006-02-15 Jön Scheibengruber <mfcn@gmx.de>
743
	toggle_volume();
2 by mfcn
Initial revision
744
}
745
746
static void about_button_clicked_cb(GtkButton *button, gpointer data)
747
{
748
	GdkPixbuf *app_icon;
146 by mfcn
* .cvsignore:
749
	GtkIconTheme *icontheme;
2 by mfcn
Initial revision
750
	static GtkWidget *about;
751
	const char *authors[] = {"Jörgen Scheibengruber <mfcn@gmx.de>", NULL};
752
	char *text;
753
	
754
	/* Feel free to put your names here translators :-) */
755
	char *translators = _("TRANSLATORS");
756
757
	if (about)
758
	{
759
		gtk_window_present(GTK_WINDOW(about));
760
		return;
761
	}
146 by mfcn
* .cvsignore:
762
	icontheme = gtk_icon_theme_get_default();
763
	app_icon = gtk_icon_theme_load_icon(icontheme, "gnomeradio", 48, 0, NULL);
2 by mfcn
Initial revision
764
765
#ifdef HAVE_LIRC	
766
	text =_("Gnomeradio is a FM-Tuner application for the GNOME desktop. "
767
							"It should work with all tuner hardware that is supported by the video4linux drivers.\n\n"
768
							"This version has been compiled with LIRC support.");
769
#else
770
	text =_("Gnomeradio is a FM-Tuner application for the GNOME desktop. "
771
							"It should work with all tuner hardware that is supported by the video4linux drivers.\n\n"
772
							"This version has been compiled without LIRC support.");
773
#endif
774
	
155 by mfcn
* configure.in: 1.7
775
	about = gnome_about_new ("Gnomeradio", VERSION, "Copyright 2001 - 2006 Jörgen Scheibengruber",
2 by mfcn
Initial revision
776
							text, (const char **) authors, NULL, 
777
							strcmp("TRANSLATORS", translators) ? translators : NULL, 
778
							app_icon);
779
780
	gtk_widget_show(about);
79 by mfcn
Fixed some issues that came along with the massive code-change...
781
	g_object_add_weak_pointer(G_OBJECT(about), (gpointer)&about);
146 by mfcn
* .cvsignore:
782
	g_object_add_weak_pointer(G_OBJECT(about), (gpointer)&app_icon);
2 by mfcn
Initial revision
783
}
784
785
static gint delete_event_cb(GtkWidget* window, GdkEventAny* e, gpointer data)
786
{
787
	exit_gnome_radio();
788
	return TRUE;
789
}
790
791
void display_help_cb(char *topic)
792
{
793
	GError *error = NULL;
794
795
	gnome_help_display(PACKAGE, topic, &error);
796
	if (error)
797
	{
798
		GtkWidget *dialog;
799
		dialog = gtk_message_dialog_new(NULL, DIALOG_FLAGS, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
800
				error->message);
801
		gtk_dialog_run (GTK_DIALOG (dialog));
802
		gtk_widget_destroy (dialog);
803
		g_error_free (error);
804
		error = NULL;
805
	}
806
}
807
121 by mfcn
* po/POTFILES.in, src/Makefile.am, trayicon.*, gui.*, prefs.c:
808
void toggle_mainwindow_visibility(GtkWidget *app)
114 by mfcn
2006-02-15 Jön Scheibengruber <mfcn@gmx.de>
809
{
810
	static gint posx, posy;
811
	if (GTK_WIDGET_VISIBLE(app))
812
	{
813
		gtk_window_get_position(GTK_WINDOW(app), &posx, &posy);
814
		gtk_widget_hide(app);
815
	}
816
	else
817
	{
818
		if ((posx >= 0) && (posy >= 0))
819
			gtk_window_move(GTK_WINDOW(app), posx, posy);
820
		gtk_window_present(GTK_WINDOW(app));
821
	}
822
}	
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
823
	
2 by mfcn
Initial revision
824
GtkWidget* gnome_radio_gui(void)
825
{
826
	GtkWidget *app;
827
	GtkWidget *prefs_button, *quit_button, *scfw_button, *scbw_button;
828
	GtkWidget *stfw_button, *stbw_button, *about_button, *rec_button;
829
	GtkWidget *prefs_pixmap, *quit_pixmap, *scfw_pixmap, *scbw_pixmap;
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
830
	GtkWidget *stfw_pixmap, *stbw_pixmap, *about_pixmap;
2 by mfcn
Initial revision
831
	GtkWidget *vol_up_pixmap, *vol_down_pixmap, *freq_up_pixmap, *freq_down_pixmap;
832
	GdkPixbuf *vol_up_pixbuf, *vol_down_pixbuf, *freq_up_pixbuf, *freq_down_pixbuf;
833
	GtkWidget *hbox1, *hbox2, *vbox, *menubox, *freq_vol_box;
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
834
	GtkWidget *vseparator1, *vseparator2, *vseparator4;
2 by mfcn
Initial revision
835
	GtkWidget *label;
75 by mfcn
Some more changes
836
	GtkWidget *frame;
2 by mfcn
Initial revision
837
	gchar *text;
79 by mfcn
Fixed some issues that came along with the massive code-change...
838
	
2 by mfcn
Initial revision
839
	app = gnome_app_new(PACKAGE, _("Gnomeradio"));
840
841
	gtk_window_set_resizable(GTK_WINDOW(app), FALSE);
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
842
	/*gtk_window_set_policy(GTK_WINDOW(app), FALSE, FALSE, FALSE);*/
2 by mfcn
Initial revision
843
	gtk_window_set_wmclass(GTK_WINDOW(app), "gnomeradio", "Gnomeradio");
844
75 by mfcn
Some more changes
845
	frame = gtk_frame_new(NULL);
2 by mfcn
Initial revision
846
	
84 by mfcn
* gui.c: use GTK_STOCK_MEDIA_* instead of GTK_STOCK_GO_*
847
	quit_pixmap = gtk_image_new_from_stock(GTK_STOCK_QUIT, GTK_ICON_SIZE_BUTTON);
75 by mfcn
Some more changes
848
	prefs_pixmap = gtk_image_new_from_stock(GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_LARGE_TOOLBAR);
84 by mfcn
* gui.c: use GTK_STOCK_MEDIA_* instead of GTK_STOCK_GO_*
849
	scfw_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_FORWARD, GTK_ICON_SIZE_LARGE_TOOLBAR);
850
	scbw_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_REWIND, GTK_ICON_SIZE_LARGE_TOOLBAR);
851
	stfw_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_NEXT, GTK_ICON_SIZE_LARGE_TOOLBAR);
852
	stbw_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PREVIOUS, GTK_ICON_SIZE_LARGE_TOOLBAR);
853
	about_pixmap = gtk_image_new_from_stock(GTK_STOCK_ABOUT, GTK_ICON_SIZE_LARGE_TOOLBAR);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
854
	/*mute_pixmap = gtk_image_new_from_stock(GNOME_STOCK_VOLUME, GTK_ICON_SIZE_LARGE_TOOLBAR);*/
84 by mfcn
* gui.c: use GTK_STOCK_MEDIA_* instead of GTK_STOCK_GO_*
855
	rec_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_RECORD, GTK_ICON_SIZE_LARGE_TOOLBAR);
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
856
	/*help_pixmap = gtk_image_new_from_stock(GTK_STOCK_HELP, GTK_ICON_SIZE_LARGE_TOOLBAR);*/
2 by mfcn
Initial revision
857
	
858
	quit_button = gtk_button_new();
859
	prefs_button = gtk_button_new();
860
	scfw_button = gtk_button_new();
861
	scbw_button = gtk_button_new();
862
	stfw_button = gtk_button_new();
863
	stbw_button = gtk_button_new();
864
	about_button = gtk_button_new();
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
865
	/*mute_button = gtk_toggle_button_new();*/
207 by Thomas Meire
Replaced bacon-volume-button with GtkVolumeButton
866
	mute_button = gtk_volume_button_new();
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
867
	gtk_button_set_relief(GTK_BUTTON(mute_button), GTK_RELIEF_NORMAL);
2 by mfcn
Initial revision
868
	rec_button = gtk_button_new();
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
869
	/*help_button = gtk_button_new();*/
2 by mfcn
Initial revision
870
871
	gtk_container_add(GTK_CONTAINER(quit_button), quit_pixmap);
872
	gtk_container_add(GTK_CONTAINER(prefs_button), prefs_pixmap);
873
	gtk_container_add(GTK_CONTAINER(scfw_button), scfw_pixmap);
874
	gtk_container_add(GTK_CONTAINER(scbw_button), scbw_pixmap);
875
	gtk_container_add(GTK_CONTAINER(stfw_button), stfw_pixmap);
876
	gtk_container_add(GTK_CONTAINER(stbw_button), stbw_pixmap);
877
	gtk_container_add(GTK_CONTAINER(about_button), about_pixmap);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
878
	/*gtk_container_add(GTK_CONTAINER(mute_button), mute_pixmap);*/
2 by mfcn
Initial revision
879
	gtk_container_add(GTK_CONTAINER(rec_button), rec_pixmap);
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
880
	/*gtk_container_add(GTK_CONTAINER(help_button), help_pixmap);*/
2 by mfcn
Initial revision
881
882
	vbox = gtk_vbox_new(FALSE, 0);
883
	hbox1 = gtk_hbox_new(FALSE, 0);
884
	hbox2 = gtk_hbox_new(FALSE, 0);
885
	menubox = gtk_vbox_new(FALSE, 0);
886
	freq_vol_box = gtk_hbox_new(FALSE, 0);
887
	
888
	adj = GTK_ADJUSTMENT(gtk_adjustment_new(SUNSHINE*STEPS, FREQ_MIN*STEPS, FREQ_MAX*STEPS+1, 1, STEPS, 1));
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
889
/*	volume = GTK_ADJUSTMENT(gtk_adjustment_new(100, 0, 101, 1, 10, 1)); */
2 by mfcn
Initial revision
890
	
79 by mfcn
Fixed some issues that came along with the massive code-change...
891
	preset_combo = gtk_combo_box_new_text();
892
	g_signal_connect(GTK_OBJECT(preset_combo), "changed", GTK_SIGNAL_FUNC(preset_combo_change_cb), NULL);
893
	
894
	gtk_widget_set_size_request(preset_combo, 10, -1);
2 by mfcn
Initial revision
895
	label = gtk_label_new(_("Presets:"));
896
	
897
	freq_scale = gtk_hscale_new(adj);
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
898
	/*gtk_range_set_update_policy(GTK_RANGE(freq_scale), GTK_UPDATE_DELAYED);*/
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
899
	/*vol_scale = gtk_hscale_new(volume);*/
2 by mfcn
Initial revision
900
	
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
901
	/*vol_up_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)vol_up_xpm);
902
	vol_down_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)vol_down_xpm);*/
2 by mfcn
Initial revision
903
	freq_up_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)freq_up_xpm);
904
	freq_down_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)freq_down_xpm);
905
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
906
	/*vol_up_pixmap = gtk_image_new_from_pixbuf(vol_up_pixbuf);
907
	vol_down_pixmap = gtk_image_new_from_pixbuf(vol_down_pixbuf);*/
2 by mfcn
Initial revision
908
	freq_up_pixmap = gtk_image_new_from_pixbuf(freq_up_pixbuf);
909
	freq_down_pixmap = gtk_image_new_from_pixbuf(freq_down_pixbuf);
910
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
911
	/*gtk_widget_set_usize(freq_scale, 160, 10);*/
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
912
	/*gtk_widget_set_size_request(freq_scale, 160, -1);*/
2 by mfcn
Initial revision
913
914
	gtk_widget_realize(app);
915
	drawing_area = gtk_drawing_area_new();
916
	digits = gdk_pixmap_create_from_xpm_d (app->window, NULL, NULL, digits_xpm);
917
	signal_s = gdk_pixmap_create_from_xpm_d (app->window, NULL, NULL, signal_xpm);
918
	stereo = gdk_pixmap_create_from_xpm_d (app->window, NULL, NULL, stereo_xpm);
919
	
920
	vseparator1 = gtk_vseparator_new();
921
	vseparator2 = gtk_vseparator_new();
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
922
	/*vseparator3 = gtk_vseparator_new();*/
2 by mfcn
Initial revision
923
	vseparator4 = gtk_vseparator_new();
924
	
925
	gtk_scale_set_digits(GTK_SCALE(freq_scale), 0);
926
	gtk_scale_set_draw_value(GTK_SCALE(freq_scale), FALSE);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
927
/*	gtk_scale_set_digits(GTK_SCALE(vol_scale), 0);
2 by mfcn
Initial revision
928
	gtk_scale_set_draw_value(GTK_SCALE(vol_scale), FALSE);
929
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
930
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mute_button), mixer_get_volume() == 0);*/
114 by mfcn
2006-02-15 Jön Scheibengruber <mfcn@gmx.de>
931
2 by mfcn
Initial revision
932
	gtk_widget_set_size_request(drawing_area, DIGIT_WIDTH*6+10+SIGNAL_WIDTH+STEREO_WIDTH, DIGIT_HEIGTH+10);
933
75 by mfcn
Some more changes
934
	gtk_container_add(GTK_CONTAINER(frame), drawing_area);
2 by mfcn
Initial revision
935
936
	gtk_box_pack_start(GTK_BOX(hbox2), scbw_button, FALSE, FALSE, 2);
937
	gtk_box_pack_start(GTK_BOX(hbox2), stbw_button, FALSE, FALSE, 2);
938
	gtk_box_pack_start(GTK_BOX(hbox2), stfw_button, FALSE, FALSE, 2);
939
	gtk_box_pack_start(GTK_BOX(hbox2), scfw_button, FALSE, FALSE, 2);
940
	gtk_box_pack_start(GTK_BOX(hbox2), vseparator1, FALSE, FALSE, 2);
941
	gtk_box_pack_start(GTK_BOX(hbox2), mute_button, FALSE, FALSE, 2);
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
942
	/*gtk_box_pack_start(GTK_BOX(hbox2), vseparator2, TRUE, TRUE, 3);*/
2 by mfcn
Initial revision
943
	gtk_box_pack_start(GTK_BOX(hbox2), rec_button, FALSE, FALSE, 2);
944
	gtk_box_pack_start(GTK_BOX(hbox2), vseparator4, FALSE, FALSE, 2);
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
945
	/*gtk_box_pack_start(GTK_BOX(hbox2), help_button, FALSE, FALSE, 2);*/
2 by mfcn
Initial revision
946
	gtk_box_pack_start(GTK_BOX(hbox2), prefs_button, FALSE, FALSE, 2);
76 by mfcn
Thats it for now ;)
947
	gtk_box_pack_start(GTK_BOX(hbox2), about_button, FALSE, FALSE, 2);
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
948
	/*gtk_box_pack_start(GTK_BOX(hbox2), quit_button, FALSE, FALSE, 2);*/
2 by mfcn
Initial revision
949
75 by mfcn
Some more changes
950
	gtk_box_pack_start(GTK_BOX(hbox1), frame, FALSE, FALSE, 3);
2 by mfcn
Initial revision
951
	gtk_box_pack_start(GTK_BOX(hbox1), menubox, TRUE, TRUE, 3);
952
	
953
	gtk_box_pack_start(GTK_BOX(menubox), label, TRUE, TRUE, 0);
79 by mfcn
Fixed some issues that came along with the massive code-change...
954
	gtk_box_pack_start(GTK_BOX(menubox), preset_combo, TRUE, TRUE, 0);
2 by mfcn
Initial revision
955
956
	gtk_box_pack_start(GTK_BOX(freq_vol_box), freq_down_pixmap, FALSE, FALSE, 2);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
957
	gtk_box_pack_start(GTK_BOX(freq_vol_box), freq_scale, TRUE, TRUE, 0);
2 by mfcn
Initial revision
958
	gtk_box_pack_start(GTK_BOX(freq_vol_box), freq_up_pixmap, FALSE, FALSE, 2);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
959
	/*gtk_box_pack_start(GTK_BOX(freq_vol_box), vseparator3, FALSE, FALSE, 2);
2 by mfcn
Initial revision
960
	gtk_box_pack_start(GTK_BOX(freq_vol_box), vol_down_pixmap, FALSE, FALSE, 2);
961
	gtk_box_pack_start(GTK_BOX(freq_vol_box), vol_scale, TRUE, TRUE, 0);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
962
	gtk_box_pack_start(GTK_BOX(freq_vol_box), vol_up_pixmap, FALSE, FALSE, 2);*/
2 by mfcn
Initial revision
963
964
	gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 4);
965
	gtk_box_pack_start(GTK_BOX(vbox), freq_vol_box, TRUE, TRUE, 2);
966
	gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 4);
75 by mfcn
Some more changes
967
	
968
	gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
969
970
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 3);
971
	gtk_container_set_border_width(GTK_CONTAINER(frame), 2);
972
973
	gnome_app_set_contents(GNOME_APP(app), vbox);
2 by mfcn
Initial revision
974
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
975
	/*status = gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_NEVER);*/
2 by mfcn
Initial revision
976
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
977
	/*gnome_app_set_statusbar(GNOME_APP(app), status);*/
2 by mfcn
Initial revision
978
979
	tooltips = gtk_tooltips_new();
980
981
	g_signal_connect(GTK_OBJECT(app), "delete_event", GTK_SIGNAL_FUNC(delete_event_cb), NULL);
982
	g_signal_connect(GTK_OBJECT(quit_button), "clicked", GTK_SIGNAL_FUNC(quit_button_clicked_cb), NULL);
983
	g_signal_connect(GTK_OBJECT(adj), "value-changed", GTK_SIGNAL_FUNC(adj_value_changed_cb), (gpointer) app);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
984
	g_signal_connect(GTK_OBJECT(mute_button), "value-changed", GTK_SIGNAL_FUNC(volume_value_changed_cb), NULL);
2 by mfcn
Initial revision
985
	g_signal_connect(GTK_OBJECT(stfw_button), "pressed", GTK_SIGNAL_FUNC(step_button_pressed_cb), (gpointer)TRUE);
986
	g_signal_connect(GTK_OBJECT(stbw_button), "pressed", GTK_SIGNAL_FUNC(step_button_pressed_cb), (gpointer)FALSE);
987
	g_signal_connect(GTK_OBJECT(stfw_button), "clicked", GTK_SIGNAL_FUNC(step_button_clicked_cb), (gpointer)TRUE);
988
	g_signal_connect(GTK_OBJECT(stbw_button), "clicked", GTK_SIGNAL_FUNC(step_button_clicked_cb), (gpointer)FALSE);
989
	g_signal_connect(GTK_OBJECT(stfw_button), "released", GTK_SIGNAL_FUNC(step_button_released_cb), NULL);
990
	g_signal_connect(GTK_OBJECT(stbw_button), "released", GTK_SIGNAL_FUNC(step_button_released_cb), NULL);
991
	g_signal_connect(GTK_OBJECT(scfw_button), "clicked", GTK_SIGNAL_FUNC(scfw_button_clicked_cb), NULL);
992
	g_signal_connect(GTK_OBJECT(scbw_button), "clicked", GTK_SIGNAL_FUNC(scbw_button_clicked_cb), NULL);
993
	g_signal_connect(GTK_OBJECT(about_button), "clicked", GTK_SIGNAL_FUNC(about_button_clicked_cb), NULL);
994
	g_signal_connect(GTK_OBJECT(rec_button), "clicked", GTK_SIGNAL_FUNC(rec_button_clicked_cb), (gpointer) app);
995
	g_signal_connect(GTK_OBJECT(prefs_button), "clicked", GTK_SIGNAL_FUNC(prefs_button_clicked_cb), (gpointer) app);
996
	g_signal_connect(GTK_OBJECT(drawing_area), "expose-event", GTK_SIGNAL_FUNC(expose_event_cb), NULL);
997
998
	gtk_tooltips_set_tip(tooltips, scbw_button, _("Scan Backwards"), NULL);
999
	gtk_tooltips_set_tip(tooltips, scfw_button, _("Scan Forwards"), NULL);
1000
	gtk_tooltips_set_tip(tooltips, stbw_button, _("0.05 MHz Backwards"), NULL);
1001
	gtk_tooltips_set_tip(tooltips, stfw_button, _("0.05 MHz Forwards"), NULL);
1002
	gtk_tooltips_set_tip(tooltips, about_button, _("About Gnomeradio"), NULL);
76 by mfcn
Thats it for now ;)
1003
	gtk_tooltips_set_tip(tooltips, rec_button, _("Record radio as Wave, OGG or MP3"), NULL);
2 by mfcn
Initial revision
1004
	gtk_tooltips_set_tip(tooltips, prefs_button, _("Edit your Preferences"), NULL);
125 by mfcn
* src/gui.c: Small fixes
1005
	gtk_tooltips_set_tip(tooltips, mute_button, _("Adjust the Volume"), NULL);
2 by mfcn
Initial revision
1006
	gtk_tooltips_set_tip(tooltips, quit_button, _("Quit"), NULL);
1007
	text = g_strdup_printf(_("Frequency: %.2f MHz"), adj->value/STEPS);
1008
	gtk_tooltips_set_tip(tooltips, freq_scale, text, NULL);
1009
	g_free(text);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
1010
/*	text = g_strdup_printf(_("Volume: %d%%"), (gint)volume->value);
2 by mfcn
Initial revision
1011
	gtk_tooltips_set_tip(tooltips, vol_scale, text, NULL);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
1012
	g_free(text);*/
2 by mfcn
Initial revision
1013
	
1014
	return app;
1015
}
1016
1017
static void
1018
session_die_cb(GnomeClient* client, gpointer client_data)
1019
{
1020
	if (settings.mute_on_exit)
1021
	{
1022
		radio_mute();
1023
		radio_stop();
1024
	}
1025
	mixer_close();
1026
	gtk_main_quit();
1027
	exit (0);
1028
}
1029
1030
static void 
1031
save_session_cb(GnomeClient *client, gint phase, GnomeSaveStyle save_style,
1032
						gint is_shutdown, GnomeInteractStyle interact_style,
1033
						gint is_fast, gpointer client_data)
1034
{
1035
	save_settings();
1036
}
1037
1038
static void
1039
gconf_error_handler(GConfClient *client, GError *error)
1040
{
1041
	g_print("GConf error: %s\n", error->message);
1042
}
1043
1044
static gboolean
1045
key_press_event_cb(GtkWidget *app, GdkEventKey *event, gpointer data)
1046
{
207 by Thomas Meire
Replaced bacon-volume-button with GtkVolumeButton
1047
	int vol = (int)(gtk_volume_button_get_value(mute_button) + 0.5f);
2 by mfcn
Initial revision
1048
	
1049
	switch (event->keyval)
1050
	{
1051
		case GDK_F1: display_help_cb(NULL);
1052
				break;
1053
		case GDK_m: 
125 by mfcn
* src/gui.c: Small fixes
1054
				toggle_volume();
2 by mfcn
Initial revision
1055
				break;
1056
		case GDK_q: 
1057
				exit_gnome_radio();
1058
				break;
1059
		case GDK_r: 
1060
				rec_button_clicked_cb(NULL, app);
1061
				break;
1062
		case GDK_f: 
1063
				scfw_button_clicked_cb(NULL, NULL);
1064
				break;
1065
		case GDK_b: 
1066
				scbw_button_clicked_cb(NULL, NULL);
1067
				break;
1068
		case GDK_n: 
1069
				change_preset(TRUE);
1070
				break;
1071
		case GDK_p: 
1072
				change_preset(FALSE);
1073
				break;
1074
		case GDK_KP_Add:
1075
		case GDK_plus:	
207 by Thomas Meire
Replaced bacon-volume-button with GtkVolumeButton
1076
				gtk_volume_button_set_value(mute_button, vol > 95 ? 100 : vol + 5);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
1077
				/*gtk_adjustment_set_value(volume, (volume->value > 95) ? 100 : volume->value+5);*/
2 by mfcn
Initial revision
1078
				break;
1079
		case GDK_minus:
1080
		case GDK_KP_Subtract: 
207 by Thomas Meire
Replaced bacon-volume-button with GtkVolumeButton
1081
				gtk_volume_button_set_value(mute_button, vol < 5 ? 0 : vol - 5);
124 by mfcn
* Add src/bacon-volume.c, src/bacon-volume.h from totem
1082
				/*gtk_adjustment_set_value(volume,(volume->value < 5) ? 0 : volume->value-5);*/
2 by mfcn
Initial revision
1083
				break;
1084
	}
1085
	return FALSE;
1086
}
126 by mfcn
* remove config.h.in
1087
2 by mfcn
Initial revision
1088
int main(int argc, char* argv[])
1089
{
1090
	GtkWidget* app;
146 by mfcn
* .cvsignore:
1091
	GList *ptr;
2 by mfcn
Initial revision
1092
	GnomeClient *client;
1093
	GError *err = NULL;
1094
	int redraw_timeout_id;
126 by mfcn
* remove config.h.in
1095
	gboolean do_scan = FALSE;
1096
#if GNOME_14 
1097
	GOptionContext *ctx;
1098
	const GOptionEntry entries[] = {
1099
		{ "scan", 0, 0, G_OPTION_ARG_NONE, &do_scan, N_("Scan for stations"), NULL },
1100
		{ NULL }
1101
	};
1102
#endif	
2 by mfcn
Initial revision
1103
	bindtextdomain(PACKAGE, GNOMELOCALEDIR);  
1104
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
1105
	textdomain(PACKAGE);
1106
126 by mfcn
* remove config.h.in
1107
	g_set_application_name(_("Gnomeradio"));
1108
	
1109
#if GNOME_14
183 by mfcn
* help/C/gnomeradio.xml:
1110
    if (!g_thread_supported ()) g_thread_init(NULL);
126 by mfcn
* remove config.h.in
1111
	ctx = g_option_context_new("- Gnomeradio");
1112
	g_option_context_add_main_entries(ctx, entries, GETTEXT_PACKAGE);  
1113
	g_option_context_add_group(ctx, gst_init_get_option_group());
1114
	g_option_context_set_ignore_unknown_options(ctx, TRUE);	
1115
#endif	
1116
2 by mfcn
Initial revision
1117
	gnome_program_init(PACKAGE, VERSION, 
1118
					LIBGNOMEUI_MODULE, argc, argv, 
126 by mfcn
* remove config.h.in
1119
					GNOME_PROGRAM_STANDARD_PROPERTIES,
1120
#if GNOME_14
1121
					GNOME_PARAM_GOPTION_CONTEXT, ctx,
1122
#endif
2 by mfcn
Initial revision
1123
					NULL);
148 by mfcn
* data/icons/Makefile.am:
1124
	gtk_window_set_default_icon_name("gnomeradio");
2 by mfcn
Initial revision
1125
	/* Main app */
204 by mfcn
* src/gui.c (main):
1126
	main_visible = FALSE;
2 by mfcn
Initial revision
1127
	app = gnome_radio_gui();
1128
119 by mfcn
* Ported Recording to gstreamer
1129
	/* Initizialize GStreamer */
1130
	gst_init(&argc, &argv);
1131
	
2 by mfcn
Initial revision
1132
	/* Initizialize Gconf */
126 by mfcn
* remove config.h.in
1133
	if (!gconf_init(argc, argv, &err)) {
1134
		char *details;
1135
		details = g_strdup_printf(_("%s\n\nChanges to the settings won't be saved."), err->message);
1136
		show_warning_message(_("Failed to init GConf!"), details);
2 by mfcn
Initial revision
1137
		g_error_free(err); 
126 by mfcn
* remove config.h.in
1138
		g_free(details);
2 by mfcn
Initial revision
1139
		err = NULL;
126 by mfcn
* remove config.h.in
1140
	} else {
2 by mfcn
Initial revision
1141
		gconf_client_set_global_default_error_handler((GConfClientErrorHandlerFunc)gconf_error_handler);
1142
		gconf_client_set_error_handling(gconf_client_get_default(),  GCONF_CLIENT_HANDLE_ALL);
119 by mfcn
* Ported Recording to gstreamer
1143
		gnome_media_profiles_init(gconf_client_get_default());
2 by mfcn
Initial revision
1144
	}
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
1145
2 by mfcn
Initial revision
1146
	load_settings();
126 by mfcn
* remove config.h.in
1147
	start_mixer(FALSE, app);
1148
	start_radio(FALSE, app);
1149
	if (is_first_start() || do_scan) {
1150
		if (!radio_is_init()) {
1151
			g_message(_("Could not scan. Radio is not initialized."));
1152
		} else {
1153
			initial_frequency_scan(app);
1154
			set_first_time_flag();
1155
		}
1156
	}
166 by mfcn
* src/gui.c: (main):
1157
	create_tray_menu(app);
1158
	
1159
	gtk_combo_box_append_text(GTK_COMBO_BOX(preset_combo), _("manual"));
1160
	for (ptr = settings.presets; ptr; ptr = g_list_next(ptr)) {
1161
		preset *ps = (preset*)ptr->data;
1162
		gtk_combo_box_append_text(GTK_COMBO_BOX(preset_combo), ps->title);
1163
	}
1164
	preset_combo_set_item(mom_ps);
1165
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
1166
	gtk_widget_show_all(app);
204 by mfcn
* src/gui.c (main):
1167
	main_visible = TRUE;
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
1168
1169
	/* Create an tray icon */
1170
	create_tray_icon(app);
1171
22 by mfcn
Added hu.po. A little fix in gui.c (lirc error msg delayed playback)
1172
	adj_value_changed_cb(NULL, (gpointer) app);
126 by mfcn
* remove config.h.in
1173
	/*volume_value_changed_cb(NULL, NULL);*/
81 by mfcn
some more fixes...
1174
	
2 by mfcn
Initial revision
1175
#ifdef HAVE_LIRC
1176
	if(!my_lirc_init())
1177
	{
70 by mfcn
Fixes #167963
1178
/*		GtkWidget *dialog;
2 by mfcn
Initial revision
1179
		dialog = gtk_message_dialog_new(NULL, DIALOG_FLAGS, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
1180
					_("Could not start lirc"));
1181
		gtk_dialog_run (GTK_DIALOG (dialog));
1182
		gtk_widget_destroy (dialog);
70 by mfcn
Fixes #167963
1183
*/
126 by mfcn
* remove config.h.in
1184
		g_message(_("Could not start lirc!"));
2 by mfcn
Initial revision
1185
	}
1186
	else
1187
		start_lirc();
1188
#endif
1189
	
1190
/* Connect the Session Management signals
1191
 */
1192
	client = gnome_master_client();
1193
	g_signal_connect(GTK_OBJECT(client), "save_yourself",
1194
						GTK_SIGNAL_FUNC(save_session_cb), NULL);
1195
	g_signal_connect(GTK_OBJECT(client), "die",
1196
						GTK_SIGNAL_FUNC(session_die_cb), NULL);
1197
	g_signal_connect(GTK_OBJECT(app), "key-press-event",
1198
						GTK_SIGNAL_FUNC(key_press_event_cb), NULL);
1199
1200
	/* Redraw the status window every 3 seconds
1201
	 * Necessary, because the mono/stereo reception
1202
	 * needs some time to be correctly detected
1203
	 */
1204
	redraw_timeout_id = gtk_timeout_add(3000, (GtkFunction)redraw_status_window, NULL);	
1205
1206
	/* Checks if the volume has been changed by an 
1207
	 * external app
1208
	 */
116 by mfcn
* src/*.c, *.h: Changes mentioned by iceberg in #330444
1209
	/*gtk_timeout_add(100, (GtkFunction)poll_volume_change, NULL);*/
2 by mfcn
Initial revision
1210
1211
	gtk_main();
1212
		
1213
#ifdef HAVE_LIRC	
1214
	my_lirc_deinit();
1215
#endif
1216
1217
	return 0;
1218
}
119 by mfcn
* Ported Recording to gstreamer
1219
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
1220
static show_message(GtkMessageType type, const char* text, const char* details)
119 by mfcn
* Ported Recording to gstreamer
1221
{
1222
	GtkWidget *dialog;
1223
	
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
1224
	g_assert(text);
119 by mfcn
* Ported Recording to gstreamer
1225
	
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
1226
	dialog = gtk_message_dialog_new(NULL, DIALOG_FLAGS, type, GTK_BUTTONS_CLOSE,
119 by mfcn
* Ported Recording to gstreamer
1227
			text);
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
1228
	if (details) {
1229
		gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), details);
1230
	}
119 by mfcn
* Ported Recording to gstreamer
1231
	gtk_dialog_run(GTK_DIALOG (dialog));
1232
	gtk_widget_destroy(dialog);
122 by mfcn
* src/gui.c, src/gui.h, src/prefs.c, src/prefs.h, src/tech.c,
1233
}	
1234
1235
void show_error_message(const char* error, const char* details)
1236
{
1237
	show_message(GTK_MESSAGE_ERROR, error, details);
1238
}	
1239
1240
void show_warning_message(const char* warning, const char* details)
1241
{
1242
	show_message(GTK_MESSAGE_WARNING, warning, details);
119 by mfcn
* Ported Recording to gstreamer
1243
}