diff options
Diffstat (limited to 'plugins/mRadio/i_tray.inc')
-rw-r--r-- | plugins/mRadio/i_tray.inc | 91 |
1 files changed, 74 insertions, 17 deletions
diff --git a/plugins/mRadio/i_tray.inc b/plugins/mRadio/i_tray.inc index f0a463c5de..ab0a04e41d 100644 --- a/plugins/mRadio/i_tray.inc +++ b/plugins/mRadio/i_tray.inc @@ -1,6 +1,9 @@ {}
var
+ doTray:bool;
+var
trayradioparent:THANDLE;
+ trayprotoh:THANDLE;
trayparent:THANDLE;
traymute :THANDLE;
trayplay :THANDLE;
@@ -79,7 +82,10 @@ begin begin
mFreeMem(tmp.name);
DestroyServiceFunction(tmp.service);
- CallService(MS_CLIST_REMOVETRAYMENUITEM,tmp.menuitem,0);
+ if doTray then
+ CallService(MS_CLIST_REMOVETRAYMENUITEM,tmp.menuitem,0)
+ else
+ CallService(MS_CLIST_REMOVEMAINMENUITEM,tmp.menuitem,0);
mFreeMem(tmp);
List_Remove(@trayStations,i);
end;
@@ -101,7 +107,10 @@ begin mi.position :=i;
mi.pszService:=@buf;
mi.szName.w :=tmp.name;
- tmp.menuitem:=Menu_AddTrayMenuItem(@mi);
+ if doTray then
+ tmp.menuitem:=Menu_AddTrayMenuItem(@mi)
+ else
+ tmp.menuitem:=Menu_AddMainMenuItem(@mi);
end;
end;
end;
@@ -116,6 +125,15 @@ begin result:=CallService(MS_RADIO_COMMAND,MRC_STOP,0);
end;
+function TrayProto(wParam:WPARAM;lParam:LPARAM):int_ptr; cdecl;
+begin
+ if PluginStatus=ID_STATUS_ONLINE then
+ wParam:=ID_STATUS_OFFLINE
+ else
+ wParam:=ID_STATUS_ONLINE;
+ result:=Service_SetStatus(wParam,lParam);
+end;
+
procedure CreateTrayMenu();
var
mi:TCListMenuItem;
@@ -126,12 +144,28 @@ begin mi.flags :=CMIF_UNICODE;
mi.szName.w:=cPluginName;
mi.hIcon :=CallService(MS_SKIN2_GETICON,0,lparam(IcoBtnSettings));
- trayradioparent:=Menu_AddTrayMenuItem(@mi);
+ if doTray then
+ trayradioparent:=Menu_AddTrayMenuItem(@mi)
+ else
+ trayradioparent:=Menu_AddMainMenuItem(@mi);
FillChar(mi, sizeof(mi), 0);
mi.cbSize :=sizeof(mi);
mi.szPopupName:=TChar(trayradioparent);
+ if PluginStatus=ID_STATUS_ONLINE then
+ mi.szName.w :='mRadio off'
+ else
+ mi.szName.w :='mRadio on';
+ mi.flags:=CMIF_UNICODE or CMIF_ROOTHANDLE;
+ mi.position :=0;
+ srvtraystop:=CreateServiceFunction('mRadio/TrayProto',@TrayProto);
+ mi.pszService:='mRadio/TrayProto';
+ if doTray then
+ trayprotoh:=Menu_AddTrayMenuItem(@mi)
+ else
+ trayprotoh:=Menu_AddMainMenuItem(@mi);
+
if gVolume<0 then
mi.flags:=CMIF_UNICODE or CMIF_ROOTHANDLE or CMIF_CHECKED
else
@@ -139,7 +173,10 @@ begin mi.szName.w :='Mute';
mi.pszService:=MS_RADIO_MUTE;
mi.position :=1;
- traymute:=Menu_AddTrayMenuItem(@mi);
+ if doTray then
+ traymute:=Menu_AddTrayMenuItem(@mi)
+ else
+ traymute:=Menu_AddMainMenuItem(@mi);
mi.flags:=CMIF_UNICODE or CMIF_ROOTHANDLE;
if CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_GET)<>RD_STATUS_PLAYING then
@@ -150,18 +187,27 @@ begin mi.position :=2;
srvtrayplaypause:=CreateServiceFunction('mRadio/TrayPlayPause',@TrayPlayPause);
mi.pszService:='mRadio/TrayPlayPause';
- trayplay:=Menu_AddTrayMenuItem(@mi);
+ if doTray then
+ trayplay:=Menu_AddTrayMenuItem(@mi)
+ else
+ trayplay:=Menu_AddTrayMenuItem(@mi);
mi.szName.w :='Stop';
mi.position :=3;
srvtraystop:=CreateServiceFunction('mRadio/TrayStop',@TrayStop);
mi.pszService:='mRadio/TrayStop';
- Menu_AddTrayMenuItem(@mi);
+ if doTray then
+ Menu_AddTrayMenuItem(@mi)
+ else
+ Menu_AddMainMenuItem(@mi);
mi.szName.w :='Play Station';
mi.position :=1000;
mi.pszService:=nil;
- trayparent:=Menu_AddTrayMenuItem(@mi);
+ if doTray then
+ trayparent:=Menu_AddTrayMenuItem(@mi)
+ else
+ trayparent:=Menu_AddMainMenuItem(@mi);
end;
function TrayPrebuild(wParam:WPARAM;lParam:LPARAM):int; cdecl;
@@ -171,6 +217,15 @@ var begin
FillChar(mi,sizeof(mi),0);
mi.cbSize:=sizeof(mi);
+
+ mi.flags:=CMIM_NAME or CMIF_UNICODE;
+ if PluginStatus=ID_STATUS_ONLINE then
+ playstr:='mRadio off'
+ else
+ playstr:='mRadio on';
+ mi.szName.w:=playstr;
+ CallService(MS_CLIST_MODIFYMENUITEM,trayprotoh,tlparam(@mi));
+
if gVolume<0 then
mi.flags:=CMIM_FLAGS or CMIF_CHECKED
else
@@ -191,13 +246,14 @@ end; procedure CreateMIMTrayMenu;
begin
- if ServiceExists(MS_CLIST_ADDTRAYMENUITEM)<>0 then
-// if hiddenwindow<>0 then
- begin
- CreateTrayMenu();
- MakeStationsMenu();
- HookEvent(ME_CLIST_PREBUILDTRAYMENU,@TrayPrebuild);
- end;
+ doTray:=ServiceExists(MS_CLIST_ADDTRAYMENUITEM)<>0;
+
+ CreateTrayMenu();
+ MakeStationsMenu();
+ if doTray then
+ HookEvent(ME_CLIST_PREBUILDTRAYMENU,@TrayPrebuild)
+ else
+ HookEvent(ME_CLIST_PREBUILDMAINMENU,@TrayPrebuild)
end;
procedure RemoveTrayItems;
@@ -218,7 +274,8 @@ begin DestroyServiceFunction(srvtrayplaypause);
DestroyServiceFunction(srvtraystop);
- if ServiceExists(MS_CLIST_REMOVETRAYMENUITEM)<>0 then
- CallService(MS_CLIST_REMOVETRAYMENUITEM,trayradioparent,0);
-
+ if doTray then
+ CallService(MS_CLIST_REMOVETRAYMENUITEM,trayradioparent,0)
+ else
+ CallService(MS_CLIST_REMOVEMAINMENUITEM,trayradioparent,0);
end;
|