~ubuntu-branches/ubuntu/saucy/lordsawar/saucy

« back to all changes in this revision

Viewing changes to src/gui/main-preferences-dialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese
  • Date: 2008-12-20 13:52:12 UTC
  • mfrom: (1.1.6 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20081220135212-noeb2w3y98ebo7o9
Tags: 0.1.4-1
[ Barry deFreese ]
* New upstream release.
* Move 0.0.8-2.1 changelog entry to correct point in changelog.
* Make lordsawar-data suggest lordsawar.
* Update my e-mail address.
* Add build-depends on intltool, uuid-dev, and libboost-dev.
* Don't install locales since there are no translations currently.
* Add simple man page for new lordsawar-pbm binary.
* Drop gcc4.3 patches as they have been fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  Copyright (C) 2008 Ben Asselstine
 
2
//
 
3
//  This program is free software; you can redistribute it and/or modify
 
4
//  it under the terms of the GNU General Public License as published by
 
5
//  the Free Software Foundation; either version 2 of the License, or
 
6
//  (at your option) any later version.
 
7
//
 
8
//  This program is distributed in the hope that it will be useful,
 
9
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
//  GNU Library General Public License for more details.
 
12
//
 
13
//  You should have received a copy of the GNU General Public License
 
14
//  along with this program; if not, write to the Free Software
 
15
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
 
16
//  02110-1301, USA.
 
17
 
 
18
#include <config.h>
 
19
 
 
20
#include <libglademm/xml.h>
 
21
#include <sigc++/functors/mem_fun.h>
 
22
 
 
23
#include "main-preferences-dialog.h"
 
24
 
 
25
#include "glade-helpers.h"
 
26
#include "image-helpers.h"
 
27
#include "ucompose.hpp"
 
28
#include "defs.h"
 
29
#include "Configuration.h"
 
30
#include "sound.h"
 
31
 
 
32
 
 
33
MainPreferencesDialog::MainPreferencesDialog()
 
34
{
 
35
    Glib::RefPtr<Gnome::Glade::Xml> xml
 
36
        = Gnome::Glade::Xml::create(get_glade_path()
 
37
                                    + "/main-preferences-dialog.glade");
 
38
 
 
39
    Gtk::Dialog *d = 0;
 
40
    xml->get_widget("dialog", d);
 
41
    dialog.reset(d);
 
42
    decorate(dialog.get());
 
43
    window_closed.connect(sigc::mem_fun(dialog.get(), &Gtk::Dialog::hide));
 
44
 
 
45
    xml->get_widget("show_turn_popup_checkbutton", show_turn_popup_checkbutton);
 
46
    xml->get_widget("show_decorated_windows_checkbutton", show_decorated_windows_checkbutton);
 
47
    xml->get_widget("play_music_checkbutton", play_music_checkbutton);
 
48
    xml->get_widget("music_volume_scale", music_volume_scale);
 
49
    xml->get_widget("music_volume_hbox", music_volume_hbox);
 
50
    show_turn_popup_checkbutton->signal_toggled().connect(
 
51
        sigc::mem_fun(this, &MainPreferencesDialog::on_show_turn_popup_toggled));
 
52
    show_decorated_windows_checkbutton->signal_toggled().connect(
 
53
        sigc::mem_fun(this, &MainPreferencesDialog::on_show_decorated_windows_toggled));
 
54
    play_music_checkbutton->signal_toggled().connect(
 
55
        sigc::mem_fun(this, &MainPreferencesDialog::on_play_music_toggled));
 
56
    music_volume_scale->signal_value_changed().connect(
 
57
        sigc::mem_fun(this, &MainPreferencesDialog::on_music_volume_changed));
 
58
 
 
59
    show_turn_popup_checkbutton->set_active(Configuration::s_showNextPlayer);
 
60
    show_decorated_windows_checkbutton->set_active(!Configuration::s_decorated);
 
61
    play_music_checkbutton->set_active(Configuration::s_musicenable);
 
62
    music_volume_hbox->set_sensitive(Configuration::s_musicenable);
 
63
    music_volume_scale->set_value(Configuration::s_musicvolume * 100.0 / 128);
 
64
    
 
65
}
 
66
 
 
67
void MainPreferencesDialog::set_parent_window(Gtk::Window &parent)
 
68
{
 
69
    dialog->set_transient_for(parent);
 
70
    //dialog->set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
 
71
}
 
72
 
 
73
void MainPreferencesDialog::hide()
 
74
{
 
75
  dialog->hide();
 
76
}
 
77
 
 
78
void MainPreferencesDialog::run()
 
79
{
 
80
    dialog->show();
 
81
    dialog->run();
 
82
    
 
83
    Configuration::saveConfigurationFile(Configuration::configuration_file_path);
 
84
    dialog->hide();
 
85
}
 
86
 
 
87
void MainPreferencesDialog::on_show_turn_popup_toggled()
 
88
{
 
89
    Configuration::s_showNextPlayer = show_turn_popup_checkbutton->get_active();
 
90
}
 
91
 
 
92
void MainPreferencesDialog::on_show_decorated_windows_toggled()
 
93
{
 
94
    Configuration::s_decorated = !show_decorated_windows_checkbutton->get_active();
 
95
}
 
96
 
 
97
void MainPreferencesDialog::on_play_music_toggled()
 
98
{
 
99
    bool play_music = play_music_checkbutton->get_active();
 
100
 
 
101
    Configuration::s_musicenable = play_music;
 
102
 
 
103
    if (play_music)
 
104
    {
 
105
        Sound::getInstance()->enableBackground();
 
106
    }
 
107
    else
 
108
    {
 
109
        Sound::getInstance()->haltMusic();
 
110
        Sound::getInstance()->disableBackground();
 
111
    }
 
112
    music_volume_hbox->set_sensitive(Configuration::s_musicenable);
 
113
}
 
114
 
 
115
void MainPreferencesDialog::on_music_volume_changed()
 
116
{
 
117
    int volume = int(music_volume_scale->get_value() / 100 * 128);
 
118
    
 
119
#ifdef FL_SOUND
 
120
    Mix_VolumeMusic(volume);
 
121
#endif
 
122
 
 
123
    Configuration::s_musicvolume = volume;
 
124
}
 
125