3
* Copyright (C) 2001 J�rgen Scheibengruber
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.
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.
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
21
/*** the gui to gnomeradio */
24
#include <glib/gi18n.h>
25
#include <libgnome-media-profiles/gnome-media-profiles.h>
26
#include <gconf/gconf-client.h>
27
#include <dbus/dbus-glib.h>
28
#include <dbus/dbus-glib-bindings.h>
38
#include "../data/pixmaps/digits.xpm"
39
#include "../data/pixmaps/signal.xpm"
40
#include "../data/pixmaps/stereo.xpm"
41
#include "../data/pixmaps/freq_up.xpm"
42
#include "../data/pixmaps/freq_down.xpm"
44
#define DIGIT_WIDTH 20
45
#define DIGIT_HEIGTH 30
46
#define SIGNAL_WIDTH 25
47
#define STEREO_WIDTH 35
50
#define TRANSLATORS "TRANSLATORS"
52
GtkWidget* mute_button, *preset_combo;
57
gnomeradio_settings settings;
59
gboolean main_visible;
61
static GtkWidget *drawing_area;
62
static GdkPixbuf *digits, *signal_s, *stereo;
63
static GtkWidget *freq_scale;
64
static GtkWidget *rec_pixmap;
66
static int timeout_id, bp_timeout_id = -1, bp_timeout_steps = 0;
68
static DBusGProxy * connect_to_session (void);
70
static gboolean is_first_start(void)
72
GConfClient *client = gconf_client_get_default();
76
return !gconf_client_get_bool(client, "/apps/gnomeradio/first_time_flag", NULL);
79
static void set_first_time_flag(void)
81
GConfClient *client = gconf_client_get_default();
85
gconf_client_set_bool(client, "/apps/gnomeradio/first_time_flag", TRUE, NULL);
95
static gboolean initial_frequency_scan_cb(gpointer data)
97
static gfloat freq = FREQ_MIN - 4.0f/STEPS;
98
FreqScanData *fsd = data;
102
if (freq > FREQ_MAX) {
103
gtk_widget_destroy(fsd->dialog);
108
if (radio_check_station(freq)) {
109
char *text = g_strdup_printf(ngettext("%d station found", "%d stations found", g_list_length(fsd->stations) + 1),
110
g_list_length(fsd->stations) + 1);
111
gfloat *f = g_malloc(sizeof(gfloat));
112
gtk_label_set_text(GTK_LABEL(fsd->label), text);
115
g_print("%.2f is a station\n", freq);
118
fsd->stations = g_list_append(fsd->stations, f);
121
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(fsd->progress), MAX(0, (freq - FREQ_MIN)/(FREQ_MAX - FREQ_MIN)));
124
radio_set_freq(freq);
129
static void initial_frequency_scan(GtkWidget *app)
135
data.stations = NULL;
137
data.dialog = gtk_dialog_new_with_buttons(_("Scanning"),
138
GTK_WINDOW(app), DIALOG_FLAGS, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
139
/* gtk_dialog_set_has_separator(GTK_DIALOG(data.dialog), FALSE); */
140
gtk_window_set_resizable(GTK_WINDOW(data.dialog), FALSE);
142
title_hdr = g_strconcat("<span weight=\"bold\">", _("Scanning for available stations:"), "</span>", NULL);
143
title = gtk_label_new(title_hdr);
144
gtk_misc_set_alignment(GTK_MISC(title), 0, 0.5);
145
gtk_label_set_use_markup(GTK_LABEL(title), TRUE);
147
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(data.dialog))), title, FALSE, FALSE, 6);
149
data.progress = gtk_progress_bar_new();
150
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(data.dialog))), data.progress, TRUE, FALSE, 6);
152
data.label = gtk_label_new(_("No stations found"));
153
gtk_misc_set_alignment(GTK_MISC(data.label), 0, 0.5);
154
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(data.dialog))), data.label, TRUE, FALSE, 6);
156
gtk_widget_show_all(data.dialog);
159
timeout_id = g_timeout_add(1000/SCAN_SPEED, (GSourceFunc)initial_frequency_scan_cb, (gpointer)&data);
160
gtk_dialog_run(GTK_DIALOG(data.dialog));
164
g_source_remove(timeout_id);
166
gtk_widget_destroy(data.dialog);
168
if (g_list_length(data.stations) > 0) {
169
gfloat f = *((gfloat*)data.stations->data);
170
gtk_adjustment_set_value(adj, f*STEPS);
177
text = g_strdup_printf(ngettext("%d station found. \nDo you want to add it as preset?\n",
178
"%d stations found. \nDo you want to add them as presets?\n",
179
g_list_length(data.stations)),
180
g_list_length(data.stations));
182
dialog = gtk_message_dialog_new(GTK_WINDOW(app), DIALOG_FLAGS, GTK_MESSAGE_QUESTION,
183
GTK_BUTTONS_YES_NO, "%s", text);
186
int response = gtk_dialog_run(GTK_DIALOG(dialog));
187
gtk_widget_destroy(dialog);
189
for (ptr = data.stations; ptr; ptr = ptr->next) {
190
if (response == GTK_RESPONSE_YES) {
191
preset *ps = g_malloc0(sizeof(preset));
192
ps->title = g_strdup(_("unnamed"));
193
ps->freq = *((gfloat*)ptr->data);
194
settings.presets = g_list_append(settings.presets, ps);
202
int gtk_volume_button_get_value (GtkWidget *button)
204
return (int) (gtk_scale_button_get_value(GTK_SCALE_BUTTON(button)) * 100);
207
void gtk_volume_button_set_value (GtkWidget *button, int value)
209
gtk_scale_button_set_value(GTK_SCALE_BUTTON(button), (gdouble) value / 100);
212
static void prefs_button_clicked_cb(GtkButton *button, gpointer app)
217
dialog = prefs_window(app);
219
/* Michael Jochum <e9725005@stud3.tuwien.ac.at> proposed to not use gnome_dialog_set_parent()
220
but following instead. */
221
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(app));
222
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
224
/*gnome_dialog_set_parent(GNOME_DIALOG(dialog), GTK_WINDOW(app));*/
226
choise = GTK_RESPONSE_HELP;
227
while (choise == GTK_RESPONSE_HELP)
229
choise = gtk_dialog_run(GTK_DIALOG(dialog));
232
case GTK_RESPONSE_HELP:
233
display_help_cb("gnomeradio-settings");
236
/* We need the hide signal to get the value of the device_entry */
237
gtk_widget_hide(dialog);
238
gtk_widget_destroy(dialog);
243
void start_radio(gboolean restart, GtkWidget *app)
245
DriverType driver = DRIVER_ANY;
249
if (settings.driver) {
250
if (0 == strcmp(settings.driver, "v4l1"))
251
driver = DRIVER_V4L1;
252
if (0 == strcmp(settings.driver, "v4l2"))
253
driver = DRIVER_V4L2;
256
if (!radio_init(settings.device, driver))
258
char *caption = g_strdup_printf(_("Could not open device \"%s\"!"), settings.device);
259
char *detail = g_strdup_printf(_("Check your settings and make sure that no other\n"
260
"program is using %s.\nAlso make sure that you have read-access to it."), settings.device);
261
show_error_message(caption, detail);
266
prefs_button_clicked_cb(NULL, app);
270
void start_mixer(gboolean restart, GtkWidget *app)
277
res = mixer_init(settings.mixer_dev, settings.mixer);
283
buffer = g_strdup_printf(_("Mixer source \"%s\" is not a valid source!"), settings.mixer);
285
buffer = g_strdup_printf(_("Could not open \"%s\"!"), settings.mixer_dev);
287
show_error_message(buffer, NULL);
291
vol = mixer_get_volume();
293
gtk_volume_button_set_value(mute_button, vol);
294
/*gtk_adjustment_set_value(volume, (double)vol);*/
298
GList* get_mixer_recdev_list(void)
302
GList *result = NULL;
304
array = mixer_get_rec_devices();
312
char *text = g_strdup(dev);
313
result = g_list_append(result, text);
322
static gboolean redraw_status_window(void)
325
GdkWindow *real_window;
328
int val, freq[5], signal_strength, is_stereo;
330
val = (int)(rint(gtk_adjustment_get_value(adj)/STEPS * 100.0));
332
freq[0] = val / 10000;
333
freq[1] = (val % 10000) / 1000;
334
freq[2] = (val % 1000) / 100;
335
freq[3] = (val % 100) / 10;
338
signal_strength = radio_get_signal();
339
is_stereo = radio_get_stereo();
341
if (signal_strength > 3) signal_strength = 3;
342
if (signal_strength < 0) signal_strength = 0;
343
is_stereo = (is_stereo == 1) ? 1 : 0;
345
real_window = gtk_widget_get_window(drawing_area);
346
if (real_window == NULL)
347
/* UI has not been realized yet */
349
/* gdk_drawable_get_size(real_window, &win_width, &win_height); */
350
win_width = gdk_window_get_width (real_window);
352
/* use doublebuffering to avoid flickering */
353
/* window = gdk_pixmap_new(real_window, win_width, win_height, -1); */
355
cr = gdk_cairo_create (real_window);
356
cairo_set_source_rgb (cr, 0, 0, 0);
362
/* gdk_draw_drawable(window, gc, digits, freq[0] * DIGIT_WIDTH, 0, win_width - DIGIT_WIDTH*6, 5, DIGIT_WIDTH, DIGIT_HEIGTH); */
363
gdk_cairo_set_source_pixbuf (cr, digits, win_width - DIGIT_WIDTH*6 - freq[0] * DIGIT_WIDTH, 5);
364
cairo_rectangle (cr, win_width - DIGIT_WIDTH*6, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
367
cairo_rectangle(cr, win_width - DIGIT_WIDTH*6, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
371
/* gdk_draw_drawable(window, gc, digits, freq[1] * DIGIT_WIDTH, 0, win_width - DIGIT_WIDTH*5, 5, DIGIT_WIDTH, DIGIT_HEIGTH); */
372
gdk_cairo_set_source_pixbuf (cr, digits, win_width - DIGIT_WIDTH*5 - freq[1] * DIGIT_WIDTH, 5);
373
cairo_rectangle (cr, win_width - DIGIT_WIDTH*5, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
375
/* gdk_draw_drawable(window, gc, digits, freq[2] * DIGIT_WIDTH, 0, win_width - DIGIT_WIDTH*4, 5, DIGIT_WIDTH, DIGIT_HEIGTH); */
376
gdk_cairo_set_source_pixbuf (cr, digits, win_width - DIGIT_WIDTH*4 - freq[2] * DIGIT_WIDTH, 5);
377
cairo_rectangle (cr, win_width - DIGIT_WIDTH*4, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
379
/* gdk_draw_drawable(window, gc, digits, 10 * DIGIT_WIDTH, 0, win_width - DIGIT_WIDTH*3, 5, DIGIT_WIDTH, DIGIT_HEIGTH); */
380
gdk_cairo_set_source_pixbuf (cr, digits, win_width - DIGIT_WIDTH*3 - 10 * DIGIT_WIDTH, 5);
381
cairo_rectangle (cr, win_width - DIGIT_WIDTH*3, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
383
/* gdk_draw_drawable(window, gc, digits, freq[3] * DIGIT_WIDTH, 0, win_width - DIGIT_WIDTH*2, 5, DIGIT_WIDTH, DIGIT_HEIGTH); */
384
gdk_cairo_set_source_pixbuf (cr, digits, win_width - DIGIT_WIDTH*2 - freq[3] * DIGIT_WIDTH, 5);
385
cairo_rectangle (cr, win_width - DIGIT_WIDTH*2, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
387
/* gdk_draw_drawable(window, gc, digits, freq[4] * DIGIT_WIDTH, 0, win_width - DIGIT_WIDTH*1, 5, DIGIT_WIDTH, DIGIT_HEIGTH); */
388
gdk_cairo_set_source_pixbuf (cr, digits, win_width - DIGIT_WIDTH*1 - freq[4] * DIGIT_WIDTH, 5);
389
cairo_rectangle (cr, win_width - DIGIT_WIDTH*1, 5, DIGIT_WIDTH, DIGIT_HEIGTH);
391
/* gdk_draw_drawable(window, gc, signal_s, signal_strength * SIGNAL_WIDTH, 0, win_width - DIGIT_WIDTH*6-SIGNAL_WIDTH, 5, SIGNAL_WIDTH, DIGIT_HEIGTH); */
392
gdk_cairo_set_source_pixbuf (cr, signal_s, win_width - DIGIT_WIDTH*6-SIGNAL_WIDTH - signal_strength * SIGNAL_WIDTH, 5);
393
cairo_rectangle (cr, win_width - DIGIT_WIDTH*6-SIGNAL_WIDTH, 5, SIGNAL_WIDTH, DIGIT_HEIGTH);
395
/* 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); */
396
gdk_cairo_set_source_pixbuf (cr, stereo, win_width - DIGIT_WIDTH*6-SIGNAL_WIDTH-STEREO_WIDTH - is_stereo * STEREO_WIDTH, 5);
397
cairo_rectangle (cr, win_width - DIGIT_WIDTH*6-SIGNAL_WIDTH-STEREO_WIDTH, 5, STEREO_WIDTH, DIGIT_HEIGTH);
400
/* draw the pixmap to the real window */
401
/* gdk_draw_drawable(real_window, gc, window, 0, 0, 0, 0, win_width + 5, win_height); */
404
/* g_object_unref(G_OBJECT(window)); */
409
static gboolean draw_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
411
redraw_status_window();
415
void exit_gnome_radio(void)
417
if (settings.mute_on_exit)
427
const char* get_preset(float freq, int *num)
429
GList *node = settings.presets;
435
preset *ps = (preset*)node->data;
436
if (fabs(ps->freq - freq) < 0.01)
446
static void adj_value_changed_cb(GtkAdjustment* data, gpointer window)
449
float freq = rint(gtk_adjustment_get_value(adj))/STEPS;
450
const char *preset_title = get_preset(freq, &mom_ps);
452
preset_combo_set_item(mom_ps);
454
redraw_status_window();
457
buffer = g_strdup_printf(_("Gnomeradio - %s"), preset_title);
459
buffer = g_strdup_printf(_("Gnomeradio - %.2f MHz"), freq);
460
gtk_window_set_title(GTK_WINDOW(window), buffer);
461
if (tray_icon) gtk_status_icon_set_tooltip_text(GTK_STATUS_ICON(tray_icon), buffer); //gtk_tooltips_set_tip(tooltips, tray_icon, buffer, NULL);
464
buffer = g_strdup_printf(_("Frequency: %.2f MHz"), freq);
465
gtk_widget_set_tooltip_text(freq_scale, buffer);
468
radio_set_freq(gtk_adjustment_get_value(adj)/STEPS);
471
static void volume_value_changed_cb(GtkVolumeButton *button, gpointer user_data)
474
int vol = (int)(gtk_volume_button_get_value(mute_button) + 0.5f);
476
mixer_set_volume(vol);
478
/* text = g_strdup_printf(_("Volume: %d%%"), vol);
479
gtk_widget_set_tooltip_text(vol_scale, text);
483
g_signal_handler_block(G_OBJECT(mute_menuitem), mute_menuitem_toggled_cb_id);
484
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mute_menuitem), vol == 0);
485
g_signal_handler_unblock(G_OBJECT(mute_menuitem), mute_menuitem_toggled_cb_id);
490
static gboolean poll_volume_change(gpointer data)
493
if ((vol = mixer_get_volume()) < 0)
496
if (vol != (int)volume->value)
498
g_print("external volume change detected\n");
499
gtk_adjustment_set_value(volume, (double)vol);
506
static void change_frequency(gpointer data)
508
gboolean increase = (gboolean)data;
509
gint v = gtk_adjustment_get_value(adj);
513
if (v >= FREQ_MAX*STEPS)
514
gtk_adjustment_set_value(adj, FREQ_MIN*STEPS);
516
gtk_adjustment_set_value(adj, v+1);
520
if (v <= FREQ_MIN*STEPS)
521
gtk_adjustment_set_value(adj, FREQ_MAX*STEPS);
523
gtk_adjustment_set_value(adj, v-1);
527
static gboolean change_frequency_timeout(gpointer data)
529
change_frequency(data);
530
if (bp_timeout_steps < 10)
532
g_source_remove(bp_timeout_id);
533
bp_timeout_id = g_timeout_add(200 - 20*bp_timeout_steps,
534
(GSourceFunc)change_frequency_timeout, data);
540
static void step_button_pressed_cb(GtkButton *button, gpointer data)
542
bp_timeout_id = g_timeout_add(500, (GSourceFunc)change_frequency_timeout, data);
545
static void step_button_clicked_cb(GtkButton *button, gpointer data)
547
change_frequency(data);
550
static void step_button_released_cb(GtkButton *button, gpointer data)
552
if (bp_timeout_id > -1)
553
g_source_remove(bp_timeout_id);
555
bp_timeout_steps = 0;
558
static gboolean scan_freq(gpointer data)
560
static gint start, mom, max;
561
gint dir = (gint)(data);
564
max = (FREQ_MAX - FREQ_MIN) * STEPS;
567
if (radio_check_station(gtk_adjustment_get_value(adj)/STEPS) || (start > max)) {
574
mom = gtk_adjustment_get_value(adj);
577
if (mom > FREQ_MAX*STEPS)
578
mom = FREQ_MIN*STEPS;
579
else if (mom < FREQ_MIN*STEPS)
580
mom = FREQ_MAX*STEPS;
584
gtk_adjustment_set_value(adj, mom);
589
void scfw_button_clicked_cb(GtkButton *button, gpointer data)
592
g_source_remove(timeout_id);
598
timeout_id = g_timeout_add(1000/SCAN_SPEED, (GSourceFunc)scan_freq, (gpointer)1);
601
void scbw_button_clicked_cb(GtkButton *button, gpointer data)
604
g_source_remove(timeout_id);
610
timeout_id = g_timeout_add(1000/SCAN_SPEED, (GSourceFunc)scan_freq, (gpointer)(-1));
613
void preset_combo_set_item(gint i)
616
if (preset_combo == NULL) return;
617
gtk_combo_box_set_active(GTK_COMBO_BOX(preset_combo), i + 1);
620
static void preset_combo_change_cb(GtkWidget *combo, gpointer data)
623
mom_ps = gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) - 1;
625
if (mom_ps < 0) return;
627
ps = (preset*)g_list_nth_data(settings.presets, mom_ps);
628
gtk_adjustment_set_value(adj, ps->freq * STEPS);
631
void change_preset(gboolean next)
634
int len = g_list_length(settings.presets);
639
mom_ps = (mom_ps + 1) % len;
641
mom_ps = (mom_ps - 1 + len) % len;
643
ps = g_list_nth_data(settings.presets, mom_ps);
644
gtk_adjustment_set_value(adj, ps->freq*STEPS);
645
preset_combo_set_item(mom_ps);
648
void gnomeradio_switch_to_preset (gint index)
650
if (0 <= index && index < g_list_length(settings.presets))
652
preset *ps = g_list_nth_data(settings.presets, index);
653
gtk_adjustment_set_value(adj, ps->freq*STEPS);
655
preset_combo_set_item(mom_ps);
659
static void quit_button_clicked_cb(GtkButton *button, gpointer data)
664
void tray_icon_items_set_sensible(gboolean sensible)
668
int i, cnt = g_list_length(settings.presets);
671
menuitems = gtk_container_get_children(GTK_CONTAINER(tray_menu));
673
g_assert(cnt + 6 == g_list_length(menuitems));
675
/* Disable the presets */
676
for (i = 0; i < cnt; i++) {
677
menuitem = g_list_nth_data(menuitems, i);
678
gtk_widget_set_sensitive(menuitem, sensible);
681
/* Disable the mute button (separator => +1) */
682
menuitem = g_list_nth_data(menuitems, cnt + 1);
683
gtk_widget_set_sensitive(menuitem, sensible);
685
/* Disable the record button */
686
menuitem = g_list_nth_data(menuitems, cnt + 2);
687
gtk_widget_set_sensitive(menuitem, sensible);
689
/* Disable the quit button */
690
menuitem = g_list_nth_data(menuitems, cnt + 5);
691
gtk_widget_set_sensitive(menuitem, sensible);
694
static int start_recording(const gchar *destination, const char* station, const char* time)
696
Recording* recording;
699
if (!mixer_set_rec_device())
702
dialog = gtk_message_dialog_new(NULL, DIALOG_FLAGS, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
703
"Could not set \"%s\" as recording Source", settings.mixer);
704
gtk_dialog_run (GTK_DIALOG (dialog));
705
gtk_widget_destroy (dialog);
709
/* You can translate the filename for a recording:
710
* args for this format are: path, station title, time
712
filename = g_strdup_printf(_("%s/%s_%s"),
716
recording = recording_start(filename);
721
tray_icon_items_set_sensible(FALSE);
723
recording->station = g_strdup(station);
724
record_status_window(recording);
726
run_status_window(recording);
731
void rec_button_clicked_cb(GtkButton *button, gpointer app)
738
/* consult man strftime to translate this. This is a filename, so don't use "/" or ":", please */
739
strftime(time_str, 100, _("%B-%d-%Y_%H-%M-%S"), localtime(&t));
742
station = g_strdup_printf(_("%.2f MHz"), rint(gtk_adjustment_get_value(adj))/STEPS);
744
g_assert(mom_ps < g_list_length(settings.presets));
745
preset* ps = g_list_nth_data(settings.presets, mom_ps);
748
station = g_strdup(ps->title);
751
/* if (!check_filename(filename)) {
752
GtkWidget *errdialog;
753
errdialog = gtk_message_dialog_new(GTK_WINDOW(app), DIALOG_FLAGS, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
754
_("Error opening file '%s':\n%s"), filename, strerror(errno));
755
gtk_dialog_run (GTK_DIALOG (errdialog));
756
gtk_widget_destroy (errdialog);
758
start_recording(rec_settings.destination, station, time_str);
762
void toggle_volume(void)
765
int vol = mixer_get_volume();
773
mixer_set_volume(vol);
774
gtk_volume_button_set_value(mute_button, vol);
775
/*gtk_adjustment_set_value(volume, vol);*/
779
static void mute_button_toggled_cb(GtkButton *button, gpointer data)
781
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mute_button)))
783
gtk_widget_set_tooltip_text(mute_button, _("Unmute"));
787
gtk_widget_set_tooltip_text(mute_button, _("Mute"));
793
static void about_button_clicked_cb(GtkButton *button, gpointer data)
796
GtkIconTheme *icontheme;
797
static GtkWidget *about;
798
const char *authors[] = {"Jörgen Scheibengruber <mfcn@gmx.de>", NULL};
801
gchar *license = g_strconcat(
802
"\nGnomeradio is free software; you can redistribute it and/or modify ",
803
"it under the terms of the GNU General Public License as published by ",
804
"the Free Software Foundation; either version 2 of the License, or "
805
"(at your option) any later version.\n\r",
806
"Gnomeradio is distributed in the hope that it will be useful, ",
807
"but WITHOUT ANY WARRANTY; without even the implied warranty of ",
808
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ",
809
"GNU General Public License for more details.\n\r",
810
"You should have received a copy of the GNU General Public License ",
811
"along with Gnomeradio; if not, write to the Free Software Foundation, ",
812
"Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA",
815
/* Feel free to put your names here translators :-) */
816
char *translators = _("TRANSLATORS");
820
gtk_window_present(GTK_WINDOW(about));
823
icontheme = gtk_icon_theme_get_default();
824
app_icon = gtk_icon_theme_load_icon(icontheme, "gnomeradio", 48, 0, NULL);
827
text =_("Gnomeradio is a FM-Tuner application for the GNOME desktop. "
828
"It should work with all tuner hardware that is supported by the video4linux drivers.\n\n"
829
"This version has been compiled with LIRC support.");
831
text =_("Gnomeradio is a FM-Tuner application for the GNOME desktop. "
832
"It should work with all tuner hardware that is supported by the video4linux drivers.\n\n"
833
"This version has been compiled without LIRC support.");
836
gtk_show_about_dialog(NULL,
837
"program-name", "Gnomeradio",
840
"wrap-license", TRUE,
841
"copyright", "Copyright 2001 - 2006 Jörgen Scheibengruber",
843
"website", "http://www.gnome.org/projects/gnomeradio/",
844
"website-label", _("Gnomeradio Homepage"),
845
"authors", (const char **) authors,
846
"translator-credits", strcmp("TRANSLATORS", translators) ? translators : NULL,
847
"logo", app_icon, NULL);
851
/* about = gnome_about_new ("Gnomeradio", VERSION, "Copyright 2001 - 2006 Jörgen Scheibengruber",
852
text, (const char **) authors, NULL,
853
strcmp("TRANSLATORS", translators) ? translators : NULL,
856
gtk_widget_show(about);
857
g_object_add_weak_pointer(G_OBJECT(about), (gpointer)&about);
858
g_object_add_weak_pointer(G_OBJECT(about), (gpointer)&app_icon); */
861
static gint delete_event_cb(GtkWidget* window, GdkEventAny* e, gpointer data)
867
void display_help_cb(char *topic)
869
GError *error = NULL;
874
uri = g_strdup_printf("ghelp:gnomeradio?%s", topic);
876
uri = "ghelp:gnomeradio";
878
gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, &error);
882
dialog = gtk_message_dialog_new(NULL, DIALOG_FLAGS, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
883
"%s", error->message);
884
gtk_dialog_run (GTK_DIALOG (dialog));
885
gtk_widget_destroy (dialog);
886
g_error_free (error);
891
void toggle_mainwindow_visibility(GtkWidget *app)
893
static gint posx, posy;
894
if (gtk_widget_get_visible(app))
896
gtk_window_get_position(GTK_WINDOW(app), &posx, &posy);
897
gtk_widget_hide(app);
901
if ((posx >= 0) && (posy >= 0))
902
gtk_window_move(GTK_WINDOW(app), posx, posy);
903
gtk_window_present(GTK_WINDOW(app));
907
GtkWidget* gnome_radio_gui(void)
910
GtkWidget *prefs_button, *quit_button, *scfw_button, *scbw_button;
911
GtkWidget *stfw_button, *stbw_button, *about_button, *rec_button;
912
GtkWidget *prefs_pixmap, *quit_pixmap, *scfw_pixmap, *scbw_pixmap;
913
GtkWidget *stfw_pixmap, *stbw_pixmap, *about_pixmap;
914
GtkWidget *freq_up_pixmap, *freq_down_pixmap;
915
GdkPixbuf *freq_up_pixbuf, *freq_down_pixbuf;
916
GtkWidget *hbox1, *hbox2, *vbox, *menubox, *freq_vol_box;
917
GtkWidget *vseparator1, *vseparator4;
922
app = gtk_window_new(GTK_WINDOW_TOPLEVEL);
923
/* app = gnome_app_new(PACKAGE, _("Gnomeradio")); */
925
gtk_window_set_resizable(GTK_WINDOW(app), FALSE);
926
/*gtk_window_set_policy(GTK_WINDOW(app), FALSE, FALSE, FALSE);*/
927
gtk_window_set_wmclass(GTK_WINDOW(app), "gnomeradio", "Gnomeradio");
929
frame = gtk_frame_new(NULL);
931
quit_pixmap = gtk_image_new_from_stock(GTK_STOCK_QUIT, GTK_ICON_SIZE_BUTTON);
932
prefs_pixmap = gtk_image_new_from_stock(GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_LARGE_TOOLBAR);
933
scfw_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_FORWARD, GTK_ICON_SIZE_LARGE_TOOLBAR);
934
scbw_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_REWIND, GTK_ICON_SIZE_LARGE_TOOLBAR);
935
stfw_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_NEXT, GTK_ICON_SIZE_LARGE_TOOLBAR);
936
stbw_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PREVIOUS, GTK_ICON_SIZE_LARGE_TOOLBAR);
937
about_pixmap = gtk_image_new_from_stock(GTK_STOCK_ABOUT, GTK_ICON_SIZE_LARGE_TOOLBAR);
938
/*mute_pixmap = gtk_image_new_from_stock(GNOME_STOCK_VOLUME, GTK_ICON_SIZE_LARGE_TOOLBAR);*/
939
rec_pixmap = gtk_image_new_from_stock(GTK_STOCK_MEDIA_RECORD, GTK_ICON_SIZE_LARGE_TOOLBAR);
940
/*help_pixmap = gtk_image_new_from_stock(GTK_STOCK_HELP, GTK_ICON_SIZE_LARGE_TOOLBAR);*/
942
quit_button = gtk_button_new();
943
prefs_button = gtk_button_new();
944
scfw_button = gtk_button_new();
945
scbw_button = gtk_button_new();
946
stfw_button = gtk_button_new();
947
stbw_button = gtk_button_new();
948
about_button = gtk_button_new();
949
/*mute_button = gtk_toggle_button_new();*/
950
mute_button = gtk_volume_button_new();
951
gtk_button_set_relief(GTK_BUTTON(mute_button), GTK_RELIEF_NORMAL);
952
rec_button = gtk_button_new();
953
/*help_button = gtk_button_new();*/
955
gtk_container_add(GTK_CONTAINER(quit_button), quit_pixmap);
956
gtk_container_add(GTK_CONTAINER(prefs_button), prefs_pixmap);
957
gtk_container_add(GTK_CONTAINER(scfw_button), scfw_pixmap);
958
gtk_container_add(GTK_CONTAINER(scbw_button), scbw_pixmap);
959
gtk_container_add(GTK_CONTAINER(stfw_button), stfw_pixmap);
960
gtk_container_add(GTK_CONTAINER(stbw_button), stbw_pixmap);
961
gtk_container_add(GTK_CONTAINER(about_button), about_pixmap);
962
/*gtk_container_add(GTK_CONTAINER(mute_button), mute_pixmap);*/
963
gtk_container_add(GTK_CONTAINER(rec_button), rec_pixmap);
964
/*gtk_container_add(GTK_CONTAINER(help_button), help_pixmap);*/
966
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
967
hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
968
hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
969
menubox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
970
freq_vol_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
972
adj = GTK_ADJUSTMENT(gtk_adjustment_new(SUNSHINE*STEPS, FREQ_MIN*STEPS, FREQ_MAX*STEPS+1, 1, STEPS, 1));
973
/* volume = GTK_ADJUSTMENT(gtk_adjustment_new(100, 0, 101, 1, 10, 1)); */
975
preset_combo = gtk_combo_box_text_new();
976
g_signal_connect(G_OBJECT(preset_combo), "changed", G_CALLBACK(preset_combo_change_cb), NULL);
978
gtk_widget_set_size_request(preset_combo, 10, -1);
979
label = gtk_label_new(_("Presets:"));
981
freq_scale = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, adj);
982
/*gtk_range_set_update_policy(GTK_RANGE(freq_scale), GTK_UPDATE_DELAYED);*/
983
/*vol_scale = gtk_hscale_new(volume);*/
985
/*vol_up_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)vol_up_xpm);
986
vol_down_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)vol_down_xpm);*/
987
freq_up_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)freq_up_xpm);
988
freq_down_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)freq_down_xpm);
990
/*vol_up_pixmap = gtk_image_new_from_pixbuf(vol_up_pixbuf);
991
vol_down_pixmap = gtk_image_new_from_pixbuf(vol_down_pixbuf);*/
992
freq_up_pixmap = gtk_image_new_from_pixbuf(freq_up_pixbuf);
993
freq_down_pixmap = gtk_image_new_from_pixbuf(freq_down_pixbuf);
995
/*gtk_widget_set_usize(freq_scale, 160, 10);*/
996
/*gtk_widget_set_size_request(freq_scale, 160, -1);*/
998
gtk_widget_realize(app);
999
gtk_widget_get_window(app);
1000
drawing_area = gtk_drawing_area_new();
1002
digits = gdk_pixbuf_new_from_xpm_data((const char**)digits_xpm);
1003
signal_s = gdk_pixbuf_new_from_xpm_data((const char**)signal_xpm);
1004
stereo = gdk_pixbuf_new_from_xpm_data((const char**)stereo_xpm);
1006
vseparator1 = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
1007
/*vseparator2 = gtk_vseparator_new();*/
1008
/*vseparator3 = gtk_vseparator_new();*/
1009
vseparator4 = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
1011
gtk_scale_set_digits(GTK_SCALE(freq_scale), 0);
1012
gtk_scale_set_draw_value(GTK_SCALE(freq_scale), FALSE);
1013
/* gtk_scale_set_digits(GTK_SCALE(vol_scale), 0);
1014
gtk_scale_set_draw_value(GTK_SCALE(vol_scale), FALSE);
1016
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mute_button), mixer_get_volume() == 0);*/
1018
gtk_widget_set_size_request(drawing_area, DIGIT_WIDTH*6+10+SIGNAL_WIDTH+STEREO_WIDTH, DIGIT_HEIGTH+10);
1020
gtk_container_add(GTK_CONTAINER(frame), drawing_area);
1022
gtk_box_pack_start(GTK_BOX(hbox2), scbw_button, FALSE, FALSE, 2);
1023
gtk_box_pack_start(GTK_BOX(hbox2), stbw_button, FALSE, FALSE, 2);
1024
gtk_box_pack_start(GTK_BOX(hbox2), stfw_button, FALSE, FALSE, 2);
1025
gtk_box_pack_start(GTK_BOX(hbox2), scfw_button, FALSE, FALSE, 2);
1026
gtk_box_pack_start(GTK_BOX(hbox2), vseparator1, FALSE, FALSE, 2);
1027
gtk_box_pack_start(GTK_BOX(hbox2), mute_button, FALSE, FALSE, 2);
1028
/*gtk_box_pack_start(GTK_BOX(hbox2), vseparator2, TRUE, TRUE, 3);*/
1029
gtk_box_pack_start(GTK_BOX(hbox2), rec_button, FALSE, FALSE, 2);
1030
gtk_box_pack_start(GTK_BOX(hbox2), vseparator4, FALSE, FALSE, 2);
1031
/*gtk_box_pack_start(GTK_BOX(hbox2), help_button, FALSE, FALSE, 2);*/
1032
gtk_box_pack_start(GTK_BOX(hbox2), prefs_button, FALSE, FALSE, 2);
1033
gtk_box_pack_start(GTK_BOX(hbox2), about_button, FALSE, FALSE, 2);
1034
/*gtk_box_pack_start(GTK_BOX(hbox2), quit_button, FALSE, FALSE, 2);*/
1036
gtk_box_pack_start(GTK_BOX(hbox1), frame, FALSE, FALSE, 3);
1037
gtk_box_pack_start(GTK_BOX(hbox1), menubox, TRUE, TRUE, 3);
1039
gtk_box_pack_start(GTK_BOX(menubox), label, TRUE, TRUE, 0);
1040
gtk_box_pack_start(GTK_BOX(menubox), preset_combo, TRUE, TRUE, 0);
1042
gtk_box_pack_start(GTK_BOX(freq_vol_box), freq_down_pixmap, FALSE, FALSE, 2);
1043
gtk_box_pack_start(GTK_BOX(freq_vol_box), freq_scale, TRUE, TRUE, 0);
1044
gtk_box_pack_start(GTK_BOX(freq_vol_box), freq_up_pixmap, FALSE, FALSE, 2);
1045
/*gtk_box_pack_start(GTK_BOX(freq_vol_box), vseparator3, FALSE, FALSE, 2);
1046
gtk_box_pack_start(GTK_BOX(freq_vol_box), vol_down_pixmap, FALSE, FALSE, 2);
1047
gtk_box_pack_start(GTK_BOX(freq_vol_box), vol_scale, TRUE, TRUE, 0);
1048
gtk_box_pack_start(GTK_BOX(freq_vol_box), vol_up_pixmap, FALSE, FALSE, 2);*/
1050
gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 4);
1051
gtk_box_pack_start(GTK_BOX(vbox), freq_vol_box, TRUE, TRUE, 2);
1052
gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 4);
1054
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
1056
gtk_container_set_border_width(GTK_CONTAINER(vbox), 3);
1057
gtk_container_set_border_width(GTK_CONTAINER(frame), 2);
1059
/* gnome_app_set_contents(GNOME_APP(app), vbox); */
1061
/*status = gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_NEVER);*/
1063
/*gnome_app_set_statusbar(GNOME_APP(app), status);*/
1065
g_signal_connect(G_OBJECT(app), "delete_event", G_CALLBACK(delete_event_cb), NULL);
1066
g_signal_connect(G_OBJECT(quit_button), "clicked", G_CALLBACK(quit_button_clicked_cb), NULL);
1067
g_signal_connect(G_OBJECT(adj), "value-changed", G_CALLBACK(adj_value_changed_cb), (gpointer) app);
1068
g_signal_connect(G_OBJECT(mute_button), "value-changed", G_CALLBACK(volume_value_changed_cb), NULL);
1069
g_signal_connect(G_OBJECT(stfw_button), "pressed", G_CALLBACK(step_button_pressed_cb), (gpointer)TRUE);
1070
g_signal_connect(G_OBJECT(stbw_button), "pressed", G_CALLBACK(step_button_pressed_cb), (gpointer)FALSE);
1071
g_signal_connect(G_OBJECT(stfw_button), "clicked", G_CALLBACK(step_button_clicked_cb), (gpointer)TRUE);
1072
g_signal_connect(G_OBJECT(stbw_button), "clicked", G_CALLBACK(step_button_clicked_cb), (gpointer)FALSE);
1073
g_signal_connect(G_OBJECT(stfw_button), "released", G_CALLBACK(step_button_released_cb), NULL);
1074
g_signal_connect(G_OBJECT(stbw_button), "released", G_CALLBACK(step_button_released_cb), NULL);
1075
g_signal_connect(G_OBJECT(scfw_button), "clicked", G_CALLBACK(scfw_button_clicked_cb), NULL);
1076
g_signal_connect(G_OBJECT(scbw_button), "clicked", G_CALLBACK(scbw_button_clicked_cb), NULL);
1077
g_signal_connect(G_OBJECT(about_button), "clicked", G_CALLBACK(about_button_clicked_cb), NULL);
1078
g_signal_connect(G_OBJECT(rec_button), "clicked", G_CALLBACK(rec_button_clicked_cb), (gpointer) app);
1079
g_signal_connect(G_OBJECT(prefs_button), "clicked", G_CALLBACK(prefs_button_clicked_cb), (gpointer) app);
1080
g_signal_connect(G_OBJECT(drawing_area), "draw", G_CALLBACK(draw_cb), NULL);
1082
gtk_widget_set_tooltip_text(scbw_button, _("Scan Backwards"));
1083
gtk_widget_set_tooltip_text(scfw_button, _("Scan Forwards"));
1084
gtk_widget_set_tooltip_text(stbw_button, _("0.05 MHz Backwards"));
1085
gtk_widget_set_tooltip_text(stfw_button, _("0.05 MHz Forwards"));
1086
gtk_widget_set_tooltip_text(about_button, _("About Gnomeradio"));
1087
gtk_widget_set_tooltip_text(rec_button, _("Record radio as Wave, OGG or MP3"));
1088
gtk_widget_set_tooltip_text(prefs_button, _("Edit your Preferences"));
1089
gtk_widget_set_tooltip_text(mute_button, _("Adjust the Volume"));
1090
gtk_widget_set_tooltip_text(quit_button, _("Quit"));
1091
text = g_strdup_printf(_("Frequency: %.2f MHz"), gtk_adjustment_get_value(adj)/STEPS);
1092
gtk_widget_set_tooltip_text(freq_scale, text);
1094
/* text = g_strdup_printf(_("Volume: %d%%"), (gint)volume->value);
1095
gtk_widget_set_tooltip_text(vol_scale, text);
1098
gtk_container_add (GTK_CONTAINER (app), vbox);
1099
gtk_widget_show_all (vbox);
1105
session_die_cb(void)
1107
if (settings.mute_on_exit)
1119
save_session_cb(gint phase, GnomeSaveStyle save_style,
1120
gint is_shutdown, GnomeInteractStyle interact_style,
1121
gint is_fast, gpointer client_data)
1128
gconf_error_handler(GConfClient *client, GError *error)
1130
g_print("GConf error: %s\n", error->message);
1134
key_press_event_cb(GtkWidget *app, GdkEventKey *event, gpointer data)
1136
int vol = (int)(gtk_volume_button_get_value(mute_button) + 0.5f);
1138
switch (event->keyval)
1140
case GDK_KEY_F1: display_help_cb(NULL);
1149
rec_button_clicked_cb(NULL, app);
1152
scfw_button_clicked_cb(NULL, NULL);
1155
scbw_button_clicked_cb(NULL, NULL);
1158
change_preset(TRUE);
1161
change_preset(FALSE);
1163
case GDK_KEY_KP_Add:
1165
gtk_volume_button_set_value(mute_button, vol > 95 ? 100 : vol + 5);
1166
/*gtk_adjustment_set_value(volume, (volume->value > 95) ? 100 : volume->value+5);*/
1169
case GDK_KEY_KP_Subtract:
1170
gtk_volume_button_set_value(mute_button, vol < 5 ? 0 : vol - 5);
1171
/*gtk_adjustment_set_value(volume,(volume->value < 5) ? 0 : volume->value-5);*/
1177
int main(int argc, char* argv[])
1182
gboolean do_scan = FALSE;
1183
GOptionContext *ctx;
1184
const GOptionEntry entries[] = {
1185
{ "scan", 0, 0, G_OPTION_ARG_NONE, &do_scan, N_("Scan for stations"), NULL },
1188
bindtextdomain(PACKAGE, GNOMELOCALEDIR);
1189
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
1190
textdomain(PACKAGE);
1192
g_set_application_name(_("Gnomeradio"));
1194
if (!g_thread_supported ()) g_thread_init(NULL);
1195
ctx = g_option_context_new("- Gnomeradio");
1196
g_option_context_add_main_entries(ctx, entries, GETTEXT_PACKAGE);
1197
g_option_context_add_group(ctx, gst_init_get_option_group());
1198
g_option_context_set_ignore_unknown_options(ctx, TRUE);
1200
gtk_init(&argc, &argv);
1201
gtk_window_set_default_icon_name("gnomeradio");
1203
main_visible = FALSE;
1204
app = gnome_radio_gui();
1206
/* Initizialize GStreamer */
1207
gst_init(&argc, &argv);
1209
/* Initizialize Gconf */
1210
if (!gconf_init(argc, argv, &err)) {
1212
details = g_strdup_printf(_("%s\n\nChanges to the settings won't be saved."), err->message);
1213
show_warning_message(_("Failed to init GConf!"), details);
1218
gconf_client_set_global_default_error_handler((GConfClientErrorHandlerFunc)gconf_error_handler);
1219
gconf_client_set_error_handling(gconf_client_get_default(), GCONF_CLIENT_HANDLE_ALL);
1220
gnome_media_profiles_init(gconf_client_get_default());
1224
start_mixer(FALSE, app);
1225
start_radio(FALSE, app);
1226
if (is_first_start() || do_scan) {
1227
if (!radio_is_init()) {
1228
g_message(_("Could not scan. Radio is not initialized."));
1230
initial_frequency_scan(app);
1231
set_first_time_flag();
1234
create_tray_menu(app);
1236
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(preset_combo), _("manual"));
1237
for (ptr = settings.presets; ptr; ptr = g_list_next(ptr)) {
1238
preset *ps = (preset*)ptr->data;
1239
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(preset_combo), ps->title);
1241
preset_combo_set_item(mom_ps);
1243
gtk_widget_show_all(app);
1244
main_visible = TRUE;
1246
/* Create an tray icon */
1247
create_tray_icon(app);
1249
adj_value_changed_cb(NULL, (gpointer) app);
1250
/*volume_value_changed_cb(NULL, NULL);*/
1255
/* GtkWidget *dialog;
1256
dialog = gtk_message_dialog_new(NULL, DIALOG_FLAGS, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
1257
_("Could not start lirc"));
1258
gtk_dialog_run (GTK_DIALOG (dialog));
1259
gtk_widget_destroy (dialog);
1261
g_message(_("Could not start lirc!"));
1267
/* Connect the Session Management signals
1270
proxy = connect_to_session ();
1271
g_signal_connect(G_OBJECT(app), "key-press-event",
1272
G_CALLBACK(key_press_event_cb), NULL);
1274
/* Redraw the status window every 3 seconds
1275
* Necessary, because the mono/stereo reception
1276
* needs some time to be correctly detected
1278
g_timeout_add(3000, (GSourceFunc)redraw_status_window, NULL);
1280
/* Checks if the volume has been changed by an
1283
/*gtk_timeout_add(100, (GSourceFunc)poll_volume_change, NULL);*/
1292
DBusGConnection *conn;
1293
conn = (DBusGConnection *)g_object_get_data (G_OBJECT (proxy), "connection");
1295
dbus_g_connection_unref (conn);
1297
g_object_unref (proxy);
1303
static DBusGProxy * connect_to_session (void)
1305
DBusGConnection *connection;
1307
GError *error = NULL;
1309
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
1312
g_warning ("%s", error->message);
1313
g_error_free(error);
1316
/* Get the current session object */
1317
proxy = dbus_g_proxy_new_for_name (connection,
1318
"org.gnome.SessionManager",
1319
"/org/gnome/SessionManager",
1320
"org.gnome.SessionManager");
1323
g_warning ("Unable to get the SessionManager.");
1324
dbus_g_connection_unref (connection);
1328
dbus_g_proxy_add_signal (proxy, "SessionOver", G_TYPE_INVALID, G_TYPE_INVALID);
1329
dbus_g_proxy_connect_signal (proxy, "SessionOver", G_CALLBACK (session_die_cb), NULL, NULL);
1331
g_object_set_data (G_OBJECT (proxy), "connection", connection);
1335
static void show_message(GtkMessageType type, const char* text, const char* details)
1341
dialog = gtk_message_dialog_new(NULL, DIALOG_FLAGS, type, GTK_BUTTONS_CLOSE,
1344
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", details);
1346
gtk_dialog_run(GTK_DIALOG (dialog));
1347
gtk_widget_destroy(dialog);
1350
void show_error_message(const char* error, const char* details)
1352
show_message(GTK_MESSAGE_ERROR, error, details);
1355
void show_warning_message(const char* warning, const char* details)
1357
show_message(GTK_MESSAGE_WARNING, warning, details);