aboutsummaryrefslogtreecommitdiff
path: root/c/episodelistview.c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-02-17 03:11:42 +0100
committerJohn Ankarström <john@ankarstrom.se>2022-02-17 03:11:42 +0100
commit447648c9db10167e5da4f0b431d7cfb878c5f807 (patch)
tree7d8b810b2b39dcfd377cd14f77deec19b3968eba /c/episodelistview.c
parentb1a9967ea3b8dd6490ee24cb6ff4e809aa51eb3c (diff)
downloadEpisodeBrowser-447648c9db10167e5da4f0b431d7cfb878c5f807.tar.gz
Even more cleanup.
Diffstat (limited to 'c/episodelistview.c')
-rw-r--r--c/episodelistview.c41
1 files changed, 19 insertions, 22 deletions
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;