aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
Diffstat (limited to 'c')
-rw-r--r--c/common.c10
-rw-r--r--c/defs.h5
-rw-r--r--c/episodelistview.c41
-rw-r--r--c/main.c11
4 files changed, 34 insertions, 33 deletions
diff --git a/c/common.c b/c/common.c
index 9a3baa8..6f7772c 100644
--- a/c/common.c
+++ b/c/common.c
@@ -32,9 +32,15 @@ TszFromSz(const char *sz, int iCp)
int
Watched(int iEpisode)
{
+ fid_t f;
term_t t;
+
+ F(f);
t = T(1);
- PI(t,iEpisode) return 0;
- P("track_episodes","watched",1,t) return 0;
+ PI(t,iEpisode) goto f;
+ P("track_episodes","watched",1,t) goto f;
+ Fd(f);
return 1;
+f: Fd(f);
+ return 0;
}
diff --git a/c/defs.h b/c/defs.h
index 041f64a..fad3ea7 100644
--- a/c/defs.h
+++ b/c/defs.h
@@ -1,6 +1,8 @@
#ifndef DEFS_H
#define DEFS_H
+#include <commctrl.h>
+
/* common.c */
TCHAR *TszFromSz(const char *, int);
int Watched(int);
@@ -14,12 +16,11 @@ HWND LvCreate(HMENU);
/* episodelistview.c */
HWND ElvCreate();
LRESULT ElvHandleNotify(LPARAM);
-int ElvItemEpisode(int);
void ElvRedraw(void);
void ElvSetTop(int);
void ElvSelectRecent(void);
void ElvUpdate(void);
-void ElvUpdateName(int, int);
+void ElvUpdateName(LPLVITEM);
/* datalistview.c */
HWND DlvCreate();
diff --git a/c/episodelistview.c b/c/episodelistview.c
index df50bad..59dfed7 100644
--- a/c/episodelistview.c
+++ b/c/episodelistview.c
@@ -9,7 +9,7 @@
extern HFONT HfBold;
extern HWND HWnd;
HWND HElv;
-int IElvSelectedItem = -1;
+LPLVITEM LpLviElvSelection;
WNDPROC ElvPrevProc;
HWND
@@ -17,6 +17,8 @@ ElvCreate()
{
LVCOLUMN lvc;
+ LpLviElvSelection = malloc(sizeof(LVITEM));
+ if (!LpLviElvSelection) return 0;
HElv = LvCreate((HMENU)IDC_EPISODELISTVIEW);
lvc.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
@@ -45,8 +47,9 @@ ElvHandleNotify(LPARAM lParam)
case LVN_ITEMCHANGED:
if ((lpNmLv->uChanged & LVIF_STATE)
&& (lpNmLv->uNewState & LVIS_FOCUSED)) {
- IElvSelectedItem = lpNmLv->iItem;
- ElvUpdateName(lpNmLv->iItem, lpNmLv->lParam);
+ LpLviElvSelection->iItem = lpNmLv->iItem;
+ LpLviElvSelection->lParam = lpNmLv->lParam;
+ ElvUpdateName(LpLviElvSelection);
DlvShowEpisode(lpNmLv->lParam);
}
break;
@@ -70,10 +73,13 @@ ElvHandleNotify(LPARAM lParam)
}
case NM_DBLCLK:
{
+ fid_t f;
term_t t;
+ F(f);
t = T(1);
- PI(t+0, ElvItemEpisode(IElvSelectedItem)) break;
+ PI(t+0, LpLviElvSelection->lParam) goto b;
P("local_episodes","open_episode",1,t);
+b: Fd(f);
break;
}
case NM_RCLICK:
@@ -90,16 +96,6 @@ ElvHandleNotify(LPARAM lParam)
return 0;
}
-
-int
-ElvItemEpisode(int iItem) {
- LVITEM lvi;
- lvi.mask = LVIF_PARAM;
- lvi.iItem = iItem;
- lvi.iSubItem = 0;
- return ListView_GetItem(HElv, &lvi) ? lvi.lParam : -1;
-}
-
void
ElvRedraw()
{
@@ -128,7 +124,7 @@ ElvSelectRecent()
F(f);
t = T(1);
P("track_episodes","most_recently_watched",1,t) goto e;
- GI(t, &iEpisode) goto e;
+ GI(t,&iEpisode) goto e;
lvfi.flags = LVFI_PARAM;
lvfi.lParam = iEpisode;
@@ -139,8 +135,9 @@ ElvSelectRecent()
if (iItem > 5)
ElvSetTop(iItem-5);
ListView_SetItemState(HElv, iItem, LVIS_SELECTED, LVIS_SELECTED);
- IElvSelectedItem = iItem;
- ElvUpdateName(iItem, iEpisode);
+ LpLviElvSelection->iItem = iItem;
+ LpLviElvSelection->lParam = iEpisode;
+ ElvUpdateName(LpLviElvSelection);
DlvShowEpisode(iEpisode);
e: Fd(f);
@@ -217,8 +214,8 @@ e: Fd(f2);
/* Reset selection and scrolling position. */
ElvSetTop(iTop);
- if (IElvSelectedItem != -1) {
- ListView_SetItemState(HElv, IElvSelectedItem,
+ if (LpLviElvSelection) {
+ ListView_SetItemState(HElv, LpLviElvSelection->iItem,
LVIS_SELECTED, LVIS_SELECTED);
}
@@ -230,7 +227,7 @@ e: Fd(f2);
/* Update episode name. */
void
-ElvUpdateName(int iItem, int iEpisode)
+ElvUpdateName(LPLVITEM lpLvi)
{
char *szName;
fid_t f;
@@ -239,14 +236,14 @@ ElvUpdateName(int iItem, int iEpisode)
F(f);
t = T(3);
- PI(t,iEpisode) goto e;
+ PI(t,lpLvi->lParam) goto e;
P("episode_data","lookup_episode",3,t) goto e;
GAC(t+1,&szName) goto e;
tszName = TszFromSz(szName, CP_UTF8);
if (!tszName) goto e;
- ListView_SetItemText(HElv, iItem, 1, tszName);
+ ListView_SetItemText(HElv, lpLvi->iItem, 1, tszName);
e: Fd(f);
return;
diff --git a/c/main.c b/c/main.c
index 82f30a6..c6364e8 100644
--- a/c/main.c
+++ b/c/main.c
@@ -128,16 +128,14 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
fid_t f;
HWND hElv;
- int iEpisode;
term_t t;
- extern int IElvSelectedItem;
+ extern LPLVITEM LpLviElvSelection;
hElv = GetDlgItem(hWnd, IDC_EPISODELISTVIEW);
- iEpisode = ElvItemEpisode(IElvSelectedItem);
F(f);
t = T(1);
- PI(t,iEpisode) break;
+ PI(t,LpLviElvSelection->lParam) break;
switch (LOWORD(wParam)) {
case ID_WATCH:
@@ -154,9 +152,9 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
case ID_LOOKUP:
P("episode_data","retract_episode",1,t);
- ElvUpdateName(IElvSelectedItem, iEpisode);
+ ElvUpdateName(LpLviElvSelection);
ElvRedraw();
- DlvShowEpisode(iEpisode);
+ DlvShowEpisode(LpLviElvSelection->lParam);
break;
}
@@ -246,7 +244,6 @@ UpdateLayout(HWND hWnd)
HWND hElv, hDlv;
int cxColumn, cyDlv;
RECT rc;
- extern int IElvSelectedItem;
static int cxVScroll = 0;
if (cxVScroll == 0)