soc.2009.vulture: 9e4632e7: Assorted cosmetic improvements.
gdick at soc.pidgin.im
gdick at soc.pidgin.im
Wed Jul 8 20:25:41 EDT 2009
-----------------------------------------------------------------
Revision: 9e4632e7cc5a28248b91cebb7d496a09db07dfbb
Ancestor: 65fc03fab04dc63fcc04ff80fe27a7909d1056fe
Author: gdick at soc.pidgin.im
Date: 2009-07-08T15:31:30
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/9e4632e7cc5a28248b91cebb7d496a09db07dfbb
Modified files:
vulture/vulture-res.rc vulture/vulture.c vulture/vulture.h
vulture/vultureconv.c vulture/vulturedlg.c
ChangeLog:
Assorted cosmetic improvements.
-------------- next part --------------
============================================================
--- vulture/vulture-res.rc 51d606e20dbade0d325ab768e89bb1ed0c2ab2f5
+++ vulture/vulture-res.rc f3435662e145624cc479fbf17f8d524047baa4f4
@@ -112,12 +112,12 @@ CAPTION "Join a Chat"
IDD_JOINCHAT DIALOG 0, 0, 204, 132
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
CAPTION "Join a Chat"
-FONT 8, "Ms Shell Dlg 2"
+FONT 8, "Ms Shell Dlg"
{
DEFPUSHBUTTON "OK", IDOK, 95, 115, 50, 14, BS_DEFPUSHBUTTON
PUSHBUTTON "Cancel", IDCANCEL, 150, 115, 50, 14, BS_PUSHBUTTON
LTEXT "Please choose an account, and then enter the details of the chat that you wish to join.", IDC_STATIC, 5, 5, 195, 20, SS_LEFT
- LTEXT "Account:", IDC_STATIC, 5, 32, 35, 10, SS_LEFT
+ LTEXT "&Account:", IDC_STATIC, 5, 32, 35, 10, SS_LEFT
CONTROL "", IDC_CBEX_ACCOUNTS, "ComboBoxEx32", 0x50000003, 45, 30, 155, 90
GROUPBOX "Details", IDC_STATIC_DETAILS, 5, 50, 195, 58
}
============================================================
--- vulture/vulture.c ea1e2e5c599034a934f3556c9ff8fb86841d479a
+++ vulture/vulture.c 7182bc7b2abddaf6071a17728c58ae8571916e70
@@ -25,6 +25,8 @@
#include <commctrl.h>
#include <glib.h>
#include <time.h>
+#include <string.h>
+#include <tchar.h>
#include "vulture.h"
#include "resource.h"
@@ -192,3 +194,48 @@ void VultureTimetToSystemTime(time_t t,
FileTimeToSystemTime(&filetime, lpsystime);
}
+
+
+/**
+ * Converts a GTK-style accelerated string (underscores) to a Win32-style one
+ * (ampersands).
+ *
+ * @param szUnderscored GTK-style string.
+ *
+ * @return Win32-style string. Free it with ProcHeapFree.
+ */
+LPTSTR VultureAmpersandify(LPCTSTR szUnderscored)
+{
+ /* Worst-case size. */
+ LPTSTR szAmpersanded = ProcHeapAlloc((_tcslen(szUnderscored) + 1) * 2 * sizeof(TCHAR));
+ LPTSTR szInAmp = szAmpersanded;
+
+ for(; *szUnderscored; szUnderscored++)
+ {
+ if(*szUnderscored == TEXT('&'))
+ {
+ /* Output *extra* ampersand. */
+ *szInAmp++ = TEXT('&');
+ }
+ else if(*szUnderscored == TEXT('_'))
+ {
+ if(szUnderscored[1] == TEXT('_'))
+ {
+ /* Skip the first underscore. */
+ szUnderscored++;
+ }
+ else
+ {
+ /* Output ampersand instead. */
+ *szInAmp++ = TEXT('&');
+ continue;
+ }
+ }
+
+ *szInAmp++ = *szUnderscored;
+ }
+
+ *szInAmp = TEXT('\0');
+
+ return szAmpersanded;
+}
============================================================
--- vulture/vulture.h cc767ffdfd651078fac1055de9851ae9d157e985
+++ vulture/vulture.h 1ea290ca0dba6c9e2c6384f66137fbf993d7b9f3
@@ -60,6 +60,7 @@ void VultureTimetToSystemTime(time_t t,
int MessageBoxFromStringTable(HWND hwnd, WORD wResourceString, UINT uiType);
void VultureTimetToSystemTime(time_t t, LPSYSTEMTIME lpsystime);
+LPTSTR VultureAmpersandify(LPCTSTR szUnderscored);
============================================================
--- vulture/vultureconv.c 0166ee8132a5b39263a6904197a9ed2169fe4818
+++ vulture/vultureconv.c 0f796f87318f187d5bbca149577cadd0f6025753
@@ -46,7 +46,7 @@ static int g_cyInput = 48;
static int g_cyInput = 48;
-static int g_cxNames = 64;
+static int g_cxNames = 128;
static LRESULT CALLBACK ConvContainerWndProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
============================================================
--- vulture/vulturedlg.c ecb0872dd5d797e36cd8a013490945150be004ba
+++ vulture/vulturedlg.c 5d5486acfea1f2b4b6ccfeab6aa96f4f82004b23
@@ -61,6 +61,7 @@ static void UpdateJoinChatFields(HWND hw
static HWND CreateJoinDlgLabel(HWND hwndDlg, int iFieldNum, LPCSTR szLabelUTF8);
static HWND CreateJoinDlgEdit(HWND hwndDlg, int iFieldNum, BOOL bNumber, BOOL bSecret);
static void UpdateJoinChatFields(HWND hwndDlg, GList **lplpglistFields, int *lpiMaxShowFields);
+static void AutoEnableJoinDlgOKButton(HWND hwndDlg, GList *lpglistFields);
/**
@@ -139,12 +140,20 @@ static INT_PTR CALLBACK JoinChatDlgProc(
/* Show fields. */
UpdateJoinChatFields(hwndDlg, &s_lpglistFields, &s_iMaxShowFields);
}
+
+ AutoEnableJoinDlgOKButton(hwndDlg, s_lpglistFields);
}
/* Let the system set the focus. */
return TRUE;
case WM_COMMAND:
+ /* Should really make sure this comes from an edit control, but
+ * no harm done.
+ */
+ if(HIWORD(wParam) == EN_CHANGE)
+ AutoEnableJoinDlgOKButton(hwndDlg, s_lpglistFields);
+
switch(LOWORD(wParam))
{
case IDOK:
@@ -190,7 +199,10 @@ static INT_PTR CALLBACK JoinChatDlgProc(
case IDC_CBEX_ACCOUNTS:
if(HIWORD(wParam) == CBN_SELCHANGE)
+ {
UpdateJoinChatFields(hwndDlg, &s_lpglistFields, &s_iMaxShowFields);
+ AutoEnableJoinDlgOKButton(hwndDlg, s_lpglistFields);
+ }
return TRUE;
}
@@ -284,11 +296,14 @@ static HWND CreateJoinDlgLabel(HWND hwnd
*/
static HWND CreateJoinDlgLabel(HWND hwndDlg, int iFieldNum, LPCSTR szLabelUTF8)
{
- LPTSTR szLabel = VultureUTF8ToTCHAR(szLabelUTF8);
+ LPTSTR szLabelTmp = VultureUTF8ToTCHAR(szLabelUTF8);
+ LPTSTR szLabel = VultureAmpersandify(szLabelTmp);
HWND hwndLabel;
RECT rc;
HFONT hfont;
+ g_free(szLabelTmp);
+
/* We cheat slightly and use right, bottom for width, height resp. */
rc.left = X_JC_LABEL;
rc.top = Y_JC_LABEL_FIRST + iFieldNum * CY_JC_INCREMENT;
@@ -308,7 +323,7 @@ static HWND CreateJoinDlgLabel(HWND hwnd
g_hInstance,
NULL);
- g_free(szLabel);
+ ProcHeapFree(szLabel);
/* Set the font, by querying the dialogue first. */
hfont = (HFONT)SendMessage(hwndDlg, WM_GETFONT, 0, 0);
@@ -440,3 +455,39 @@ static void UpdateJoinChatFields(HWND hw
g_list_free(getchatfields.lpglistFields);
}
+
+
+/**
+ * Enables or disables the OK button in the join-chat dialogue according to the
+ * values of the fields.
+ *
+ * @param hwndDlg Join-chat dialogue.
+ */
+static void AutoEnableJoinDlgOKButton(HWND hwndDlg, GList *lpglistFields)
+{
+ HWND hwndOK = GetDlgItem(hwndDlg, IDOK);
+ BOOL bEnable = TRUE;
+
+ if(lpglistFields)
+ {
+ for(; lpglistFields; lpglistFields = lpglistFields->next)
+ {
+ JOIN_DLG_FIELD *lpjdf = lpglistFields->data;
+
+ if(lpjdf->bRequired && GetWindowTextLength(lpjdf->hwndEdit) == 0)
+ bEnable = FALSE;
+ }
+ }
+ else bEnable = FALSE;
+
+ if(!bEnable)
+ {
+ /* Don't leave the focus on a disabled control. */
+ if(GetFocus() == hwndOK)
+ SendMessage(hwndDlg, WM_NEXTDLGCTL, 0, 0);
+
+ EnableWindow(hwndOK, FALSE);
+ }
+ else
+ EnableWindow(hwndOK, TRUE);
+}
More information about the Commits
mailing list