2
* Copyright (C) 2010 Michael Lamothe
4
* This file is part of Me TV
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Library General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
21
#include "meters_dialog.h"
22
#include "application.h"
24
MetersDialog& MetersDialog::create(Glib::RefPtr<Gtk::Builder> builder)
26
MetersDialog* meters_dialog = NULL;
27
builder->get_widget_derived("dialog_meters", meters_dialog);
28
return *meters_dialog;
31
MetersDialog::MetersDialog(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder) :
32
Gtk::Dialog(cobject), builder(builder), meters_thread(*this), frontend(get_application().device_manager.get_frontend())
34
builder->get_widget("progress_bar_signal_strength", progress_bar_signal_strength);
35
builder->get_widget("progress_bar_signal_noise", progress_bar_signal_noise);
37
Gtk::Button* button = NULL;
38
builder->get_widget("button_meters_close", button);
39
button->signal_clicked().connect(sigc::mem_fun(*this, &Gtk::Widget::hide));
43
MetersDialog::~MetersDialog()
48
void MetersDialog::start()
50
meters_thread.start();
53
void MetersDialog::stop()
56
meters_thread.join(true);
60
void MetersDialog::update_meters()
62
gdouble strength = frontend.get_signal_strength();
63
gdouble snr = frontend.get_snr();
65
usleep(METERS_POLL_INTERVAL);
68
set_meters(strength, snr);
71
void MetersDialog::set_meters(gdouble strength, gdouble snr)
73
gdouble bits16 = 0xFFFF;
74
Glib::ustring signal_strength_text = Glib::ustring::compose(_("Signal Strength (%1%%)"), (guint)((strength/bits16)*100));
75
Glib::ustring signal_noise_text = Glib::ustring::compose(_("S/N Ratio (%1%%)"), (guint)((snr/bits16)*100));
76
progress_bar_signal_strength->set_text(signal_strength_text);
77
progress_bar_signal_strength->set_fraction(strength/bits16);
78
progress_bar_signal_noise->set_text(signal_noise_text);
79
progress_bar_signal_noise->set_fraction(snr/bits16);
82
void MetersDialog::on_hide()