File: dlgMainConfig.cpp

package info (click to toggle)
pgadmin3 1.20.0~beta2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 73,704 kB
  • ctags: 18,591
  • sloc: cpp: 193,786; ansic: 18,736; sh: 5,154; pascal: 1,120; yacc: 927; makefile: 516; lex: 421; xml: 126; perl: 40
file content (183 lines) | stat: -rw-r--r-- 4,289 bytes parent folder | download
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// dlgMainConfig.cpp - Configure setting
//
//////////////////////////////////////////////////////////////////////////



// App headers
#include "pgAdmin3.h"

#include "dlg/dlgMainConfig.h"


// Icons
#include "images/property.pngc"





BEGIN_EVENT_TABLE(dlgMainConfig, DialogWithHelp)
	EVT_BUTTON (wxID_OK,              dlgMainConfig::OnOK)
	EVT_BUTTON (wxID_CANCEL,          dlgMainConfig::OnCancel)
	EVT_TEXT(XRCID("txtValue"),       dlgMainConfig::OnChange)
	EVT_TEXT(XRCID("cbValue"),        dlgMainConfig::OnChange)
	EVT_CHECKBOX(XRCID("chkValue"),   dlgMainConfig::OnChange)
END_EVENT_TABLE()


#define chkEnabled          CTRL_CHECKBOX("chkEnabled")
#define cbValue             CTRL_COMBOBOX("cbValue")
#define txtValue            CTRL_TEXT("txtValue")
#define chkValue            CTRL_CHECKBOX("chkValue")
#define txtComment          CTRL_TEXT("txtComment")
#define stName              CTRL_STATIC("stName")
#define stDescription       CTRL_STATIC("stDescription")


static const wxChar *contextStrings[] =
{
	__("Internal - not externally settable"),
	__("Postmaster - set on server start"),
	__("SIGHUP - reloaded on SIGHUP signal"),
	__("Backend - overridable in individual backend"),
	__("Suset - may be overridden by superuser"),
	__("Userlimit - may be set by user"),
	__("Userset - may be set by user"),
	__("Unknown")
};


static const wxChar *sourceStrings[] =
{
	__("Variable has still its initial default value"),
	__("Set via environment variable"),
	__("Set in configuration file"),
	__("Set on command line"),
	__("Set by unprivileged command"),
	__("Set in database variables"),
	__("Set in user variables"),
	__("Set in client parameters"),
	__("set by Override"),
	__("Set interactively"),
	__("Set by test"),
	__("Set by session parameters")
};


dlgMainConfig::dlgMainConfig(pgFrame *parent, pgSettingItem *_item) :
	DialogWithHelp((frmMain *)parent)
{
	SetFont(settings->GetSystemFont());
	LoadResource((wxWindow *)parent, wxT("dlgMainConfig"));

	// Icon
	SetIcon(*property_png_ico);
	RestorePosition();

	item = _item;

	SetTitle(wxString::Format(_("Configuration setting \"%s\""), item->name.c_str()));

	// Setup the default values

	cbValue->Hide();
	chkValue->Hide();

	if (!item->newLine)
	{
		if (item->orgLine)
			item->newLine = new pgConfigLine(item->orgLine);
		else
		{
			item->newLine = new pgConfigLine();
			item->newLine->item = item;
		}
	}

	chkEnabled->SetValue(!item->newLine->isComment);
	txtValue->SetValue(item->newLine->value);
	txtComment->SetValue(item->newLine->comment);

	wxFont fntLabel = stName->GetFont();
	fntLabel.SetWeight(wxBOLD);
	stName->SetFont(fntLabel);
	stName->SetLabel(item->name);

	wxString str;
	str += _("Category") + wxString(wxT(": ")) + item->category + END_OF_LINE;
	str += _("Context") + wxString(wxT(": "));
	str += wxGetTranslation(contextStrings[item->context]);
	str += END_OF_LINE;

	if (item->source != pgSettingItem::PGC_UNKNOWNSOURCE)
	{
		str += _("Current value") + wxString(wxT(": "));

		if (item->value == wxT("unset") && item->source == pgSettingItem::PGC_DEFAULT)
			str += _("unset");
		else
			str += item->value + END_OF_LINE wxT("     ") + wxGetTranslation(sourceStrings[item->source]);

		str += END_OF_LINE;
	}

	stDescription->SetLabel(str + END_OF_LINE + item->short_desc + END_OF_LINE + item->extra_desc);
	btnOK->Enable();
}


dlgMainConfig::~dlgMainConfig()
{
	SavePosition();
}


wxString dlgMainConfig::GetValue()
{
	return txtValue->GetValue();
}


wxString dlgMainConfig::GetHelpPage() const
{
	return wxT("pg/runtime-config");
}


void dlgMainConfig::OnChange(wxCommandEvent &ev)
{
}


void dlgMainConfig::OnOK(wxCommandEvent &ev)
{
#ifdef __WXGTK__
	if (!btnOK->IsEnabled())
		return;
#endif
	item->newLine->value = GetValue();
	item->newLine->comment = txtComment->GetValue();
	item->newLine->isComment = !chkEnabled->GetValue();

	EndModal(wxID_OK);
}


void dlgMainConfig::OnCancel(wxCommandEvent &ev)
{
	EndModal(wxID_CANCEL);
}

int dlgMainConfig::Go()
{
	// Set focus on the Password textbox and show modal
	return ShowModal();
}