aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--c/common.c2
-rw-r--r--c/datalistview.c35
-rw-r--r--c/defs.h2
-rw-r--r--c/episodelistview.c4
-rw-r--r--c/main.c7
5 files changed, 40 insertions, 10 deletions
diff --git a/c/common.c b/c/common.c
index c1f9614..c672a4d 100644
--- a/c/common.c
+++ b/c/common.c
@@ -6,7 +6,7 @@
/* Convert zero-terminated non-wide (multi-byte) string to
* zero-terminated wide/non-wide string depending on UNICODE. */
TCHAR *
-TSZFromSZ(char *sz, int iCp)
+TSZFromSZ(const char *sz, int iCp)
{
TCHAR *tsz;
diff --git a/c/datalistview.c b/c/datalistview.c
index 873befc..4a0208d 100644
--- a/c/datalistview.c
+++ b/c/datalistview.c
@@ -34,9 +34,17 @@ DlvCreate(HWND hWnd)
void
DlvShowEpisode(int iEpisode)
{
+ HWND hListView;
int r;
+ LVITEM lviKey, lviValue;
term_t t;
+ hListView = GetDlgItem(gDlv_hWnd, IDC_DATALISTVIEW);
+ ListView_DeleteAllItems(hListView);
+
+ lviKey.mask = LVIF_TEXT;
+ lviValue.mask = LVIF_TEXT;
+
t = PL_new_term_refs(3);
if(!PL_put_integer(t+0, iEpisode))
return;
@@ -56,23 +64,46 @@ DlvShowEpisode(int iEpisode)
tHead = PL_new_term_ref();
tList = PL_copy_term_ref(t+2);
- while (PL_get_list(tList, tHead, tList)) {
+ for (int i = 0; PL_get_list(tList, tHead, tList); i++) {
atom_t aKey;
const char *szKey;
char *szValue;
+ TCHAR *tszKey, *tszValue;
term_t tValue;
size_t iArity;
if (!PL_get_name_arity(tHead, &aKey, &iArity))
continue;
szKey = PL_atom_chars(aKey);
+ if (!szKey)
+ continue;
if (!PL_get_arg(1, tHead, tValue))
continue;
if (!PL_get_atom_chars(tValue, &szValue))
continue;
- //printf("%s/%d: %s\n", szKey, iArity, szValue);
+ tszKey = TSZFromSZ(szKey, CP_UTF8);
+ if (!tszKey)
+ continue;
+ tszValue = TSZFromSZ(szValue, CP_UTF8);
+ if (!tszValue)
+ continue;
+
+ lviKey.mask = LVIF_TEXT;
+ lviKey.iItem = i;
+ lviKey.iSubItem = 0;
+ lviKey.pszText = tszKey;
+ lviKey.lParam = iEpisode;
+ ListView_InsertItem(hListView, &lviKey);
+
+ lviValue.iItem = i;
+ lviValue.iSubItem = 1;
+ lviValue.pszText = tszValue;
+ ListView_SetItem(hListView, &lviValue);
+
+ free(tszKey);
+ free(tszValue);
}
}
}
diff --git a/c/defs.h b/c/defs.h
index d27d573..8c808b7 100644
--- a/c/defs.h
+++ b/c/defs.h
@@ -5,7 +5,7 @@
#include <commctrl.h>
/* common.c */
-TCHAR *TSZFromSZ(char *, int);
+TCHAR *TSZFromSZ(const char *, int);
int Watched(int);
/* main.c */
diff --git a/c/episodelistview.c b/c/episodelistview.c
index ab54f81..0b9e855 100644
--- a/c/episodelistview.c
+++ b/c/episodelistview.c
@@ -51,7 +51,7 @@ ElvHandleNotify(LPARAM lParam)
&& (pNmLv->uNewState & LVIS_FOCUSED)) {
g_SelectedItem = pNmLv->iItem;
ElvUpdateName(pNmLv);
- //DlvShowEpisode(pNmLv->lParam);
+ DlvShowEpisode(pNmLv->lParam);
}
break;
case NM_CUSTOMDRAW:
@@ -87,7 +87,6 @@ ElvUpdate()
term_t t;
hListView = GetDlgItem(gElv_hWnd, IDC_EPISODELISTVIEW);
-
ListView_DeleteAllItems(hListView);
lviEpisode.mask = LVIF_TEXT|LVIF_PARAM;
@@ -139,7 +138,6 @@ ElvUpdate()
/* Insert item. */
- lviEpisode.mask = LVIF_TEXT|LVIF_STATE|LVIF_PARAM;
lviEpisode.iItem = i;
lviEpisode.iSubItem = 0;
lviEpisode.pszText = tszEpisode;
diff --git a/c/main.c b/c/main.c
index 40c25b4..045d31c 100644
--- a/c/main.c
+++ b/c/main.c
@@ -207,7 +207,7 @@ void
UpdateLayout(HWND hWnd)
{
HWND hElv, hDlv;
- int cxColumn;
+ int cxColumn, cyDlv;
RECT rc;
static int cxVScroll = 0;
extern int g_SelectedItem;
@@ -222,7 +222,8 @@ UpdateLayout(HWND hWnd)
/* Resize data list view. */
hDlv = GetDlgItem(hWnd, IDC_DATALISTVIEW);
- MoveWindow(hDlv, 0, rc.bottom-100,
+ cyDlv = rc.bottom-100;
+ MoveWindow(hDlv, 0, cyDlv,
rc.right, rc.bottom,
TRUE);
@@ -234,7 +235,7 @@ UpdateLayout(HWND hWnd)
hElv = GetDlgItem(hWnd, IDC_EPISODELISTVIEW);
MoveWindow(hElv, 0, 0,
- rc.right, rc.bottom-100+1,
+ rc.right, cyDlv+1,
TRUE);
cxColumn = ListView_GetColumnWidth(hElv, 0);