1
// Copyright (C) 2008 Ben Asselstine
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.
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.
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
20
#include <libglademm/xml.h>
21
#include <sigc++/functors/mem_fun.h>
23
#include "main-preferences-dialog.h"
25
#include "glade-helpers.h"
26
#include "image-helpers.h"
27
#include "ucompose.hpp"
29
#include "Configuration.h"
33
MainPreferencesDialog::MainPreferencesDialog()
35
Glib::RefPtr<Gnome::Glade::Xml> xml
36
= Gnome::Glade::Xml::create(get_glade_path()
37
+ "/main-preferences-dialog.glade");
40
xml->get_widget("dialog", d);
42
decorate(dialog.get());
43
window_closed.connect(sigc::mem_fun(dialog.get(), &Gtk::Dialog::hide));
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));
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);
67
void MainPreferencesDialog::set_parent_window(Gtk::Window &parent)
69
dialog->set_transient_for(parent);
70
//dialog->set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
73
void MainPreferencesDialog::hide()
78
void MainPreferencesDialog::run()
83
Configuration::saveConfigurationFile(Configuration::configuration_file_path);
87
void MainPreferencesDialog::on_show_turn_popup_toggled()
89
Configuration::s_showNextPlayer = show_turn_popup_checkbutton->get_active();
92
void MainPreferencesDialog::on_show_decorated_windows_toggled()
94
Configuration::s_decorated = !show_decorated_windows_checkbutton->get_active();
97
void MainPreferencesDialog::on_play_music_toggled()
99
bool play_music = play_music_checkbutton->get_active();
101
Configuration::s_musicenable = play_music;
105
Sound::getInstance()->enableBackground();
109
Sound::getInstance()->haltMusic();
110
Sound::getInstance()->disableBackground();
112
music_volume_hbox->set_sensitive(Configuration::s_musicenable);
115
void MainPreferencesDialog::on_music_volume_changed()
117
int volume = int(music_volume_scale->get_value() / 100 * 128);
120
Mix_VolumeMusic(volume);
123
Configuration::s_musicvolume = volume;