summaryrefslogtreecommitdiff
path: root/protocols/Weather/src/weather_popup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Weather/src/weather_popup.cpp')
-rw-r--r--protocols/Weather/src/weather_popup.cpp48
1 files changed, 29 insertions, 19 deletions
diff --git a/protocols/Weather/src/weather_popup.cpp b/protocols/Weather/src/weather_popup.cpp
index b19d36f67e..5f2ca4ac3b 100644
--- a/protocols/Weather/src/weather_popup.cpp
+++ b/protocols/Weather/src/weather_popup.cpp
@@ -132,8 +132,8 @@ int WeatherPopup(WPARAM hContact, LPARAM lParam)
POPUPDATAW ppd;
ppd.lchContact = hContact;
ppd.PluginData = ppd.lchIcon = Skin_LoadProtoIcon(MODULENAME, winfo.status);
- GetDisplay(&winfo, opt.pTitle, ppd.lpwzContactName);
- GetDisplay(&winfo, opt.pText, ppd.lpwzText);
+ GetDisplay(&winfo, GetTextValue('P'), ppd.lpwzContactName);
+ GetDisplay(&winfo, GetTextValue('p'), ppd.lpwzText);
ppd.PluginWindowProc = PopupDlgProc;
ppd.colorBack = (opt.UseWinColors) ? GetSysColor(COLOR_BTNFACE) : opt.BGColour;
ppd.colorText = (opt.UseWinColors) ? GetSysColor(COLOR_WINDOWTEXT) : opt.TextColour;
@@ -199,6 +199,18 @@ LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
//============ POPUP OPTIONS ============
+struct
+{
+ wchar_t c;
+ int id;
+ char *setting;
+}
+static controls[] =
+{
+ { 'p', IDC_PText, "PopupText" },
+ { 'P', IDC_PTitle, "PopupTitle" },
+};
+
// used to select the menu item for popup action menu
static void SelectMenuItem(HMENU hMenu, int Check)
{
@@ -210,7 +222,6 @@ static void SelectMenuItem(HMENU hMenu, int Check)
// but does not write to the database
void ReadPopupOpt(HWND hdlg)
{
- wchar_t text[MAX_TEXT_SIZE];
wchar_t str[512];
// popup colour
@@ -229,14 +240,6 @@ void ReadPopupOpt(HWND hdlg)
opt.AlertPopup = (BYTE)IsDlgButtonChecked(hdlg, IDC_POP2);
opt.PopupOnChange = (BYTE)IsDlgButtonChecked(hdlg, IDC_CH);
opt.ShowWarnings = (BYTE)IsDlgButtonChecked(hdlg, IDC_W);
-
- // popup texts
- wfree(&opt.pText);
- wfree(&opt.pTitle);
- GetDlgItemText(hdlg, IDC_PText, text, _countof(text));
- wSetData(&opt.pText, text);
- GetDlgItemText(hdlg, IDC_PTitle, text, _countof(text));
- wSetData(&opt.pTitle, text);
}
// copied and modified from NewStatusNotify
@@ -269,8 +272,10 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
CheckDlgButton(hdlg, IDC_POP1, opt.UpdatePopup ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_CH, opt.PopupOnChange ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_W, opt.ShowWarnings ? BST_CHECKED : BST_UNCHECKED);
- SetDlgItemText(hdlg, IDC_PText, opt.pText);
- SetDlgItemText(hdlg, IDC_PTitle, opt.pTitle);
+
+ for (auto &it : controls)
+ SetDlgItemText(hdlg, it.id, GetTextValue(it.c));
+
// setting popup delay option
_ltow(opt.pDelay, str, 10);
SetDlgItemText(hdlg, IDC_DELAY, str);
@@ -384,11 +389,8 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_PDEF:
// set the default value for popup texts
- SetTextDefault("Pp");
- SetDlgItemText(hdlg, IDC_PText, opt.pText);
- SetDlgItemText(hdlg, IDC_PTitle, opt.pTitle);
- wfree(&opt.pText);
- wfree(&opt.pTitle);
+ for (auto &it : controls)
+ SetDlgItemText(hdlg, it.id, GetDefaultText(it.c));
break;
case IDC_VAR3:
@@ -405,7 +407,6 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
hContact = opt.DefStn;
ReadPopupOpt(hdlg); // read new options to memory
WeatherPopup((WPARAM)opt.DefStn, (BOOL)TRUE); // display popup using new opt
- DestroyOptions();
LoadOptions(); // restore old option in memory
opt.DefStn = hContact;
break;
@@ -417,6 +418,15 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
case PSN_APPLY:
ReadPopupOpt(hdlg);
+ wchar_t textstr[MAX_TEXT_SIZE];
+ for (auto &it : controls) {
+ GetDlgItemText(hdlg, it.id, textstr, _countof(textstr));
+ if (!mir_wstrcmpi(textstr, GetDefaultText(it.c)))
+ g_plugin.delSetting(it.setting);
+ else
+ g_plugin.setWString(it.setting, textstr);
+ }
+
// save the options, and update main menu
SaveOptions();
UpdatePopupMenu(opt.UsePopup);