~ubuntu-branches/ubuntu/wily/me-tv/wily-proposed

« back to all changes in this revision

Viewing changes to src/meters_dialog.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Lamothe
  • Date: 2010-05-22 13:10:32 UTC
  • mfrom: (1.1.12 upstream) (3.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20100522131032-ibethpcgb8lpwt1w
Tags: 1.2.4-1
* New upstream release
* Maintainer change to Michael Lamothe
* Updated debian/control
  - Added libunique-dev to Build-Depends
  - Added libdbus-glib-1-dev to Build-Depends
* Added me-tv-player.1 to debian/me-tv.manpages

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2010 Michael Lamothe
3
 
 *
4
 
 * This file is part of Me TV
5
 
 *
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.
10
 
 * 
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.
15
 
 * 
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
19
 
 */
20
 
 
21
 
#include "meters_dialog.h"
22
 
#include "application.h"
23
 
 
24
 
MetersDialog& MetersDialog::create(Glib::RefPtr<Gtk::Builder> builder)
25
 
{
26
 
        MetersDialog* meters_dialog = NULL;
27
 
        builder->get_widget_derived("dialog_meters", meters_dialog);
28
 
        return *meters_dialog;
29
 
}
30
 
 
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())
33
 
{
34
 
        builder->get_widget("progress_bar_signal_strength", progress_bar_signal_strength);
35
 
        builder->get_widget("progress_bar_signal_noise", progress_bar_signal_noise);
36
 
 
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));
40
 
        set_meters(0, 0);
41
 
}
42
 
 
43
 
MetersDialog::~MetersDialog()
44
 
{
45
 
        stop();
46
 
}
47
 
 
48
 
void MetersDialog::start()
49
 
{
50
 
        meters_thread.start();
51
 
}
52
 
        
53
 
void MetersDialog::stop()
54
 
{
55
 
        gdk_threads_leave();
56
 
        meters_thread.join(true);
57
 
        gdk_threads_enter();
58
 
}
59
 
 
60
 
void MetersDialog::update_meters()
61
 
{
62
 
        gdouble strength = frontend.get_signal_strength();
63
 
        gdouble snr = frontend.get_snr();
64
 
        
65
 
        usleep(METERS_POLL_INTERVAL);
66
 
 
67
 
        GdkLock gdk_lock;
68
 
        set_meters(strength, snr);
69
 
}
70
 
 
71
 
void MetersDialog::set_meters(gdouble strength, gdouble snr)
72
 
{
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);
80
 
}
81
 
 
82
 
void MetersDialog::on_hide()
83
 
{
84
 
        stop();
85
 
        Widget::on_hide();
86
 
}
87