This repository has been archived by the owner on Jul 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preferences_window.cxx
153 lines (123 loc) · 4.06 KB
/
preferences_window.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
Copyright (C) 2015, 2019 daltomi <[email protected]>
This file is part of flvlc.
flvlc is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
flvlc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with flvlc. If not, see <http://www.gnu.org/licenses/>.
*/
#include "preferences_window.hpp"
Preferences_Window::Preferences_Window(int x, int y,
Fl_Preferences *pref_parent)
: Fl_Menu_Window(x, y, 275, 240, 0), pref_parent(pref_parent)
{
color((Fl_Color)215);
grp_vlc = new Fl_Group(5, 80, 260, 50, "VLC:");
grp_vlc->box(FL_BORDER_BOX);
grp_vlc->color((Fl_Color)55);
grp_vlc->labelsize(9);
grp_vlc->labelfont(1);
grp_vlc->align(Fl_Align(FL_ALIGN_TOP_LEFT));
input_param = new Fl_Input(89, 95, 166, 20, "(*) Parameters:");
input_param->labelsize(9);
input_param->textsize(9);
input_param->callback(Preferences_Window::callback, this);
grp_vlc->end();
grp_general = new Fl_Group(5, 15, 260, 50, "General:");
grp_general->box(FL_BORDER_BOX);
grp_general->color((Fl_Color)55);
grp_general->labelsize(9);
grp_general->labelfont(1);
grp_general->align(Fl_Align(FL_ALIGN_TOP_LEFT));
ch_theme = new Fl_Choice(63, 25, 192, 20, "(*) Theme:");
ch_theme->down_box(FL_BORDER_BOX);
ch_theme->labelsize(9);
ch_theme->textsize(9);
ch_theme->deactivate();
ch_theme->callback(Preferences_Window::callback, this);
grp_general->end();
btn_cancel = new Fl_Button(200, 205, 60, 20, "&Cancel");
btn_cancel->box(FL_SHADOW_BOX);
btn_cancel->down_box(FL_SHADOW_BOX);
btn_cancel->color((Fl_Color)55);
btn_cancel->labelsize(9);
btn_cancel->callback(Preferences_Window::callback, this);
btn_save = new Fl_Button(125, 205, 60, 20, "&Save");
btn_save->box(FL_SHADOW_BOX);
btn_save->down_box(FL_SHADOW_BOX);
btn_save->color((Fl_Color)55);
btn_save->labelsize(9);
btn_save->callback(Preferences_Window::callback, this);
box_info_restart = new Fl_Box(5, 210, 95, 15, "(*) Need restart.");
box_info_restart->labelsize(9);
box_info_restart->align(Fl_Align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE));
grp_playlist = new Fl_Group(5, 145, 260, 50, "Playlist:");
grp_playlist->box(FL_BORDER_BOX);
grp_playlist->color((Fl_Color)55);
grp_playlist->labelfont(1);
grp_playlist->labelsize(9);
grp_playlist->align(Fl_Align(FL_ALIGN_TOP_LEFT));
chk_save = new Fl_Check_Button(15, 160, 20, 25);
chk_save->down_box(FL_DOWN_BOX);
chk_save->callback(Preferences_Window::callback, this);
box_info_save =
new Fl_Box(35, 160, 185, 25, "Automatically save and load.");
box_info_save->labelsize(9);
box_info_save->align(Fl_Align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE));
grp_playlist->end();
end();
initilize();
box(FL_BORDER_BOX);
set_modal();
clear_border();
position(x - (w() / 2), y - (h() / 2));
show();
}
Preferences_Window::~Preferences_Window()
{
delete btn_cancel;
delete btn_save;
delete ch_theme;
delete input_param;
delete box_info_restart;
delete box_info_save;
delete chk_save;
///////////////////
delete grp_vlc;
delete grp_general;
delete grp_playlist;
}
void Preferences_Window::initilize()
{
char *char_value;
int int_value;
if (0 != pref_parent->get("vlc", char_value, "")) {
input_param->value(char_value);
free(char_value);
}
if (0 != pref_parent->get("pls/save", int_value, 0)) {
chk_save->value(int_value);
}
}
// TODO:
// void Preferences_Window::initialize_theme()
//{
//}
void Preferences_Window::callback(Fl_Widget *w, void *data)
{
Preferences_Window *win = (Preferences_Window *)data;
if (win->btn_cancel == w) {
win->hide();
} else if (win->btn_save == w) {
win->pref_parent->set("vlc", win->input_param->value());
win->pref_parent->set("pls/save", win->chk_save->value());
win->pref_parent->flush();
win->hide();
}
}